// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/graphics/backends/fontbackend.cpp
// Function: smooth::GUI::FontBackend::GetTextSize(smooth::String const&, bool) const
S::GUI::Size S::GUI::FontBackend::GetTextSize(const String &text, Bool scaled) const
{
	if (text == NIL) return Size();

	/* Check for existing cache entry.
	 */
	ExtentsCacheEntry	 entry(text, fontName, fontSize, fontWeight, fontStyle);

	Float			 dpi = Surface().GetSurfaceDPI();
	Int			 crc = entry.GetCRC32();

	if (ExtentsCacheEntry *cacheEntry = extentsCache.Get(crc))
	{
		if (scaled || Math::Abs(dpi - 96.0) < 0.1) return cacheEntry->GetExtents();
		else					   return cacheEntry->GetExtents() * 96.0 / dpi;
	}

	/* Compute scaled text size.
	 */
	Size	 size = GetTextSize(text);

	entry.SetExtents(size);

	/* Save at most 2048 cache entries.
	 */
	if (extentsCache.Length() >= 2048)
	{
		for (Int i = 0; i < 1024; i++)
		{
			delete extentsCache.GetFirst();

			extentsCache.RemoveNth(0);
		}
	}

	extentsCache.Add(new ExtentsCacheEntry(entry), crc);

	/* Return computed text size.
	 */
	if (scaled || Math::Abs(dpi - 96.0) < 0.1) return size;
	else					   return size * 96.0 / dpi;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
xorl %r12d, %r12d
movq %rsi, %rdi
xorl %esi, %esi
callq 0x55260
testb %al, %al
jne 0x60838
leaq 0x10(%r15), %rdx
movswl 0xa(%r15), %ecx
movswl 0x38(%r15), %r8d
movswl 0x3a(%r15), %r9d
leaq 0x1c(%rsp), %rdi
movq %r14, %rsi
callq 0x6096c
leaq 0x28(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x10(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x57150
movq %r12, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x57b20
movl 0x1c(%rsp), %ebp
leaq 0x10f112(%rip), %rdi    # 0x16f718
movl %ebp, %esi
callq 0x5b7ae
movq (%rax), %r12
testq %r12, %r12
je 0x6064f
testb %bl, %bl
jne 0x6063e
movsd 0x93ebf(%rip), %xmm0    # 0xf44e0
addsd 0x8(%rsp), %xmm0
callq 0x55660
movsd 0x93eb4(%rip), %xmm1    # 0xf44e8
ucomisd %xmm0, %xmm1
jbe 0x60759
movq 0x4(%r12), %r14
movq %r14, %r15
shrq $0x20, %r15
jmp 0x6082e
movq (%r15), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x10(%rax)
movq %rax, %r14
movq %rax, 0x20(%rsp)
cmpl $0x800, 0x10f0b3(%rip)  # imm = 0x800
jl 0x606a5
movl $0x400, %r12d           # imm = 0x400
leaq 0x10f09c(%rip), %r15    # 0x16f718
movq %r15, %rdi
callq 0x60a9c
movq (%rax), %rdi
testq %rdi, %rdi
je 0x60696
movl $0xc, %esi
callq 0x55480
movq %r15, %rdi
xorl %esi, %esi
callq 0x5acf2
decl %r12d
jne 0x6067c
movq %r14, %r15
shrq $0x20, %r15
movl $0xc, %edi
callq 0x556b0
movq 0x1c(%rsp), %rcx
movq %rcx, (%rax)
movl 0x24(%rsp), %ecx
movl %ecx, 0x8(%rax)
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x10f044(%rip), %rdi    # 0x16f718
movl %ebp, %edx
callq 0x5af72
testb %bl, %bl
jne 0x6082e
movsd 0x93df5(%rip), %xmm0    # 0xf44e0
addsd 0x8(%rsp), %xmm0
callq 0x55660
movsd 0x93dea(%rip), %xmm1    # 0xf44e8
ucomisd %xmm0, %xmm1
ja 0x6082e
cvtsi2sd %r14d, %xmm3
movsd 0x93ddb(%rip), %xmm4    # 0xf44f0
mulsd %xmm4, %xmm3
xorpd %xmm1, %xmm1
movapd %xmm3, %xmm5
cmpltsd %xmm1, %xmm5
movsd 0x93c62(%rip), %xmm0    # 0xf4390
movapd %xmm5, %xmm6
andpd %xmm0, %xmm6
movsd 0x93c5a(%rip), %xmm2    # 0xf4398
andnpd %xmm2, %xmm5
orpd %xmm6, %xmm5
addsd %xmm3, %xmm5
cvttsd2si %xmm5, %rax
xorps %xmm3, %xmm3
cvtsi2sd %r15d, %xmm3
jmp 0x607ac
cvtsi2sdl 0x4(%r12), %xmm3
movsd 0x93d88(%rip), %xmm4    # 0xf44f0
mulsd %xmm4, %xmm3
xorpd %xmm1, %xmm1
movapd %xmm3, %xmm5
cmpltsd %xmm1, %xmm5
movsd 0x93c0f(%rip), %xmm0    # 0xf4390
movapd %xmm5, %xmm6
andpd %xmm0, %xmm6
movsd 0x93c07(%rip), %xmm2    # 0xf4398
andnpd %xmm2, %xmm5
orpd %xmm6, %xmm5
addsd %xmm3, %xmm5
cvttsd2si %xmm5, %rax
xorps %xmm3, %xmm3
cvtsi2sdl 0x8(%r12), %xmm3
mulsd %xmm4, %xmm3
movapd %xmm3, %xmm4
cmpltsd %xmm1, %xmm4
movapd %xmm4, %xmm5
andpd %xmm0, %xmm5
andnpd %xmm2, %xmm4
orpd %xmm5, %xmm4
addsd %xmm3, %xmm4
cvttsd2si %xmm4, %rcx
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
movsd 0x8(%rsp), %xmm6
divsd %xmm6, %xmm3
movapd %xmm3, %xmm4
cmpltsd %xmm1, %xmm4
movapd %xmm4, %xmm5
andpd %xmm0, %xmm5
andnpd %xmm2, %xmm4
orpd %xmm5, %xmm4
addsd %xmm3, %xmm4
cvttsd2si %xmm4, %r14
xorps %xmm3, %xmm3
cvtsi2sd %ecx, %xmm3
divsd %xmm6, %xmm3
movapd %xmm3, %xmm4
cmpltsd %xmm1, %xmm4
andpd %xmm4, %xmm0
andnpd %xmm2, %xmm4
orpd %xmm0, %xmm4
addsd %xmm3, %xmm4
cvttsd2si %xmm4, %r15
shlq $0x20, %r15
movl %r14d, %r12d
orq %r15, %r12
movq %r12, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x57b20
movq %rbx, %rdi
callq 0x57090
nop