[cairo] [PATCH 4/4] Don't miss any chance of getting clip region

Taekyun Kim podain77 at gmail.com
Tue Jul 5 00:17:57 PDT 2011


From: Taekyun Kim <tkq.kim at samsung.com>

_cairo_clip_to_boxes() might intersect clip with extents causing
the clip to be reduced to a region which was not possible before.

Many subroutines of image backend (e.g. _composite_boxes) does not
do any clipping if _cairo_clip_get_region() succeeds. They assume
that geometries are already clipped. So we have to calculate clip
region again whenever it is modified.
---
 src/cairo-clip.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 9527c59..d51a471 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -1435,10 +1435,20 @@ _cairo_clip_to_boxes (cairo_clip_t **clip,
     if (*clip == NULL)
 	goto EXTENTS;
 
+    /* _cairo_clip_rectangle() might add additional rectangle clip path to the clip
+     * causing reduction of the clip to a region which could not be possible before.
+     * This is because image backend assumes that geometries are already clipped if
+     * _cairo_clip_get_region() succeeds.
+     */
     status = _cairo_clip_rectangle (*clip, rect);
     if (unlikely (status))
 	return status;
 
+    /* Try to reduce given clip to a region because it can be magically reduced to
+     * a region due to previous _cairo_clip_rectangle().
+     * */
+    _cairo_clip_get_region (*clip, NULL);
+
     status = _cairo_clip_get_boxes (*clip, boxes, num_boxes);
     switch ((int) status) {
     case CAIRO_STATUS_SUCCESS:
-- 
1.7.1



More information about the cairo mailing list