[cairo] question about bad cairo performance on the olpc xo

Behdad Esfahbod behdad.esfahbod at gmail.com
Fri Sep 3 03:39:43 EDT 2010


On 09/03/10 01:49, Erik Blankinship wrote:
> 
>             context.set_source_pixbuf( self.pixbuf, self.box_x, self.box_y )

This innocuous-looking line...

What's happening every single time you do that and do a fill() is:

  - The pixbuf is converted to a new allocated cairo image surface (involves a
per-pixel loop to premultiply alpha)

  - The newly created image surface is send over to the X server

  - When "bliting", it actually has to convert formats again (IIRC) because
the XO framebuffer is RGB656 while the image surace is RGB32


To fix that, before your expose event, get hold of a cairo_surface_t for your
destination surface, then create a similar surface for it
(cairo_surface_create_similar()), then "blit" the pixbuf to that similar
surface (which uses a pixmap in the X server, matching your destination in
format).  In your expose event, you can blit from the similar surface now, for
maximum performance.

behdad



More information about the Devel mailing list