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>
This commit is contained in:
Chris Wilson 2012-03-06 14:59:44 +00:00
parent f8f0510f89
commit d40b90a577

View file

@ -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