diff options
-rw-r--r-- | clutter/clutter/cogl/clutter-stage-cogl.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index 2a2a17e05..1ed7e01c4 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -152,6 +152,9 @@ clutter_stage_cogl_schedule_update (ClutterStageWindow *stage_window, gint64 now; float refresh_rate; gint64 refresh_interval; + int64_t min_render_time_allowed; + int64_t max_render_time_allowed; + int64_t next_presentation_time; if (stage_cogl->update_time != -1) return; @@ -184,10 +187,18 @@ clutter_stage_cogl_schedule_update (ClutterStageWindow *stage_window, if (refresh_interval == 0) refresh_interval = 16667; /* 1/60th second */ - stage_cogl->update_time = stage_cogl->last_presentation_time + 1000 * sync_delay; + min_render_time_allowed = refresh_interval / 2; + max_render_time_allowed = refresh_interval - 1000 * sync_delay; - while (stage_cogl->update_time < now) - stage_cogl->update_time += refresh_interval; + if (min_render_time_allowed > max_render_time_allowed) + min_render_time_allowed = max_render_time_allowed; + + next_presentation_time = stage_cogl->last_presentation_time + refresh_interval; + + while (next_presentation_time < now + min_render_time_allowed) + next_presentation_time += refresh_interval; + + stage_cogl->update_time = next_presentation_time - max_render_time_allowed; } static gint64 |