[Cairo] New functions to get/set current path (in Cairo 0.1.4)

Keith Packard keithp at keithp.com
Thu Sep 25 10:34:55 PDT 2003


Around 11 o'clock on Sep 25, Carl Worth wrote:

> 	cairo_path_t *
>	cairo_current_path (cairo_t *cr);
>
>	void
>	cairo_set_path (cairo_t *cr, cairo_path_t *path);
>
>	void
>	cairo_path_destroy (cairo_path_t *path);

While these functions may seem relatively harmless, they cause a cascade 
of additional APIs and raise many questions about where graphics state 
should live -- transformation matrices, pen sizes and line styles are 
nominally a part of the 'graphics state', and yet could easily be seen as 
a part of this new path object instead.

As this change is a significant departure from the PostScript model, I'd 
like to rethink whether it is strictly necessary; I know we aren't trying 
to be religious about the model, but still, I suspect Adobe would have 
added these operators to PostScript if they found some "real" need.

What PS does have is 'user paths'.  Looking through the documentation for
those, they appear to be largely an optimization for repeated application
of the same shape.  In fact, the implication from the operators is that the
intent is to pre-render the user path and use the result as a stencil on
the page.  Given that cairo provides significantly more powerful mechanisms
for this already, it's quite hard to see the value in adding the PostScript
user paths to cairo.

The utility of external path objects seems to me to be limited to parallel
construction of multiple paths.  Nested construction of multiple paths for
painting can be easily accomplished with cairo_save/cairo_restore.  About
the only thing which can't be done with save/restore is the construction of
a clip list in the middle of path construction -- deciding in the middle of
drawing that some kind of clipping is needed, instead of computing the clip
list before drawing the object.  This seems like a case with sufficiently
limited utility to question the wisdom of making such a large addition to
the cairo API.

-keith






More information about the cairo mailing list