diff options
author | Bryce Harrington <b.harrington@samsung.com> | 2013-07-10 17:27:28 -0700 |
---|---|---|
committer | Uli Schlachter <psychon@znc.in> | 2013-09-11 19:32:08 +0200 |
commit | ade7089f72e0d147db961dec88d3cb1b2280a438 (patch) | |
tree | a48c90fd9dc588741d0e64268d5813368c06eb97 /test/pixman-downscale.c | |
parent | 0f554c36d3edf341a9aef8eedfde57f3be635500 (diff) | |
download | cairo-ade7089f72e0d147db961dec88d3cb1b2280a438.tar.gz |
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@samsung.com>
Diffstat (limited to 'test/pixman-downscale.c')
-rw-r--r-- | test/pixman-downscale.c | 146 |
1 files changed, 132 insertions, 14 deletions
diff --git a/test/pixman-downscale.c b/test/pixman-downscale.c index eeaa6e387..3e7985569 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) |