Skip to content

Commit cacdcec

Browse files
committed
Keep primatives for at most 2 previous buffers
1 parent 39950aa commit cacdcec

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tiny_skia/src/window/compositor.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,14 @@ pub fn present<T: AsRef<str>>(
168168
.map_err(|_| compositor::SurfaceError::Lost)?;
169169

170170
let age = buffer.age();
171-
if age != 0 {
172-
while surface.primitives.len() as u8 > age {
173-
let _ = surface.primitives.pop_front();
174-
}
171+
172+
// Forget primatives for back buffers older than `age`
173+
// Or if this is a new buffer, keep at most two.
174+
let max = if age == 0 { 2 } else { age };
175+
while surface.primitives.len() as u8 > max {
176+
let _ = surface.primitives.pop_front();
175177
}
178+
176179
let last_primitives = if surface.primitives.len() as u8 == age {
177180
surface.primitives.pop_front()
178181
} else {

0 commit comments

Comments
 (0)