[cairo] default rendering engine

Carl Worth cworth at east.isi.edu
Fri Jun 4 07:18:49 PDT 2004


On Mon, 3 May 2004 11:29:48 -0700, Bill Spitzak wrote:
> One thing I have found is that I *cannot* reuse contexts at all. It appears
> that you cannot call cairo_set_target_drawable more than once on a given
> surface, even for the same drawable. It always crashes. Also if the window
> changes size, it crashes the entire X server.
> 
> Are these known bugs? It seems all the demos just create a local context and
> then destroy it for every redraw and thus nobody has seen these.

There aren't any known bugs here that I am aware of.

The cairo-knockout demo re-targets a cairo context to a pixmap to
pre-composite some elements. Also, libsvg-cairo does something similar
whenever a group has non-unity opacity.

Oh, but I notice that each of these examples are calling
cairo_set_target_surface. So, I'll try to cook up a minimal test for
calling cairo_set_target_drawable multiple times.

I've never seen any problems with resizing windows.

> I'm wondering if the solution is not to fix these, but to change the interface so
> that it is clear that reuse of a context is not allowed, by passing the
> drawable and dimensions of it to the constructor.

I think we'd like to re-use contexts.

> Also, like many other libraries, it is very unclear if I should be wasting
> time and effort avoiding the construction/destruction of these context
> objects. In fact it may be cheaper to call this a lot than the memory used to
> keep a context around. Can anybody explain the expected use of Cairo for
> multiple windows?

I think you should code as if calling cairo_create were free. The
current implementation does more work than strictly necessary, but it
should not take much effort to defer things like font creation until
they are actually needed.

-Carl




More information about the cairo mailing list