pub struct TextShapingCache { /* private fields */ }Expand description
Bounded DPI-independent single-probe FxHash text shaping and line-break cache with O(1) intrusive LRU eviction.
Implementations§
Source§impl TextShapingCache
Single-probe FxHash shaping & line-break caching, independent font-chain invalidation, and O(1) intrusive LRU eviction for TextShapingCache.
impl TextShapingCache
Single-probe FxHash shaping & line-break caching, independent font-chain invalidation, and O(1) intrusive LRU eviction for TextShapingCache.
Sourcepub fn with_budget(budget_bytes: usize) -> Self
pub fn with_budget(budget_bytes: usize) -> Self
Sourcepub fn set_memory_budget(&mut self, max_bytes: usize)
pub fn set_memory_budget(&mut self, max_bytes: usize)
Updates the resident byte budget and immediately evicts cold entries if currently over budget.
§Arguments
&Self- Mutable shaping cache.usize- New maximum resident bytes.
Sourcepub fn invalidate_font_chain(&mut self, new_revision: u64) -> bool
pub fn invalidate_font_chain(&mut self, new_revision: u64) -> bool
Sourcepub fn peek_shaped(&self, key: &TextShapingKey) -> Option<&ShapedGlyphRun>
pub fn peek_shaped(&self, key: &TextShapingKey) -> Option<&ShapedGlyphRun>
Sourcepub fn peek_line_break(&self, key: &LineBreakKey) -> Option<&TextLayoutResult>
pub fn peek_line_break(&self, key: &LineBreakKey) -> Option<&TextLayoutResult>
Sourcepub fn get_or_shape<F>(
&mut self,
key: TextShapingKey,
shape_fn: F,
) -> &ShapedGlyphRun
pub fn get_or_shape<F>( &mut self, key: TextShapingKey, shape_fn: F, ) -> &ShapedGlyphRun
Looks up or computes a DPI- and wrap-width-independent ShapedGlyphRun for key with a single FxHash probe.
§Arguments
&Self- Mutable shaping cache.TextShapingKey- Shaping lookup key.F- Lazy shaping function returning(cluster_advances, total_width)on a miss.
§Returns
&ShapedGlyphRun- Cached shaping run reference.
Sourcepub fn get_or_break_lines<F>(
&mut self,
key: LineBreakKey,
break_fn: F,
) -> &TextLayoutResultwhere
F: FnOnce() -> TextLayoutResult,
pub fn get_or_break_lines<F>(
&mut self,
key: LineBreakKey,
break_fn: F,
) -> &TextLayoutResultwhere
F: FnOnce() -> TextLayoutResult,
Looks up or computes a DPI- and color-independent wrapped TextLayoutResult for key with a single FxHash probe.
§Arguments
&Self- Mutable shaping cache.LineBreakKey- Line-break lookup key.F- Lazy line-break computation invoked only on cache miss.
§Returns
&TextLayoutResult- Cached wrapped layout result.
Sourcepub fn evict_if_over_budget(&mut self)
pub fn evict_if_over_budget(&mut self)
Evicts coldest entries whenever current resident bytes exceed the configured budget.
§Arguments
&Self- Mutable shaping cache.
Sourcepub fn total_entries(&self) -> usize
pub fn total_entries(&self) -> usize
Source§impl TextShapingCache
impl TextShapingCache
pub fn get_budget_bytes(&self) -> usize
pub fn get_mut_budget_bytes(&mut self) -> &mut usize
pub fn set_budget_bytes(&mut self, val: usize) -> &mut Self
pub fn get_resident_bytes(&self) -> usize
pub fn get_font_chain_revision(&self) -> u64
pub fn get_shaping_hits(&self) -> u64
pub fn get_shaping_misses(&self) -> u64
pub fn get_line_break_hits(&self) -> u64
pub fn get_line_break_misses(&self) -> u64
pub fn get_evictions(&self) -> u64
Trait Implementations§
Source§impl Clone for TextShapingCache
impl Clone for TextShapingCache
Source§impl Debug for TextShapingCache
impl Debug for TextShapingCache
Auto Trait Implementations§
impl Forget for TextShapingCache
impl Freeze for TextShapingCachewhere
*const u8 is !null: Freeze,
PhantomData<u64>: Freeze,
PhantomData<ShapingRunSlot>: Freeze,
PhantomData<LineBreakSlot>: Freeze,
PhantomData<u32>: Freeze,
impl Move for TextShapingCache
impl RefUnwindSafe for TextShapingCache
impl Send for TextShapingCachewhere
RawVecInner: Send,
impl Sync for TextShapingCachewhere
RawVecInner: Sync,
impl Unpin for TextShapingCache
impl UnsafeUnpin for TextShapingCachewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u64>: UnsafeUnpin,
PhantomData<ShapingRunSlot>: UnsafeUnpin,
PhantomData<LineBreakSlot>: UnsafeUnpin,
PhantomData<u32>: UnsafeUnpin,
impl UnwindSafe for TextShapingCachewhere
RawVecInner: UnwindSafe,
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