Merge branch 'frame-clock' into 'master'

gdkframeclockidle: Don't permanently skew frame time

Closes #1612

See merge request GNOME/gtk!731
This commit is contained in:
Matthias Clasen 2019-04-11 17:23:03 +00:00
commit b6f2969872

View File

@ -38,9 +38,6 @@
struct _GdkFrameClockIdlePrivate struct _GdkFrameClockIdlePrivate
{ {
GTimer *timer;
/* timer_base is used to avoid ever going backward */
gint64 timer_base;
gint64 frame_time; gint64 frame_time;
gint64 min_next_frame_time; gint64 min_next_frame_time;
gint64 sleep_serial; gint64 sleep_serial;
@ -161,22 +158,12 @@ compute_frame_time (GdkFrameClockIdle *idle)
{ {
GdkFrameClockIdlePrivate *priv = idle->priv; GdkFrameClockIdlePrivate *priv = idle->priv;
gint64 computed_frame_time; gint64 computed_frame_time;
gint64 elapsed;
elapsed = g_get_monotonic_time () + priv->timer_base; computed_frame_time = g_get_monotonic_time ();
if (elapsed < priv->frame_time)
{ /* ensure monotonicity of frame time */
/* clock went backward. adapt to that by forevermore increasing if (computed_frame_time <= priv->frame_time)
* timer_base. For now, assume we've gone forward in time 1ms.
*/
/* hmm. just fix GTimer? */
computed_frame_time = priv->frame_time + 1; computed_frame_time = priv->frame_time + 1;
priv->timer_base += (priv->frame_time - elapsed) + 1;
}
else
{
computed_frame_time = elapsed;
}
return computed_frame_time; return computed_frame_time;
} }