No subject


Mon Aug 15 11:10:41 PDT 2005


drawing into foo" and "go back to the previous drawing" unless you either 
make them macros that store the state in local variables or make it keep a 
stack in static variables. You say that any program using cairo would need to 
keep other state in such static variables anyway, but in my opinion if this 
is true it indicates a deficiency in cairo, and also means that it will be 
impossible for different libraries using cairo to cooperate, since they must 
be relying on information that is not in the cairo_t.

>  2)	The status would become less persistent -- 'popping' a cairo_t
> 	from an application-specific stack would lose any status
> 	information, so application errors would cause local damage instead
> 	of global damage in the display.  This seems like more of a bug
> 	than a feature to me; I like the fact that an application fault
> 	will cause all future output to disappear as that encourages
> 	developers to fix things (just as IEEE NaN does).

Here I disagree. I like NaN precisely because it does not affect other math 
operations, as long as they do not depend on the output of the NaN. Old 
floating point behavior (throwing an exception on any error) was truly 
painful to program around. I would prefer that popping an empty stack not 
change anything.

My recomendation:

Though internally cairo_gstate_t exists, no public calls take or return them. 
cairo_gstate_t contains a pointer to another cairo_gstate_t which is the one 
to "pop" to. Thus the expense of the stack is only 1 pointer per gstate.

cairo_t is like now, a pointer to a cairo_gstate_t, and apparently some other 
state information.

cairo_copy_state should return a cairo_t. This points at a *copy* of the top 
cairo_gstate_t, but the pop pointer is set to zero. (internally it may be a 
good idea to use some sort of copy-on-write?)

Destruction of a cairo_t destroys all the cairo_gstate_t's in it's stack.

cairo_pop (or whatever it is called) will do nothing if the pop pointer is 
zero.

-- 
                   ,~,~,~,~ ~ ~ ~ ~
     /\_       _|_========___         Bill Spitzak
 ~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com




More information about the cairo mailing list