pub struct GlyphOutlineCache { /* private fields */ }Expand description
Bounded least-recently-used cache of glyph outlines.
Keys are opaque u128s combining font identity and glyph id (the
renderer passes identifier().cache_key()); values are the outlines in
glyph space. When the cache is full, inserting a new outline evicts the
least-recently-used one. Eviction is always output-neutral — it only
decides which outlines get rebuilt.
A disabled cache (set_enabled) never hits and
stores nothing; every lookup counts as a miss. Already-stored entries are
kept while disabled, so re-enabling resumes from them.
Implementations§
Source§impl GlyphOutlineCache
impl GlyphOutlineCache
Sourcepub const DEFAULT_CAPACITY: usize = 4096
pub const DEFAULT_CAPACITY: usize = 4096
Default entry bound.
A typical Latin page uses well under 256 distinct glyphs and a whole Latin/Cyrillic/Greek document stays in the hundreds, so 4096 serves common documents with zero evictions. Long CJK documents can reach a few thousand distinct glyphs overall, but the per-page working set is in the hundreds, which stays resident. Memory stays modest: a Latin outline is typically hundreds of bytes to ~2KB and a complex CJK outline up to ~10KB, so a full cache holds single-digit megabytes — small next to the page pixmaps (tens of MB).
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty cache with DEFAULT_CAPACITY entries.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
An empty cache holding at most capacity entries.
A capacity of zero is allowed: lookups always build and nothing is ever stored (every call counts as a miss).
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enable or disable the cache. A disabled cache rebuilds every outline (each build counts as a miss) and stores nothing; re-enabling resumes from the entries stored before.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether lookups can hit.
Trait Implementations§
Source§impl Debug for GlyphOutlineCache
impl Debug for GlyphOutlineCache
Auto Trait Implementations§
impl Freeze for GlyphOutlineCache
impl RefUnwindSafe for GlyphOutlineCache
impl Send for GlyphOutlineCache
impl Sync for GlyphOutlineCache
impl Unpin for GlyphOutlineCache
impl UnsafeUnpin for GlyphOutlineCache
impl UnwindSafe for GlyphOutlineCache
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().