// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r12
xorl %r14d, %r14d
movq %rsi, %rdi
xorl %esi, %esi
callq 0x56280
testb %al, %al
jne 0x6151e
leaq 0x10(%r12), %rdx
movswl 0xa(%r12), %ecx
movswl 0x38(%r12), %r8d
movswl 0x3a(%r12), %r9d
leaq 0x14(%rsp), %rdi
movq %r15, %rsi
callq 0x61662
leaq 0x20(%rsp), %rdx
andq $0x0, (%rdx)
movq %rsp, %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x58340
movq %r14, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %rsp, %rdi
callq 0x58d90
movl 0x14(%rsp), %ebp
leaq 0x1034e7(%rip), %rdi    # 0x1648d8
movl %ebp, %esi
callq 0x5c86e
movq (%rax), %r14
testq %r14, %r14
je 0x61432
testb %bl, %bl
jne 0x61429
movsd 0x820f4(%rip), %xmm0    # 0xe3500
addsd 0x8(%rsp), %xmm0
callq 0x566a0
movsd 0x820e9(%rip), %xmm1    # 0xe3508
ucomisd %xmm0, %xmm1
jbe 0x614f6
movq 0x4(%r14), %r14
jmp 0x6151e
movq (%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *0x10(%rax)
movq %rax, %r14
movq %rax, (%rsp)
movq %rax, 0x18(%rsp)
cmpl $0x800, 0x10348b(%rip)  # imm = 0x800
jl 0x6148d
movl $0x400, %r13d           # imm = 0x400
leaq 0x103474(%rip), %r15    # 0x1648d8
pushq $0xc
popq %r12
subl $0x1, %r13d
jb 0x6148d
movq %r15, %rdi
callq 0x6185c
movq (%rax), %rdi
movq %r12, %rsi
callq 0x564c0
movq %r15, %rdi
xorl %esi, %esi
callq 0x5be3e
jmp 0x61468
pushq $0xc
popq %rdi
callq 0x56700
movq 0x14(%rsp), %rcx
movq %rcx, (%rax)
movl 0x1c(%rsp), %ecx
movl %ecx, 0x8(%rax)
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x103425(%rip), %rdi    # 0x1648d8
movl %ebp, %edx
callq 0x617e2
testb %bl, %bl
jne 0x6151e
movsd 0x8203a(%rip), %xmm0    # 0xe3500
addsd 0x8(%rsp), %xmm0
callq 0x566a0
movsd 0x8202f(%rip), %xmm1    # 0xe3508
ucomisd %xmm0, %xmm1
ja 0x6151e
movq %rsp, %rdi
movsd 0x82026(%rip), %xmm0    # 0xe3510
callq 0x57480
leaq 0x20(%rsp), %rdi
jmp 0x6150d
addq $0x4, %r14
movsd 0x8200e(%rip), %xmm0    # 0xe3510
movq %r14, %rdi
callq 0x57480
movq %rsp, %rdi
movq %rax, (%rdi)
movsd 0x8(%rsp), %xmm0
callq 0x59050
movq %rax, %r14
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x58d90
movq %rbx, %rdi
callq 0x58260
nop