question about bad cairo performance on the olpc xo

Benjamin Berg benzea at
Fri Sep 3 09:18:34 EDT 2010


Some notes:

On Fri, 2010-09-03 at 01:49 -0400, Erik Blankinship wrote:
>         self.cairo_img = cairo.ImageSurface( cairo.FORMAT_ARGB32, self.box_w, self.box_h )

You are using client side image surfaces. It might be better to create a
new server side surface using create_similar on the contexts target in
the expose handler (the first time you need it).
(You can also use the realize event.)

>         ctx = cairo.Context( self.cairo_img )
>         ctx.set_source_rgb( 0, 0, 1 )
>         ctx.rectangle( 0, 0, self.box_w, self.box_h )
>         ctx.fill( )

This particular code right now does not need alpha. Should you not need
alpha, you could try cairo.FORMAT_RGB24.

>         elif (self.box_type == 3):
>             context.set_source_pixbuf( self.pixbuf, self.box_x, self.box_y )

set_source_pixbuf not very efficient. It needs to convert the pixel
format from the one used by GdkPixbuf (RGB(A), not endian specific to
premultiplied endian specific ARGB).
You can instead call set_source_pixbuf once, to let gdk convert the
pixel format, and after that keep around the cairo surface. Two ways of
doing this come to mind:
 1. Create a cairo surface (best with create_similar), then the context,
and draw the surface on that.
 2. Use ctx.get_source().get_surface(), this returns the ImageSurface

That said, I just happened to read this mail, and these things came to
my mind. I have no idea what operations the video driver on the XO can
properly accelerate. The above notes should hover be true in general, I


More information about the Devel mailing list