pub struct RenderingCache<T> { /* private fields */ }
Expand description
The RenderingCache, in combination with CachedGraphicsData, allows back ends to store data that’s either intensive to compute or has bad CPU locality. Back ends typically keep a RenderingCache instance and use the item’s cached_rendering_data() integer as index in the vec_arena::Arena.
This is used only for the crate::item_rendering::PartialRenderingCache
Implementations§
Source§impl<T> RenderingCache<T>
impl<T> RenderingCache<T>
Sourcepub fn generation(&self) -> usize
pub fn generation(&self) -> usize
Returns the generation of the cache. The generation starts at 1 and is increased whenever the cache is cleared, for example when the GL context is lost.
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut CachedGraphicsData<T>>
pub fn get_mut(&mut self, index: usize) -> Option<&mut CachedGraphicsData<T>>
Retrieves a mutable reference to the cached graphics data at index.
Sourcepub fn contains(&self, index: usize) -> bool
pub fn contains(&self, index: usize) -> bool
Returns true if a cache entry exists for the given index.
Sourcepub fn insert(&mut self, data: CachedGraphicsData<T>) -> usize
pub fn insert(&mut self, data: CachedGraphicsData<T>) -> usize
Inserts data into the cache and returns the index for retrieval later.
Sourcepub fn get(&self, index: usize) -> Option<&CachedGraphicsData<T>>
pub fn get(&self, index: usize) -> Option<&CachedGraphicsData<T>>
Retrieves an immutable reference to the cached graphics data at index.
Sourcepub fn remove(&mut self, index: usize) -> CachedGraphicsData<T>
pub fn remove(&mut self, index: usize) -> CachedGraphicsData<T>
Removes the cached graphics data at the given index.