[cairo-commit] goocanvas/src goocanvas.c,1.17,1.18

Damon Chaplin commit at pdx.freedesktop.org
Mon Apr 30 14:09:55 PDT 2007


Committed by: damon

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

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

	* src/goocanvas.c (goo_canvas_create_cairo_context): if the GooCanvas
	isn't realized, use a temporary image surface to create the cairo_t.
	Hopefully that will result in exactly the same bounds of items.
	(goo_canvas_get_item): initialize item to NULL.



Index: goocanvas.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvas.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- goocanvas.c	5 Apr 2007 11:28:40 -0000	1.17
+++ goocanvas.c	30 Apr 2007 21:09:45 -0000	1.18
@@ -541,10 +541,23 @@
 goo_canvas_create_cairo_context (GooCanvas *canvas)
 {
   cairo_t *cr;
+  cairo_surface_t *surface;
 
-  g_return_val_if_fail (canvas->canvas_window != NULL, NULL);
-
-  cr = gdk_cairo_create (canvas->canvas_window);
+  /* If the canvas is realized we can use the GDK function to create a cairo
+     context for the canvas window. Otherwise we create a small temporary
+     image surface. */
+  if (canvas->canvas_window)
+    {
+      cr = gdk_cairo_create (canvas->canvas_window);
+    }
+  else
+    {
+      surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+      cr = cairo_create (surface);
+      /* The cairo context will keep a reference to the surface so we can
+	 drop our reference. */
+      cairo_surface_destroy (surface);
+    }
 
   /* We use CAIRO_ANTIALIAS_GRAY as the default antialiasing mode, as that is
      what is recommended when using unhinted text. */
@@ -832,7 +845,7 @@
 goo_canvas_get_item (GooCanvas          *canvas,
 		     GooCanvasItemModel *model)
 {
-  GooCanvasItem *item;
+  GooCanvasItem *item = NULL;
 
   g_return_val_if_fail (GOO_IS_CANVAS (canvas), NULL);
   g_return_val_if_fail (GOO_IS_CANVAS_ITEM_MODEL (model), NULL);



More information about the cairo-commit mailing list