[cairo] Serialization
Maarten Bosmans
mkbosmans at gmail.com
Thu Sep 16 00:44:25 PDT 2010
2010/9/15 Talguy <talguy385 at gmail.com>:
> I have a interface data structure consisting of a list of objects of the
> graphical elements that I manipulate on the screen. The objects are gauges
> that update with new data 30 times a second. To help speedup startup time
> of the program I would like to be able to serialize this data structure and
> store it on the disk and then read it back in to the last state of the
> interface. My question is how would I serialize the image surfaces,
> transformation matrics and other cairomm classes that I use in my program.
How long does the drawing of all the gauges take, have you measured
it? I'd imagine that it takes too long to get to a decent framerate,
so you'll probably need some caching at runtime. But the one time
effort of drawing your background to an imagesurface is likely not to
delay your startup significantly. So I'd advise you to measure before
you optimize!
But to answer your question: image surfaces can be serialized to png
files or to raw bit data, but in the last case you'll have to store
the width, height, surface format and possibly stride too. The
transformation matrix and other cairo_t state you'd be best to just
set them again at program startup, using the standard cairo functions.
Maarten
More information about the cairo
mailing list