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



commit 6a6fd5a6da67db1296ca447d2e366aed2e77fd9d
Author: Damon Chaplin <damon gnome org>
Date:   Wed Jul 7 22:21:09 2010 +0100

    2010-07-07  Damon Chaplin  <damon gnome org>
    
    	    * src/goocanvasitemsimple.c
    	    (goo_canvas_item_simple_user_bounds_to_device): if the transform is
    	    a translation just add it to the bounds to save time.

 ChangeLog                 |    6 ++++
 src/goocanvasitemsimple.c |   73 +++++++++++++++++++++++++++------------------
 2 files changed, 50 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d9ac701..058e32b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-07-07  Damon Chaplin  <damon gnome org>
 
+	* src/goocanvasitemsimple.c
+	(goo_canvas_item_simple_user_bounds_to_device): if the transform is
+	a translation just add it to the bounds to save time.
+
+2010-07-07  Damon Chaplin  <damon gnome org>
+
 	* src/goocanvasitemsimple.c (goo_canvas_item_simple_get_path_bounds):
 	removed code to support cairo pre-1.4 since we depend on >1.4 now.
 
diff --git a/src/goocanvasitemsimple.c b/src/goocanvasitemsimple.c
index d65ad7b..f09e177 100644
--- a/src/goocanvasitemsimple.c
+++ b/src/goocanvasitemsimple.c
@@ -1398,35 +1398,50 @@ goo_canvas_item_simple_user_bounds_to_device (GooCanvasItemSimple *item,
 					      cairo_t             *cr,
 					      GooCanvasBounds     *bounds)
 {
-  GooCanvasBounds tmp_bounds = *bounds, tmp_bounds2 = *bounds;
-
-  /* Convert the top-left and bottom-right corners to device coords. */
-  cairo_user_to_device (cr, &tmp_bounds.x1, &tmp_bounds.y1);
-  cairo_user_to_device (cr, &tmp_bounds.x2, &tmp_bounds.y2);
-
-  /* Now convert the top-right and bottom-left corners. */
-  cairo_user_to_device (cr, &tmp_bounds2.x1, &tmp_bounds2.y2);
-  cairo_user_to_device (cr, &tmp_bounds2.x2, &tmp_bounds2.y1);
-
-  /* Calculate the minimum x coordinate seen and put in x1. */
-  bounds->x1 = MIN (tmp_bounds.x1, tmp_bounds.x2);
-  bounds->x1 = MIN (bounds->x1, tmp_bounds2.x1);
-  bounds->x1 = MIN (bounds->x1, tmp_bounds2.x2);
-
-  /* Calculate the maximum x coordinate seen and put in x2. */
-  bounds->x2 = MAX (tmp_bounds.x1, tmp_bounds.x2);
-  bounds->x2 = MAX (bounds->x2, tmp_bounds2.x1);
-  bounds->x2 = MAX (bounds->x2, tmp_bounds2.x2);
-
-  /* Calculate the minimum y coordinate seen and put in y1. */
-  bounds->y1 = MIN (tmp_bounds.y1, tmp_bounds.y2);
-  bounds->y1 = MIN (bounds->y1, tmp_bounds2.y1);
-  bounds->y1 = MIN (bounds->y1, tmp_bounds2.y2);
+  cairo_matrix_t matrix;
 
-  /* Calculate the maximum y coordinate seen and put in y2. */
-  bounds->y2 = MAX (tmp_bounds.y1, tmp_bounds.y2);
-  bounds->y2 = MAX (bounds->y2, tmp_bounds2.y1);
-  bounds->y2 = MAX (bounds->y2, tmp_bounds2.y2);
+  /* If the transform is a translation we can simply add it to the bounds. */
+  cairo_get_matrix (cr, &matrix);
+  if (matrix.xx == 1.0 && matrix.yx == 0.0
+      && matrix.xy == 0.0 && matrix.yy == 1.0)
+    {
+      bounds->x1 += matrix.x0;
+      bounds->x2 += matrix.x0;
+      bounds->y1 += matrix.y0;
+      bounds->y2 += matrix.y0;
+    }
+  else
+    {
+      GooCanvasBounds tmp_bounds = *bounds, tmp_bounds2 = *bounds;
+
+      /* Convert the top-left and bottom-right corners to device coords. */
+      cairo_user_to_device (cr, &tmp_bounds.x1, &tmp_bounds.y1);
+      cairo_user_to_device (cr, &tmp_bounds.x2, &tmp_bounds.y2);
+
+      /* Now convert the top-right and bottom-left corners. */
+      cairo_user_to_device (cr, &tmp_bounds2.x1, &tmp_bounds2.y2);
+      cairo_user_to_device (cr, &tmp_bounds2.x2, &tmp_bounds2.y1);
+
+      /* Calculate the minimum x coordinate seen and put in x1. */
+      bounds->x1 = MIN (tmp_bounds.x1, tmp_bounds.x2);
+      bounds->x1 = MIN (bounds->x1, tmp_bounds2.x1);
+      bounds->x1 = MIN (bounds->x1, tmp_bounds2.x2);
+
+      /* Calculate the maximum x coordinate seen and put in x2. */
+      bounds->x2 = MAX (tmp_bounds.x1, tmp_bounds.x2);
+      bounds->x2 = MAX (bounds->x2, tmp_bounds2.x1);
+      bounds->x2 = MAX (bounds->x2, tmp_bounds2.x2);
+
+      /* Calculate the minimum y coordinate seen and put in y1. */
+      bounds->y1 = MIN (tmp_bounds.y1, tmp_bounds.y2);
+      bounds->y1 = MIN (bounds->y1, tmp_bounds2.y1);
+      bounds->y1 = MIN (bounds->y1, tmp_bounds2.y2);
+
+      /* Calculate the maximum y coordinate seen and put in y2. */
+      bounds->y2 = MAX (tmp_bounds.y1, tmp_bounds.y2);
+      bounds->y2 = MAX (bounds->y2, tmp_bounds2.y1);
+      bounds->y2 = MAX (bounds->y2, tmp_bounds2.y2);
+    }
 }
 
 



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