[cairo] Re-working cairo_current_path

Kristian Høgsberg krh at bitplanet.net
Mon Jan 24 10:30:13 PST 2005


Keith Packard wrote:
> Around 11 o'clock on Jan 24, Carl Worth wrote:
> 
> 
>>Keith, what was your proposed data structure for the path? A list of
>>double with magic values to specify each operator?
> 
> 
> Perhaps:
> 
> typedef union {
> 	struct {
> 		enum { Move, Draw, Curve } Type;
> 		uint16_t	len;
> 	} head;
> 	double value;
> } cairo_path_elt_t;
> 
> Or is that too complicated?  It seems like a feature to encode the length 
> of each element right into the element; it might permit the kinds of 
> elements to be extended in the future (and exposed in some new call) 
> without completely wrecking all existing code.
> 
> But, I'd support the simpler
> 
> #define CAIRO_PATH_MOVE		0.0
> #define CAIRO_PATH_DRAW		1.0
> #define CAIRO_PATH_CURVE	2.0
> 
> if that seems nicer.
> 
> (oh, the names above are unconsidered and should be taken only as 
> representative of the structure of the objects)

What about:

struct cairo_path_element {
	enum { move, draw, curve } type;
	uint16_t length;
	union {
		struct { double x, y; } move_to;
		struct { double x, y; } line_to;
		struct { double x1, y1, x2, y2, x3, y3 } curve_to;
	};	
};

possibly with a CAIRO_PATH_ELEMENT_NEXT macro that does the pointer 
arithmetic to get the next element.

Kristian



More information about the cairo mailing list