[cairo-commit] 3 commits - src/cairo-xlib-source.c test/bug-51910.c test/Makefile.sources test/reference test/sample.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Jul 9 13:57:47 PDT 2012


 src/cairo-xlib-source.c                  |   20 +++--
 test/Makefile.sources                    |    2 
 test/bug-51910.c                         |   91 ++++++++++++++++++++++++
 test/reference/bug-51910.ref.png         |binary
 test/reference/sample-diagonal.ref.png   |binary
 test/reference/sample-horizontal.ref.png |binary
 test/reference/sample-vertical.ref.png   |binary
 test/sample.c                            |  117 +++++++++++++++++++++++++++++++
 8 files changed, 223 insertions(+), 7 deletions(-)

New commits:
commit 6938592ec7e1a1b4cfccb11521ecdfdb8579f380
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jul 9 21:50:34 2012 +0100

    xlib: If a sample accesses outside of a repeating image, upload it all
    
    Fixes bug-51910
    
    Reported-by: Albertas Vyšniauskas <thezbyg at gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51910
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-xlib-source.c b/src/cairo-xlib-source.c
index ac0fdf8..09f824f 100644
--- a/src/cairo-xlib-source.c
+++ b/src/cairo-xlib-source.c
@@ -920,13 +920,19 @@ surface_source (cairo_xlib_surface_t *dst,
     cairo_matrix_t m;
 
     upload = *sample;
-    if (_cairo_surface_get_extents (pattern->surface, &limit) &&
-	! _cairo_rectangle_intersect (&upload, &limit))
-    {
-	if (pattern->base.extend == CAIRO_EXTEND_NONE)
-	    return alpha_source (dst, 0);
-
-	upload = limit;
+    if (_cairo_surface_get_extents (pattern->surface, &limit)) {
+	if (pattern->base.extend == CAIRO_EXTEND_NONE) {
+	    if (! _cairo_rectangle_intersect (&upload, &limit))
+		return alpha_source (dst, 0);
+	} else {
+	    if (upload.x < limit.x ||
+		upload.x + upload.width > limit.x + limit.width ||
+		upload.y < limit.y ||
+		upload.y + upload.height > limit.y + limit.height)
+	    {
+		upload = limit;
+	    }
+	}
     }
 
     src = (cairo_xlib_surface_t *)
commit ff22ab4c10e169e457887fae4fbd5394d45b939e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jul 9 16:13:49 2012 +0100

    test: Add example from bug-51910
    
    The calculation of the required source extents blows up under xlib.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/Makefile.sources b/test/Makefile.sources
index 309cf07..8975b46 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -25,6 +25,7 @@ test_sources = \
 	big-trap.c					\
 	bilevel-image.c					\
 	bug-40410.c					\
+	bug-51910.c					\
 	bug-bo-rectangular.c				\
 	bug-bo-collins.c				\
 	bug-bo-ricotz.c					\
diff --git a/test/bug-51910.c b/test/bug-51910.c
new file mode 100644
index 0000000..37881de
--- /dev/null
+++ b/test/bug-51910.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * 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.
+ */
+
+#include "cairo-test.h"
+
+/* An error in xlib pattern transformation discovered by Albertas Vyšniauskas */
+
+static cairo_pattern_t *
+source(void)
+{
+    cairo_surface_t *surface;
+    cairo_pattern_t *pattern;
+    cairo_matrix_t matrix;
+    cairo_t *cr;
+    int i;
+
+    surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 32, 32);
+    cr = cairo_create (surface);
+    cairo_surface_destroy (surface);
+
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_paint (cr);
+
+    cairo_set_source_rgb (cr, .5, .5, .5);
+    cairo_set_line_width (cr, 2);
+
+    for (i = -1; i <= 8; i++) {
+	cairo_move_to (cr, -34 + 8*i, 34);
+	cairo_rel_line_to (cr, 36, -36);
+	cairo_stroke (cr);
+    }
+
+    pattern = cairo_pattern_create_for_surface (cairo_get_target (cr));
+    cairo_destroy (cr);
+
+    cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+    cairo_matrix_init_translate(&matrix, 14.1, 0);
+    cairo_pattern_set_matrix(pattern, &matrix);
+
+    return pattern;
+}
+
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_pattern_t *pattern;
+    int i;
+
+    cairo_paint (cr);
+
+    pattern = source ();
+    cairo_set_source (cr, pattern);
+    cairo_pattern_destroy (pattern);
+
+    for (i = 0; i < 8; i++) {
+	cairo_rectangle (cr, 3.5*i, 32*i, 256, 32);
+	cairo_fill (cr);
+    }
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (bug_51910,
+	    "A bug in the xlib pattern transformation",
+	    " paint", /* keywords */
+	    NULL, /* requirements */
+	    256, 256,
+	    NULL, draw)
diff --git a/test/reference/bug-51910.ref.png b/test/reference/bug-51910.ref.png
new file mode 100644
index 0000000..7f55eaa
Binary files /dev/null and b/test/reference/bug-51910.ref.png differ
commit 7b6f9fd14091d23a69b06c422262d293268035d0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jun 29 19:57:21 2012 +0100

    test: Add a simple exercise for raster sampling of subpixel geometry
    
    Test that the rasteriser doesn't incorrectly merge disjoint geometry at
    the subpixel level.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/Makefile.sources b/test/Makefile.sources
index 9aada62..309cf07 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -280,6 +280,7 @@ test_sources = \
 	rotated-clip.c					\
 	rounded-rectangle-fill.c			\
 	rounded-rectangle-stroke.c			\
+	sample.c					\
 	scale-down-source-surface-paint.c		\
 	scale-offset-image.c				\
 	scale-offset-similar.c				\
diff --git a/test/reference/sample-diagonal.ref.png b/test/reference/sample-diagonal.ref.png
new file mode 100644
index 0000000..f866c2e
Binary files /dev/null and b/test/reference/sample-diagonal.ref.png differ
diff --git a/test/reference/sample-horizontal.ref.png b/test/reference/sample-horizontal.ref.png
new file mode 100644
index 0000000..75f866b
Binary files /dev/null and b/test/reference/sample-horizontal.ref.png differ
diff --git a/test/reference/sample-vertical.ref.png b/test/reference/sample-vertical.ref.png
new file mode 100644
index 0000000..75f866b
Binary files /dev/null and b/test/reference/sample-vertical.ref.png differ
diff --git a/test/sample.c b/test/sample.c
new file mode 100644
index 0000000..da2dcf2
--- /dev/null
+++ b/test/sample.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2012 Intel Corporation
+ *
+ * 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: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+/* Test the fidelity of the rasterisation, because Cairo is my favourite
+ * driver test suite.
+ */
+
+#define GENERATE_REFERENCE 0
+
+#define WIDTH 256
+#define HEIGHT 40
+
+#include "../src/cairo-fixed-type-private.h"
+#define PRECISION (1 << CAIRO_FIXED_FRAC_BITS)
+
+static cairo_test_status_t
+vertical (cairo_t *cr, int width, int height)
+{
+    int x;
+
+    cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+    cairo_paint (cr);
+
+    cairo_set_source_rgba (cr, 1, 1, 1, 1);
+    for (x = -HEIGHT*PRECISION-2; x <= (WIDTH+HEIGHT)*PRECISION+2; x += 4) {
+	cairo_move_to (cr, x / (double)PRECISION - 2, -2);
+	cairo_rel_line_to (cr, 0, HEIGHT + 4);
+    }
+    cairo_set_line_width (cr, 2 / (double)PRECISION);
+    cairo_stroke (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+horizontal (cairo_t *cr, int width, int height)
+{
+    int x;
+
+    cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+    cairo_paint (cr);
+
+    cairo_set_source_rgba (cr, 1, 1, 1, 1);
+    for (x = -HEIGHT*PRECISION-2; x <= (WIDTH+HEIGHT)*PRECISION+2; x += 4) {
+	cairo_move_to (cr, -2, x / (double)PRECISION - 2);
+	cairo_rel_line_to (cr, HEIGHT + 4, 0);
+    }
+    cairo_set_line_width (cr, 2 / (double)PRECISION);
+    cairo_stroke (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+diagonal (cairo_t *cr, int width, int height)
+{
+    int x;
+
+    cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+    cairo_paint (cr);
+
+    cairo_set_source_rgba (cr, 1, 1, 1, 1);
+    for (x = -HEIGHT*PRECISION-2; x <= (WIDTH+HEIGHT)*PRECISION+2; x += 6) {
+	cairo_move_to (cr, x / (double)PRECISION - 2, -2);
+	cairo_rel_line_to (cr, HEIGHT + 4, HEIGHT + 4);
+    }
+    cairo_set_line_width (cr, 2 / (double)PRECISION);
+    cairo_stroke (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (sample_vertical,
+	    "Check the fidelity of the rasterisation.",
+	    NULL, /* keywords */
+	    "target=raster slow", /* requirements */
+	    WIDTH, HEIGHT,
+	    NULL, vertical)
+
+CAIRO_TEST (sample_horizontal,
+	    "Check the fidelity of the rasterisation.",
+	    NULL, /* keywords */
+	    "target=raster slow", /* requirements */
+	    WIDTH, HEIGHT,
+	    NULL, vertical)
+
+CAIRO_TEST (sample_diagonal,
+	    "Check the fidelity of the rasterisation.",
+	    NULL, /* keywords */
+	    "target=raster slow", /* requirements */
+	    WIDTH, HEIGHT,
+	    NULL, diagonal)


More information about the cairo-commit mailing list