[cairo] basic question?

Theo Veenker T.J.G.Veenker at uu.nl
Tue Aug 18 23:53:40 PDT 2009


Carl Worth wrote:
> Excerpts from Charles سمير Doutriaux's message of Tue Aug 18 14:09:43 -0700 2009:
>> On Aug 18, 2009, at 1:54 PM, David Björkevik wrote:
>>> Charles سمير Doutriaux wrote:
>>>> For speed reason I'm thinking it would be better to draw "in memory"
>>>> on a cairo_image surface and then whenever I need to update copy the
>>>> image back to my X11 window.
>>> This is not correct. When drawing through X, cairo uses XRENDER  
>>> which is
>>> hardware accelerated (if your X driver supports it).
>> Actually, speed is not the only issue, the way our software is  
>> designed there's a LOT of polygons to fill and it is more pleasant to  
>> the user to see the image pop up finished instead of looking at it  
>> being drawn.
> 
> OK, Charles, but you're the one who said "for speed reasons". :-)
> 
> As for not making the user look at the thing being drawn, you can also
> do that with cairo-xlib by simply creating a Pixmap, directing cairo
> at that, and finally copying the Pixmap to the Window when complete.
> 
> Of course, using a cairo_image_surface_t should work identically too.
> 
> The only result *should* be that the image surface is strictly slower
> than the xlib surface, (though sometimes driver bugs do get in the way
> and make xlib drawing slower than image).

Glad this topic comes up. It's my experience that drawing into a backbuffer
and copying that to the window (which is what Charles wants) is actually
/faster/ than drawing directly onto the window. I've various systems with
different modern video hardware at my hands and they all demonstrate the
same effect. I must add I'm copying the backbuffer through a clipmask which
reflects only the changed bits of the image, but still I expect it to cause
more traffic than the actual lines, polygons etc. In my test case there are
several graphic shapes flying around (and changing color, opacity, size
etc.) but with backbuffering on it is faster and causes less CPU load than
when I let the X server do all the drawing. Is there a way to accually
check what is being accelerated and what not?

Theo


More information about the cairo mailing list