[cairo] Lander Game

Carl Worth cworth at cworth.org
Mon Jan 8 15:04:52 PST 2007

On Mon, 8 Jan 2007 14:19:41 -0800, Simon Burton wrote:
> "Daniel Amelang" <daniel.amelang at gmail.com> wrote:
> > 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.
> Is this a generic technique ?

Yes, drawing into a surface once, and then using that surface later as
a source is a very generic technique. It's a simple matter of caching
the results from some drawing operations into a cairo surface rather
than executing all of the drawing commands again.

It's one of the things I was surprised to see that goocanvas isn't
doing at all. In the little bit of playing I did there, (writing
drawing functions for custom canvas objects, then animating their
position), it would be a huge performance advantage to cache the
result of drawing the objects, (and only re-draw when the scale
changes), but it would be a fair amount of code for me to handle that
at the application level. It would be really nice for something like a
canvas layer to handle all of that transparently for me.

It's not as obvious that there's an immediate need for something like
this at the cairo layer. It would be possible for cairo to cache
individual things like "the tessellation of a path" but an "object" at
the scene-graph level could be arbitrarily more complex than that, and
it makes sense to get the higher-level caching in place first.

If some canvas layer does a good job at optimizing redrawing like
this, and then finds that it could still benefit from further caching
down inside cairo, only then would it make sense to consider adding
something to cairo.

As for doing something like a "display list" that could capture
arbitrary sequences of calls to cairo functions, that's functionally
similar to the cairo-meta-surface we've got in cairo now, and that we
would like to expose at some point. The meta-surface has the potential
to allow some very interesting things, (like vector-based patterns
that can be transformed without bad pre-rasterization effects). But in
general, application-specific (or canvas-specific) data structures
stand a better chance of performing better than a meta-surface would
anyway, (it's not as if we have the ability to compile an entire
meta-surface into a program to be executed on the video card at this
point, for example).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070108/9b999813/attachment.pgp

More information about the cairo mailing list