From a9768b035f2c47be0908520474073cc68d225d8a Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 19 Jan 2010 23:10:44 +0000 Subject: Updated to: libX11-1.3.3 pixman-0.17.4 --- pixman/test/Makefile.am | 21 ++++-- pixman/test/Makefile.in | 178 ++++++++++++++++++++++++++++++++++---------- pixman/test/alphamap.c | 49 ++++++++++++ pixman/test/blitters-test.c | 59 ++++++++++----- pixman/test/fetch-test.c | 102 +++++++++++++++---------- pixman/test/utils.c | 14 ++++ pixman/test/utils.h | 4 + 7 files changed, 323 insertions(+), 104 deletions(-) create mode 100644 pixman/test/alphamap.c (limited to 'pixman/test') diff --git a/pixman/test/Makefile.am b/pixman/test/Makefile.am index 89d32e96f..5f6ba13ac 100644 --- a/pixman/test/Makefile.am +++ b/pixman/test/Makefile.am @@ -3,13 +3,14 @@ INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman TESTPROGRAMS = \ region-test \ - scaling-test \ - blitters-test \ - composite \ fetch-test \ oob-test \ window-test \ - trap-crasher + trap-crasher \ + alphamap \ + blitters-test \ + scaling-test \ + composite fetch_test_LDADD = $(TEST_LDADD) region_test_LDADD = $(TEST_LDADD) @@ -24,6 +25,9 @@ blitters_test_SOURCES = blitters-test.c utils.c utils.h scaling_test_LDADD = $(TEST_LDADD) scaling_test_SOURCES = scaling-test.c utils.c utils.h +alphamap_LDADD = $(TEST_LDADD) +alphamap_SOURCES = alphamap.c utils.c utils.h + # GTK using test programs if HAVE_GTK @@ -31,7 +35,7 @@ if HAVE_GTK GTK_LDADD = $(TEST_LDADD) $(GTK_LIBS) GTK_UTILS = gtk-utils.c gtk-utils.h -TESTPROGRAMS += \ +TESTPROGRAMS_GTK = \ clip-test \ clip-in \ composite-test \ @@ -39,7 +43,8 @@ TESTPROGRAMS += \ alpha-test \ screen-test \ convolution-test \ - trap-test + trap-test \ + alphamap INCLUDES += $(GTK_CFLAGS) @@ -69,5 +74,7 @@ convolution_test_SOURCES = convolution-test.c $(GTK_UTILS) endif -noinst_PROGRAMS = $(TESTPROGRAMS) +noinst_PROGRAMS = $(TESTPROGRAMS) $(TESTPROGRAMS_GTK) + +TESTS = $(TESTPROGRAMS) diff --git a/pixman/test/Makefile.in b/pixman/test/Makefile.in index 4c19caf94..e7f0ab067 100644 --- a/pixman/test/Makefile.in +++ b/pixman/test/Makefile.in @@ -32,18 +32,9 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@HAVE_GTK_TRUE@am__append_1 = \ -@HAVE_GTK_TRUE@ clip-test \ -@HAVE_GTK_TRUE@ clip-in \ -@HAVE_GTK_TRUE@ composite-test \ -@HAVE_GTK_TRUE@ gradient-test \ -@HAVE_GTK_TRUE@ alpha-test \ -@HAVE_GTK_TRUE@ screen-test \ -@HAVE_GTK_TRUE@ convolution-test \ -@HAVE_GTK_TRUE@ trap-test - -@HAVE_GTK_TRUE@am__append_2 = $(GTK_CFLAGS) -noinst_PROGRAMS = $(am__EXEEXT_2) +@HAVE_GTK_TRUE@am__append_1 = $(GTK_CFLAGS) +noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) +TESTS = $(am__EXEEXT_1) subdir = test DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -53,14 +44,15 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = -@HAVE_GTK_TRUE@am__EXEEXT_1 = clip-test$(EXEEXT) clip-in$(EXEEXT) \ +am__EXEEXT_1 = region-test$(EXEEXT) fetch-test$(EXEEXT) \ + oob-test$(EXEEXT) window-test$(EXEEXT) trap-crasher$(EXEEXT) \ + alphamap$(EXEEXT) blitters-test$(EXEEXT) scaling-test$(EXEEXT) \ + composite$(EXEEXT) +@HAVE_GTK_TRUE@am__EXEEXT_2 = clip-test$(EXEEXT) clip-in$(EXEEXT) \ @HAVE_GTK_TRUE@ composite-test$(EXEEXT) gradient-test$(EXEEXT) \ @HAVE_GTK_TRUE@ alpha-test$(EXEEXT) screen-test$(EXEEXT) \ -@HAVE_GTK_TRUE@ convolution-test$(EXEEXT) trap-test$(EXEEXT) -am__EXEEXT_2 = region-test$(EXEEXT) scaling-test$(EXEEXT) \ - blitters-test$(EXEEXT) composite$(EXEEXT) fetch-test$(EXEEXT) \ - oob-test$(EXEEXT) window-test$(EXEEXT) trap-crasher$(EXEEXT) \ - $(am__EXEEXT_1) +@HAVE_GTK_TRUE@ convolution-test$(EXEEXT) trap-test$(EXEEXT) \ +@HAVE_GTK_TRUE@ alphamap$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) am__alpha_test_SOURCES_DIST = alpha-test.c gtk-utils.c gtk-utils.h @HAVE_GTK_TRUE@am__objects_1 = gtk-utils.$(OBJEXT) @@ -71,6 +63,9 @@ am__DEPENDENCIES_1 = @HAVE_GTK_TRUE@am__DEPENDENCIES_2 = $(TEST_LDADD) \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) @HAVE_GTK_TRUE@alpha_test_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_alphamap_OBJECTS = alphamap.$(OBJEXT) utils.$(OBJEXT) +alphamap_OBJECTS = $(am_alphamap_OBJECTS) +alphamap_DEPENDENCIES = $(TEST_LDADD) am_blitters_test_OBJECTS = blitters-test.$(OBJEXT) utils.$(OBJEXT) blitters_test_OBJECTS = $(am_blitters_test_OBJECTS) blitters_test_DEPENDENCIES = $(TEST_LDADD) @@ -144,15 +139,17 @@ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(alpha_test_SOURCES) $(blitters_test_SOURCES) \ - $(clip_in_SOURCES) $(clip_test_SOURCES) composite.c \ - $(composite_test_SOURCES) $(convolution_test_SOURCES) \ - fetch-test.c $(gradient_test_SOURCES) oob-test.c region-test.c \ +SOURCES = $(alpha_test_SOURCES) $(alphamap_SOURCES) \ + $(blitters_test_SOURCES) $(clip_in_SOURCES) \ + $(clip_test_SOURCES) composite.c $(composite_test_SOURCES) \ + $(convolution_test_SOURCES) fetch-test.c \ + $(gradient_test_SOURCES) oob-test.c region-test.c \ $(scaling_test_SOURCES) $(screen_test_SOURCES) trap-crasher.c \ $(trap_test_SOURCES) window-test.c -DIST_SOURCES = $(am__alpha_test_SOURCES_DIST) $(blitters_test_SOURCES) \ - $(am__clip_in_SOURCES_DIST) $(am__clip_test_SOURCES_DIST) \ - composite.c $(am__composite_test_SOURCES_DIST) \ +DIST_SOURCES = $(am__alpha_test_SOURCES_DIST) $(alphamap_SOURCES) \ + $(blitters_test_SOURCES) $(am__clip_in_SOURCES_DIST) \ + $(am__clip_test_SOURCES_DIST) composite.c \ + $(am__composite_test_SOURCES_DIST) \ $(am__convolution_test_SOURCES_DIST) fetch-test.c \ $(am__gradient_test_SOURCES_DIST) oob-test.c region-test.c \ $(scaling_test_SOURCES) $(am__screen_test_SOURCES_DIST) \ @@ -291,9 +288,18 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ TEST_LDADD = $(top_builddir)/pixman/libpixman-1.la INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman \ - $(am__append_2) -TESTPROGRAMS = region-test scaling-test blitters-test composite \ - fetch-test oob-test window-test trap-crasher $(am__append_1) + $(am__append_1) +TESTPROGRAMS = \ + region-test \ + fetch-test \ + oob-test \ + window-test \ + trap-crasher \ + alphamap \ + blitters-test \ + scaling-test \ + composite + fetch_test_LDADD = $(TEST_LDADD) region_test_LDADD = $(TEST_LDADD) composite_LDADD = $(TEST_LDADD) @@ -304,10 +310,23 @@ blitters_test_LDADD = $(TEST_LDADD) blitters_test_SOURCES = blitters-test.c utils.c utils.h scaling_test_LDADD = $(TEST_LDADD) scaling_test_SOURCES = scaling-test.c utils.c utils.h +alphamap_LDADD = $(TEST_LDADD) +alphamap_SOURCES = alphamap.c utils.c utils.h # GTK using test programs @HAVE_GTK_TRUE@GTK_LDADD = $(TEST_LDADD) $(GTK_LIBS) @HAVE_GTK_TRUE@GTK_UTILS = gtk-utils.c gtk-utils.h +@HAVE_GTK_TRUE@TESTPROGRAMS_GTK = \ +@HAVE_GTK_TRUE@ clip-test \ +@HAVE_GTK_TRUE@ clip-in \ +@HAVE_GTK_TRUE@ composite-test \ +@HAVE_GTK_TRUE@ gradient-test \ +@HAVE_GTK_TRUE@ alpha-test \ +@HAVE_GTK_TRUE@ screen-test \ +@HAVE_GTK_TRUE@ convolution-test \ +@HAVE_GTK_TRUE@ trap-test \ +@HAVE_GTK_TRUE@ alphamap + @HAVE_GTK_TRUE@gradient_test_LDADD = $(GTK_LDADD) @HAVE_GTK_TRUE@gradient_test_SOURCES = gradient-test.c $(GTK_UTILS) @HAVE_GTK_TRUE@alpha_test_LDADD = $(GTK_LDADD) @@ -367,6 +386,9 @@ clean-noinstPROGRAMS: alpha-test$(EXEEXT): $(alpha_test_OBJECTS) $(alpha_test_DEPENDENCIES) @rm -f alpha-test$(EXEEXT) $(LINK) $(alpha_test_OBJECTS) $(alpha_test_LDADD) $(LIBS) +alphamap$(EXEEXT): $(alphamap_OBJECTS) $(alphamap_DEPENDENCIES) + @rm -f alphamap$(EXEEXT) + $(LINK) $(alphamap_OBJECTS) $(alphamap_LDADD) $(LIBS) blitters-test$(EXEEXT): $(blitters_test_OBJECTS) $(blitters_test_DEPENDENCIES) @rm -f blitters-test$(EXEEXT) $(LINK) $(blitters_test_OBJECTS) $(blitters_test_LDADD) $(LIBS) @@ -420,6 +442,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alphamap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blitters-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clip-in.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clip-test.Po@am__quote@ @@ -512,6 +535,79 @@ GTAGS: distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -539,6 +635,7 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(PROGRAMS) installdirs: @@ -627,18 +724,19 @@ uninstall-am: .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstPROGRAMS ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-generic clean-libtool clean-noinstPROGRAMS ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/pixman/test/alphamap.c b/pixman/test/alphamap.c new file mode 100644 index 000000000..e6a25efcb --- /dev/null +++ b/pixman/test/alphamap.c @@ -0,0 +1,49 @@ +#include +#include +#include "utils.h" + +#define WIDTH 400 +#define HEIGHT 200 + +int +main (int argc, char **argv) +{ + uint8_t *alpha = make_random_bytes (WIDTH * HEIGHT); + uint32_t *src = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * 4); + uint32_t *dest = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * 4); + int i; + + pixman_image_t *a = pixman_image_create_bits (PIXMAN_a8, WIDTH, HEIGHT, (uint32_t *)alpha, WIDTH); + pixman_image_t *d = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, dest, WIDTH * 4); + + for (i = 0; i < 2; ++i) + { + pixman_format_code_t sformat = (i == 0)? PIXMAN_a8r8g8b8 : PIXMAN_a2r10g10b10; + pixman_image_t *s = pixman_image_create_bits (sformat, WIDTH, HEIGHT, src, WIDTH * 4); + int j, k; + + pixman_image_set_alpha_map (s, a, 0, 0); + + pixman_image_composite (PIXMAN_OP_SRC, s, NULL, d, 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); + + for (j = 0; j < HEIGHT; ++j) + { + for (k = 0; k < WIDTH; ++k) + { + uint8_t ap = ((uint8_t *)alpha)[j * WIDTH + k]; + uint32_t dap = (dest[j * WIDTH + k] >> 24); + uint32_t sap = (src[j * WIDTH + k] >> 24); + + if (ap != dap) + { + printf ("Wrong alpha value at (%d, %d). Should be %d; got %d (src was %d)\n", k, j, ap, dap, sap); + return 1; + } + } + } + + pixman_image_unref (s); + } + + return 0; +} diff --git a/pixman/test/blitters-test.c b/pixman/test/blitters-test.c index ac816eba1..4664db63b 100644 --- a/pixman/test/blitters-test.c +++ b/pixman/test/blitters-test.c @@ -270,7 +270,7 @@ test_composite (uint32_t initcrc, int testnum, int verbose) int w, h; int op; pixman_format_code_t src_fmt, dst_fmt, mask_fmt; - uint32_t *dstbuf; + uint32_t *dstbuf, *srcbuf, *maskbuf; uint32_t crc32; int max_width, max_height, max_extra_stride; @@ -308,12 +308,43 @@ test_composite (uint32_t initcrc, int testnum, int verbose) dst_img = create_random_image (img_fmt_list, max_width, max_height, max_extra_stride, &dst_fmt); + src_width = pixman_image_get_width (src_img); + src_height = pixman_image_get_height (src_img); + src_stride = pixman_image_get_stride (src_img); + + dst_width = pixman_image_get_width (dst_img); + dst_height = pixman_image_get_height (dst_img); + dst_stride = pixman_image_get_stride (dst_img); + + dstbuf = pixman_image_get_data (dst_img); + srcbuf = pixman_image_get_data (src_img); + + src_x = lcg_rand_n (src_width); + src_y = lcg_rand_n (src_height); + dst_x = lcg_rand_n (dst_width); + dst_y = lcg_rand_n (dst_height); + mask_img = NULL; mask_fmt = -1; mask_x = 0; mask_y = 0; + maskbuf = NULL; - if (lcg_rand_n (2)) + if ((src_fmt == PIXMAN_x8r8g8b8 || src_fmt == PIXMAN_x8b8g8r8) && + (lcg_rand_n (4) == 0)) + { + /* PIXBUF */ + mask_fmt = lcg_rand_n (2) ? PIXMAN_a8r8g8b8 : PIXMAN_a8b8g8r8; + mask_img = pixman_image_create_bits (mask_fmt, + src_width, + src_height, + srcbuf, + src_stride); + mask_x = src_x; + mask_y = src_y; + maskbuf = srcbuf; + } + else if (lcg_rand_n (2)) { if (lcg_rand_n (2)) { @@ -335,20 +366,6 @@ test_composite (uint32_t initcrc, int testnum, int verbose) mask_y = lcg_rand_n (pixman_image_get_height (mask_img)); } - src_width = pixman_image_get_width (src_img); - src_height = pixman_image_get_height (src_img); - src_stride = pixman_image_get_stride (src_img); - - dst_width = pixman_image_get_width (dst_img); - dst_height = pixman_image_get_height (dst_img); - dst_stride = pixman_image_get_stride (dst_img); - - dstbuf = pixman_image_get_data (dst_img); - - src_x = lcg_rand_n (src_width); - src_y = lcg_rand_n (src_height); - dst_x = lcg_rand_n (dst_width); - dst_y = lcg_rand_n (dst_height); w = lcg_rand_n (dst_width - dst_x + 1); h = lcg_rand_n (dst_height - dst_y + 1); @@ -392,7 +409,13 @@ test_composite (uint32_t initcrc, int testnum, int verbose) crc32 = free_random_image (initcrc, dst_img, dst_fmt); if (mask_img) - free_random_image (initcrc, mask_img, -1); + { + if (srcbuf == maskbuf) + pixman_image_unref(mask_img); + else + free_random_image (initcrc, mask_img, -1); + } + return crc32; } @@ -440,7 +463,7 @@ main (int argc, char *argv[]) /* Predefined value for running with all the fastpath functions disabled. It needs to be updated every time when changes are introduced to this program or behavior of pixman changes! */ - if (crc == 0x1911E2C3) + if (crc == 0x20CBE02C) { printf ("blitters test passed\n"); } diff --git a/pixman/test/fetch-test.c b/pixman/test/fetch-test.c index 6306a4c42..c7b32ff3b 100644 --- a/pixman/test/fetch-test.c +++ b/pixman/test/fetch-test.c @@ -6,7 +6,8 @@ #define SIZE 1024 -pixman_indexed_t mono_pallete = { +static const pixman_indexed_t mono_palette = +{ .rgba = { 0x00000000, 0x00ffffff }, }; @@ -20,14 +21,15 @@ typedef struct { pixman_indexed_t *indexed; } testcase_t; -testcase_t testcases[] = { +static const testcase_t testcases[] = +{ { .format = PIXMAN_a8r8g8b8, .width = 2, .height = 2, .stride = 8, - .src = { 0x00112233, 0x44556677, + .src = { 0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff }, - .dst = { 0x00112233, 0x44556677, + .dst = { 0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff }, .indexed = NULL, }, @@ -36,24 +38,33 @@ testcase_t testcases[] = { .width = 8, .height = 2, .stride = 4, #ifdef WORDS_BIGENDIAN - .src = { 0xaa000000, - 0x55000000 }, + .src = + { + 0xaa000000, + 0x55000000 + }, #else - .src = { 0x00000055, - 0x000000aa }, + .src = + { + 0x00000055, + 0x000000aa + }, #endif - .dst = { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, - 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff }, - .indexed = &mono_pallete, + .dst = + { + 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, + 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff + }, + .indexed = &mono_palette, }, #if 0 { .format = PIXMAN_g8, .width = 4, .height = 2, .stride = 4, - .src = { 0x01234567, + .src = { 0x01234567, 0x89abcdef }, - .dst = { 0x00010101, 0x00232323, 0x00454545, 0x00676767, + .dst = { 0x00010101, 0x00232323, 0x00454545, 0x00676767, 0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, }, }, #endif @@ -63,28 +74,33 @@ testcase_t testcases[] = { .width = 8, .height = 2, .stride = 8, #ifdef WORDS_BIGENDIAN - .src = { 0x00ff00ff, 0x00ff00ff, - 0xff00ff00, 0xff00ff00, - 0x80ff8000, - 0x800080ff + .src = + { + 0x00ff00ff, 0x00ff00ff, + 0xff00ff00, 0xff00ff00, + 0x80ff8000, + 0x800080ff }, #else - .src = { 0xff00ff00, 0xff00ff00, - 0x00ff00ff, 0x00ff00ff, - 0x0080ff80, - 0xff800080 - }, + .src = + { + 0xff00ff00, 0xff00ff00, + 0x00ff00ff, 0x00ff00ff, + 0x0080ff80, + 0xff800080 + }, #endif - .dst = { - 0xff000000, 0xffffffff, 0xffb80000, 0xffffe113, - 0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff, - 0xffffffff, 0xff000000, 0xffffe113, 0xffb80000, - 0xffffffff, 0xff000000, 0xff4affff, 0xff0023ee, + .dst = + { + 0xff000000, 0xffffffff, 0xffb80000, 0xffffe113, + 0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff, + 0xffffffff, 0xff000000, 0xffffe113, 0xffb80000, + 0xffffffff, 0xff000000, 0xff4affff, 0xff0023ee, }, }, }; -const int ntestcases = sizeof(testcases)/sizeof(testcases[0]); +const int n_test_cases = sizeof(testcases)/sizeof(testcases[0]); static uint32_t @@ -133,26 +149,29 @@ main (int argc, char **argv) int i, j, x, y; int ret = 0; - for (i = 0; i < ntestcases; ++i) { - for (j = 0; j < 2; ++j) { + for (i = 0; i < n_test_cases; ++i) + { + for (j = 0; j < 2; ++j) + { src_img = pixman_image_create_bits (testcases[i].format, - testcases[i].width, + testcases[i].width, testcases[i].height, testcases[i].src, testcases[i].stride); pixman_image_set_indexed(src_img, testcases[i].indexed); dst_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, - testcases[i].width, + testcases[i].width, testcases[i].height, dst, testcases[i].width*4); - if (j) { + if (j) + { pixman_image_set_accessors (src_img, reader, writer); pixman_image_set_accessors (dst_img, reader, writer); } - + pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img, 0, 0, 0, 0, 0, 0, testcases[i].width, testcases[i].height); @@ -160,18 +179,23 @@ main (int argc, char **argv) pixman_image_unref (dst_img); for (y = 0; y < testcases[i].height; ++y) - for (x = 0; x < testcases[i].width; ++x) { - int offset = y*testcases[i].width + x; - if (dst[offset] != testcases[i].dst[offset]) { + { + for (x = 0; x < testcases[i].width; ++x) + { + int offset = y * testcases[i].width + x; + + if (dst[offset] != testcases[i].dst[offset]) + { printf ("test %i%c: pixel mismatch at (x=%d,y=%d): %08x expected, %08x obtained\n", i + 1, 'a' + j, - x, y, + x, y, testcases[i].dst[offset], dst[offset]); ret = 1; } } + } } } - + return ret; } diff --git a/pixman/test/utils.c b/pixman/test/utils.c index 1e42d89d8..58cd100e2 100644 --- a/pixman/test/utils.c +++ b/pixman/test/utils.c @@ -192,3 +192,17 @@ image_endian_swap (pixman_image_t *img, int bpp) } } +uint8_t * +make_random_bytes (int n_bytes) +{ + uint8_t *bytes = malloc (n_bytes); + int i; + + if (!bytes) + return NULL; + + for (i = 0; i < n_bytes; ++i) + bytes[i] = lcg_rand () & 0xff; + + return bytes; +} diff --git a/pixman/test/utils.h b/pixman/test/utils.h index 8fdb2ce4f..fb1ccec48 100644 --- a/pixman/test/utils.h +++ b/pixman/test/utils.h @@ -39,3 +39,7 @@ compute_crc32 (uint32_t in_crc32, */ void image_endian_swap (pixman_image_t *img, int bpp); + +/* Generate n_bytes random bytes in malloced memory */ +uint8_t * +make_random_bytes (int n_bytes); -- cgit v1.2.3