From 28e3334b106502eeea9c2f2104979975284106ad Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Thu, 7 Dec 2023 16:28:20 +0800 Subject: [PATCH] clutter/frame-clock: Reuse existing idle period detection While it was correct for double buffering, the test was wrong for triple buffering and would lead to accidentally staying in triple buffering for too long. Fixes: 8f27ebf87eee6057992a90560d4118ab7bdf138d --- clutter/clutter/clutter-frame-clock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clutter/clutter/clutter-frame-clock.c b/clutter/clutter/clutter-frame-clock.c index 30a319f60..0c578a7af 100644 --- a/clutter/clutter/clutter-frame-clock.c +++ b/clutter/clutter/clutter-frame-clock.c @@ -496,6 +496,7 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock, int64_t min_render_time_allowed_us; int64_t max_render_time_allowed_us; int64_t next_presentation_time_us; + int64_t next_smooth_presentation_time_us; int64_t next_update_time_us; now_us = g_get_monotonic_time (); @@ -540,7 +541,8 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock, * */ last_presentation_time_us = frame_clock->last_presentation_time_us; - next_presentation_time_us = last_presentation_time_us + refresh_interval_us; + next_smooth_presentation_time_us = last_presentation_time_us + refresh_interval_us; + next_presentation_time_us = next_smooth_presentation_time_us; /* * However, the last presentation could have happened more than a frame ago. @@ -607,7 +609,7 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock, } if (frame_clock->last_presentation_flags & CLUTTER_FRAME_INFO_FLAG_VSYNC && - next_presentation_time_us != last_presentation_time_us + refresh_interval_us) + next_presentation_time_us != next_smooth_presentation_time_us) { /* There was an idle period since the last presentation, so there seems * be no constantly updating actor. In this case it's best to start