[cairo] default rendering engine

Bill Spitzak spitzak at d2.com
Mon May 3 11:29:48 PDT 2004


On Monday 03 May 2004 09:59 am, Maarten Breddels wrote:
> Yes, I thought about that too, it might be nice to get a (non-serious)
>         cairo_screen_surface_create(char* title, int width, int height);
> And maybe a
>         cairo_hardcopy_surface_create(char* filename, int width, int
> height);

I might be interested in ripping the guts out of fltk and making something 
like this. Your idea of making it be a new type of cairo surface is 
interesting, it avoids the need to do window->cairo_context in the cairo 
calls.

The interface would be pure C. It should either be a seperate library or it 
shuld be carefully designed so that programmers are clear as to the fact that 
they don't *have* to use it. I think it better also have an event callback so 
the program knows where the user clicked the mouse and what keys they hit on 
the keyboard, the trick here is to avoid "turn it into a toolkit" disease!

PS: I am also working on making fltk use Cairo to do it's drawing.

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. 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.

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?

My current solution is to keep exactly one Cairo context in memory, for the 
most recent window drawn. If you draw into another window, or if you resize 
the current window, or if you destroy it, that context is destroyed.

Alternatives are: keep a context for every window, destroying them only when 
they are resized or when the window is destroyed. And the opposite is: create 
a context only when need to draw a window and destroy it immediately.

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




More information about the cairo mailing list