Skip to main content

TileCache

Struct TileCache 

Source
pub struct TileCache { /* private fields */ }
Expand description

The in-memory tile cache.

Implementations§

Source§

impl TileCache

Source

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).

Source

pub fn size(&self) -> usize

Source

pub fn max_tiles(&self) -> u64

Source

pub fn set_max_tiles(&mut self, max_tiles: u64)

Overrides the limit (tests use small fixed caches).

Source

pub fn stats(&self) -> TileCacheStats

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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.

Source

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).

Source

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.

Source

pub fn is_resident(&self, key: &TileKey) -> bool

Whether key is resident, without changing the eviction order.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get(&self, id: u32) -> Option<&Tile>

Source

pub fn get_mut(&mut self, id: u32) -> Option<&mut Tile>

Source

pub fn id_of(&self, key: &TileKey) -> Option<u32>

Source

pub fn mark_dirty(&mut self, id: u32, now: f64)

Marks a tile written at the host’s time now.

Source

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.

Source

pub fn encoded(&mut self)

The host encoded one tile for storage.

Source

pub fn saved(&mut self, id: u32)

The host stored a resident tile: it is clean and has a stored copy.

Source

pub fn clear(&mut self)

Drops every resident tile (the host flushes first).

Trait Implementations§

Source§

impl Debug for TileCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.