I'm caching fonts using a primitive LRU system I came up with, but something is behaving funny.
core2_flex_font/include/flex_font.hpp at main · codewitch-honey-crisis/core2_flex_font · GitHub[
^]
core2_flex_font/src/flex_font.cpp at main · codewitch-honey-crisis/core2_flex_font · GitHub[
^]
Without caching I get
32 FPS for 16-bit Windows raster fonts - which is about the max for that display
9 FPS for Truetype
With caching I get
32 FPS for 16-bit windows raster fonts
22 FPS for Truetype.
I should note that this is an embedded device running an RTOS, so it behaves consistently every time. Makes benchmarking easy.
What's curious about this caching, is I have two callbacks on my fonts
on_measure
and
on_draw
when I use the cache, it doesn't trigger those callbacks on a cache hit.
The callbacks are what take the time, for most fonts, especially those with kerning table lookups and vectors, like Truetype.
Since the draw routine and measure routine are a common base of all font classes, the caching code is exactly the same code.
In my tests reported from above the cache is big enough to hold everything without expiring items, and I've verified that no expirations are happening.
I'm expecting - once cache hits start happening - for the performance to be consistent regardless of the type of font since it's not even calling the font specific overrides anymore
What I have tried:
I verified that it's caching everything. I'm always getting cache hits after the first time.
I thought maybe my buckets were unbalanced but that doesn't explain the discrepancy in frame rates either, because they'd be unbalanced for all of the fonts. It's the same caching code, configured the same way.
It's not memory, because again, I'm still getting cache hits every time.
My cache doesn't create items on its own, so it's not calling some create function spuriously.
I don't know what else to try. I need some ideas here.