SVG-to-SDL

Hi,

For a game project I’m working on, I want to have a
fast SVG rendering module that targets SDL. Ideally
this would be a straightforward non-anti-aliased
system that would render to palette-based or full-color
(8 or 32 bit) surfaces. This is so I can use
vector-graphic animation cels which have various
advantages over bitmaps.

So far I have worked out a slow and inefficient
way to do it, which is to:

  1. Hack Raph Levien’s “rsvg” renderer slightly to accept
    SVG in a string instead of from a file.

  2. It does high-quality (but therefore slower) anti-
    aliased graphics using the libart library. Also, the
    anti-aliasing creates blended colors, so that even if
    my original drawing used a simple palette it is now
    complex to do palette effects.

  3. A relatively simple hack adds a translation stage to
    copy the libart pixbuf to an SDL surface. I just use
    the pixel routines in SGE to do this. (This might
    not be the most efficient way to translate it, but
    considering how much CPU I’m throwing away on the other
    parts of the task, it’s probably not worth optimizing.)

  4. Optionally, I can then color-reduce the output to
    get an 8-bit palette surface to use with palette effects.

Now, obviously, it’s a tremendous waste of resources to
do it this way: I spend lots of CPU getting anti-aliased
graphics, then spend more CPU getting rid of the anti-aliasing
(and I don’t even get rid of it completely, of course). Also,
the “rsvg”/“libart” dependencies drag in a lot of bloat to
my application, in the form of libraries I would otherwise
not be using.

The obvious solution would be to go through rsvg and "port"
it to a simple, non-anti-aliasing graphics library (probably
SGE, which I’m already using anyway). This is going to
take me a long time, though, especially since I’m knee deep
in the rest of the project, and I’m not very familiar with
libart or what the exact rendering requirements are.

I know I’m going to need bezier curves – but fortunately
that’s recently been added to SGE.

So, my question is, is anybody else interested in
working on this with me? Or is there another package
that already does it? Or another way to solve my
problem?

Perhaps someone who knows both SGE/SDL and libart would
find this easy to do? Or at least be able to improve my
understanding of the problems involved?

Thanks for any advice!–
Terry Hancock
@Terry_Hancock