[cairo] RFC: duplicating, storing and serializing drawing operations

Pedro de Medeiros pedrovmm+cairo-ml at gmail.com
Wed Dec 27 17:14:34 PST 2006


On 12/27/06, Bill Spitzak <spitzak at d2.com> wrote:
> I think the original request can be satisfied with a new cairo backend.
> I'm not sure if this is possible with the current cairo implementation,
> if not I recommend cairo should be fixed so this *is* possible, whether
> or not such a backend is added to it.
>
> I'll call it a "cairo_recorder". The api would be something like this:
>
> cairo_t = cairo_recorder_create();
>      creates a new recorder, with nothing in it
>
> cairo_recorder_clear(cairo_t)
>      restores it to the empty state
>
> cairo_recorder_playback(cairo_t recorder, cairo_t destination)
>      acts exactly as though all the calls send to the recorder since it
>      was last cleared are sent to the destination.
>
> cairo_recorder_save(filename)
> cairo_recorder_load(filename)
>      write/read a stream format. loading from a saved file will make the
>      recorder have exactly the same contents as were in the saved one.
>      (obviously there is also an api to allow different stream functions
>      and not just filenames).
>
> I don't think much else is needed. Notice that you can "save as pdf" by
> playing it back to a pdf cairo backend. I recommend the stream format be
> text, but highly compressed (ie not xml, and numbers printed with %g
> with leading zeros stripped). I suspect this can also be used to cut &
> paste graphics between Linux programs.


Maybe some kind of iterator interface, with prev() and next(), would be
useful for things like "redo" and "undo". Suppose you have a frontend
GTK+ drawing program working on a cairo "detached" surface, it would
be simpler to be able to undo and redo commands you used on that
surface.


P.S.: I think some recipients will receive this message twice, I am
very sorry. :)

Cheers.
--
Pedro de Medeiros - Ciência da Computação - Universidade de Brasília
Home Page: http://www.nonseq.net - Linux User No.: 234250


More information about the cairo mailing list