summaryrefslogtreecommitdiff
path: root/src/cairo-clip.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-06-17 14:46:53 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-06-17 16:20:07 +0100
commit394e139213e8f6692115c4c24818bfeb5e6d456a (patch)
treef830919c3e971eb9964e1287c0adf8ccaa20ee74 /src/cairo-clip.c
parent650b85ec7721fb1302284e3ca4b7f4b72358abed (diff)
[clip] During _clip() limit the extracted traps to the current clip extents
By applying a tight _cairo_traps_limit() we can reduce the amount of work we need to do when tessellating the path and extracting the trapezoids.
Diffstat (limited to 'src/cairo-clip.c')
-rw-r--r--src/cairo-clip.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 5edc1243..d373f1ea 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -626,9 +626,10 @@ _cairo_clip_clip (cairo_clip_t *clip,
cairo_surface_t *target)
{
cairo_status_t status;
- cairo_rectangle_int_t rectangle;
+ cairo_rectangle_int_t limits, extents;
cairo_traps_t traps;
cairo_box_t ignored_box;
+ cairo_bool_t have_limits;
if (clip->all_clipped)
return CAIRO_STATUS_SUCCESS;
@@ -662,13 +663,43 @@ _cairo_clip_clip (cairo_clip_t *clip,
_cairo_traps_init (&traps);
- /* Limit the traps to the target surface
+ /* Limit the traps to the target surface and current clip
* - so we don't add more traps than needed. */
- status = _cairo_surface_get_extents (target, &rectangle);
+ have_limits = FALSE;
+ if (clip->region != NULL) {
+ cairo_region_get_extents (clip->region, &limits);
+ have_limits = TRUE;
+ }
+
+ if (clip->surface != NULL) {
+ if (have_limits) {
+ if (! _cairo_rectangle_intersect (&limits, &clip->surface_rect)) {
+ _cairo_clip_set_all_clipped (clip, target);
+ return CAIRO_STATUS_SUCCESS;
+ }
+ } else {
+ limits = clip->surface_rect;
+ have_limits = TRUE;
+ }
+ }
+
+ status = _cairo_surface_get_extents (target, &extents);
if (status == CAIRO_STATUS_SUCCESS) {
+ if (have_limits) {
+ if (! _cairo_rectangle_intersect (&limits, &extents)) {
+ _cairo_clip_set_all_clipped (clip, target);
+ return CAIRO_STATUS_SUCCESS;
+ }
+ } else {
+ limits = extents;
+ have_limits = TRUE;
+ }
+ }
+
+ if (have_limits) {
cairo_box_t box;
- _cairo_box_from_rectangle (&box, &rectangle);
+ _cairo_box_from_rectangle (&box, &limits);
_cairo_traps_limit (&traps, &box);
}