pub struct GlyphAtlas { /* private fields */ }Expand description
Memoized glyph rasterization cache shared across frames with O(1) slot indexing, ASCII direct tables, bounded LRU budget, and hit/miss telemetry.
Implementations§
Source§impl GlyphAtlas
Caching lookup, bounded LRU eviction, and telemetry operations for GlyphAtlas.
impl GlyphAtlas
Caching lookup, bounded LRU eviction, and telemetry operations for GlyphAtlas.
Sourcepub fn effective_budget_bytes(&self) -> usize
pub fn effective_budget_bytes(&self) -> usize
Sourcepub fn set_memory_budget(&mut self, max_bytes: usize)
pub fn set_memory_budget(&mut self, max_bytes: usize)
Configures a bounded resident memory budget in bytes and immediately evicts cold glyphs if currently over budget.
§Arguments
&Self- Mutable glyph atlas reference.usize- Maximum resident byte budget (clamped to>= 1024).
Sourcepub fn evict_if_over_budget(&mut self)
pub fn evict_if_over_budget(&mut self)
Evicts least-recently-used glyphs when resident_bytes exceeds the active budget and slots are unpinned.
§Arguments
&Self- Mutable glyph atlas reference.
Sourcepub fn begin_frame_fence(&mut self, fence_id: u64)
pub fn begin_frame_fence(&mut self, fence_id: u64)
Tags subsequent glyph accesses and insertions with GPU submission fence_id for fence-deferred reclamation.
§Arguments
&Self- Mutable glyph atlas reference.u64- Active frame GPU fence identifier.
Sourcepub fn complete_fence(&mut self, fence_id: u64) -> usize
pub fn complete_fence(&mut self, fence_id: u64) -> usize
Sourcepub fn invalidate_for_render_params(
&mut self,
dpi_scale: f32,
aa: AntialiasingMode,
font_chain_revision: u64,
) -> bool
pub fn invalidate_for_render_params( &mut self, dpi_scale: f32, aa: AntialiasingMode, font_chain_revision: u64, ) -> bool
Invalidates bitmap atlas entries independently of text shaping whenever DPI scale, AA mode, or font chain changes.
§Arguments
&Self- Mutable glyph atlas reference.f32- Active display scale factor.AntialiasingMode- Active anti-aliasing policy.u64- Active font fallback chain revision.
§Returns
bool-truewhen atlas bitmaps were invalidated and queued for fence-deferred release.
Sourcepub fn lookup_slot(&self, key: GlyphKey) -> Option<u32>
pub fn lookup_slot(&self, key: GlyphKey) -> Option<u32>
Sourcepub fn lookup(&self, key: GlyphKey) -> Option<&RasterizedGlyph>
pub fn lookup(&self, key: GlyphKey) -> Option<&RasterizedGlyph>
Sourcepub fn lookup_ascii_slot(&self, table_idx: usize, byte: u8) -> Option<u32>
pub fn lookup_ascii_slot(&self, table_idx: usize, byte: u8) -> Option<u32>
Performs a zero-hash, zero-allocation read-only lookup of an ASCII glyph slot in ascii_tables[table_idx].
§Arguments
&Self- Glyph atlas reference.usize- Style table index previously obtained fromascii_table_index.u8- ASCII byte in0..128.
§Returns
Option<u32>- Cached arena slot index when resident.
Sourcepub fn get_glyph_by_slot(&self, slot: u32) -> Option<&RasterizedGlyph>
pub fn get_glyph_by_slot(&self, slot: u32) -> Option<&RasterizedGlyph>
Sourcepub fn collect_missing_keys(
&self,
keys: &[GlyphKey],
out_missing: &mut Vec<GlyphKey>,
) -> usize
pub fn collect_missing_keys( &self, keys: &[GlyphKey], out_missing: &mut Vec<GlyphKey>, ) -> usize
Appends unique uncached GlyphKey entries from keys into caller-provided out_missing with zero temporary allocations.
§Arguments
&Self- Glyph atlas reference.&[GlyphKey]- Candidate glyph keys to probe.&mut Vec<GlyphKey>- Reusable output buffer receiving deduplicated missing keys.
§Returns
usize- Number of newly appended missing glyph keys.
Sourcepub fn prewarm_batch_with(
&mut self,
keys: &[GlyphKey],
provider: &dyn SystemFontProvider,
) -> usize
pub fn prewarm_batch_with( &mut self, keys: &[GlyphKey], provider: &dyn SystemFontProvider, ) -> usize
Batch-rasterizes all missing unique glyphs in keys through provider in a single pass and inserts them into the atlas.
§Arguments
&Self- Mutable glyph atlas reference.&[GlyphKey]- Glyph keys needed for the current frame or text run.&dyn SystemFontProvider- Native or deterministic font provider supporting batched rasterization.
§Returns
usize- Number of newly rasterized and inserted glyphs (0when all keys were already cached).
Sourcepub fn prewarm_text_with(
&mut self,
text: &str,
physical_size: f32,
style: TextStyle,
provider: &dyn SystemFontProvider,
) -> usize
pub fn prewarm_text_with( &mut self, text: &str, physical_size: f32, style: TextStyle, provider: &dyn SystemFontProvider, ) -> usize
Prewarms all missing unique glyphs for text under (physical_size, style) in a single provider batch (0 allocations when warm).
§Arguments
&Self- Mutable glyph atlas reference.&str- UTF-8 text string whose missing glyphs should be rasterized together.f32- Physical font size in pixels.TextStyle- Typography style parameters.&dyn SystemFontProvider- Native or deterministic font provider.
§Returns
usize- Number of newly rasterized and inserted glyphs.
Sourcepub fn get_or_rasterize(&mut self, key: GlyphKey) -> &RasterizedGlyph
pub fn get_or_rasterize(&mut self, key: GlyphKey) -> &RasterizedGlyph
Sourcepub fn get_or_rasterize_with(
&mut self,
key: GlyphKey,
provider: &dyn SystemFontProvider,
) -> &RasterizedGlyph
pub fn get_or_rasterize_with( &mut self, key: GlyphKey, provider: &dyn SystemFontProvider, ) -> &RasterizedGlyph
Returns the cached RasterizedGlyph for key, rasterizing through provider on a miss.
§Arguments
&Self- Mutable reference to the glyph atlas.GlyphKey- Quantized glyph lookup key.&dyn SystemFontProvider- Native or deterministic font rasterization provider.
§Returns
&RasterizedGlyph- Cached coverage bitmap and pixel metrics.