[cairo] Path as a resource

Mike Emmel mike.emmel at gmail.com
Thu Nov 9 09:49:40 PST 2006


I've been thinking about the concept of having paths as resource like
patterns or fonts.

If you think about it fonts are just a custom set of path resources
and the concept is quite useful. Why can we not have user defined
paths treated in the same manner ?

The current path type would not change and can be used to import and
export path data to/from cairo.

The resource path would basically expose a opaque wrapper around the
current fixed point path internal format. In addition we could add
glyph like caching to a surface if desired.

The path would be considered a pattern and be created with this function.

cairo_public cairo_pattern_t *
cairo_pattern_create_path();

And we have a new pattern type of

CAIRO_PATTERN_TYPE_PATH

pixel pattern operations would work on a path as a stroked or argb
filled surface.

The intrinsic surface format could be ARGB or A8 ?
Maybe the constructor would take surface parameters ?

I feel that by treating paths as patterns it makes paths first class
objects of the cairo api.
Its consistent and it provides a route to bridging font related
resources with the cairo drawing api since the font api could now
export as a cairo path pattern.

Next it gives you a sort of pattern algebra since you can take path
patterns combine them with other types of patterns to create new
patterns clipped or stroked by the path pattern.
Thus you can combine paths and other patterns to create a single source pattern.

Next it opens up the ability to cache the path flattened tessellated
or rasterized or as a alpha or argb surface.

It can be argued that cairo_t operates this way now but the problem is
it also has a lot of other responsibilities so breaking out the path
related functionality makes sense and decouples path operations from
the target surface which is not needed.

For me the strongest argument is that patterns exhibit an algebra and
adding paths as patterns completes the math :)


More information about the cairo mailing list