[cairo] cairo_clip()-related question

Alexei Babich a.babich at rez.ru
Wed Nov 26 02:21:21 PST 2008


> You seem to be abusing the
> cairo_save/restore calls
Do you mean the stack overflow with cairo_save() calls? If yes, then see the sequence of calls in my example:
--
cairo_save();
while(1){
 cairo_restore();
 cairo_save();
}
--
That is, we have separately the current cairo context and the saved
context. The last one is to be extracted from stack before its modification
by means of carrying in a clipping mask for cairo_clip(); so no stack
overflow takes place.

> and reusing a cairo context
> for a transient window
> which i am not sure will
> work.
I'm little bit confused about what the "transient window" is. Can you
comment on it? My example draws the single constant window.

> First try splitting
> out your drawing code to a
> seperate function that
> accepts only a cairo
> context. Then create a new
> cairo surface and context
> on every fillWinWithCairo
> but if it's a redrawRequest
> just add the clip like you
> have it before calling
> drawing function.

OK. I've created initCairo() function for creating a surface and a context
for a one window; a function redraw() as well for adding a clipping and stroke to the
current context.  The context isn't passed as a parameter; it is global and
it is applied to one single window.
The source file is attended. Look through, please (this is modified
according to your advice as I understood it).
If line 106 is uncommented, the clipping would take place and _nothing_ be
drawn, although the clipping borders are defined correctly. In other case it
is drawn without clipping. Is there some glitch?


-- 
Regards,
Alexei Babich, circuit engineer, OOO NPP "Rezonans", Chelyabinsk, Russia
http://www.rez.ru
Jabber ID: impatt at jabber.ru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_2_cairo_clip_example.c
Type: text/x-csrc
Size: 2707 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20081126/6855e67e/attachment.c 


More information about the cairo mailing list