[gnome-builder] rg: avoid duplicate draws for same offset



commit 277a3ea25f5a0e1c732d35def91a90c52db7bddf
Author: Christian Hergert <christian hergert me>
Date:   Tue Jun 2 01:50:01 2015 -0700

    rg: avoid duplicate draws for same offset
    
    When we are working with small graphs, we can have multiple draws that
    would result in blitting at the same offset. This avoids that by ignoring
    the draw if the x_offset hasn't moved.

 contrib/rg/rg-graph.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/contrib/rg/rg-graph.c b/contrib/rg/rg-graph.c
index 3d0f56d..90dac51 100644
--- a/contrib/rg/rg-graph.c
+++ b/contrib/rg/rg-graph.c
@@ -117,6 +117,7 @@ rg_graph_tick_cb (GtkWidget     *widget,
   gint64 frame_time;
   gint64 end_time;
   gint64 timespan;
+  gint x_offset;
 
   g_assert (RG_IS_GRAPH (self));
 
@@ -137,9 +138,13 @@ rg_graph_tick_cb (GtkWidget     *widget,
   end_time = rg_table_get_end_time (priv->table);
   timespan = rg_table_get_timespan (priv->table);
 
-  priv->x_offset = -((frame_time - end_time) / (gdouble)timespan * alloc.width);
+  x_offset = -((frame_time - end_time) / (gdouble)timespan * alloc.width);
 
-  gtk_widget_queue_draw (widget);
+  if (x_offset != priv->x_offset)
+    {
+      priv->x_offset = x_offset;
+      gtk_widget_queue_draw (widget);
+    }
 
   return G_SOURCE_CONTINUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]