[cairo] Lander Game

Daniel Amelang daniel.amelang at gmail.com
Mon Jan 8 16:29:07 PST 2007


On 1/8/07, Alex Mac <lots.of.mailing.lists at gmail.com> wrote:
> On 08/01/07, Daniel Amelang <daniel.amelang at gmail.com> wrote:
> > On 1/8/07, Alex Mac <lots.of.mailing.lists at gmail.com> wrote:
> > > I'm guessing that rsvg does no caching and simply re-parses the svg
> > > file every time? that would explain why its so slow.
> > >
> > > I saw something like this mentioned in another thread but I'll mention
> > > it again here. It would be really useful if cairo had something like
> > > OpenGL's display lists so that sequences of commands can be recorded
> > > and then later replayed to a surface.
> >
> > You don't necessarily need display lists in this case to get that
> > behavior. You can cache all that complex drawing in an intermediate
> > cairo surface that you keep around to paint onto your destination
> > surface as needed. That way, you only need to use rsvg to render the
> > SVG once. If/when you need to draw the SVG at a different resolution,
> > you'll probably want to re-render it for that resolution.
>
> I've added in some code to render the background once to an Image
> surface, but my goal is to have animated backgrounds so I dont really
> want to have to do that.

If you break your scene into various layers correctly, you can still
take advantage of this technique. It sounds like you're thinking of
having all the background art on one single surface, drawn in one
pass, which doesn't have to be the case. In fact, since you plan on
adding animations, it's probably better to plan on decomposing that
background into layers/pieces.

More importantly, there's something fishy going on here: Steve said:

"...I comment out
 self.level_svgpic.render_cairo(cr) from LanderWindow.Render()
I get 105 FPS."

but you said that when caching the SVG image (and thus eliminating the
render_cairo call from the Render method), you didn't get much
improvement at all. Even with the image surface, you should have seen
more than a "small improvement", I would think. Can you share with us
the new version that caches the SVG image on a surface?

Dan


More information about the cairo mailing list