From c2df5586c1e73bb991548294dd10def15fa2aabd Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Wed, 17 Jul 2024 14:01:37 +0200 Subject: [PATCH] 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 --- build-aux/flatpak/org.gnome.Loupe.Devel.json | 2 +- src/decoder/tiling.rs | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/build-aux/flatpak/org.gnome.Loupe.Devel.json b/build-aux/flatpak/org.gnome.Loupe.Devel.json index af7895d..db4a00d 100644 --- a/build-aux/flatpak/org.gnome.Loupe.Devel.json +++ b/build-aux/flatpak/org.gnome.Loupe.Devel.json @@ -159,7 +159,7 @@ { "type": "git", "url": "https://gitlab.gnome.org/sophie-h/glycin.git", - "commit": "4b0759839322fad9277c7f823438abe4937e4027" + "commit": "9701eb7ac36cd85ce75241bf50dfe325b50f54c9" } ] }, diff --git a/src/decoder/tiling.rs b/src/decoder/tiling.rs index 9656268..55185b1 100644 --- a/src/decoder/tiling.rs +++ b/src/decoder/tiling.rs @@ -648,12 +648,13 @@ impl SharedFrameBuffer { /// Return true if the next frame should be shown and removes the outdated /// frame pub fn frame_timeout(&self, elapsed: Duration) -> bool { - if self - .buffer - .load() - .images - .front() - .is_some_and(|next_frame| elapsed >= next_frame.delay) + let images = &self.buffer.load().images; + + // Only move to next image if there is one buffered + if images.len() > 1 + && images + .front() + .is_some_and(|next_frame| elapsed >= next_frame.delay) { self.next_frame(); return true;