[cairo] XShm

BJörn Lindqvist bjourne at gmail.com
Thu Oct 18 15:58:07 PDT 2007


Hello Chris,

On 10/18/07, Chris Wilson <chris at chris-wilson.co.uk> wrote:
> Using XShm for transferring the images between Cairo and the Xserver
> seems like a sensible performance optimization and one that interests
> quite a few people. The nasty part is that in order to avoid copying the
> image data, the shared memory segment must be constructed upon image
> create and the image's pixels allocated from within the shared memory.
> To allow the higher levels and application code to construct XShm-based
> cairo_image_surface_t, we add a new function
> cairo_image_surface_create_for_target() that purports to create an image
> optimized for future use with the target backend.

I'm not sure if my test program (see attachment) is totally accurate.
But here is the results with your patch applied and without. Without
patch (best result):

    total 5651,23 ms, per loop 5,65

And with patch applied (best result):

    total 2045,10 ms, per loop 2,05

Which is totally great and faster than gdk_draw_pixbuf(). :) But there
seem to be no fallback in case Cairo is compiled with shm and the X
server doesn't support it. cairo_image_surface_create_for_target()
calls _cairo_xlib_surface_create_image_surface() which won't fall back
on cairo_image_surface_create() if shm isn't available (but compiled
in).

Only drawback I can see is that you need to use
cairo_image_surface_create_for_target() to get shm goodness. Is there
no way to get around that? AFAIK, GDK doesn't need such a function to
draw pixbufs using shm.


-- 
mvh Björn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairoblit.c
Type: text/x-csrc
Size: 1255 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071019/5fab97c4/attachment.c 


More information about the cairo mailing list