Commit graph

7 commits

Author SHA1 Message Date
catbot
c169986835 perf(font): cache per-codepoint advances in font units (#57)
Font::GetLineWidth called stbtt_GetCodepointHMetrics for every glyph on
every invocation. InputField_HitTestCursor rescans the whole field once
per character, making caret hit-testing O(n²) in HMetrics lookups.

Memoise advances per Font via Font::AdvanceUnits: ASCII in a flat array,
the rest in a map. Advances are cached in unscaled font *units* and
rescaled per call — Glyph::advance in the FontAtlas is baked at kBaseSize
and is wrong at any other size, so it cannot be reused. The per-glyph
(int) truncation in GetLineWidth is preserved exactly.

Adds the FontAdvanceCache CPU-only regression test covering size
independence of the cached unit advance, the per-glyph-truncated rescale
pipeline, cache-hit determinism, width scaling with size, and the
non-ASCII map path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 17:00:48 +00:00
216972e73a new UI system 2026-05-01 23:35:37 +02:00
c9ebd448f9 update 2026-04-16 23:03:24 +02:00
7f46ac13fa rendering improvements 2026-03-12 01:07:46 +01:00
d661c88ee2 cleaned up renderer 2026-03-09 20:10:19 +01:00
475ecd149b removed debug cout 2025-11-17 00:46:03 +01:00
4bb7219ccf semi working wayland 2025-11-17 00:44:45 +01:00