[cairo-commit] 2 commits - src/cairo-clip.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Jun 17 08:21:51 PDT 2009


 src/cairo-clip.c |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 13 deletions(-)

New commits:
commit 394e139213e8f6692115c4c24818bfeb5e6d456a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jun 17 14:46:53 2009 +0100

    [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.

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 5edc124..d373f1e 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);
     }
 
commit 650b85ec7721fb1302284e3ca4b7f4b72358abed
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jun 17 14:19:19 2009 +0100

    [clip] Avoid copying region within  _cairo_clip_intersect_region()
    
    Within _cairo_clip_intersect_region() we can simply assign the freshly
    extracted traps-region if we previously had no region set.

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index bb04a9e..5edc124 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -336,17 +336,11 @@ _cairo_clip_intersect_region (cairo_clip_t    *clip,
 
     if (clip->region) {
 	status = cairo_region_intersect (clip->region, region);
-    } else {
-	clip->region = cairo_region_copy (region);
-
-	assert (clip->region != NULL);
-	
-        if ((status = cairo_region_status (clip->region)))
-	    clip->region = NULL;
-    }
+	cairo_region_destroy (region);
+    } else
+	clip->region = region;
 
     clip->serial = _cairo_surface_allocate_clip_serial (target);
-    cairo_region_destroy (region);
 
     if (!clip->region || cairo_region_is_empty (clip->region))
 	_cairo_clip_set_all_clipped (clip, target);


More information about the cairo-commit mailing list