[cairo] Background image

Olivier Jolet olivier.jolet at skynet.be
Mon Feb 19 01:39:20 PST 2007


> -----Message d'origine-----
> De: Daniel Amelang [mailto:daniel.amelang at gmail.com]
> Envoyé: jeudi 15 février 2007 21:26
> À: Olivier Jolet
> Cc: cairo at cairographics.org
> Objet: Re: [cairo] Background image
>
> On 2/15/07, Olivier Jolet <olivier.jolet at skynet.be> wrote:
> > I need to use a background image (of course always the same).
> >
> > Actually, I draw the background image in a surface "surfBG " and
> before each
> > draw, I use
> >
> > cairo_set_source_surface (cr, surfBG, 0, 0);
> >
> > cairo_paint (cr);
> >
> > But I'm not sure that's the better way to do it...
> >
> > Is there a better method to use a background?
>
> Looks good to me. Are you running into some problem with this method?
>
> Dan
>
> No, I don't have problem with this method. But the display is very
slow
> (zoom in & out with the scroll mouse button) and I thought that it
could
> be because of the background. Apparently it's not that. Perhaps it's
> because of the many primitive functions to draw a big graphic? I
should
> perhaps try to use GLX backend...

It's quite possible that you don't have to use the glitz backend to
get a nice speedup. Alex Mac recently sped up his lander game from 6
fps to 70 fps by just optimizing his own code to use cairo more
efficiently.

The lander game (with full source code):

http://alexmac.cc/lander/

The cairo thread about optimizing the game:

http://lists.freedesktop.org/archives/cairo/2007-January/009062.html

If you share your code (and maybe some profiles, too), it's likely
that someone on this list will also help you get better performance
without having to use a different backend.

Dan


Ok, I will not use glitz backend... I still use native (Xlib) surfaces.
The problem is that I need to draw many (between 10k 500k) lines,
polygones and arcs (fill or not), and I don't get a nice speedup. (I
tried to reduce the number of calls to cairo_stroke). I noticed that the
worst performance came from the build of arcs. 
I'm going to try another method that consist in drawing the arcs I need
with specifics sizes in another surface and copy them with a color mask
instead of building them at each call.

Oli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo_draw.c
Type: application/octet-stream
Size: 4557 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070219/2e23959b/cairo_draw.obj


More information about the cairo mailing list