pub struct GlyphCache { /* private fields */ }Expand description
Glyph cache with LRU eviction.
Tracks a frame generation counter. Each get marks the glyph as used
in the current generation. evict_unused removes glyphs not used
for max_idle_frames generations and deallocates their atlas space.
Implementations§
Source§impl GlyphCache
impl GlyphCache
pub fn new() -> Self
Sourcepub fn advance_generation(&mut self)
pub fn advance_generation(&mut self)
Advance the frame generation counter. Call once per render frame.
pub fn generation(&self) -> u64
Sourcepub fn get(&mut self, key: &GlyphCacheKey) -> Option<&CachedGlyph>
pub fn get(&mut self, key: &GlyphCacheKey) -> Option<&CachedGlyph>
Look up a cached glyph, marking it as used in the current generation.
Sourcepub fn peek(&self, key: &GlyphCacheKey) -> Option<&CachedGlyph>
pub fn peek(&self, key: &GlyphCacheKey) -> Option<&CachedGlyph>
Look up without marking as used (for read-only queries).
pub fn insert(&mut self, key: GlyphCacheKey, glyph: CachedGlyph)
Sourcepub fn evict_unused(&mut self) -> Vec<AllocId>
pub fn evict_unused(&mut self) -> Vec<AllocId>
Evict glyphs unused for MAX_IDLE_FRAMES generations. Returns the AllocIds that should be deallocated from the atlas.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GlyphCache
impl RefUnwindSafe for GlyphCache
impl Send for GlyphCache
impl Sync for GlyphCache
impl Unpin for GlyphCache
impl UnsafeUnpin for GlyphCache
impl UnwindSafe for GlyphCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more