From f27dd214267b5b907411cefb85350acfbb26ac77 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 26 Apr 2016 03:08:11 -0700 Subject: frametimings: reuse previous frame timing in common case Typically, there won't be any references on old frame timings except for the most recent timing. So instead of discarding these and re-entering gslice twice, just steal the old frame timing and reuse it. https://bugzilla.gnome.org/show_bug.cgi?id=765592 --- gdk/gdkframeclock.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'gdk/gdkframeclock.c') diff --git a/gdk/gdkframeclock.c b/gdk/gdkframeclock.c index f84aee77bb..6f6d1a1d42 100644 --- a/gdk/gdkframeclock.c +++ b/gdk/gdkframeclock.c @@ -416,12 +416,18 @@ _gdk_frame_clock_begin_frame (GdkFrameClock *frame_clock) priv->frame_counter++; priv->current = (priv->current + 1) % FRAME_HISTORY_MAX_LENGTH; + /* Try to steal the previous frame timing instead of discarding + * and allocating a new one. + */ + if G_LIKELY (priv->n_timings == FRAME_HISTORY_MAX_LENGTH && + _gdk_frame_timings_steal (priv->timings[priv->current], + priv->frame_counter)) + return; + if (priv->n_timings < FRAME_HISTORY_MAX_LENGTH) priv->n_timings++; else - { - gdk_frame_timings_unref(priv->timings[priv->current]); - } + gdk_frame_timings_unref(priv->timings[priv->current]); priv->timings[priv->current] = _gdk_frame_timings_new (priv->frame_counter); } -- cgit v1.2.1