[cairo] which operations modify the canvas?

Kalle Vahlman kalle.vahlman at gmail.com
Thu Jun 21 05:19:50 PDT 2007


2007/6/20, Tamas K Papp <tpapp at princeton.edu>:
> On Wed, Jun 20, 2007 at 02:20:10PM -0400, Behdad Esfahbod wrote:
> > On Wed, 2007-06-20 at 13:56 -0400, Carl Worth wrote:
> > >
> > > Anything is possible, really. But I'm a bit confused as to what
> > > problem you are running into. You really shouldn't be needing to call
> > > XSync to get results to appear, (and if you are, I fear negative
> > > performance impacts).
> >
> > Well you need to do something to make sure xlib flushes its buffer.
> > With Gtk+, the main loop does that implicitly (by asking for next X
> > event).
>
> The situation is the following:
>
> I start a thread ("background"), which creates an X11 window, a cairo
> surface and context on a pixmap (pixmap uses XDamage), and enters into
> an event loop, handling exposure and damage notify events.
>
> Then, in another thread ("foreground"), I draw on the canvas using
> cairo commands.  The event loop in background uses XNextEvent which
> does flush the buffer, but if the canvas was drawn on in foreground
> after the last XNextEvent in background, this doesn't happen.
[snip]
> A callback function that would be called for operations on the X11
> surface would be a nice thing --- it doesn't make sense for any other
> surface, but would here.  Of course, any other suggestions would be
> appreciated.

I guess you could flush the buffer in the bindings explicitly after
calling the various drawing operations that Carl mentioned? Those
should be the only functions that actually cause X traffic AFAIK.

Also, using XFlush() should be better than XSync() since it only does
the client side flush (waiting for the server to process the request
could take long).

-- 
Kalle Vahlman, zuh at iki.fi
Powered by http://movial.fi
Interesting stuff at http://syslog.movial.fi


More information about the cairo mailing list