From f1215d2d776dd44e389b7c141eaac3f72942deae Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 22 May 2020 15:30:05 +0200 Subject: [PATCH] frame clock: Use compositor refresh rate info even if presentation time not set On my X11 + nvidia setup gnome-shell doesn't report presentation times. However it does report refresh rate. We were mostly using this in our calculation except when computing predicted presentation time, were it fell back on the default 60Hz. --- gdk/gdkframeclock.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/gdk/gdkframeclock.c b/gdk/gdkframeclock.c index fc0fbe6b8c..04dfd93c7b 100644 --- a/gdk/gdkframeclock.c +++ b/gdk/gdkframeclock.c @@ -599,16 +599,12 @@ gdk_frame_clock_get_refresh_info (GdkFrameClock *frame_clock, gint64 *presentation_time_return) { gint64 frame_counter; + gint64 default_refresh_interval = DEFAULT_REFRESH_INTERVAL; g_return_if_fail (GDK_IS_FRAME_CLOCK (frame_clock)); frame_counter = gdk_frame_clock_get_frame_counter (frame_clock); - if (presentation_time_return) - *presentation_time_return = 0; - if (refresh_interval_return) - *refresh_interval_return = DEFAULT_REFRESH_INTERVAL; - while (TRUE) { GdkFrameTimings *timings = gdk_frame_clock_get_timings (frame_clock, frame_counter); @@ -616,19 +612,21 @@ gdk_frame_clock_get_refresh_info (GdkFrameClock *frame_clock, gint64 refresh_interval; if (timings == NULL) - return; + break; refresh_interval = timings->refresh_interval; presentation_time = timings->presentation_time; + if (refresh_interval == 0) + refresh_interval = default_refresh_interval; + else + default_refresh_interval = refresh_interval; + if (presentation_time != 0) { if (presentation_time > base_time - MAX_HISTORY_AGE && presentation_time_return) { - if (refresh_interval == 0) - refresh_interval = DEFAULT_REFRESH_INTERVAL; - if (refresh_interval_return) *refresh_interval_return = refresh_interval; @@ -637,13 +635,20 @@ gdk_frame_clock_get_refresh_info (GdkFrameClock *frame_clock, if (presentation_time_return) *presentation_time_return = presentation_time; + + return; } - return; + break; } frame_counter--; } + + if (presentation_time_return) + *presentation_time_return = 0; + if (refresh_interval_return) + *refresh_interval_return = default_refresh_interval; } void