[cairo-commit] goocanvas/src goocanvasrect.c,1.12,1.13

Damon Chaplin commit at pdx.freedesktop.org
Wed Apr 25 03:23:50 PDT 2007


Committed by: damon

Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv11578/src

Modified Files:
	goocanvasrect.c 
Log Message:
2007-04-25  Damon Chaplin  <damon at gnome.org>

	* src/goocanvasrect.c (goo_canvas_rect_update): added optimized
	function to calculate the bounds without using cairo.



Index: goocanvasrect.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasrect.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- goocanvasrect.c	25 Feb 2007 17:37:57 -0000	1.12
+++ goocanvasrect.c	25 Apr 2007 10:23:40 -0000	1.13
@@ -29,6 +29,7 @@
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "goocanvasrect.h"
+#include "goocanvas.h"
 
 
 enum {
@@ -44,17 +45,6 @@
 
 
 static void canvas_item_interface_init   (GooCanvasItemIface *iface);
-static void goo_canvas_rect_finalize     (GObject            *object);
-static void goo_canvas_rect_get_property (GObject            *object,
-					  guint               param_id,
-					  GValue             *value,
-					  GParamSpec         *pspec);
-static void goo_canvas_rect_set_property (GObject            *object,
-					  guint               param_id,
-					  const GValue       *value,
-					  GParamSpec         *pspec);
-static void goo_canvas_rect_create_path (GooCanvasItemSimple *simple,
-					 cairo_t             *cr);
 
 G_DEFINE_TYPE_WITH_CODE (GooCanvasRect, goo_canvas_rect,
 			 GOO_TYPE_CANVAS_ITEM_SIMPLE,
@@ -112,23 +102,6 @@
 
 
 static void
-goo_canvas_rect_class_init (GooCanvasRectClass *klass)
-{
-  GObjectClass *gobject_class = (GObjectClass*) klass;
-  GooCanvasItemSimpleClass *simple_class = (GooCanvasItemSimpleClass*) klass;
-
-  gobject_class->finalize     = goo_canvas_rect_finalize;
-
-  gobject_class->get_property = goo_canvas_rect_get_property;
-  gobject_class->set_property = goo_canvas_rect_set_property;
-
-  simple_class->simple_create_path = goo_canvas_rect_create_path;
-
-  goo_canvas_rect_install_common_properties (gobject_class);
-}
-
-
-static void
 goo_canvas_rect_init (GooCanvasRect *rect)
 {
   rect->rect_data = g_slice_new0 (GooCanvasRectData);
@@ -392,6 +365,32 @@
 }
 
 
+static void
+goo_canvas_rect_update  (GooCanvasItemSimple *simple,
+			 cairo_t             *cr)
+{
+  GooCanvasRect *rect = (GooCanvasRect*) simple;
+  GooCanvasRectData *rect_data = rect->rect_data;
+  gdouble line_width, half_line_width;
+  GValue *value;
+
+  /* We can quickly compute the bounds as being just the rectangle's size
+     plus half the line width around each edge. */
+  value = goo_canvas_style_get_property (simple->simple_data->style,
+					 goo_canvas_style_line_width_id);
+  if (value)
+    line_width = value->data[0].v_double;
+  else
+    line_width = goo_canvas_get_default_line_width (simple->canvas);
+
+  half_line_width = line_width / 2;
+
+  simple->bounds.x1 = rect_data->x - half_line_width;
+  simple->bounds.y1 = rect_data->y - half_line_width;
+  simple->bounds.x2 = rect_data->x + rect_data->width + half_line_width;
+  simple->bounds.y2 = rect_data->y + rect_data->height + half_line_width;
+}
+
 
 static void
 goo_canvas_rect_set_model    (GooCanvasItem      *item,
@@ -420,6 +419,24 @@
 }
 
 
+static void
+goo_canvas_rect_class_init (GooCanvasRectClass *klass)
+{
+  GObjectClass *gobject_class = (GObjectClass*) klass;
+  GooCanvasItemSimpleClass *simple_class = (GooCanvasItemSimpleClass*) klass;
+
+  gobject_class->finalize     = goo_canvas_rect_finalize;
+
+  gobject_class->get_property = goo_canvas_rect_get_property;
+  gobject_class->set_property = goo_canvas_rect_set_property;
+
+  simple_class->simple_create_path = goo_canvas_rect_create_path;
+  simple_class->simple_update      = goo_canvas_rect_update;
+
+  goo_canvas_rect_install_common_properties (gobject_class);
+}
+
+
 /**
  * SECTION:goocanvasrectmodel
  * @Title: GooCanvasRectModel



More information about the cairo-commit mailing list