[PATCH] throbber: Don't skip last frame when waiting for end.
Michal Srb
msrb at suse.com
Thu Oct 25 13:45:38 UTC 2018
If the stop_trigger is set and we are waiting for the last frame to stop the
animation, make sure we don't accidentally skip the last frame. It could
happen if the machine is busy and can't keep up with the frames or when the
animation has more than 60 frames (30FPS * 2 seconds).
---
This is fix for downstream bug in openSUSE:
https://bugzilla.opensuse.org/show_bug.cgi?id=1110199
The openSUSE Leap plymouth theme has 73 frames for the throbber animation.
(Strange, I know, I have now requested to reduce it to 60 frames). This way the
last frame is usually skipped until some random timing in the system makes it
finally hit the last frame. This caused that plymouth ran many more loops of
the throbber animation after being told to quit.
src/libply-splash-graphics/ply-throbber.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/libply-splash-graphics/ply-throbber.c b/src/libply-splash-graphics/ply-throbber.c
index f18feb6..a4311fd 100644
--- a/src/libply-splash-graphics/ply-throbber.c
+++ b/src/libply-splash-graphics/ply-throbber.c
@@ -144,6 +144,7 @@ animate_at_time (ply_throbber_t *throbber,
ply_pixel_buffer_t *const *frames;
bool should_continue;
double percent_in_sequence;
+ int last_frame_number;
number_of_frames = ply_array_get_size (throbber->frames);
@@ -152,11 +153,19 @@ animate_at_time (ply_throbber_t *throbber,
should_continue = true;
percent_in_sequence = fmod (time, THROBBER_DURATION) / THROBBER_DURATION;
+ last_frame_number = throbber->frame_number;
throbber->frame_number = (int) (number_of_frames * percent_in_sequence);
- if (throbber->stop_trigger != NULL)
+ if (throbber->stop_trigger != NULL) {
+ /* If we are trying to stop, make sure we don't skip the last
+ * frame and loop around. Clamp it to the last frame.
+ */
+ if (last_frame_number > throbber->frame_number)
+ throbber->frame_number = number_of_frames - 1;
+
if (throbber->frame_number == number_of_frames - 1)
should_continue = false;
+ }
frames = (ply_pixel_buffer_t *const *) ply_array_get_pointer_elements (throbber->frames);
ply_pixel_buffer_get_size (frames[throbber->frame_number], &throbber->frame_area);
--
2.16.4
More information about the plymouth
mailing list