summaryrefslogtreecommitdiff
path: root/src/cairo-clip-polygon.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-03-06 14:59:44 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-03-06 15:00:53 +0000
commitd40b90a577f3dd159d3871185ed8d649a03a2a4e (patch)
treee47d57268e99a5e84e9188ea18dbbf4a05ac2927 /src/cairo-clip-polygon.c
parentf8f0510f8929980f9b8da7ef0f39d231dfe24686 (diff)
downloadcairo-d40b90a577f3dd159d3871185ed8d649a03a2a4e.tar.gz
clip: Use the boxes-intersection routine for computing the clip polygon
If we have more than a single box, run the boxes intersection as a post-processing step on the clip polygon, as it should be faster than doing it inline. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-clip-polygon.c')
-rw-r--r--src/cairo-clip-polygon.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/cairo-clip-polygon.c b/src/cairo-clip-polygon.c
index 0e1968d05..db0298f6e 100644
--- a/src/cairo-clip-polygon.c
+++ b/src/cairo-clip-polygon.c
@@ -88,15 +88,23 @@ _cairo_clip_get_polygon (const cairo_clip_t *clip,
if (! can_convert_to_polygon (clip))
return CAIRO_INT_STATUS_UNSUPPORTED;
- _cairo_polygon_init_with_clip (polygon, clip);
+ if (clip->num_boxes < 2)
+ _cairo_polygon_init_with_clip (polygon, clip);
+ else
+ _cairo_polygon_init_with_clip (polygon, NULL);
clip_path = clip->path;
status = _cairo_path_fixed_fill_to_polygon (&clip_path->path,
clip_path->tolerance,
polygon);
- if (unlikely (status)) {
- _cairo_polygon_fini (polygon);
- return status;
+ if (unlikely (status))
+ goto err;
+
+ if (clip->num_boxes > 1) {
+ status = _cairo_polygon_intersect_with_boxes (polygon, fill_rule,
+ clip->boxes, clip->num_boxes);
+ if (unlikely (status))
+ goto err;
}
polygon->limits = NULL;
@@ -115,15 +123,17 @@ _cairo_clip_get_polygon (const cairo_clip_t *clip,
status = _cairo_polygon_intersect (polygon, *fill_rule,
&next, clip_path->fill_rule);
_cairo_polygon_fini (&next);
- if (unlikely (status)) {
- _cairo_polygon_fini (polygon);
- return status;
- }
+ if (unlikely (status))
+ goto err;
*fill_rule = CAIRO_FILL_RULE_WINDING;
}
return CAIRO_STATUS_SUCCESS;
+
+err:
+ _cairo_polygon_fini (polygon);
+ return status;
}
cairo_bool_t