[cairo-commit] 4 commits - src/cairo-gl-surface.c src/cairo-polygon.c test/reference

Chris Wilson ickle at kemper.freedesktop.org
Tue Dec 6 07:01:22 PST 2011


 src/cairo-gl-surface.c                                |    6 -
 src/cairo-polygon.c                                   |   55 +++++++++++++++++-
 test/reference/a1-tiger.ref.png                       |binary
 test/reference/clip-nesting.argb32.ref.png            |binary
 test/reference/clip-nesting.rgb24.ref.png             |binary
 test/reference/clip-operator.argb32.ref.png           |binary
 test/reference/clip-operator.rgb24.ref.png            |binary
 test/reference/hatchings.ref.png                      |binary
 test/reference/mask.argb32.ref.png                    |binary
 test/reference/mask.rgb24.ref.png                     |binary
 test/reference/random-intersections-curves-eo.ref.png |binary
 test/reference/random-intersections-curves-nz.ref.png |binary
 test/reference/record-fill-alpha.ref.png              |binary
 test/reference/record-paint-alpha-clip-mask.ref.png   |binary
 test/reference/rel-path.rgb24.ref.png                 |binary
 test/reference/scale-offset-image.ref.png             |binary
 test/reference/scale-offset-similar.ref.png           |binary
 test/reference/tiger.ref.png                          |binary
 18 files changed, 56 insertions(+), 5 deletions(-)

New commits:
commit d60a2930e1743ad634794472c66a303595ce1290
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 6 14:56:49 2011 +0000

    test: reference ref images after tweaking polygon clipping

diff --git a/test/reference/a1-tiger.ref.png b/test/reference/a1-tiger.ref.png
index e207d7d..cc641e2 100644
Binary files a/test/reference/a1-tiger.ref.png and b/test/reference/a1-tiger.ref.png differ
diff --git a/test/reference/clip-nesting.argb32.ref.png b/test/reference/clip-nesting.argb32.ref.png
index 927a7d4..4d79d67 100644
Binary files a/test/reference/clip-nesting.argb32.ref.png and b/test/reference/clip-nesting.argb32.ref.png differ
diff --git a/test/reference/clip-nesting.rgb24.ref.png b/test/reference/clip-nesting.rgb24.ref.png
index 432318d..3a7be9a 100644
Binary files a/test/reference/clip-nesting.rgb24.ref.png and b/test/reference/clip-nesting.rgb24.ref.png differ
diff --git a/test/reference/clip-operator.argb32.ref.png b/test/reference/clip-operator.argb32.ref.png
index 47c16de..131c66f 100644
Binary files a/test/reference/clip-operator.argb32.ref.png and b/test/reference/clip-operator.argb32.ref.png differ
diff --git a/test/reference/clip-operator.rgb24.ref.png b/test/reference/clip-operator.rgb24.ref.png
index 8ef57e1..5ec44ca 100644
Binary files a/test/reference/clip-operator.rgb24.ref.png and b/test/reference/clip-operator.rgb24.ref.png differ
diff --git a/test/reference/hatchings.ref.png b/test/reference/hatchings.ref.png
index a8af87c..e8efd45 100644
Binary files a/test/reference/hatchings.ref.png and b/test/reference/hatchings.ref.png differ
diff --git a/test/reference/mask.argb32.ref.png b/test/reference/mask.argb32.ref.png
index f1f14d7..c6f2828 100644
Binary files a/test/reference/mask.argb32.ref.png and b/test/reference/mask.argb32.ref.png differ
diff --git a/test/reference/mask.rgb24.ref.png b/test/reference/mask.rgb24.ref.png
index 0f9cb37..7e78a9a 100644
Binary files a/test/reference/mask.rgb24.ref.png and b/test/reference/mask.rgb24.ref.png differ
diff --git a/test/reference/random-intersections-curves-eo.ref.png b/test/reference/random-intersections-curves-eo.ref.png
index e8cfebd..53073fb 100644
Binary files a/test/reference/random-intersections-curves-eo.ref.png and b/test/reference/random-intersections-curves-eo.ref.png differ
diff --git a/test/reference/random-intersections-curves-nz.ref.png b/test/reference/random-intersections-curves-nz.ref.png
index 6cd9495..c889b17 100644
Binary files a/test/reference/random-intersections-curves-nz.ref.png and b/test/reference/random-intersections-curves-nz.ref.png differ
diff --git a/test/reference/record-fill-alpha.ref.png b/test/reference/record-fill-alpha.ref.png
index 3f8fa43..50cc034 100644
Binary files a/test/reference/record-fill-alpha.ref.png and b/test/reference/record-fill-alpha.ref.png differ
diff --git a/test/reference/record-paint-alpha-clip-mask.ref.png b/test/reference/record-paint-alpha-clip-mask.ref.png
index 3c7089c..9c2ab2c 100644
Binary files a/test/reference/record-paint-alpha-clip-mask.ref.png and b/test/reference/record-paint-alpha-clip-mask.ref.png differ
diff --git a/test/reference/rel-path.rgb24.ref.png b/test/reference/rel-path.rgb24.ref.png
index 8254eb5..2eebde6 100644
Binary files a/test/reference/rel-path.rgb24.ref.png and b/test/reference/rel-path.rgb24.ref.png differ
diff --git a/test/reference/scale-offset-image.ref.png b/test/reference/scale-offset-image.ref.png
index 67e1fce..1e216e5 100644
Binary files a/test/reference/scale-offset-image.ref.png and b/test/reference/scale-offset-image.ref.png differ
diff --git a/test/reference/scale-offset-similar.ref.png b/test/reference/scale-offset-similar.ref.png
index 67e1fce..1e216e5 100644
Binary files a/test/reference/scale-offset-similar.ref.png and b/test/reference/scale-offset-similar.ref.png differ
diff --git a/test/reference/tiger.ref.png b/test/reference/tiger.ref.png
index 1a84906..b31d358 100644
Binary files a/test/reference/tiger.ref.png and b/test/reference/tiger.ref.png differ
commit 291efa76de7572720e82b25cc105bb94fd351cd4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 6 14:45:27 2011 +0000

    polygon: Tweak the y-coordinates of the edge so that it is inside the clip
    
    As we evaluate the line first using y-for-x to find the clipped
    vertical range and then rasterise the line using x-for-y, we can incur
    severe rounding errors that cause us to draw beyond the clipped region.
    The first simple attempt at a fix is to tweak the clipped vertical range
    such that the evaluated extents of the line are contained.
    
    Reported-by: Taekyun Kim <tkq.kim at samsung.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index 82fbb88..c714b32 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -423,6 +423,9 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 	    top_left_to_bottom_right = (p1->x < p2->x) == (p1->y < p2->y);
 
 	    if (top_left_to_bottom_right) {
+		if (_cairo_edge_compute_intersection_x_for_y (p1, p2, left_y) < limits->p1.x)
+		    left_y++;
+
 		left_y = MIN (left_y, bot_y);
 		if (top_y < left_y) {
 		    _add_edge (polygon, &limits->p1, &bot_left,
@@ -431,6 +434,9 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		    top_y = left_y;
 		}
 
+		if (_cairo_edge_compute_intersection_x_for_y (p1, p2, right_y) > limits->p1.y)
+		    right_y--;
+
 		right_y = MAX (right_y, top_y);
 		if (bot_y > right_y) {
 		    _add_edge (polygon, &top_right, &limits->p2,
@@ -439,6 +445,9 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		    bot_y = right_y;
 		}
 	    } else {
+		if (_cairo_edge_compute_intersection_x_for_y (p1, p2, right_y) > limits->p2.x)
+		    right_y++;
+
 		right_y = MIN (right_y, bot_y);
 		if (top_y < right_y) {
 		    _add_edge (polygon, &top_right, &limits->p2,
@@ -447,6 +456,9 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		    top_y = right_y;
 		}
 
+		if (_cairo_edge_compute_intersection_x_for_y (p1, p2, left_y) < limits->p1.x)
+		    left_y--;
+
 		left_y = MAX (left_y, top_y);
 		if (bot_y > left_y) {
 		    _add_edge (polygon, &limits->p1, &bot_left,
commit 19dd6e7e530275aa1ee37dea922c8396b1077758
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 6 14:44:57 2011 +0000

    polygon: Assert that we add edges that are wholly contained by the clip
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index 90f81f7..82fbb88 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -41,6 +41,38 @@
 #include "cairo-contour-private.h"
 #include "cairo-error-private.h"
 
+#define DEBUG_POLYGON 0
+
+#if DEBUG_POLYGON && !NDEBUG
+static void
+assert_last_edge_is_valid(cairo_polygon_t *polygon,
+			  const cairo_box_t *limit)
+{
+    cairo_edge_t *edge;
+    cairo_fixed_t x;
+
+    edge = &polygon->edges[polygon->num_edges-1];
+
+    assert (edge->bottom > edge->top);
+    assert (edge->top >= limit->p1.y);
+    assert (edge->bottom <= limit->p2.y);
+
+    x = _cairo_edge_compute_intersection_x_for_y (&edge->line.p1,
+						  &edge->line.p2,
+						  edge->top);
+    assert (x >= limit->p1.x);
+    assert (x <= limit->p2.x);
+
+    x = _cairo_edge_compute_intersection_x_for_y (&edge->line.p1,
+						  &edge->line.p2,
+						  edge->bottom);
+    assert (x >= limit->p1.x);
+    assert (x <= limit->p2.x);
+}
+#else
+#define assert_last_edge_is_valid(p, l)
+#endif
+
 static void
 _cairo_polygon_add_edge (cairo_polygon_t *polygon,
 			 const cairo_point_t *p1,
@@ -340,16 +372,19 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 	     * clip vertically by restricting top and bottom */
 
 	    _add_edge (polygon, p1, p2, top_y, bot_y, dir);
+	    assert_last_edge_is_valid (polygon, limits);
 	} else if (pright <= limits->p1.x) {
 	    /* Projection of the edge to the left of the box:
 	     * replace with the left side of the box (clipped top/bottom) */
 
 	    _add_edge (polygon, &limits->p1, &bot_left, top_y, bot_y, dir);
+	    assert_last_edge_is_valid (polygon, limits);
 	} else if (limits->p2.x <= pleft) {
 	    /* Projection of the edge to the right of the box:
 	     * replace with the right side of the box (clipped top/bottom) */
 
 	    _add_edge (polygon, &top_right, &limits->p2, top_y, bot_y, dir);
+	    assert_last_edge_is_valid (polygon, limits);
 	} else {
 	    /* The edge and the box intersect in a generic way */
 	    cairo_fixed_t left_y, right_y;
@@ -392,6 +427,7 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		if (top_y < left_y) {
 		    _add_edge (polygon, &limits->p1, &bot_left,
 			       top_y, left_y, dir);
+		    assert_last_edge_is_valid (polygon, limits);
 		    top_y = left_y;
 		}
 
@@ -399,6 +435,7 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		if (bot_y > right_y) {
 		    _add_edge (polygon, &top_right, &limits->p2,
 			       right_y, bot_y, dir);
+		    assert_last_edge_is_valid (polygon, limits);
 		    bot_y = right_y;
 		}
 	    } else {
@@ -406,6 +443,7 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		if (top_y < right_y) {
 		    _add_edge (polygon, &top_right, &limits->p2,
 			       top_y, right_y, dir);
+		    assert_last_edge_is_valid (polygon, limits);
 		    top_y = right_y;
 		}
 
@@ -413,12 +451,15 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		if (bot_y > left_y) {
 		    _add_edge (polygon, &limits->p1, &bot_left,
 			       left_y, bot_y, dir);
+		    assert_last_edge_is_valid (polygon, limits);
 		    bot_y = left_y;
 		}
 	    }
 
-	    if (top_y != bot_y)
+	    if (top_y != bot_y) {
 		_add_edge (polygon, p1, p2, top_y, bot_y, dir);
+		assert_last_edge_is_valid (polygon, limits);
+	    }
 	}
     }
 }
commit 6b472e12ae11f7b68289cdfd616e765be9a25a98
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 6 10:27:17 2011 +0000

    gl: Re-enable the CLEAR optimisation
    
    It was temporarily disabled whilst the surface API was in flux.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index c201c51..90b2594 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -1161,19 +1161,17 @@ _cairo_gl_surface_paint (void			*surface,
 			 const cairo_pattern_t	*source,
 			 const cairo_clip_t	*clip)
 {
-#if 0
     /* simplify the common case of clearing the surface */
     if (clip == NULL) {
         if (op == CAIRO_OPERATOR_CLEAR)
-            return _cairo_gl_surface_clear (abstract_surface, CAIRO_COLOR_TRANSPARENT);
+            return _cairo_gl_surface_clear (surface, CAIRO_COLOR_TRANSPARENT);
        else if (source->type == CAIRO_PATTERN_TYPE_SOLID &&
                 (op == CAIRO_OPERATOR_SOURCE ||
                  (op == CAIRO_OPERATOR_OVER && _cairo_pattern_is_opaque_solid (source)))) {
-            return _cairo_gl_surface_clear (abstract_surface,
+            return _cairo_gl_surface_clear (surface,
                                             &((cairo_solid_pattern_t *) source)->color);
         }
     }
-#endif
 
     return _cairo_compositor_paint (get_compositor (surface), surface,
 				    op, source, clip);


More information about the cairo-commit mailing list