Type Alias Cache
pub type Cache<Renderer = Renderer<Renderer, Renderer>> = Cache<Renderer>;
Expand description
Aliased Type§
struct Cache<Renderer = Renderer<Renderer, Renderer>> { /* private fields */ }
Implementations
§impl<Renderer> Cache<Renderer>where
Renderer: Renderer,
impl<Renderer> Cache<Renderer>where
Renderer: Renderer,
pub fn new() -> Cache<Renderer>
pub fn new() -> Cache<Renderer>
Creates a new empty [Cache
].
pub fn with_group(group: Group) -> Cache<Renderer>
pub fn with_group(group: Group) -> Cache<Renderer>
Creates a new empty [Cache
] with the given Group
.
Caches within the same group may reuse internal rendering storage.
You should generally group caches that are likely to change together.
pub fn clear(&self)
pub fn clear(&self)
Clears the [Cache
], forcing a redraw the next time it is used.
pub fn draw(
&self,
renderer: &Renderer,
bounds: Size,
draw_fn: impl FnOnce(&mut Frame<Renderer>),
) -> <Renderer as Renderer>::Geometry
pub fn draw( &self, renderer: &Renderer, bounds: Size, draw_fn: impl FnOnce(&mut Frame<Renderer>), ) -> <Renderer as Renderer>::Geometry
Draws geometry using the provided closure and stores it in the
[Cache
].
The closure will only be called when
- the bounds have changed since the previous draw call.
- the [
Cache
] is empty or has been explicitly cleared.
Otherwise, the previously stored geometry will be returned. The
[Cache
] is not cleared in this case. In other words, it will keep
returning the stored geometry if needed.