Struct forma_render::cpu::buffer::BufferLayerCache
source · pub struct BufferLayerCache { /* private fields */ }Expand description
A per-Buffer cache that enables forma to skip rendering to buffer
regions that have not changed.
Examples
let mut buffer = vec![0; 4];
let mut composition = Composition::new();
let mut renderer = Renderer::new();
let layer_cache = renderer.create_buffer_layer_cache().unwrap();
renderer.render(
&mut composition,
&mut BufferBuilder::new(&mut buffer, &mut LinearLayout::new(1, 1 * 4, 1))
.layer_cache(layer_cache.clone())
.build(),
RGBA,
Color { r: 1.0, g: 1.0, b: 1.0, a: 1.0 },
None,
);
// Rendered white on first frame.
assert_eq!(buffer, [255; 4]);
// Reset buffer manually.
buffer = vec![0; 4];
renderer.render(
&mut composition,
&mut BufferBuilder::new(&mut buffer, &mut LinearLayout::new(1, 1 * 4, 1))
.layer_cache(layer_cache.clone())
.build(),
RGBA,
Color { r: 1.0, g: 1.0, b: 1.0, a: 1.0 },
None,
);
// Skipped rendering on second frame since nothing changed.
assert_eq!(buffer, [0; 4]);Implementations§
Trait Implementations§
source§impl Clone for BufferLayerCache
impl Clone for BufferLayerCache
source§fn clone(&self) -> BufferLayerCache
fn clone(&self) -> BufferLayerCache
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more