[cairo] How can I fin out out the current clip region of cairo

M Joonas Pihlaja jpihlaja at cc.helsinki.fi
Thu Feb 25 14:08:10 PST 2010

On Thu, 25 Feb 2010, silverburgh wrote:

> Hi,
> >From cairo documentation
> http://www.cairographics.org/manual/cairo-context.html#cairo-clip, it
> said:
> The current clip region affects all drawing operations by effectively
> masking out any changes to the surface that are outside the current
> clip region.
> Can you please tell me how can I print out the current cairo clip
> region to screen/file for debugging purpose?

You can get the clip region as a list of rectangles using 
cairo_copy_clip_rectangle_list().  If the clip isn't possible to 
represent as rectangles that won't do you any good though.

An alternative way to debug the clip might be to paint with solid 
white to a temporary surface something like this and seeing where the 
paint lands:

cairo_pattern_t *clip_pattern;
cairo_surface_t *clip_surface;

cairo_push_group (cr);
  cairo_set_source_rgb (cr, 1, 1, 1);
  cairo_paint (cr);
clip_pattern = cairo_pop_target (cr);

cairo_pattern_get_surface (clip_pattern, &clip_surface);
cairo_surface_write_to_png (clip_surface, "clip.png");
cairo_pattern_destroy (clip_pattern);

Hope that helps,


More information about the cairo mailing list