tiling: Don't completely empty buffer in animation

Previously, this would lead to flickering if the decoder was too slow.
Now, the last frame will be shown until a new one is available.

Closes #382
This commit is contained in:
Sophie Herold 2024-07-17 14:01:37 +02:00
parent 9b56f30c3b
commit c2df5586c1
2 changed files with 8 additions and 7 deletions

View file

@ -159,7 +159,7 @@
{ {
"type": "git", "type": "git",
"url": "https://gitlab.gnome.org/sophie-h/glycin.git", "url": "https://gitlab.gnome.org/sophie-h/glycin.git",
"commit": "4b0759839322fad9277c7f823438abe4937e4027" "commit": "9701eb7ac36cd85ce75241bf50dfe325b50f54c9"
} }
] ]
}, },

View file

@ -648,12 +648,13 @@ impl SharedFrameBuffer {
/// Return true if the next frame should be shown and removes the outdated /// Return true if the next frame should be shown and removes the outdated
/// frame /// frame
pub fn frame_timeout(&self, elapsed: Duration) -> bool { pub fn frame_timeout(&self, elapsed: Duration) -> bool {
if self let images = &self.buffer.load().images;
.buffer
.load() // Only move to next image if there is one buffered
.images if images.len() > 1
.front() && images
.is_some_and(|next_frame| elapsed >= next_frame.delay) .front()
.is_some_and(|next_frame| elapsed >= next_frame.delay)
{ {
self.next_frame(); self.next_frame();
return true; return true;