1
0
Fork 0

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: 8f27ebf87e
This commit is contained in:
Daniel van Vugt 2023-12-07 16:28:20 +08:00
parent dc37139410
commit 28e3334b10

View file

@ -496,6 +496,7 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock,
int64_t min_render_time_allowed_us; int64_t min_render_time_allowed_us;
int64_t max_render_time_allowed_us; int64_t max_render_time_allowed_us;
int64_t next_presentation_time_us; int64_t next_presentation_time_us;
int64_t next_smooth_presentation_time_us;
int64_t next_update_time_us; int64_t next_update_time_us;
now_us = g_get_monotonic_time (); 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; 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. * 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 && 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 /* 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 * be no constantly updating actor. In this case it's best to start