[cairo] basic question?

Bill Spitzak spitzak at gmail.com
Wed Aug 19 12:40:25 PDT 2009



Jamey Sharp wrote:
> On Wed, Aug 19, 2009 at 9:53 AM, Bill Spitzak<spitzak at gmail.com> wrote:
>> For the normal displays Cairo has to be able to get the display to be
>> up to date after every single cairo call.
> 
> Is that true? I don't see documentation calling for XFlush when using
> the Xlib backend, but there are no calls to XFlush in the cairo source,
> and the only calls to XSync are during connection close. That seems
> appropriate to me: only the application can know when it cares about
> having its drawing happen.

What I am complaining about is the *LACK* of a Cairo flush call. As it 
is Cairo has to get the resulting drawing into the memory that is used 
for the display as soon as possible. This may require a memory copy that 
would be saved if it knew that very shortly in the future it may get 
some more drawing that it could do and then memory copy the result.

Basically what I would like is the ability of a backend to do double 
buffering if it is faster. I cannot see any way to do this without 
adding some flush() call to Cairo, though I guess a timeout and use of 
XFlush calls would get close.

>> It could also be used to queue up driver requests locally.
> 
> This is, of course, exactly what Xlib and XCB do for you already, and as
> you suggest, that's all about avoiding syscalls and context switches.

> Perhaps I'm mis-reading your comment. Xlib only flushes its buffer when
> the buffer is full and you try to send more through it, or under various
> circumstances around reading server responses. Those flushes are
> generally necessary to accomplish what you asked Xlib to do, and in a
> drawing-intensive setting it's the full-buffer case that's going to
> trigger flush most of the time. You really can't get around that.

The problem with XFlush is that it is called for all kinds of xlib 
calls. With current programming practices of gigantic toolkits is is 
quite difficult to write any kind of complex drawing code that does not 
call some toolkit function that does an XFlush for some reason or 
another. Fonts in particular are a problem, but just reliable methods of 
getting the window's size or state require this.



More information about the cairo mailing list