print: Use LpImage for preview

This commit is contained in:
Sophie Herold 2023-12-25 20:18:26 +01:00
parent e387d8dc66
commit 6827a9c176
9 changed files with 143 additions and 44 deletions

View file

@ -583,6 +583,7 @@ pub trait FrameBufferExt {
/// Return true if the next frame should be shown and removes the outdated
/// frame
fn frame_timeout(&self, elapsed: Duration) -> bool;
fn next_frame(&self);
/// Returns the number of currently buffered frames
fn n_frames(&self) -> usize;
fn set_original_dimensions(&self, size: Coordinates);
@ -661,17 +662,21 @@ impl FrameBufferExt for ArcSwap<FrameBuffer> {
.front()
.is_some_and(|next_frame| elapsed >= next_frame.delay)
{
self.rcu(|tiling_store| {
let mut new_store = (**tiling_store).clone();
new_store.images.pop_front();
Arc::new(new_store)
});
self.next_frame();
return true;
}
false
}
fn next_frame(&self) {
self.rcu(|tiling_store| {
let mut new_store = (**tiling_store).clone();
new_store.images.pop_front();
Arc::new(new_store)
});
}
fn n_frames(&self) -> usize {
self.load().images.len()
}