[cairo] Re: Proposal: cairo_save_state/cairo_restore_state

Robert Staudinger robert.staudinger at gmail.com
Tue Jan 24 12:32:05 PST 2006


On 1/24/06, Carl Worth <cworth at cworth.org> wrote:


> Here's the API that I think is needed:
>         cairo_state_t *
>         cairo_save_state (cairo_t *cr);
>         void
>         cairo_restore_state (cairo_t *cr, cairo_state_t *state);
> along with the necessary:
>         void
>         cairo_state_reference (cairo_state_t *state);
>         void
>         cairo_state_destroy (cairo_state_t *state);

given the internals permit this, it would be very handy to have a
variant for putting the cairo_state_t on the stack.

Usage example:

void draw_foo (cairo_t *cr) {

    cairo_state_t cs;
    cairo_save_state (cr, &cs);
    /* drawing code goes here */
    cairo_restore_state (cr, &cs);

That would make it very easy and efficient to draw on the cairo_t
instance without side effects.


More information about the cairo mailing list