clutter/stage-cogl: Protect against extremely high refresh rates

After 4faeb12731, the maximum time allowed for an update to happen
is calculated as:

  max_render_time_allowed = refresh_interval - 1000 * sync_delay;

However, extremely small refresh intervals -- that come as consequence
to extremely high refresh rates -- may fall into an odd numerical range
when refresh_interval < 1000 * sync_delay. That would give us a negative
time.

To be extra cautious about it, add another sanity check for this case.

Change suggested by Jasper St. Pierre.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/363
This commit is contained in:
Georges Basile Stavracas Neto 2019-06-07 12:12:55 -03:00
parent e415cc538a
commit 1dbf25afa1
No known key found for this signature in database
GPG Key ID: 886C17EE170D1385

View File

@ -199,6 +199,17 @@ clutter_stage_cogl_schedule_update (ClutterStageWindow *stage_window,
min_render_time_allowed = refresh_interval / 2;
max_render_time_allowed = refresh_interval - 1000 * sync_delay;
/* Be robust in the case of incredibly bogus refresh rate */
if (max_render_time_allowed <= 0)
{
g_warning ("Unsupported monitor refresh rate detected. "
"(Refresh rate: %.3f, refresh interval: %ld)",
refresh_rate,
refresh_interval);
stage_cogl->update_time = now;
return;
}
if (min_render_time_allowed > max_render_time_allowed)
min_render_time_allowed = max_render_time_allowed;