[cairo-commit] test/linear-gradient-large.c test/linear-gradient-large.ref.png test/Makefile.am test/Makefile.sources

Benjamin Otte company at kemper.freedesktop.org
Tue Aug 10 09:39:11 PDT 2010


 test/Makefile.am                   |    5 +-
 test/Makefile.sources              |    1 
 test/linear-gradient-large.c       |   67 +++++++++++++++++++++++++++++++++++++
 test/linear-gradient-large.ref.png |binary
 4 files changed, 71 insertions(+), 2 deletions(-)

New commits:
commit a7762e3d6570a6981d8fb74ecc6ae30391c39b89
Author: Krzysztof Kosiński <tweenk.pl at gmail.com>
Date:   Tue Aug 10 17:55:03 2010 +0200

    tests: Add linear-gradient-large test
    
    Shows large rounding errors in Pixman when computing gradients. Added as
    a test to Cairo to catch similar issues in other backends.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=29470

diff --git a/test/Makefile.am b/test/Makefile.am
index df504ba..e1b0768 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -779,13 +779,14 @@ REFERENCE_IMAGES = \
 	linear-gradient.quartz.ref.png \
 	linear-gradient.ref.png \
 	linear-gradient.xlib.ref.png \
+	linear-gradient-large.ref.png \
+	linear-gradient-one-stop.argb32.ref.png \
+	linear-gradient-one-stop.rgb24.ref.png \
 	linear-gradient-subset.image16.ref.png \
 	linear-gradient-subset.quartz.ref.png \
 	linear-gradient-subset.ref.png \
 	linear-gradient-subset.xlib.ref.png \
 	linear-gradient-subset.ps3.ref.png \
-	linear-gradient-one-stop.argb32.ref.png \
-	linear-gradient-one-stop.rgb24.ref.png \
 	linear-step-function.xfail.png \
 	linear-uniform.image16.ref.png \
 	linear-uniform.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 7881cf0..bf8979d 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -147,6 +147,7 @@ test_sources = \
 	line-width-zero.c				\
 	linear-gradient.c				\
 	linear-gradient-extend.c			\
+	linear-gradient-large.c				\
 	linear-gradient-one-stop.c			\
 	linear-gradient-reflect.c			\
 	linear-gradient-subset.c			\
diff --git a/test/linear-gradient-large.c b/test/linear-gradient-large.c
new file mode 100644
index 0000000..f5e6a66
--- /dev/null
+++ b/test/linear-gradient-large.c
@@ -0,0 +1,67 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright 2010 Krzysztof Kosiński
+ *
+ * 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: Krzysztof Kosiński <tweenk.pl at gmail.com>
+ */
+
+#include "cairo-test.h"
+
+/* originally reported in https://bugs.freedesktop.org/show_bug.cgi?id=29470 */
+
+#define OFFSET 50
+#define SIZE 1000
+
+static void mark_point(cairo_t *ct, double x, double y)
+{
+    cairo_rectangle(ct, x-2, y-2, 4, 4);
+    cairo_set_source_rgb(ct, 1,0,0);
+    cairo_fill(ct);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_pattern_t *gr = cairo_pattern_create_linear (SIZE - OFFSET, OFFSET,
+                                                       OFFSET, SIZE - OFFSET);
+
+    cairo_pattern_add_color_stop_rgb (gr, 0.0, 1, 1, 1);
+    cairo_pattern_add_color_stop_rgb (gr, 0.0, 0, 0, 0);
+    cairo_pattern_add_color_stop_rgb (gr, 1.0, 0, 0, 0);
+    cairo_pattern_add_color_stop_rgb (gr, 1.0, 1, 1, 1);
+
+    cairo_set_source (cr, gr);
+    cairo_paint (cr);
+
+    mark_point(cr, SIZE - OFFSET, OFFSET);
+    mark_point(cr, OFFSET, SIZE - OFFSET);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (linear_gradient_large,
+	    "Tests that large linear gradients get rendered at the correct place",
+	    "linear, pattern", /* keywords */
+	    NULL, /* requirements */
+	    SIZE, SIZE,
+	    NULL, draw)
diff --git a/test/linear-gradient-large.ref.png b/test/linear-gradient-large.ref.png
new file mode 100644
index 0000000..cd5a07a
Binary files /dev/null and b/test/linear-gradient-large.ref.png differ


More information about the cairo-commit mailing list