[cairo-commit] 4 commits - src/cairo-composite-rectangles.c src/cairo-polygon-intersect.c src/cairo-spans-compositor.c test/reference

Chris Wilson ickle at kemper.freedesktop.org
Thu Sep 27 03:45:03 PDT 2012


 src/cairo-composite-rectangles.c                |   17 +++++++++++++-
 src/cairo-polygon-intersect.c                   |   22 +++++++++++-------
 src/cairo-spans-compositor.c                    |   29 +++++++++++++++---------
 test/reference/clip-disjoint-quad.ref.png       |binary
 test/reference/clip-disjoint-quad.traps.ref.png |binary
 5 files changed, 49 insertions(+), 19 deletions(-)

New commits:
commit c05147b215072f9bd5e951011f68d9e647cf001f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Sep 27 11:41:58 2012 +0100

    test: Refresh reference image for clip-disjoint-quad
    
    Rather than using the traps reference for all target as this then
    generates false negatives with the spans compositor.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/reference/clip-disjoint-quad.ref.png b/test/reference/clip-disjoint-quad.ref.png
index de5ceb7..aaa7603 100644
Binary files a/test/reference/clip-disjoint-quad.ref.png and b/test/reference/clip-disjoint-quad.ref.png differ
diff --git a/test/reference/clip-disjoint-quad.traps.ref.png b/test/reference/clip-disjoint-quad.traps.ref.png
new file mode 100644
index 0000000..de5ceb7
Binary files /dev/null and b/test/reference/clip-disjoint-quad.traps.ref.png differ
commit ef0b2e43ee299a1c2e7ecfbdf36a610c4ec53d0e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Sep 27 11:35:40 2012 +0100

    composite-rectangles: Update unbounded (clip extents) after reducing clip
    
    So that the composite-rectangles remains consistent with the reduced
    clip in case the individual compositors try to optimise their rendering
    strategies based on the reduced clip and the overall extents.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-composite-rectangles.c b/src/cairo-composite-rectangles.c
index c358671..c792985 100644
--- a/src/cairo-composite-rectangles.c
+++ b/src/cairo-composite-rectangles.c
@@ -130,6 +130,10 @@ _cairo_composite_rectangles_init_for_paint (cairo_composite_rectangles_t *extent
     if (_cairo_clip_is_all_clipped (extents->clip))
 	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
+    if (! _cairo_rectangle_intersect (&extents->unbounded,
+				      _cairo_clip_get_extents (extents->clip)))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
+
     if (extents->source_pattern.base.type != CAIRO_PATTERN_TYPE_SOLID)
 	_cairo_pattern_sampled_area (&extents->source_pattern.base,
 				     &extents->bounded,
@@ -159,6 +163,10 @@ _cairo_composite_rectangles_intersect (cairo_composite_rectangles_t *extents,
     if (_cairo_clip_is_all_clipped (extents->clip))
 	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
+    if (! _cairo_rectangle_intersect (&extents->unbounded,
+				      _cairo_clip_get_extents (extents->clip)))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
+
     if (extents->source_pattern.base.type != CAIRO_PATTERN_TYPE_SOLID)
 	_cairo_pattern_sampled_area (&extents->source_pattern.base,
 				     &extents->bounded,
@@ -219,6 +227,10 @@ _cairo_composite_rectangles_intersect_source_extents (cairo_composite_rectangles
     if (_cairo_clip_is_all_clipped (extents->clip))
 	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
+    if (! _cairo_rectangle_intersect (&extents->unbounded,
+				      _cairo_clip_get_extents (extents->clip)))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
+
     if (extents->source_pattern.base.type != CAIRO_PATTERN_TYPE_SOLID)
 	_cairo_pattern_sampled_area (&extents->source_pattern.base,
 				     &extents->bounded,
@@ -277,6 +289,10 @@ _cairo_composite_rectangles_intersect_mask_extents (cairo_composite_rectangles_t
     if (_cairo_clip_is_all_clipped (extents->clip))
 	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
+    if (! _cairo_rectangle_intersect (&extents->unbounded,
+				      _cairo_clip_get_extents (extents->clip)))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
+
     if (extents->source_pattern.base.type != CAIRO_PATTERN_TYPE_SOLID)
 	_cairo_pattern_sampled_area (&extents->source_pattern.base,
 				     &extents->bounded,
@@ -307,7 +323,6 @@ _cairo_composite_rectangles_init_for_mask (cairo_composite_rectangles_t *extents
 	return CAIRO_INT_STATUS_NOTHING_TO_DO;
     }
 
-
     extents->original_mask_pattern = mask;
     _cairo_composite_reduce_pattern (mask, &extents->mask_pattern);
     _cairo_pattern_get_extents (&extents->mask_pattern.base, &extents->mask);
commit 36536d3eb83a8f942bcf1afba4d0815fbeaca10f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Sep 27 11:14:18 2012 +0100

    spans-compositor: Use the tight clip-boxes for polygon construction
    
    If we will be reducing the clip intersection to a single clip box check
    during construction, it helps if we use the tight clip box.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-spans-compositor.c b/src/cairo-spans-compositor.c
index 602d6a6..031ccbb 100644
--- a/src/cairo-spans-compositor.c
+++ b/src/cairo-spans-compositor.c
@@ -1019,12 +1019,16 @@ _cairo_spans_compositor_stroke (const cairo_compositor_t	*_compositor,
 	cairo_polygon_t polygon;
 	cairo_fill_rule_t fill_rule = CAIRO_FILL_RULE_WINDING;
 
-	if (extents->mask.width  > extents->unbounded.width ||
-	    extents->mask.height > extents->unbounded.height)
+	if (! _cairo_rectangle_contains_rectangle (&extents->unbounded,
+						   &extents->mask))
 	{
-	    cairo_box_t limits;
-	    _cairo_box_from_rectangle (&limits, &extents->unbounded);
-	    _cairo_polygon_init (&polygon, &limits, 1);
+	    if (extents->clip->num_boxes == 1) {
+		_cairo_polygon_init (&polygon, extents->clip->boxes, 1);
+	    } else {
+		cairo_box_t limits;
+		_cairo_box_from_rectangle (&limits, &extents->unbounded);
+		_cairo_polygon_init (&polygon, &limits, 1);
+	    }
 	}
 	else
 	{
@@ -1101,13 +1105,17 @@ _cairo_spans_compositor_fill (const cairo_compositor_t		*_compositor,
 
 	TRACE((stderr, "%s - polygon\n", __FUNCTION__));
 
-	if (extents->mask.width  > extents->unbounded.width ||
-	    extents->mask.height > extents->unbounded.height)
+	if (! _cairo_rectangle_contains_rectangle (&extents->unbounded,
+						   &extents->mask))
 	{
-	    cairo_box_t limits;
 	    TRACE((stderr, "%s - clipping to bounds\n", __FUNCTION__));
-	    _cairo_box_from_rectangle (&limits, &extents->unbounded);
-	    _cairo_polygon_init (&polygon, &limits, 1);
+	    if (extents->clip->num_boxes == 1) {
+		_cairo_polygon_init (&polygon, extents->clip->boxes, 1);
+	    } else {
+		cairo_box_t limits;
+		_cairo_box_from_rectangle (&limits, &extents->unbounded);
+		_cairo_polygon_init (&polygon, &limits, 1);
+	    }
 	}
 	else
 	{
@@ -1122,6 +1130,7 @@ _cairo_spans_compositor_fill (const cairo_compositor_t		*_compositor,
 							  extents->clip->boxes,
 							  extents->clip->num_boxes);
 	}
+	TRACE_ (_cairo_debug_print_polygon (stderr, &polygon));
 	if (likely (status == CAIRO_INT_STATUS_SUCCESS)) {
 	    cairo_clip_t *saved_clip = extents->clip;
 
commit 7e856071a27b06a6ae35b6445635da9276975c69
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Sep 27 11:13:23 2012 +0100

    polygon-intersect: Exclude non-overlapping clip boxes from consideration
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-polygon-intersect.c b/src/cairo-polygon-intersect.c
index c900c89..2cd73d2 100644
--- a/src/cairo-polygon-intersect.c
+++ b/src/cairo-polygon-intersect.c
@@ -1394,7 +1394,7 @@ _cairo_polygon_intersect (cairo_polygon_t *a, int winding_a,
     if (unlikely (0 == a->num_edges))
 	return CAIRO_STATUS_SUCCESS;
 
-    if (unlikely (b->num_edges == 0)) {
+    if (unlikely (0 == b->num_edges)) {
 	a->num_edges = 0;
 	return CAIRO_STATUS_SUCCESS;
     }
@@ -1505,16 +1505,22 @@ _cairo_polygon_intersect_with_boxes (cairo_polygon_t *polygon,
 
     _cairo_polygon_init (&b, NULL, 0);
     for (n = 0; n < num_boxes; n++) {
-	cairo_point_t p1, p2;
+	if (boxes[n].p2.x > polygon->extents.p1.x &&
+	    boxes[n].p1.x < polygon->extents.p2.x &&
+	    boxes[n].p2.y > polygon->extents.p1.y &&
+	    boxes[n].p1.y < polygon->extents.p2.y)
+	{
+	    cairo_point_t p1, p2;
 
-	p1.y = boxes[n].p1.y;
-	p2.y = boxes[n].p2.y;
+	    p1.y = boxes[n].p1.y;
+	    p2.y = boxes[n].p2.y;
 
-	p2.x = p1.x = boxes[n].p1.x;
-	_cairo_polygon_add_external_edge (&b, &p1, &p2);
+	    p2.x = p1.x = boxes[n].p1.x;
+	    _cairo_polygon_add_external_edge (&b, &p1, &p2);
 
-	p2.x = p1.x = boxes[n].p2.x;
-	_cairo_polygon_add_external_edge (&b, &p2, &p1);
+	    p2.x = p1.x = boxes[n].p2.x;
+	    _cairo_polygon_add_external_edge (&b, &p2, &p1);
+	}
     }
 
     status = _cairo_polygon_intersect (polygon, *winding,


More information about the cairo-commit mailing list