[cairo] drawing on and reusing an off-screen image surface

Peter Groves pdgroves at gmail.com
Mon Dec 3 10:31:58 PST 2007


On Mon, 03 Dec 2007 09:00:37 -0800
Carl Worth <cworth at cworth.org> wrote:

> Instead, you can use a "similar surface", which in the case of X will
> give you server-side storage so the cairo_paint operation can be much
> faster. This should be as simple as doing cairo_surface_create_similar
> instead of cairo_image_surface_create.
> 
> The only trick will be that you will have to get some surface to your
> startup() function to let cairo_surface_create_similar know what kind
> of surface to create. GTK+ hides the target surface from you just a
> little bit, but you can get at it easily enough by calling
> cairo_get_target after gdk_cairo_create.
>

I didn't realize I could use cairo to draw on any gdk/gtk elements other
than what gdk_cairo_create gives you. It was also mentioned I could use a
GdkPixmap (also for better performance).

So what I'm hearing is that manipulations with raster data are typically
best done on the gtk side. Is this a safe generalization to live by? 

I ask b/c next I'll be drawing small glyphs with cairo and then making a 
few hundred copies of each to make a large data plot, and was going to use this 
same basic idea (draw to an image, then copy the image onto the background). 


More information about the cairo mailing list