[cairo] cairo_clip_extents returns all 0s after a cairo_clip call

Uli Schlachter psychon at znc.in
Fri Mar 9 05:19:06 PST 2012

On 09.03.2012 13:21, Christian Kellermann wrote:
> Hi!
> I want to check the size of the current clipping region to adjust
> scaling of composed surfaces before masking them in.
> So I am currently doing the following:
> double x1, y1, x2, y2;
> cairo_rectangle( cr, 100, 100, 100, 100);
> cairo_stroke(cr);
> cairo_rectangle(cr, 100, 100, 20, 20);
> cairo_clip(cr);
> cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
> This returns all x1,... to be 0.0.
> Now If I call cairo_clip_extents before the call to cairo_clip, I am
> seeing the current screen size, as I would have expected.
> I am probably doing it wrong(tm). What's the right way to do this?

Attached is a small test program which does just what I was expecting. I get the
following output:

0 0 200 200
100 100 120 120

First there is no clip set, thus the clip extents are the surface's size. The
second call then prints the result of the clip which was just applied.

What are you doing different?


A learning experience is one of those things that say,
'You know that thing you just did? Don't do that.'
                     -- Douglas Adams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.c
Type: text/x-csrc
Size: 473 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120309/c7a7fd4a/attachment.c>

More information about the cairo mailing list