[cairo-commit] test/a1-image-sample.c test/a1-image-sample-ref.png test/a1-traps-sample.c test/a1-traps-sample-ref.png test/cairo-test.c test/.gitignore test/Makefile.am
Carl Worth
cworth at kemper.freedesktop.org
Fri Jan 18 12:44:16 PST 2008
test/.gitignore | 2 +
test/Makefile.am | 2 +
test/a1-image-sample-ref.png |binary
test/a1-image-sample.c | 83 +++++++++++++++++++++++++++++++++++++++++++
test/a1-traps-sample-ref.png |binary
test/a1-traps-sample.c | 72 +++++++++++++++++++++++++++++++++++++
test/cairo-test.c | 2 +
7 files changed, 161 insertions(+)
New commits:
commit 50d0767c8bf4c738b86e10be09d5c4fd7e14a05f
Author: Carl Worth <cworth at cworth.org>
Date: Fri Jan 18 12:41:57 2008 -0800
Add a1-image-sample and a1-traps-sample tests
Both of these currently fail due to bugs in the way pixman does
its sampling.
diff --git a/test/.gitignore b/test/.gitignore
index e3decc7..a02b29d 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -4,6 +4,8 @@ Makefile
Makefile.in
index.html
ref.hash
+a1-image-sample
+a1-traps-sample
a8-mask
big-trap
bitmap-font
diff --git a/test/Makefile.am b/test/Makefile.am
index 81d71ba..14bafc3 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -2,6 +2,8 @@ SUBDIRS=pdiff .
# Here are all the tests that are run unconditionally
TESTS = \
+a1-image-sample$(EXEEXT) \
+a1-traps-sample$(EXEEXT) \
a8-mask$(EXEEXT) \
big-trap$(EXEEXT) \
caps-joins$(EXEEXT) \
diff --git a/test/a1-image-sample-ref.png b/test/a1-image-sample-ref.png
new file mode 100644
index 0000000..b4e81eb
Binary files /dev/null and b/test/a1-image-sample-ref.png differ
diff --git a/test/a1-image-sample.c b/test/a1-image-sample.c
new file mode 100644
index 0000000..2dc4254
--- /dev/null
+++ b/test/a1-image-sample.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2008 Red Hat, Inc.
+ *
+ * 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: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_draw_function_t draw;
+
+#define POINTS 10
+#define STEP (1.0 / POINTS)
+#define PAD 1
+#define WIDTH (PAD + POINTS * 2 + PAD)
+#define HEIGHT (WIDTH)
+
+cairo_test_t test = {
+ "a1-image-sample",
+ "Test sample position when drawing images with FILTER_NEAREST",
+ WIDTH, HEIGHT,
+ draw
+};
+
+/* A single, black pixel */
+static const uint32_t black_pixel = 0xff000000;
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ int i, j;
+ cairo_surface_t *surface;
+
+ surface = cairo_image_surface_create_for_data ((unsigned char *) &black_pixel,
+ CAIRO_FORMAT_ARGB32,
+ 1, 1, 4);
+
+ /* Fill background white */
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ /* Draw in black */
+ cairo_set_source_rgb (cr, 0, 0, 0);
+
+ cairo_translate (cr, PAD, PAD);
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+
+ for (i = 0; i < POINTS; i++)
+ for (j = 0; j < POINTS; j++) {
+ cairo_set_source_surface (cr, surface,
+ 2 * i + i * STEP, 2 * j + j * STEP);
+ cairo_pattern_set_filter (cairo_get_source (cr),
+ CAIRO_FILTER_NEAREST);
+ cairo_paint (cr);
+ }
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
diff --git a/test/a1-traps-sample-ref.png b/test/a1-traps-sample-ref.png
new file mode 100644
index 0000000..b4e81eb
Binary files /dev/null and b/test/a1-traps-sample-ref.png differ
diff --git a/test/a1-traps-sample.c b/test/a1-traps-sample.c
new file mode 100644
index 0000000..1148a8b
--- /dev/null
+++ b/test/a1-traps-sample.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2008 Red Hat, Inc.
+ *
+ * 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: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_draw_function_t draw;
+
+#define POINTS 10
+#define STEP (1.0 / POINTS)
+#define PAD 1
+#define WIDTH (PAD + POINTS * 2 + PAD)
+#define HEIGHT (WIDTH)
+
+cairo_test_t test = {
+ "a1-traps-sample",
+ "Test sample position when drawing trapezoids with ANTIALIAS_NONE",
+ WIDTH, HEIGHT,
+ draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ int i, j;
+
+ /* Fill background white */
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ /* Draw in black */
+ cairo_set_source_rgb (cr, 0, 0, 0);
+
+ cairo_translate (cr, PAD, PAD);
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+
+ for (i = 0; i < POINTS; i++)
+ for (j = 0; j < POINTS; j++) {
+ cairo_rectangle (cr, 2 * i + i * STEP, 2 * j + j * STEP, 1, 1);
+ cairo_fill (cr);
+ }
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
diff --git a/test/cairo-test.c b/test/cairo-test.c
index fb09fee..61cbb31 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -79,6 +79,8 @@ static const char *vector_ignored_tests[] = {
/* We can't match the results of tests that depend on
* CAIRO_ANTIALIAS_NONE/SUBPIXEL for vector backends
* (nor do we care). */
+ "a1-image-sample",
+ "a1-traps-sample",
"ft-text-antialias-none",
"rectangle-rounding-error",
"text-antialias-gray",
More information about the cairo-commit
mailing list