Files
LCUI/lib
Liu ef23c9cd11 refactor(pandagl): flatten glyph bitmap cache to hash + lru
The previous bitmap cache was a three-level rbtree keyed by
(wchar_t, font_id, size), which had two problems:

1. The wchar_t key collapses Unicode codepoints that map to the
   same glyph in a given face into separate cache slots, missing
   real reuse opportunities and bloating memory under text-heavy
   workloads.
2. There was no upper bound; long-running apps would grow the
   cache without limit until pd_font_library_destroy.

Replace it with a flat hash table keyed by a packed 64-bit
(face_id, glyph_index, size) tuple, plus a doubly-linked LRU list
for O(1) eviction.

- pd_font_engine gets a new get_glyph_index hook; FreeType maps
  via FT_Get_Char_Index, the in-core engine treats codepoints as
  identity (no cmap).
- pd_font_cache_add_bitmap / pd_font_cache_get_bitmap now resolve
  the glyph index via the engine before keying the cache, so the
  same glyph reused across composed sequences hits the same entry.
- pd_font_cache_set_capacity / pd_font_cache_count expose the LRU
  bound (default 8192 entries, 0 = unlimited) for runtime tuning
  and tests. Shrinking the capacity evicts immediately.
- list_t is used with append at tail / evict from head so the
  yutil tail.prev pointer stays consistent (list_link does not
  update it).

Adds lib/pandagl/tests/test_font_cache.c covering hit identity,
size differentiation, unknown-codepoint fallback, and LRU eviction.
2026-05-24 23:11:04 +08:00
..
2025-01-05 23:29:56 +08:00
2025-01-05 23:29:56 +08:00