From d40b90a577f3dd159d3871185ed8d649a03a2a4e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 6 Mar 2012 14:59:44 +0000 Subject: [PATCH] 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 --- src/cairo-clip-polygon.c | 26 ++++++++++++++++++-------- 1 file 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