[cairo-commit] Branch '1.10' - 3 commits - src/cairo-image-surface.c test/clipped-group.image16.ref.png test/clipped-group.ref.png test/clip-stroke.image16.ref.png test/clip-stroke.ref.png test/Makefile.am test/Makefile.sources test/rectilinear-grid.c test/rectilinear-grid.image16.ref.png test/rectilinear-grid.ref.png

Andrea Canciani ranma42 at kemper.freedesktop.org
Thu Dec 2 02:08:09 PST 2010


 src/cairo-image-surface.c             |   22 ++++++---
 test/Makefile.am                      |    2 
 test/Makefile.sources                 |    1 
 test/clip-stroke.image16.ref.png      |binary
 test/clip-stroke.ref.png              |binary
 test/clipped-group.image16.ref.png    |binary
 test/clipped-group.ref.png            |binary
 test/rectilinear-grid.c               |   78 ++++++++++++++++++++++++++++++++++
 test/rectilinear-grid.image16.ref.png |binary
 test/rectilinear-grid.ref.png         |binary
 10 files changed, 95 insertions(+), 8 deletions(-)

New commits:
commit f832ff7f22499bfa8e907f9fb059d56857d11e68
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sun Nov 28 16:58:20 2010 +0100

    test: Fix ref images
    
    The corners of the boxes in these ref images were not correct.

diff --git a/test/clip-stroke.image16.ref.png b/test/clip-stroke.image16.ref.png
index d0019b8..ad62af4 100644
Binary files a/test/clip-stroke.image16.ref.png and b/test/clip-stroke.image16.ref.png differ
diff --git a/test/clip-stroke.ref.png b/test/clip-stroke.ref.png
index dd5ae9a..e66cc43 100644
Binary files a/test/clip-stroke.ref.png and b/test/clip-stroke.ref.png differ
diff --git a/test/clipped-group.image16.ref.png b/test/clipped-group.image16.ref.png
index 85819fe..bf419f6 100644
Binary files a/test/clipped-group.image16.ref.png and b/test/clipped-group.image16.ref.png differ
diff --git a/test/clipped-group.ref.png b/test/clipped-group.ref.png
index c3fcbf8..fe9b8dc 100644
Binary files a/test/clipped-group.ref.png and b/test/clipped-group.ref.png differ
commit ff35af3fd73e59ea29b1a322c833f7dd24b0b8bc
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sun Nov 28 14:32:51 2010 +0100

    image: Fix compositing of unaligned boxes
    
    The input of _fill_unaligned_boxes is (supposed to be) composed only
    of disjoint rectangles, that can safely be passed to the rectilinear
    span converter, but this function artificially introduces intersecting
    rectangles when drawing non-aligned boxes.
    
    Using non-intersecting rectangles is easy and makes the code correct.
    
    Fixes rectilinear-grid.
    
    Reviewed-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index d28267a..fcc832e 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -2692,7 +2692,13 @@ _fill_unaligned_boxes (cairo_image_surface_t *dst,
 			     x1, y1, x2 - x1, y2 - y1,
 			     pixel);
 
-		/* top */
+		/*
+		 * Corners have to be included only once if the rects
+		 * are passed to the rectangular scan converter
+		 * because it can only handle disjoint rectangles.
+		*/
+
+		/* top (including top-left and top-right corners) */
 		if (! _cairo_fixed_is_integer (box[i].p1.y)) {
 		    b.p1.x = box[i].p1.x;
 		    b.p1.y = box[i].p1.y;
@@ -2704,31 +2710,31 @@ _fill_unaligned_boxes (cairo_image_surface_t *dst,
 			goto CLEANUP_CONVERTER;
 		}
 
-		/* left */
+		/* left (no corners) */
 		if (! _cairo_fixed_is_integer (box[i].p1.x)) {
 		    b.p1.x = box[i].p1.x;
-		    b.p1.y = box[i].p1.y;
+		    b.p1.y = _cairo_fixed_from_int (y1);
 		    b.p2.x = _cairo_fixed_from_int (x1);
-		    b.p2.y = box[i].p2.y;
+		    b.p2.y = _cairo_fixed_from_int (y2);
 
 		    status = _cairo_rectangular_scan_converter_add_box (&converter, &b, 1);
 		    if (unlikely (status))
 			goto CLEANUP_CONVERTER;
 		}
 
-		/* right */
+		/* right (no corners) */
 		if (! _cairo_fixed_is_integer (box[i].p2.x)) {
 		    b.p1.x = _cairo_fixed_from_int (x2);
-		    b.p1.y = box[i].p1.y;
+		    b.p1.y = _cairo_fixed_from_int (y1);
 		    b.p2.x = box[i].p2.x;
-		    b.p2.y = box[i].p2.y;
+		    b.p2.y = _cairo_fixed_from_int (y2);
 
 		    status = _cairo_rectangular_scan_converter_add_box (&converter, &b, 1);
 		    if (unlikely (status))
 			goto CLEANUP_CONVERTER;
 		}
 
-		/* bottom */
+		/* bottom (including bottom-left and bottom-right corners) */
 		if (! _cairo_fixed_is_integer (box[i].p2.y)) {
 		    b.p1.x = box[i].p1.x;
 		    b.p1.y = _cairo_fixed_from_int (y2);
commit 7b29f1d5d85ebb7e92e9759692233c80a4687a07
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Fri Nov 26 17:55:35 2010 +0100

    test: Add rectilinear-grid
    
    The rectilinear scan converter assumes disjoint rects as input, but
    cairo-image passes intersecting rectangles to it.
    
    This test shows that image and any backends passing through it for the
    rasterization (fallbacks, vector backends whose renderer is
    cairo-based) fail in compute the corners of intersecting rectangles
    correctly.

diff --git a/test/Makefile.am b/test/Makefile.am
index a3c1f7a..ad2b959 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1066,6 +1066,8 @@ REFERENCE_IMAGES = \
 	rectilinear-dash.quartz.xfail.png \
 	rectilinear-dash.ref.png \
 	rectilinear-fill.ref.png \
+	rectilinear-grid.image16.ref.png \
+	rectilinear-grid.ref.png \
 	rectilinear-miter-limit.ps2.ref.png \
 	rectilinear-miter-limit.ps3.ref.png \
 	rectilinear-miter-limit.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index a13aea8..b6431d1 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -207,6 +207,7 @@ test_sources = \
 	random-intersections-curves-nz.c		\
 	rectangle-rounding-error.c			\
 	rectilinear-fill.c				\
+	rectilinear-grid.c				\
 	rectilinear-miter-limit.c			\
 	rectilinear-dash.c				\
 	rectilinear-stroke.c				\
diff --git a/test/rectilinear-grid.c b/test/rectilinear-grid.c
new file mode 100644
index 0000000..1baadf7
--- /dev/null
+++ b/test/rectilinear-grid.c
@@ -0,0 +1,78 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright 2010 Andrea Canciani
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Andrea Canciani <ranma42 at gmail.com>
+ */
+
+#include "cairo-test.h"
+
+#define SIZE 52
+#define OFFSET 5
+#define DISTANCE 10.25
+
+/*
+  This test checks that boxes not aligned to pixels are drawn
+  correctly.
+
+  In particular the corners of the boxes are drawn incorrectly by
+  cairo-image in cairo 1.10.0, because overlapping boxes are passed to
+  a span converter which assumes disjoint boxes as input.
+
+  This results in corners to be drawn with the wrong shade.
+*/
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    int i;
+
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_paint (cr);
+
+    cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+    cairo_set_source_rgb (cr, 0, 0, 0);
+    cairo_set_line_width (cr, 4);
+    cairo_translate (cr, 2*OFFSET, 2*OFFSET);
+
+    for (i = 0; i < 4; i++) {
+	double x = i * DISTANCE;
+
+	cairo_move_to (cr, x, -OFFSET-0.75);
+	cairo_line_to (cr, x, SIZE-3*OFFSET-0.25);
+
+	cairo_move_to (cr, -OFFSET-0.75, x);
+	cairo_line_to (cr, SIZE-3*OFFSET-0.25, x);
+    }
+
+    cairo_stroke (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (rectilinear_grid,
+	    "Test rectilinear rasterizer (covering partial pixels)",
+	    "rectilinear", /* keywords */
+	    NULL, /* requirements */
+	    SIZE, SIZE,
+	    NULL, draw)
diff --git a/test/rectilinear-grid.image16.ref.png b/test/rectilinear-grid.image16.ref.png
new file mode 100644
index 0000000..4d4c4da
Binary files /dev/null and b/test/rectilinear-grid.image16.ref.png differ
diff --git a/test/rectilinear-grid.ref.png b/test/rectilinear-grid.ref.png
new file mode 100644
index 0000000..8d47ef5
Binary files /dev/null and b/test/rectilinear-grid.ref.png differ


More information about the cairo-commit mailing list