[cairo-commit] 4 commits - test/Makefile.sources test/pixman-downscale.c test/quad-color.png test/reference
Uli Schlachter
psychon at kemper.freedesktop.org
Wed Sep 11 10:35:50 PDT 2013
test/Makefile.sources | 1
test/pixman-downscale.c | 204 ++++++++++++++++++++
test/quad-color.png |binary
test/reference/pixman-downscale-best-24.ref.png |binary
test/reference/pixman-downscale-best-95.ref.png |binary
test/reference/pixman-downscale-best-96.ref.png |binary
test/reference/pixman-downscale-bilinear-24.ref.png |binary
test/reference/pixman-downscale-bilinear-95.ref.png |binary
test/reference/pixman-downscale-bilinear-96.ref.png |binary
test/reference/pixman-downscale-fast-24.ref.png |binary
test/reference/pixman-downscale-fast-95.ref.png |binary
test/reference/pixman-downscale-fast-96.ref.png |binary
test/reference/pixman-downscale-good-24.ref.png |binary
test/reference/pixman-downscale-good-95.ref.png |binary
test/reference/pixman-downscale-good-96.ref.png |binary
test/reference/pixman-downscale-nearest-24.ref.png |binary
test/reference/pixman-downscale-nearest-95.ref.png |binary
test/reference/pixman-downscale-nearest-96.ref.png |binary
18 files changed, 205 insertions(+)
New commits:
commit ac5f3e2b8ef1937b3e6e3a3f03773cf471e46cc3
Author: Bryce Harrington <b.harrington at samsung.com>
Date: Wed Sep 11 09:59:01 2013 -0700
test: Move cairo_pattern_set_filter to after cairo_set_source_surface
Also update the image.arg32 reference images, since for now we're just
accepting pixman's output as truth. This fixes up several tests:
was is
Tests run: 420 420
Passed: 224 261
Failed: 195 159
Expected Failed: 0 0
Error: 0 0
Crashed: 0 0
Untested: 0 0
Total: 420 420
Thanks to psychon for finding the code error in the test.
diff --git a/test/pixman-downscale.c b/test/pixman-downscale.c
index 3e79855..621a5b9 100644
--- a/test/pixman-downscale.c
+++ b/test/pixman-downscale.c
@@ -54,9 +54,9 @@ draw (cairo_t *cr, int width, int height, cairo_filter_t filter)
scale = fmin(x_scale, y_scale);
cairo_save (cr);
- cairo_pattern_set_filter (cairo_get_source (cr), filter);
cairo_scale (cr, scale, scale);
cairo_set_source_surface (cr, image, 0, 0);
+ cairo_pattern_set_filter (cairo_get_source (cr), filter);
cairo_paint (cr);
cairo_restore (cr);
cairo_surface_destroy (image);
diff --git a/test/reference/pixman-downscale-fast-95.ref.png b/test/reference/pixman-downscale-fast-95.ref.png
index 49011d5..3340423 100644
Binary files a/test/reference/pixman-downscale-fast-95.ref.png and b/test/reference/pixman-downscale-fast-95.ref.png differ
diff --git a/test/reference/pixman-downscale-nearest-95.ref.png b/test/reference/pixman-downscale-nearest-95.ref.png
index 49011d5..3340423 100644
Binary files a/test/reference/pixman-downscale-nearest-95.ref.png and b/test/reference/pixman-downscale-nearest-95.ref.png differ
commit ade7089f72e0d147db961dec88d3cb1b2280a438
Author: Bryce Harrington <b.harrington at samsung.com>
Date: Wed Jul 10 17:27:28 2013 -0700
test: Exercise image scaling quality when downscaling
This adds testcases for the various cairo filter options, each of which
match to corresponding pixman filters. Use the 'downscale' keyword if
invoking tests using cairo-test-suite.
The 24-pixel reference images were produced from quad-color.png using
Gimp's Scale Image command with Interpolation set to None. It is
assumed that all filters should handle a 1:4 scaling cleanly with no
antialiased blurring.
The 95-pixel reference images assume differing types of antialiasing
based on the quality level. We are using the image.argb32 output as
reference here. Potentially some other rendering algorithm could
conceivably provide better results in the future.
The 96-pixel reference images are simply copies of the original
quad-color.png file. It is assumed that 1:1 downscaling operations
should produce no visible change to the original image.
Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
diff --git a/test/pixman-downscale.c b/test/pixman-downscale.c
index eeaa6e3..3e79855 100644
--- a/test/pixman-downscale.c
+++ b/test/pixman-downscale.c
@@ -41,7 +41,7 @@ static const char png_filename[] = "quad-color.png";
/* Draw an image scaled down, with antialiasing disabled */
static cairo_test_status_t
-draw (cairo_t *cr, int width, int height)
+draw (cairo_t *cr, int width, int height, cairo_filter_t filter)
{
const cairo_test_context_t *ctx = cairo_test_get_context (cr);
cairo_surface_t *image;
@@ -54,7 +54,7 @@ draw (cairo_t *cr, int width, int height)
scale = fmin(x_scale, y_scale);
cairo_save (cr);
- cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_FAST);
+ cairo_pattern_set_filter (cairo_get_source (cr), filter);
cairo_scale (cr, scale, scale);
cairo_set_source_surface (cr, image, 0, 0);
cairo_paint (cr);
@@ -64,23 +64,141 @@ draw (cairo_t *cr, int width, int height)
return CAIRO_TEST_SUCCESS;
}
-CAIRO_TEST (pixman_downscale_96,
- "Tests scaling to equivalent size",
- "image, transform, raster", /* keywords */
+static cairo_test_status_t
+draw_fast (cairo_t *cr, int width, int height)
+{
+ return draw (cr, width, height, CAIRO_FILTER_FAST);
+}
+
+static cairo_test_status_t
+draw_good (cairo_t *cr, int width, int height)
+{
+ return draw (cr, width, height, CAIRO_FILTER_GOOD);
+}
+
+static cairo_test_status_t
+draw_best (cairo_t *cr, int width, int height)
+{
+ return draw (cr, width, height, CAIRO_FILTER_BEST);
+}
+
+static cairo_test_status_t
+draw_nearest (cairo_t *cr, int width, int height)
+{
+ return draw (cr, width, height, CAIRO_FILTER_NEAREST);
+}
+
+static cairo_test_status_t
+draw_bilinear (cairo_t *cr, int width, int height)
+{
+ return draw (cr, width, height, CAIRO_FILTER_BILINEAR);
+}
+
+CAIRO_TEST (pixman_downscale_fast_96,
+ "Tests scaling to equivalent size using the fast filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 96, 96,
+ NULL, draw_fast)
+
+CAIRO_TEST (pixman_downscale_fast_95,
+ "Tests downscaling by a single pixel using the fast filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 95, 95,
+ NULL, draw_fast)
+
+CAIRO_TEST (pixman_downscale_fast_24,
+ "Tests downscaling by an even multiple using the fast filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 24, 24,
+ NULL, draw_fast)
+
+
+CAIRO_TEST (pixman_downscale_good_96,
+ "Tests scaling to equivalent size using the good filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 96, 96,
+ NULL, draw_good)
+
+CAIRO_TEST (pixman_downscale_good_95,
+ "Tests downscaling by a single pixel using the good filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 95, 95,
+ NULL, draw_good)
+
+CAIRO_TEST (pixman_downscale_good_24,
+ "Tests downscaling by an even multiple using the good filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 24, 24,
+ NULL, draw_good)
+
+
+CAIRO_TEST (pixman_downscale_best_96,
+ "Tests scaling to equivalent size using the best filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 96, 96,
+ NULL, draw_best)
+
+CAIRO_TEST (pixman_downscale_best_95,
+ "Tests downscaling by a single pixel using the best filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 95, 95,
+ NULL, draw_best)
+
+CAIRO_TEST (pixman_downscale_best_24,
+ "Tests downscaling by an even multiple using the best filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 24, 24,
+ NULL, draw_best)
+
+
+CAIRO_TEST (pixman_downscale_nearest_96,
+ "Tests scaling to equivalent size using the nearest filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 96, 96,
+ NULL, draw_nearest)
+
+CAIRO_TEST (pixman_downscale_nearest_95,
+ "Tests downscaling by a single pixel using the nearest filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 95, 95,
+ NULL, draw_nearest)
+
+CAIRO_TEST (pixman_downscale_nearest_24,
+ "Tests downscaling by an even multiple using the nearest filter",
+ "image, transform, raster, downscale", /* keywords */
+ NULL, /* requirements */
+ 24, 24,
+ NULL, draw_nearest)
+
+
+CAIRO_TEST (pixman_downscale_bilinear_96,
+ "Tests scaling to equivalent size using the bilinear filter",
+ "image, transform, raster, downscale", /* keywords */
NULL, /* requirements */
96, 96,
- NULL, draw)
+ NULL, draw_bilinear)
-CAIRO_TEST (pixman_downscale_95,
- "Tests downscaling by a single pixel",
- "image, transform, raster", /* keywords */
+CAIRO_TEST (pixman_downscale_bilinear_95,
+ "Tests downscaling by a single pixel using the bilinear filter",
+ "image, transform, raster, downscale", /* keywords */
NULL, /* requirements */
95, 95,
- NULL, draw)
+ NULL, draw_bilinear)
-CAIRO_TEST (pixman_downscale_24,
- "Tests downscaling by an even multiple",
- "image, transform, raster", /* keywords */
+CAIRO_TEST (pixman_downscale_bilinear_24,
+ "Tests downscaling by an even multiple using the bilinear filter",
+ "image, transform, raster, downscale", /* keywords */
NULL, /* requirements */
24, 24,
- NULL, draw)
+ NULL, draw_bilinear)
diff --git a/test/reference/pixman-downscale-24.ref.png b/test/reference/pixman-downscale-24.ref.png
deleted file mode 100644
index df0f9c0..0000000
Binary files a/test/reference/pixman-downscale-24.ref.png and /dev/null differ
diff --git a/test/reference/pixman-downscale-95.ref.png b/test/reference/pixman-downscale-95.ref.png
deleted file mode 100644
index 0a59176..0000000
Binary files a/test/reference/pixman-downscale-95.ref.png and /dev/null differ
diff --git a/test/reference/pixman-downscale-96.ref.png b/test/reference/pixman-downscale-96.ref.png
deleted file mode 100644
index 0d68a82..0000000
Binary files a/test/reference/pixman-downscale-96.ref.png and /dev/null differ
diff --git a/test/reference/pixman-downscale-best-24.ref.png b/test/reference/pixman-downscale-best-24.ref.png
new file mode 100644
index 0000000..df0f9c0
Binary files /dev/null and b/test/reference/pixman-downscale-best-24.ref.png differ
diff --git a/test/reference/pixman-downscale-best-95.ref.png b/test/reference/pixman-downscale-best-95.ref.png
new file mode 100644
index 0000000..49011d5
Binary files /dev/null and b/test/reference/pixman-downscale-best-95.ref.png differ
diff --git a/test/reference/pixman-downscale-best-96.ref.png b/test/reference/pixman-downscale-best-96.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/reference/pixman-downscale-best-96.ref.png differ
diff --git a/test/reference/pixman-downscale-bilinear-24.ref.png b/test/reference/pixman-downscale-bilinear-24.ref.png
new file mode 100644
index 0000000..df0f9c0
Binary files /dev/null and b/test/reference/pixman-downscale-bilinear-24.ref.png differ
diff --git a/test/reference/pixman-downscale-bilinear-95.ref.png b/test/reference/pixman-downscale-bilinear-95.ref.png
new file mode 100644
index 0000000..49011d5
Binary files /dev/null and b/test/reference/pixman-downscale-bilinear-95.ref.png differ
diff --git a/test/reference/pixman-downscale-bilinear-96.ref.png b/test/reference/pixman-downscale-bilinear-96.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/reference/pixman-downscale-bilinear-96.ref.png differ
diff --git a/test/reference/pixman-downscale-fast-24.ref.png b/test/reference/pixman-downscale-fast-24.ref.png
new file mode 100644
index 0000000..df0f9c0
Binary files /dev/null and b/test/reference/pixman-downscale-fast-24.ref.png differ
diff --git a/test/reference/pixman-downscale-fast-95.ref.png b/test/reference/pixman-downscale-fast-95.ref.png
new file mode 100644
index 0000000..49011d5
Binary files /dev/null and b/test/reference/pixman-downscale-fast-95.ref.png differ
diff --git a/test/reference/pixman-downscale-fast-96.ref.png b/test/reference/pixman-downscale-fast-96.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/reference/pixman-downscale-fast-96.ref.png differ
diff --git a/test/reference/pixman-downscale-good-24.ref.png b/test/reference/pixman-downscale-good-24.ref.png
new file mode 100644
index 0000000..df0f9c0
Binary files /dev/null and b/test/reference/pixman-downscale-good-24.ref.png differ
diff --git a/test/reference/pixman-downscale-good-95.ref.png b/test/reference/pixman-downscale-good-95.ref.png
new file mode 100644
index 0000000..49011d5
Binary files /dev/null and b/test/reference/pixman-downscale-good-95.ref.png differ
diff --git a/test/reference/pixman-downscale-good-96.ref.png b/test/reference/pixman-downscale-good-96.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/reference/pixman-downscale-good-96.ref.png differ
diff --git a/test/reference/pixman-downscale-nearest-24.ref.png b/test/reference/pixman-downscale-nearest-24.ref.png
new file mode 100644
index 0000000..df0f9c0
Binary files /dev/null and b/test/reference/pixman-downscale-nearest-24.ref.png differ
diff --git a/test/reference/pixman-downscale-nearest-95.ref.png b/test/reference/pixman-downscale-nearest-95.ref.png
new file mode 100644
index 0000000..49011d5
Binary files /dev/null and b/test/reference/pixman-downscale-nearest-95.ref.png differ
diff --git a/test/reference/pixman-downscale-nearest-96.ref.png b/test/reference/pixman-downscale-nearest-96.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/reference/pixman-downscale-nearest-96.ref.png differ
commit 0f554c36d3edf341a9aef8eedfde57f3be635500
Author: Bryce Harrington <b.harrington at samsung.com>
Date: Wed Jul 10 16:29:56 2013 -0700
test: Test a variety of scales when downscaling
Downscaling from 96 to 24 is easy since it's an even multiple, so try
scaling by -1 pixel too.
This adds a 1:1 scaling test case as well, which should pass through the
image unchanged.
Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
diff --git a/test/pixman-downscale.c b/test/pixman-downscale.c
index 3a1a6ef..eeaa6e3 100644
--- a/test/pixman-downscale.c
+++ b/test/pixman-downscale.c
@@ -54,8 +54,7 @@ draw (cairo_t *cr, int width, int height)
scale = fmin(x_scale, y_scale);
cairo_save (cr);
- cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
- cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_FAST);
cairo_scale (cr, scale, scale);
cairo_set_source_surface (cr, image, 0, 0);
cairo_paint (cr);
@@ -65,9 +64,23 @@ draw (cairo_t *cr, int width, int height)
return CAIRO_TEST_SUCCESS;
}
-CAIRO_TEST (pixman_downscale,
- "Exposes errors when downscaling",
+CAIRO_TEST (pixman_downscale_96,
+ "Tests scaling to equivalent size",
"image, transform, raster", /* keywords */
NULL, /* requirements */
96, 96,
NULL, draw)
+
+CAIRO_TEST (pixman_downscale_95,
+ "Tests downscaling by a single pixel",
+ "image, transform, raster", /* keywords */
+ NULL, /* requirements */
+ 95, 95,
+ NULL, draw)
+
+CAIRO_TEST (pixman_downscale_24,
+ "Tests downscaling by an even multiple",
+ "image, transform, raster", /* keywords */
+ NULL, /* requirements */
+ 24, 24,
+ NULL, draw)
diff --git a/test/reference/pixman-downscale-24.ref.png b/test/reference/pixman-downscale-24.ref.png
new file mode 100644
index 0000000..df0f9c0
Binary files /dev/null and b/test/reference/pixman-downscale-24.ref.png differ
diff --git a/test/reference/pixman-downscale-95.ref.png b/test/reference/pixman-downscale-95.ref.png
new file mode 100644
index 0000000..0a59176
Binary files /dev/null and b/test/reference/pixman-downscale-95.ref.png differ
diff --git a/test/reference/pixman-downscale-96.ref.png b/test/reference/pixman-downscale-96.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/reference/pixman-downscale-96.ref.png differ
diff --git a/test/reference/pixman-downscale.ref.png b/test/reference/pixman-downscale.ref.png
deleted file mode 100644
index df0f9c0..0000000
Binary files a/test/reference/pixman-downscale.ref.png and /dev/null differ
commit 642b6d80917feeea878a11f8aaf179b7a1e5392d
Author: Bryce Harrington <b.harrington at samsung.com>
Date: Wed Jul 10 10:19:21 2013 -0700
test: Add test for image downscaling
This adds pixman-downscale.c, which tests correctness of PNG images
scaled down using pixman routines.
Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 509c11c..9fbfb96 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -248,6 +248,7 @@ test_sources = \
pattern-get-type.c \
pattern-getters.c \
pdf-isolated-group.c \
+ pixman-downscale.c \
pixman-rotate.c \
png.c \
push-group.c \
diff --git a/test/pixman-downscale.c b/test/pixman-downscale.c
new file mode 100644
index 0000000..3a1a6ef
--- /dev/null
+++ b/test/pixman-downscale.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright © 2013 Samsung Electronics
+ *
+ * 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: Bryce Harrington <b.harrington at samsung.com>
+ */
+
+/* This test exercises scaling a png image to smaller pixel dimensions
+ *
+ * Currently, this exercises several of pixman's scaling filters.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <cairo.h>
+
+#include "cairo-test.h"
+
+static const char png_filename[] = "quad-color.png";
+
+/* Draw an image scaled down, with antialiasing disabled */
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
+ cairo_surface_t *image;
+ double x_scale, y_scale, scale;
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ image = cairo_test_create_surface_from_png (ctx, png_filename);
+ x_scale = width * 1.0 / cairo_image_surface_get_width (image);
+ y_scale = height * 1.0 / cairo_image_surface_get_height (image);
+ scale = fmin(x_scale, y_scale);
+
+ cairo_save (cr);
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
+ cairo_scale (cr, scale, scale);
+ cairo_set_source_surface (cr, image, 0, 0);
+ cairo_paint (cr);
+ cairo_restore (cr);
+ cairo_surface_destroy (image);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (pixman_downscale,
+ "Exposes errors when downscaling",
+ "image, transform, raster", /* keywords */
+ NULL, /* requirements */
+ 96, 96,
+ NULL, draw)
diff --git a/test/quad-color.png b/test/quad-color.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/quad-color.png differ
diff --git a/test/reference/pixman-downscale.ref.png b/test/reference/pixman-downscale.ref.png
new file mode 100644
index 0000000..df0f9c0
Binary files /dev/null and b/test/reference/pixman-downscale.ref.png differ
More information about the cairo-commit
mailing list