[goocanvas/new-api] 2010-06-28 Damon Chaplin <damon gnome org>



commit 6a794ef692df7555186fff3a9e511794d2e2b134
Author: Damon Chaplin <damon gnome org>
Date:   Mon Jun 28 19:31:03 2010 +0100

    2010-06-28  Damon Chaplin  <damon gnome org>
    
    	    * src/goocanvas.c: added "before-initial-expose" flag which we use
    	    to ignore any redraw requests before the initial expose (since we
    	    know the entire canvas needs redrawing anyway). This speeds up the
    	    creation of lots of items, e.g. scalability-demo.

 ChangeLog       |    7 +++++++
 src/goocanvas.c |   13 ++++++++++++-
 src/goocanvas.h |    3 +++
 3 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dbcc0fd..2753883 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-06-28  Damon Chaplin  <damon gnome org>
 
+	* src/goocanvas.c: added "before-initial-expose" flag which we use
+	to ignore any redraw requests before the initial expose (since we
+	know the entire canvas needs redrawing anyway). This speeds up the
+	creation of lots of items, e.g. scalability-demo.
+
+2010-06-28  Damon Chaplin  <damon gnome org>
+
 	* src/goocanvasitemsimple.c:
 	(goo_canvas_item_simple_paint_path): removed "add_tolerance" argument
 	as it is never needed for painting.
diff --git a/src/goocanvas.c b/src/goocanvas.c
index bc4b78c..923ab55 100644
--- a/src/goocanvas.c
+++ b/src/goocanvas.c
@@ -442,6 +442,7 @@ goo_canvas_init (GooCanvas *canvas)
   canvas->anchor = GTK_ANCHOR_NORTH_WEST;
   canvas->clear_background = TRUE;
   canvas->redraw_when_scrolled = FALSE;
+  canvas->before_initial_expose = TRUE;
 
   /* Set the default bounds to a reasonable size. */
   canvas->bounds.x1 = 0.0;
@@ -2242,6 +2243,11 @@ goo_canvas_request_item_redraw (GooCanvas             *canvas,
 				const GooCanvasBounds *bounds,
 				gboolean               is_static)
 {
+  /* If the canvas hasn't been painted yet, we can just return as it all needs
+     a redraw. This can save a lot of time if there are lots of items. */
+  if (canvas->before_initial_expose)
+    return;
+
   if (is_static)
     request_static_redraw (canvas, bounds);
   else
@@ -2282,7 +2288,10 @@ goo_canvas_expose_event (GtkWidget      *widget,
   double x1, y1, x2, y2;
 
   if (!canvas->root_item)
-    return FALSE;
+    {
+      canvas->before_initial_expose = FALSE;
+      return FALSE;
+    }
 
   if (event->window != canvas->canvas_window)
     return FALSE;
@@ -2355,6 +2364,8 @@ goo_canvas_expose_event (GtkWidget      *widget,
 
   GTK_WIDGET_CLASS (goo_canvas_parent_class)->expose_event (widget, event);
 
+  canvas->before_initial_expose = FALSE;
+
   return FALSE;
 }
 
diff --git a/src/goocanvas.h b/src/goocanvas.h
index b9d1833..a5d060f 100644
--- a/src/goocanvas.h
+++ b/src/goocanvas.h
@@ -88,6 +88,9 @@ struct _GooCanvas
      useful when there are sticky items to reduce flicker, but is slower. */
   guint redraw_when_scrolled : 1;
 
+  /* If the canvas hasn't received the initial expose event yet. */
+  guint before_initial_expose : 1;
+
   /* This is the padding around the automatic bounds. */
   gdouble bounds_padding;
 



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