[cairo] [PATCH 2/3 v2] test: Test a variety of scales when downscaling
Bryce W. Harrington
b.harrington at samsung.com
Mon Sep 9 15:59:50 PDT 2013
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>
---
test/pixman-downscale.c | 25 +++++++++++++++++++------
test/reference/pixman-downscale-24.ref.png | Bin 0 -> 191 bytes
test/reference/pixman-downscale-95.ref.png | Bin 0 -> 285 bytes
test/reference/pixman-downscale-96.ref.png | Bin 0 -> 301 bytes
test/reference/pixman-downscale.ref.png | Bin 191 -> 0 bytes
5 files changed, 19 insertions(+), 6 deletions(-)
create mode 100644 test/reference/pixman-downscale-24.ref.png
create mode 100644 test/reference/pixman-downscale-95.ref.png
create mode 100644 test/reference/pixman-downscale-96.ref.png
delete mode 100644 test/reference/pixman-downscale.ref.png
diff --git a/test/pixman-downscale.c b/test/pixman-downscale.c
index 0562015..1f8a9b4 100644
--- a/test/pixman-downscale.c
+++ b/test/pixman-downscale.c
@@ -44,13 +44,12 @@ draw (cairo_t *cr, int width, int height)
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);
+ 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_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);
@@ -60,9 +59,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 0000000000000000000000000000000000000000..df0f9c0d84f3f48d00fdb0f3f08ae587754a269d
GIT binary patch
literal 191
zcmeAS at N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9jKx9jP7LeL$-D$|I14-?iy0WW
zg+Z8+Vb&awa`qBWUsv|K>|BC!7IA*pm4QNmo-U3d7N_3^pXOpv;3&RWA0EGNU1}T4
zrIUAMg4_8gwy>{ZJlV~aSJYV)vi6&EaICP+3<LMb7lqjZ5!yx;9>LS69R3%PQJ;M;
gq~!8p8PysezC2Ei17|)i02<EV>FVdQ&MBb at 0ICT&&j0`b
literal 0
HcmV?d00001
diff --git a/test/reference/pixman-downscale-95.ref.png b/test/reference/pixman-downscale-95.ref.png
new file mode 100644
index 0000000000000000000000000000000000000000..0a5917665f68cb6be8c3e80491e0b918111ac9a1
GIT binary patch
literal 285
zcmeAS at N?(olHy`uVBq!ia0vp^@gU5>1SA>tdKQ7G;vjb?hIQv;UIICs1s;*b3=G`D
zAk4 at xYmNj^kiEpy*OmP)JC~q=p!jdMWT4P`PZ!6Kid%1Q2XZwi2sk*J?<z0*^p>TL
zLwe?!- at PvEtqZbzC#iS>QN3PT{)scw(?wpd`L at CF#f62=?R;~2tzOFoznj%qbx`8w
zTUqsPK3S`h7ad>{q at WL?OxCK}<gcAJoBY8qn>0mxMBYlpZ7iRo15^rB<PIj=L3&)k
vWLWmU at 6T$g-FBX<dJ8fRqz2-IU%S`?lQ`R|?%m!FbUK5ltDnm{r-UW|k at jd-
literal 0
HcmV?d00001
diff --git a/test/reference/pixman-downscale-96.ref.png b/test/reference/pixman-downscale-96.ref.png
new file mode 100644
index 0000000000000000000000000000000000000000..0d68a82cc27532aa78fc12af7646f6821a730a2b
GIT binary patch
literal 301
zcmeAS at N?(olHy`uVBq!ia0vp^2_VeD1SE5RJ;(=AY)RhkE)4%caKYZ?lYt_SJY5_^
zD(1Ysy^*iUK*S+1>rej2(}h=B at 0d(;Js;WVUVNE%S1wQ;!=K59zYi43gs*v=>!Y8U
z_vgvq?cQM at omse;SR0!h92Y1A>{u^la;*65g4(k)k}t|wYjB7lNebZM8vKpTne!)c
zbN%i~M<*ZqX0g}kFdxELd^!~Z1T at ab2krlH<ByqM{lP1D%YXuKdqK|r at Q}6kF=t0)
R<@7`l*VEO{Wt~$(698O(XEy)<
literal 0
HcmV?d00001
diff --git a/test/reference/pixman-downscale.ref.png b/test/reference/pixman-downscale.ref.png
deleted file mode 100644
index df0f9c0d84f3f48d00fdb0f3f08ae587754a269d..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 191
zcmeAS at N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9jKx9jP7LeL$-D$|I14-?iy0WW
zg+Z8+Vb&awa`qBWUsv|K>|BC!7IA*pm4QNmo-U3d7N_3^pXOpv;3&RWA0EGNU1}T4
zrIUAMg4_8gwy>{ZJlV~aSJYV)vi6&EaICP+3<LMb7lqjZ5!yx;9>LS69R3%PQJ;M;
gq~!8p8PysezC2Ei17|)i02<EV>FVdQ&MBb at 0ICT&&j0`b
--
1.7.9.5
More information about the cairo
mailing list