[evolution/gtk3] canvas: Simplify gnome_canvas_draw()



commit a8f7820b67845c5f49694906916830162d81363f
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jan 21 05:00:53 2011 +0100

    canvas: Simplify gnome_canvas_draw()
    
    There's no need to draw all rectangles of the invalid region separately.
    It's in fact much faster to draw them all at once.

 libgnomecanvas/gnome-canvas.c |   74 ++++++++++++++--------------------------
 1 files changed, 26 insertions(+), 48 deletions(-)
---
diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c
index a1a8585..c343ed8 100644
--- a/libgnomecanvas/gnome-canvas.c
+++ b/libgnomecanvas/gnome-canvas.c
@@ -2285,57 +2285,35 @@ static gboolean
 gnome_canvas_draw (GtkWidget *widget,
                    cairo_t *cr)
 {
-	GnomeCanvas *canvas;
-	cairo_rectangle_list_t *list;
-	gint i;
-	cairo_matrix_t save_matrix;
-
-	canvas = GNOME_CANVAS (widget);
-
-	if (!gtk_widget_is_drawable (widget))
-		return FALSE;
-
-#ifdef VERBOSE
-	g_print ("Expose\n");
-#endif
-
-	list = cairo_copy_clip_rectangle_list (cr);
-
-	for (i = 0; i < list->num_rectangles; i++) {
-		cairo_rectangle_t rect;
-
-		rect.x = list->rectangles[i].x - canvas->zoom_xofs;
-		rect.y = list->rectangles[i].y - canvas->zoom_yofs;
-		rect.width = list->rectangles[i].width;
-		rect.height = list->rectangles[i].height;
-
-		if (canvas->need_update) {
-			gnome_canvas_request_redraw (canvas,
-                                                     rect.x, rect.y,
-                                                     rect.x + rect.width,
-                                                     rect.y + rect.height);
-		} else {
-			/* No pending updates, draw exposed area immediately */
-			gnome_canvas_paint_rect (canvas, cr,
-                                                 rect.x, rect.y,
-                                                 rect.x + rect.width,
-                                                 rect.y + rect.height);
-
-			cairo_get_matrix (cr, &save_matrix);
-			cairo_save (cr);
-
-			/* And call expose on parent container class */
-			GTK_WIDGET_CLASS (canvas_parent_class)->
-				draw (widget, cr);
+	GnomeCanvas *canvas = GNOME_CANVAS (widget);
+	cairo_rectangle_int_t rect;
 
-			cairo_restore (cr);
-			cairo_set_matrix (cr, &save_matrix);
-		}
-	}
+        gdk_cairo_get_clip_rectangle (cr, &rect);
 
-	cairo_rectangle_list_destroy (list);
+        if (canvas->need_update) {
+                gnome_canvas_request_redraw (canvas,
+                                             rect.x, rect.y,
+                                             rect.x + rect.width,
+                                             rect.y + rect.height);
+        } else {
+                cairo_save (cr);
+                cairo_translate (cr,
+                                 - canvas->zoom_xofs,
+                                 - canvas->zoom_yofs);
+
+                /* No pending updates, draw exposed area immediately */
+                gnome_canvas_paint_rect (canvas, cr,
+                                         rect.x, rect.y,
+                                         rect.x + rect.width,
+                                         rect.y + rect.height);
+                cairo_restore (cr);
+
+                /* And call expose on parent container class */
+                GTK_WIDGET_CLASS (canvas_parent_class)->
+                        draw (widget, cr);
+        }
 
-	return FALSE;
+return FALSE;
 }
 
 /* Emits an event for an item in the canvas, be it the current item, grabbed



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