cpw.qulogic.cairo: 4ab01998: Cache the cairo context for the pixmap. ...

qulogic at pidgin.im qulogic at pidgin.im
Sat Aug 21 02:11:54 EDT 2010


----------------------------------------------------------------------
Revision: 4ab0199887f74442673fd46dcbb662bc7f070bc4
Parent:   96ccb79efc205ff8fb4fe55818a50c0fdcbd76c6
Author:   qulogic at pidgin.im
Date:     08/21/10 02:04:13
Branch:   im.pidgin.cpw.qulogic.cairo
URL: http://d.pidgin.im/viewmtn/revision/info/4ab0199887f74442673fd46dcbb662bc7f070bc4

Changelog: 

Cache the cairo context for the pixmap. I'm not really sure if this
makes things any faster or anything.

Changes against parent 96ccb79efc205ff8fb4fe55818a50c0fdcbd76c6

  patched  pidgin/gtkwhiteboard.c

-------------- next part --------------
============================================================
--- pidgin/gtkwhiteboard.c	9246da3f7a740885b6658d579e3e0f9173d88184
+++ pidgin/gtkwhiteboard.c	23ba5e978f3cdc281aa0fe35e80a3dcb58e4777c
@@ -282,6 +282,9 @@ static void pidgin_whiteboard_destroy(Pu
 	/* Clear graphical memory */
 	if(gtkwb->pixmap)
 	{
+		cairo_t *cr = g_object_get_data(G_OBJECT(gtkwb->pixmap), "cairo-context");
+		if (cr)
+			cairo_destroy(cr);
 		g_object_unref(gtkwb->pixmap);
 		gtkwb->pixmap = NULL;
 	}
@@ -356,8 +359,12 @@ static gboolean pidgin_whiteboard_config
 	GdkPixmap *pixmap = gtkwb->pixmap;
 	cairo_t *cr;
 
-	if(pixmap)
+	if (pixmap) {
+		cr = g_object_get_data(G_OBJECT(pixmap), "cairo-context");
+		if (cr)
+			cairo_destroy(cr);
 		g_object_unref(pixmap);
+	}
 
 	pixmap = gdk_pixmap_new(widget->window,
 							widget->allocation.width,
@@ -366,12 +373,12 @@ static gboolean pidgin_whiteboard_config
 	gtkwb->pixmap = pixmap;
 
 	cr = gdk_cairo_create(GDK_DRAWABLE(pixmap));
+	g_object_set_data(G_OBJECT(pixmap), "cairo-context", cr);
 	gdk_cairo_set_source_color(cr, &widget->style->white);
 	cairo_rectangle(cr,
 	                0, 0,
 	                widget->allocation.width, widget->allocation.height);
 	cairo_fill(cr);
-	cairo_destroy(cr);
 
 	return TRUE;
 }
@@ -588,7 +595,7 @@ static void pidgin_whiteboard_draw_brush
 	GtkWidget *widget = gtkwb->drawing_area;
 	GdkPixmap *pixmap = gtkwb->pixmap;
 
-	cairo_t *gfx_con = gdk_cairo_create(GDK_DRAWABLE(pixmap));
+	cairo_t *gfx_con = g_object_get_data(G_OBJECT(pixmap), "cairo-context");
 	GdkColor col;
 
 	/* Interpret and convert color */
@@ -606,8 +613,6 @@ static void pidgin_whiteboard_draw_brush
 	gtk_widget_queue_draw_area(widget,
 							   x - size / 2, y - size / 2,
 							   size, size);
-
-	cairo_destroy(gfx_con);
 }
 
 /* Uses Bresenham's algorithm (as provided by Wikipedia) */
@@ -698,7 +703,7 @@ static void pidgin_whiteboard_clear(Purp
 	PidginWhiteboard *gtkwb = wb->ui_data;
 	GdkPixmap *pixmap = gtkwb->pixmap;
 	GtkWidget *drawing_area = gtkwb->drawing_area;
-	cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(pixmap));
+	cairo_t *cr = g_object_get_data(G_OBJECT(pixmap), "cairo-context");
 
 	gdk_cairo_set_source_color(cr, &drawing_area->style->white);
 	cairo_rectangle(cr,
@@ -706,7 +711,6 @@ static void pidgin_whiteboard_clear(Purp
 	                drawing_area->allocation.width,
 	                drawing_area->allocation.height);
 	cairo_fill(cr);
-	cairo_destroy(cr);
 
 	gtk_widget_queue_draw_area(drawing_area,
 							   0, 0,


More information about the Commits mailing list