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 = CpuRenderer::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 moreAuto Trait Implementations§
impl Freeze for BufferLayerCache
impl !RefUnwindSafe for BufferLayerCache
impl !Send for BufferLayerCache
impl !Sync for BufferLayerCache
impl Unpin for BufferLayerCache
impl !UnwindSafe for BufferLayerCache
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)