Memory usage in OpenGL Cairo UI

View: New views
4 Messages — Rating Filter:   Alert me  

Memory usage in OpenGL Cairo UI

by Stephen Gentle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

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
or,
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?

Thanks,

Stephen
_______________________________________________
cairo mailing list
cairo@...
http://lists.cairographics.org/mailman/listinfo/cairo

Re: Memory usage in OpenGL Cairo UI

by Matt Rice-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 19, 2009 at 9:39 PM, Stephen Gentle
<stephen@...> wrote:

>
> 2. I use only one surface and have all the controls draw directly onto that
>
> 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?

it sounds like you want cairo_translate()

http://cairographics.org/manual/cairo-transformations.html#cairo-translate
_______________________________________________
cairo mailing list
cairo@...
http://lists.cairographics.org/mailman/listinfo/cairo

Parent Message unknown Re: Memory usage in OpenGL Cairo UI

by Stephen Gentle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Oct 20, 2009 at 5:46 PM, Matt Rice <ratmice@...> wrote:

> On Mon, Oct 19, 2009 at 9:39 PM, Stephen Gentle
> <stephen@...> wrote:
>>
>> 2. I use only one surface and have all the controls draw directly onto that
>>
>> 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?
>
> it sounds like you want cairo_translate()
>
> http://cairographics.org/manual/cairo-transformations.html#cairo-translate
>

That works perfectly, thanks! I thought there must be a way but I
couldn't find it.

Do you think this is the best way to go then?
_______________________________________________
cairo mailing list
cairo@...
http://lists.cairographics.org/mailman/listinfo/cairo

Re: Memory usage in OpenGL Cairo UI

by Chris Wilson-11 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Excerpts from Stephen Gentle's message of Tue Oct 20 09:18:18 +0100 2009:
> > On Mon, Oct 19, 2009 at 9:39 PM, Stephen Gentle
> > <stephen@...> wrote:
> >>
> >> 2. I use only one surface and have all the controls draw directly onto that
>
> Do you think this is the best way to go then?

Yes. Track the damage extents (probably best as a region, or a set of
non-overlapping rectangles) and use TexSubImage to download the dirty
pixels to your texture. (Alas, damage tracking is not part of the cairo
API, yet.)

In the near future, the cairo-gl backend will have matured sufficiently
that you will be able to use cairo to render into the texture or
framebuffer directly (with the premise of full GPU acceleration) which
will eliminate the need for the additional temporary storage and
management on your part. With rendering via the GPU (be it direct or via
XRender, though here you depend upon mature drivers and lack of
pre-emption from other clients) there is a significant advantage to
maintaining a single target buffer, again favouring the second option.

Hope this helps, and you are having fun using Cairo!
-ickle
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
cairo mailing list
cairo@...
http://lists.cairographics.org/mailman/listinfo/cairo