[cairo] Path as a resource

Mike Emmel mike.emmel at gmail.com
Thu Nov 9 11:15:10 PST 2006


On 11/9/06, Behdad Esfahbod <behdad at behdad.org> wrote:
> On Thu, 2006-11-09 at 12:49 -0500, Mike Emmel wrote:
> > I've been thinking about the concept of having paths as resource like
> > patterns or fonts.
>
> What is the problem you are trying to solve?
>

The basic problem is that I need to create and manipulate paths before
I know the
destination surface.

Cairo does not really support paths outside of a cairo_t structure.
And there is no way to transfer a path between cairo_t's except to
export it to a floating point format.

If you build paths up outside cairo_t your forced into a floating
point format. If you don't have a fpu this means redeveloping all of
the fixed point logic.

Most graphics systems treat paths as first class objects cairo does not.
This means paths are created and manipulated before the destination
surface is known.
Cairo does not support the concept.

SVG postscript etc all support paths as standalone objects.

For example

http://developer.classpath.org/pipermail/classpath/2006-July/001253.html

To me the problem the developer is facing in this example is the lack
of ability to save
path information in a optimized format. If he had a handle to the
internal path structure  it would help.

Right now my approach is to create a cairo_t with a one pixel surface
to serve as a proxy for a path. The problem is that to transfer this
path to the real surface for rendering requires that I copy out the
path in floating point format then reapply it to the destination. Also
of course I can't freadily flatten the path or perform other
operations to optimize drawing of known paths.

To flatten a path now requires.

p = cairo_copy_path_flat()
cairo_new_path()
cairo_append_path(p)

So even if you have the right cairo_t you have to do a copy just to
flatten a path.

By having paths only exist in a cairo_t your tying paths to the
destination I don't believe this tie is required.




> --
> behdad
> http://behdad.org/
>
> "Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
>         -- Dan Bern, "New American Language"
>
>


More information about the cairo mailing list