[cairo] cairo and gdk/X11

Tamas K Papp tpapp at Princeton.EDU
Mon Jun 11 03:25:41 PDT 2007


Hi Dan (and others),

Thanks for the references, I found the thread and it was useful.  I
will be using plain Xlib, not Gtk, since the latter is a mess with
threads.

I still have one question.  I refresh (copy from the pixmap to the
drawable in the window) each time 

1. X asks for it via an expose event, 
2. cairo draws on the pixmap.

I could call refresh explicitly each time (2) happens, but I wonder if
there is a neater way, since my library supports various surfaces and
I would have to handle one of them differently.

Things I can imagine:

a. a flag on the pixmap, indicating it was drawn on, I could check
this periodically, refresh and reset the flag.

b. a callback function that gets called each time the surface is
modified.

Does cairo support either of these approaches, or is there something
else that would be useful?

Thanks,

Tamas

On Sun, Jun 10, 2007 at 10:53:20AM -0700, Dan Amelang wrote:
> On 6/10/07, Tamas K Papp <tpapp at princeton.edu> wrote:
> >
> >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.
> 
> Yes, we've advised people to use that technique in the past.
> Basically, you can use a separate cairo surface to "cache" the drawing
> and "paint" it to the destination surface as needed. If you search the
> mailing list archives, you'll find at least two long threads on how
> and when to use this technique (you don't need to use a Gdk or Gtk
> anything to make this work, just cairo surfaces). Look for the words
> 'surface', 'cache', and/or 'lander' (which is the name of a game that
> was written to use cairo that uses this technique).
> 
> Let us know if you need more direction,
> 
> Dan


More information about the cairo mailing list