[cairo] Memory usage in OpenGL Cairo UI

Stephen Gentle stephen at stephengentle.com
Mon Oct 19 21:39:30 PDT 2009


I'm trying to make an application which uses Cairomm with OpenGL to
render its interface. Currently, all the controls have Image Surfaces
which are then painted onto a master image surface which is used for
the texture of the interface. The background of the surface is
transparent and I have other things under this surface so it's all
blended nicely. The problem with this approach though is that I'm
using a lot of memory to just draw the UI. So I was wondering what is
the better option:

1. I create surfaces when the screen needs to be redrawn, and then
delete them afterwards
2. I use only one surface and have all the controls draw directly onto that

Now, option 1 doesn't seem that bad now but I'm concerned that there
could be performance problems in the future as I have more and more
controls on the screen at once. So option 2 sounds better, but I'm not
sure if its possible. I would want the cairo context to act as if the
coordinates 0,0 were the top left hand corner of the widget that I'm
drawing, and not the top corner of the window. I can create a clip
region around the control to stop it drawing to other areas of the
screen, but it draws in the wrong place. Is there a way to change the
coordinate system to fix this?

Of course, one other option is to have an OpenGL quad for every
control, but that would be quite a bit more complex, and would only
let me get rid of the master surface, which is only about six to eight
MB. Is this the way to go?



More information about the cairo mailing list