pub struct TileCache { /* private fields */ }Expand description
The in-memory tile cache.
Implementations§
Source§impl TileCache
impl TileCache
Sourcepub fn new(size: usize, memory_mb: f64) -> Result<Self, TileError>
pub fn new(size: usize, memory_mb: f64) -> Result<Self, TileError>
A cache for size-pixel tiles under a memory_mb working-memory budget, of which it reserves 30% for
tiles (the rest is for native frames, decoder surfaces, features and the page).
pub fn size(&self) -> usize
pub fn max_tiles(&self) -> u64
Sourcepub fn set_max_tiles(&mut self, max_tiles: u64)
pub fn set_max_tiles(&mut self, max_tiles: u64)
Overrides the limit (tests use small fixed caches).
pub fn stats(&self) -> TileCacheStats
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn configure_budget(&mut self, memory_mb: f64, reserved_bytes: f64)
pub fn configure_budget(&mut self, memory_mb: f64, reserved_bytes: f64)
Rebalances the same budget between passes: 80% of what reserved_bytes leaves of memory_mb.
Sourcepub fn footprint(&self, width: f64, height: f64) -> u64
pub fn footprint(&self, width: f64, height: f64) -> u64
Tiles a width×height area can touch at any integer pose (a partial tile on each side).
Sourcepub fn ensure_footprint(&mut self, areas: &[(f64, f64)]) -> u64
pub fn ensure_footprint(&mut self, areas: &[(f64, f64)]) -> u64
Raises the limit to at least what one frame paints: the footprint of each of areas (every region it
places, each on its own canvas), plus two. An LRU cache smaller than the set one frame touches turns every
frame into a full miss cycle, so the budget yields here. Returns the tiles added, 0 if none.
Sourcepub fn is_resident(&self, key: &TileKey) -> bool
pub fn is_resident(&self, key: &TileKey) -> bool
Whether key is resident, without changing the eviction order.
Sourcepub fn touch(&mut self, key: &TileKey) -> Option<u32>
pub fn touch(&mut self, key: &TileKey) -> Option<u32>
A resident tile becomes the most recently used one; returns its id, None when it is not resident.
Sourcepub fn victim(&self) -> Option<u32>
pub fn victim(&self) -> Option<u32>
The tile to let go to make room for one more: the least recently used one while the cache is full, None
when there is room. Changes nothing; the host stores the tile if it is dirty, then calls
TileCache::evict. Repeat until None before TileCache::insert.
Sourcepub fn evict(&mut self, id: u32) -> Option<Tile>
pub fn evict(&mut self, id: u32) -> Option<Tile>
Removes a resident tile and counts the eviction, handing the tile back; None (and nothing counted) when
id is not resident.
Sourcepub fn insert(
&mut self,
key: TileKey,
stored: Option<StoredTile>,
) -> Result<u32, TileError>
pub fn insert( &mut self, key: TileKey, stored: Option<StoredTile>, ) -> Result<u32, TileError>
Adds key as the most recently used tile, from its stored copy or, with None, empty. Returns its id.
pub fn get(&self, id: u32) -> Option<&Tile>
pub fn get_mut(&mut self, id: u32) -> Option<&mut Tile>
pub fn id_of(&self, key: &TileKey) -> Option<u32>
Sourcepub fn mark_dirty(&mut self, id: u32, now: f64)
pub fn mark_dirty(&mut self, id: u32, now: f64)
Marks a tile written at the host’s time now.
Sourcepub fn dirty(&self, settled_before: Option<f64>) -> Vec<u32>
pub fn dirty(&self, settled_before: Option<f64>) -> Vec<u32>
Dirty resident tiles a flush must store, least recently used first. With settled_before, only tiles
whose last write precedes it: tiles still being painted every frame wait for a later flush or eviction.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TileCache
impl RefUnwindSafe for TileCache
impl Send for TileCache
impl Sync for TileCache
impl Unpin for TileCache
impl UnsafeUnpin for TileCache
impl UnwindSafe for TileCache
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
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 more