[cairo] cairo and gdk/X11

Tamas K Papp tpapp at Princeton.EDU
Sun Jun 10 03:02:58 PDT 2007

On Wed, Jun 06, 2007 at 07:56:40PM -0700, Dan Amelang wrote:
> >I have looked at the Cairo tutorial code and saw that it works by
> >calling the draw function to redraw everything whenever required (if
> >the window is resized/exposed etc).  Is there a way to avoid this, eg
> >by making Cairo remember the draw operations and replay them when
> >needed?
> Nope. Cairo is a an immediate-mode graphics library; it has no
> remebrance of drawings past.
> If rerendering the whole scene is costly, it is best to use the
> "damaged" area of the screen (you get this from the expose event) to
> determine what needs to be redrawn, so you can skip the rest.
> cairo_clip is a handy way to tell cairo not to bother rendering
> anything outside a particular region, although it's best if you just
> don't bother issuing unecessary drawing calls.

Dear Dan (and Dominic too),

Thanks for your answers.  Recording operations in my application would
be clumsy, so I started looking at another solution: drawing into a
buffer with cairo and copying it onto the screen when needed.

This thread [1] suggests that I create a GdkPixmap, use
gtk_cairo_create(GdkPixmap*) to create a Cairo surface, then copy with
gdk_draw_drawable().  But it appears that GdkPixmap is deprecated. [2]

What would be the recommended way to implement this `double-buffering'
in the current Gtk?  Is there perhaps some widget that could take care
of double buffering and provide a Cairo surface?



[1] http://permalink.gmane.org/gmane.comp.lib.cairo/5468
[2] http://www.gtk.org/api/2.6/gtk/GtkPixmap.html

More information about the cairo mailing list