aboutsummaryrefslogtreecommitdiff
path: root/pixman/test
diff options
context:
space:
mode:
Diffstat (limited to 'pixman/test')
-rw-r--r--pixman/test/Makefile.am174
-rw-r--r--pixman/test/Makefile.in829
-rw-r--r--pixman/test/blitters-test.c981
-rw-r--r--pixman/test/fuzzer-find-diff.pl68
-rw-r--r--pixman/test/gradient-crash-test.c117
-rw-r--r--pixman/test/gtk-utils.c228
-rw-r--r--pixman/test/scaling-crash-test.c124
-rw-r--r--pixman/test/scaling-test.c538
-rw-r--r--pixman/test/utils.c529
-rw-r--r--pixman/test/utils.h109
10 files changed, 1630 insertions, 2067 deletions
diff --git a/pixman/test/Makefile.am b/pixman/test/Makefile.am
index 841ff8d7d..efd9cd91a 100644
--- a/pixman/test/Makefile.am
+++ b/pixman/test/Makefile.am
@@ -1,84 +1,90 @@
-TEST_LDADD = $(top_builddir)/pixman/libpixman-1.la
-INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman
-
-TESTPROGRAMS = \
- a1-trap-test \
- region-test \
- fetch-test \
- oob-test \
- window-test \
- trap-crasher \
- alphamap \
- blitters-test \
- scaling-test \
- composite
-
-a1_trap_test_LDADD = $(TEST_LDADD)
-fetch_test_LDADD = $(TEST_LDADD)
-composite_LDADD = $(TEST_LDADD)
-trap_crasher_LDADD = $(TEST_LDADD)
-oob_test_LDADD = $(TEST_LDADD)
-window_test_LDADD = $(TEST_LDADD)
-
-region_test_LDADD = $(TEST_LDADD)
-region_test_SOURCES = region-test.c utils.c utils.h
-
-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
-
-if HAVE_GTK
-
-GTK_LDADD = $(TEST_LDADD) $(GTK_LIBS)
-GTK_UTILS = gtk-utils.c gtk-utils.h
-
-TESTPROGRAMS_GTK = \
- clip-test \
- clip-in \
- composite-test \
- gradient-test \
- alpha-test \
- screen-test \
- convolution-test \
- trap-test \
- alphamap
-
-INCLUDES += $(GTK_CFLAGS)
-
-gradient_test_LDADD = $(GTK_LDADD)
-gradient_test_SOURCES = gradient-test.c $(GTK_UTILS)
-
-alpha_test_LDADD = $(GTK_LDADD)
-alpha_test_SOURCES = alpha-test.c $(GTK_UTILS)
-
-composite_test_LDADD = $(GTK_LDADD)
-composite_test_SOURCES = composite-test.c $(GTK_UTILS)
-
-clip_test_LDADD = $(GTK_LDADD)
-clip_test_SOURCES = clip-test.c $(GTK_UTILS)
-
-clip_in_LDADD = $(GTK_LDADD)
-clip_in_SOURCES = clip-in.c $(GTK_UTILS)
-
-trap_test_LDADD = $(GTK_LDADD)
-trap_test_SOURCES = trap-test.c $(GTK_UTILS)
-
-screen_test_LDADD = $(GTK_LDADD)
-screen_test_SOURCES = screen-test.c $(GTK_UTILS)
-
-convolution_test_LDADD = $(GTK_LDADD)
-convolution_test_SOURCES = convolution-test.c $(GTK_UTILS)
-
-endif
-
-noinst_PROGRAMS = $(TESTPROGRAMS) $(TESTPROGRAMS_GTK)
-
-TESTS = $(TESTPROGRAMS)
-
+AM_CFLAGS = @OPENMP_CFLAGS@
+AM_LDFLAGS = @OPENMP_CFLAGS@
+
+TEST_LDADD = $(top_builddir)/pixman/libpixman-1.la
+INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman
+
+TESTPROGRAMS = \
+ a1-trap-test \
+ region-test \
+ fetch-test \
+ oob-test \
+ window-test \
+ gradient-crash-test \
+ trap-crasher \
+ alphamap \
+ scaling-crash-test \
+ blitters-test \
+ scaling-test \
+ composite
+
+a1_trap_test_LDADD = $(TEST_LDADD)
+fetch_test_LDADD = $(TEST_LDADD)
+composite_LDADD = $(TEST_LDADD)
+gradient_crash_test_LDADD = $(TEST_LDADD)
+trap_crasher_LDADD = $(TEST_LDADD)
+oob_test_LDADD = $(TEST_LDADD)
+window_test_LDADD = $(TEST_LDADD)
+scaling_crash_test_LDADD = $(TEST_LDADD)
+
+region_test_LDADD = $(TEST_LDADD)
+region_test_SOURCES = region-test.c utils.c utils.h
+
+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
+
+if HAVE_GTK
+
+GTK_LDADD = $(TEST_LDADD) $(GTK_LIBS)
+GTK_UTILS = gtk-utils.c gtk-utils.h
+
+TESTPROGRAMS_GTK = \
+ clip-test \
+ clip-in \
+ composite-test \
+ gradient-test \
+ alpha-test \
+ screen-test \
+ convolution-test \
+ trap-test
+
+INCLUDES += $(GTK_CFLAGS)
+
+gradient_test_LDADD = $(GTK_LDADD)
+gradient_test_SOURCES = gradient-test.c $(GTK_UTILS)
+
+alpha_test_LDADD = $(GTK_LDADD)
+alpha_test_SOURCES = alpha-test.c $(GTK_UTILS)
+
+composite_test_LDADD = $(GTK_LDADD)
+composite_test_SOURCES = composite-test.c $(GTK_UTILS)
+
+clip_test_LDADD = $(GTK_LDADD)
+clip_test_SOURCES = clip-test.c $(GTK_UTILS)
+
+clip_in_LDADD = $(GTK_LDADD)
+clip_in_SOURCES = clip-in.c $(GTK_UTILS)
+
+trap_test_LDADD = $(GTK_LDADD)
+trap_test_SOURCES = trap-test.c $(GTK_UTILS)
+
+screen_test_LDADD = $(GTK_LDADD)
+screen_test_SOURCES = screen-test.c $(GTK_UTILS)
+
+convolution_test_LDADD = $(GTK_LDADD)
+convolution_test_SOURCES = convolution-test.c $(GTK_UTILS)
+
+endif
+
+noinst_PROGRAMS = $(TESTPROGRAMS) $(TESTPROGRAMS_GTK)
+
+TESTS = $(TESTPROGRAMS)
+
diff --git a/pixman/test/Makefile.in b/pixman/test/Makefile.in
deleted file mode 100644
index 8d2292ac8..000000000
--- a/pixman/test/Makefile.in
+++ /dev/null
@@ -1,829 +0,0 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-@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
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-am__EXEEXT_1 = a1-trap-test$(EXEEXT) 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) \
-@HAVE_GTK_TRUE@ alphamap$(EXEEXT)
-PROGRAMS = $(noinst_PROGRAMS)
-a1_trap_test_SOURCES = a1-trap-test.c
-a1_trap_test_OBJECTS = a1-trap-test.$(OBJEXT)
-a1_trap_test_DEPENDENCIES = $(TEST_LDADD)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
-am__v_lt_0 = --silent
-am__alpha_test_SOURCES_DIST = alpha-test.c gtk-utils.c gtk-utils.h
-@HAVE_GTK_TRUE@am__objects_1 = gtk-utils.$(OBJEXT)
-@HAVE_GTK_TRUE@am_alpha_test_OBJECTS = alpha-test.$(OBJEXT) \
-@HAVE_GTK_TRUE@ $(am__objects_1)
-alpha_test_OBJECTS = $(am_alpha_test_OBJECTS)
-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)
-am__clip_in_SOURCES_DIST = clip-in.c gtk-utils.c gtk-utils.h
-@HAVE_GTK_TRUE@am_clip_in_OBJECTS = clip-in.$(OBJEXT) $(am__objects_1)
-clip_in_OBJECTS = $(am_clip_in_OBJECTS)
-@HAVE_GTK_TRUE@clip_in_DEPENDENCIES = $(am__DEPENDENCIES_2)
-am__clip_test_SOURCES_DIST = clip-test.c gtk-utils.c gtk-utils.h
-@HAVE_GTK_TRUE@am_clip_test_OBJECTS = clip-test.$(OBJEXT) \
-@HAVE_GTK_TRUE@ $(am__objects_1)
-clip_test_OBJECTS = $(am_clip_test_OBJECTS)
-@HAVE_GTK_TRUE@clip_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-composite_SOURCES = composite.c
-composite_OBJECTS = composite.$(OBJEXT)
-composite_DEPENDENCIES = $(TEST_LDADD)
-am__composite_test_SOURCES_DIST = composite-test.c gtk-utils.c \
- gtk-utils.h
-@HAVE_GTK_TRUE@am_composite_test_OBJECTS = composite-test.$(OBJEXT) \
-@HAVE_GTK_TRUE@ $(am__objects_1)
-composite_test_OBJECTS = $(am_composite_test_OBJECTS)
-@HAVE_GTK_TRUE@composite_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-am__convolution_test_SOURCES_DIST = convolution-test.c gtk-utils.c \
- gtk-utils.h
-@HAVE_GTK_TRUE@am_convolution_test_OBJECTS = \
-@HAVE_GTK_TRUE@ convolution-test.$(OBJEXT) $(am__objects_1)
-convolution_test_OBJECTS = $(am_convolution_test_OBJECTS)
-@HAVE_GTK_TRUE@convolution_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-fetch_test_SOURCES = fetch-test.c
-fetch_test_OBJECTS = fetch-test.$(OBJEXT)
-fetch_test_DEPENDENCIES = $(TEST_LDADD)
-am__gradient_test_SOURCES_DIST = gradient-test.c gtk-utils.c \
- gtk-utils.h
-@HAVE_GTK_TRUE@am_gradient_test_OBJECTS = gradient-test.$(OBJEXT) \
-@HAVE_GTK_TRUE@ $(am__objects_1)
-gradient_test_OBJECTS = $(am_gradient_test_OBJECTS)
-@HAVE_GTK_TRUE@gradient_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-oob_test_SOURCES = oob-test.c
-oob_test_OBJECTS = oob-test.$(OBJEXT)
-oob_test_DEPENDENCIES = $(TEST_LDADD)
-am_region_test_OBJECTS = region-test.$(OBJEXT) utils.$(OBJEXT)
-region_test_OBJECTS = $(am_region_test_OBJECTS)
-region_test_DEPENDENCIES = $(TEST_LDADD)
-am_scaling_test_OBJECTS = scaling-test.$(OBJEXT) utils.$(OBJEXT)
-scaling_test_OBJECTS = $(am_scaling_test_OBJECTS)
-scaling_test_DEPENDENCIES = $(TEST_LDADD)
-am__screen_test_SOURCES_DIST = screen-test.c gtk-utils.c gtk-utils.h
-@HAVE_GTK_TRUE@am_screen_test_OBJECTS = screen-test.$(OBJEXT) \
-@HAVE_GTK_TRUE@ $(am__objects_1)
-screen_test_OBJECTS = $(am_screen_test_OBJECTS)
-@HAVE_GTK_TRUE@screen_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-trap_crasher_SOURCES = trap-crasher.c
-trap_crasher_OBJECTS = trap-crasher.$(OBJEXT)
-trap_crasher_DEPENDENCIES = $(TEST_LDADD)
-am__trap_test_SOURCES_DIST = trap-test.c gtk-utils.c gtk-utils.h
-@HAVE_GTK_TRUE@am_trap_test_OBJECTS = trap-test.$(OBJEXT) \
-@HAVE_GTK_TRUE@ $(am__objects_1)
-trap_test_OBJECTS = $(am_trap_test_OBJECTS)
-@HAVE_GTK_TRUE@trap_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-window_test_SOURCES = window-test.c
-window_test_OBJECTS = window-test.$(OBJEXT)
-window_test_DEPENDENCIES = $(TEST_LDADD)
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
-am__v_at_0 = @
-CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
-am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = a1-trap-test.c $(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_SOURCES) \
- $(scaling_test_SOURCES) $(screen_test_SOURCES) trap-crasher.c \
- $(trap_test_SOURCES) window-test.c
-DIST_SOURCES = a1-trap-test.c $(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_SOURCES) $(scaling_test_SOURCES) \
- $(am__screen_test_SOURCES_DIST) trap-crasher.c \
- $(am__trap_test_SOURCES_DIST) window-test.c
-ETAGS = etags
-CTAGS = ctags
-am__tty_colors = \
-red=; grn=; lgn=; blu=; std=
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCAS = @CCAS@
-CCASDEPMODE = @CCASDEPMODE@
-CCASFLAGS = @CCASFLAGS@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DEP_CFLAGS = @DEP_CFLAGS@
-DEP_LIBS = @DEP_LIBS@
-DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-FGREP = @FGREP@
-GREP = @GREP@
-GTK_CFLAGS = @GTK_CFLAGS@
-GTK_LIBS = @GTK_LIBS@
-HAVE_PTHREAD_SETSPECIFIC = @HAVE_PTHREAD_SETSPECIFIC@
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LD = @LD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIPO = @LIPO@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-LT_VERSION_INFO = @LT_VERSION_INFO@
-MAKEINFO = @MAKEINFO@
-MKDIR_P = @MKDIR_P@
-MMX_CFLAGS = @MMX_CFLAGS@
-MMX_LDFLAGS = @MMX_LDFLAGS@
-NM = @NM@
-NMEDIT = @NMEDIT@
-OBJDUMP = @OBJDUMP@
-OBJEXT = @OBJEXT@
-OTOOL = @OTOOL@
-OTOOL64 = @OTOOL64@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PERL = @PERL@
-PIXMAN_TIMERS = @PIXMAN_TIMERS@
-PIXMAN_VERSION_MAJOR = @PIXMAN_VERSION_MAJOR@
-PIXMAN_VERSION_MICRO = @PIXMAN_VERSION_MICRO@
-PIXMAN_VERSION_MINOR = @PIXMAN_VERSION_MINOR@
-PKG_CONFIG = @PKG_CONFIG@
-PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@
-RANLIB = @RANLIB@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-SSE2_CFLAGS = @SSE2_CFLAGS@
-SSE2_LDFLAGS = @SSE2_LDFLAGS@
-STRIP = @STRIP@
-TOOLCHAIN_SUPPORTS__THREAD = @TOOLCHAIN_SUPPORTS__THREAD@
-VERSION = @VERSION@
-VMX_CFLAGS = @VMX_CFLAGS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-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_1)
-TESTPROGRAMS = \
- a1-trap-test \
- region-test \
- fetch-test \
- oob-test \
- window-test \
- trap-crasher \
- alphamap \
- blitters-test \
- scaling-test \
- composite
-
-a1_trap_test_LDADD = $(TEST_LDADD)
-fetch_test_LDADD = $(TEST_LDADD)
-composite_LDADD = $(TEST_LDADD)
-trap_crasher_LDADD = $(TEST_LDADD)
-oob_test_LDADD = $(TEST_LDADD)
-window_test_LDADD = $(TEST_LDADD)
-region_test_LDADD = $(TEST_LDADD)
-region_test_SOURCES = region-test.c utils.c utils.h
-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)
-@HAVE_GTK_TRUE@alpha_test_SOURCES = alpha-test.c $(GTK_UTILS)
-@HAVE_GTK_TRUE@composite_test_LDADD = $(GTK_LDADD)
-@HAVE_GTK_TRUE@composite_test_SOURCES = composite-test.c $(GTK_UTILS)
-@HAVE_GTK_TRUE@clip_test_LDADD = $(GTK_LDADD)
-@HAVE_GTK_TRUE@clip_test_SOURCES = clip-test.c $(GTK_UTILS)
-@HAVE_GTK_TRUE@clip_in_LDADD = $(GTK_LDADD)
-@HAVE_GTK_TRUE@clip_in_SOURCES = clip-in.c $(GTK_UTILS)
-@HAVE_GTK_TRUE@trap_test_LDADD = $(GTK_LDADD)
-@HAVE_GTK_TRUE@trap_test_SOURCES = trap-test.c $(GTK_UTILS)
-@HAVE_GTK_TRUE@screen_test_LDADD = $(GTK_LDADD)
-@HAVE_GTK_TRUE@screen_test_SOURCES = screen-test.c $(GTK_UTILS)
-@HAVE_GTK_TRUE@convolution_test_LDADD = $(GTK_LDADD)
-@HAVE_GTK_TRUE@convolution_test_SOURCES = convolution-test.c $(GTK_UTILS)
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --foreign test/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-
-clean-noinstPROGRAMS:
- @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
- echo " rm -f" $$list; \
- rm -f $$list || exit $$?; \
- test -n "$(EXEEXT)" || exit 0; \
- list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f" $$list; \
- rm -f $$list
-a1-trap-test$(EXEEXT): $(a1_trap_test_OBJECTS) $(a1_trap_test_DEPENDENCIES)
- @rm -f a1-trap-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(a1_trap_test_OBJECTS) $(a1_trap_test_LDADD) $(LIBS)
-alpha-test$(EXEEXT): $(alpha_test_OBJECTS) $(alpha_test_DEPENDENCIES)
- @rm -f alpha-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(alpha_test_OBJECTS) $(alpha_test_LDADD) $(LIBS)
-alphamap$(EXEEXT): $(alphamap_OBJECTS) $(alphamap_DEPENDENCIES)
- @rm -f alphamap$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(alphamap_OBJECTS) $(alphamap_LDADD) $(LIBS)
-blitters-test$(EXEEXT): $(blitters_test_OBJECTS) $(blitters_test_DEPENDENCIES)
- @rm -f blitters-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(blitters_test_OBJECTS) $(blitters_test_LDADD) $(LIBS)
-clip-in$(EXEEXT): $(clip_in_OBJECTS) $(clip_in_DEPENDENCIES)
- @rm -f clip-in$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(clip_in_OBJECTS) $(clip_in_LDADD) $(LIBS)
-clip-test$(EXEEXT): $(clip_test_OBJECTS) $(clip_test_DEPENDENCIES)
- @rm -f clip-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(clip_test_OBJECTS) $(clip_test_LDADD) $(LIBS)
-composite$(EXEEXT): $(composite_OBJECTS) $(composite_DEPENDENCIES)
- @rm -f composite$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(composite_OBJECTS) $(composite_LDADD) $(LIBS)
-composite-test$(EXEEXT): $(composite_test_OBJECTS) $(composite_test_DEPENDENCIES)
- @rm -f composite-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(composite_test_OBJECTS) $(composite_test_LDADD) $(LIBS)
-convolution-test$(EXEEXT): $(convolution_test_OBJECTS) $(convolution_test_DEPENDENCIES)
- @rm -f convolution-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(convolution_test_OBJECTS) $(convolution_test_LDADD) $(LIBS)
-fetch-test$(EXEEXT): $(fetch_test_OBJECTS) $(fetch_test_DEPENDENCIES)
- @rm -f fetch-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(fetch_test_OBJECTS) $(fetch_test_LDADD) $(LIBS)
-gradient-test$(EXEEXT): $(gradient_test_OBJECTS) $(gradient_test_DEPENDENCIES)
- @rm -f gradient-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(gradient_test_OBJECTS) $(gradient_test_LDADD) $(LIBS)
-oob-test$(EXEEXT): $(oob_test_OBJECTS) $(oob_test_DEPENDENCIES)
- @rm -f oob-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(oob_test_OBJECTS) $(oob_test_LDADD) $(LIBS)
-region-test$(EXEEXT): $(region_test_OBJECTS) $(region_test_DEPENDENCIES)
- @rm -f region-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(region_test_OBJECTS) $(region_test_LDADD) $(LIBS)
-scaling-test$(EXEEXT): $(scaling_test_OBJECTS) $(scaling_test_DEPENDENCIES)
- @rm -f scaling-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(scaling_test_OBJECTS) $(scaling_test_LDADD) $(LIBS)
-screen-test$(EXEEXT): $(screen_test_OBJECTS) $(screen_test_DEPENDENCIES)
- @rm -f screen-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(screen_test_OBJECTS) $(screen_test_LDADD) $(LIBS)
-trap-crasher$(EXEEXT): $(trap_crasher_OBJECTS) $(trap_crasher_DEPENDENCIES)
- @rm -f trap-crasher$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(trap_crasher_OBJECTS) $(trap_crasher_LDADD) $(LIBS)
-trap-test$(EXEEXT): $(trap_test_OBJECTS) $(trap_test_DEPENDENCIES)
- @rm -f trap-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(trap_test_OBJECTS) $(trap_test_LDADD) $(LIBS)
-window-test$(EXEEXT): $(window_test_OBJECTS) $(window_test_DEPENDENCIES)
- @rm -f window-test$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(window_test_OBJECTS) $(window_test_LDADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a1-trap-test.Po@am__quote@
-@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@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/composite-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/composite.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convolution-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fetch-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gradient-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtk-utils.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oob-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/region-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scaling-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/screen-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trap-crasher.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trap-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/window-test.Po@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- set x; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- shift; \
- if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- if test $$# -gt 0; then \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- "$$@" $$unique; \
- else \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$unique; \
- fi; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- test -z "$(CTAGS_ARGS)$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && $(am__cd) $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) "$$here"
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-check-TESTS: $(TESTS)
- @failed=0; all=0; xfail=0; xpass=0; skip=0; \
- srcdir=$(srcdir); export srcdir; \
- list=' $(TESTS) '; \
- $(am__tty_colors); \
- 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 \
- *[\ \ ]$$tst[\ \ ]*) \
- xpass=`expr $$xpass + 1`; \
- failed=`expr $$failed + 1`; \
- col=$$red; res=XPASS; \
- ;; \
- *) \
- col=$$grn; res=PASS; \
- ;; \
- esac; \
- elif test $$? -ne 77; then \
- all=`expr $$all + 1`; \
- case " $(XFAIL_TESTS) " in \
- *[\ \ ]$$tst[\ \ ]*) \
- xfail=`expr $$xfail + 1`; \
- col=$$lgn; res=XFAIL; \
- ;; \
- *) \
- failed=`expr $$failed + 1`; \
- col=$$red; res=FAIL; \
- ;; \
- esac; \
- else \
- skip=`expr $$skip + 1`; \
- col=$$blu; res=SKIP; \
- fi; \
- echo "$${col}$$res$${std}: $$tst"; \
- done; \
- if test "$$all" -eq 1; then \
- tests="test"; \
- All=""; \
- else \
- tests="tests"; \
- All="All "; \
- fi; \
- if test "$$failed" -eq 0; then \
- if test "$$xfail" -eq 0; then \
- banner="$$All$$all $$tests passed"; \
- else \
- if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
- 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 \
- if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
- banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
- fi; \
- fi; \
- dashes="$$banner"; \
- skipped=""; \
- if test "$$skip" -ne 0; then \
- if test "$$skip" -eq 1; then \
- skipped="($$skip test was not run)"; \
- else \
- skipped="($$skip tests were not run)"; \
- fi; \
- 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`; \
- if test "$$failed" -eq 0; then \
- echo "$$grn$$dashes"; \
- else \
- echo "$$red$$dashes"; \
- fi; \
- echo "$$banner"; \
- test -z "$$skipped" || echo "$$skipped"; \
- test -z "$$report" || echo "$$report"; \
- echo "$$dashes$$std"; \
- test "$$failed" -eq 0; \
- else :; fi
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
-check-am: all-am
- $(MAKE) $(AM_MAKEFLAGS) check-TESTS
-check: check-am
-all-am: Makefile $(PROGRAMS)
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
- mostlyclean-am
-
-distclean: distclean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am:
-
-.MAKE: check-am install-am install-strip
-
-.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.
-.NOEXPORT:
diff --git a/pixman/test/blitters-test.c b/pixman/test/blitters-test.c
index 18f871eae..1340e081a 100644
--- a/pixman/test/blitters-test.c
+++ b/pixman/test/blitters-test.c
@@ -1,497 +1,484 @@
-/*
- * Test program, which stresses the use of different color formats and
- * compositing operations.
- *
- * Just run it without any command line arguments, and it will report either
- * "blitters test passed" - everything is ok
- * "blitters test failed!" - there is some problem
- *
- * In the case of failure, finding the problem involves the following steps:
- * 1. Get the reference 'blitters-test' binary. It makes sense to disable all
- * the cpu specific optimizations in pixman and also configure it with
- * '--disable-shared' option. Those who are paranoid can also tweak the
- * sources to disable all fastpath functions. The resulting binary
- * can be renamed to something like 'blitters-test.ref'.
- * 2. Compile the buggy binary (also with the '--disable-shared' option).
- * 3. Run 'ruby blitters-test-bisect.rb ./blitters-test.ref ./blitters-test'
- * 4. Look at the information about failed case (destination buffer content
- * will be shown) and try to figure out what is wrong. Loading
- * test program in gdb, specifying failed test number in the command
- * line with '-' character prepended and setting breakpoint on
- * 'pixman_image_composite' function can provide detailed information
- * about function arguments
- */
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <config.h>
-#include "utils.h"
-
-static pixman_indexed_t palette;
-
-static void *
-aligned_malloc (size_t align, size_t size)
-{
- void *result;
-
-#ifdef HAVE_POSIX_MEMALIGN
- if (posix_memalign (&result, align, size) != 0)
- result = NULL;
-#else
- result = malloc (size);
-#endif
-
- return result;
-}
-
-/* Create random image for testing purposes */
-static pixman_image_t *
-create_random_image (pixman_format_code_t *allowed_formats,
- int max_width,
- int max_height,
- int max_extra_stride,
- pixman_format_code_t *used_fmt)
-{
- int n = 0, i, width, height, stride;
- pixman_format_code_t fmt;
- uint32_t *buf;
- pixman_image_t *img;
-
- while (allowed_formats[n] != -1)
- n++;
- fmt = allowed_formats[lcg_rand_n (n)];
-
- width = lcg_rand_n (max_width) + 1;
- height = lcg_rand_n (max_height) + 1;
- stride = (width * PIXMAN_FORMAT_BPP (fmt) + 7) / 8 +
- lcg_rand_n (max_extra_stride + 1);
- stride = (stride + 3) & ~3;
-
- /* do the allocation */
- buf = aligned_malloc (64, stride * height);
-
- /* initialize image with random data */
- for (i = 0; i < stride * height; i++)
- {
- /* generation is biased to having more 0 or 255 bytes as
- * they are more likely to be special-cased in code
- */
- *((uint8_t *)buf + i) = lcg_rand_n (4) ? lcg_rand_n (256) :
- (lcg_rand_n (2) ? 0 : 255);
- }
-
- img = pixman_image_create_bits (fmt, width, height, buf, stride);
-
- if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_COLOR ||
- PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_GRAY)
- {
- pixman_image_set_indexed (img, &palette);
- }
-
- image_endian_swap (img, PIXMAN_FORMAT_BPP (fmt));
-
- if (used_fmt) *used_fmt = fmt;
- return img;
-}
-
-/* Free random image, and optionally update crc32 based on its data */
-static uint32_t
-free_random_image (uint32_t initcrc,
- pixman_image_t *img,
- pixman_format_code_t fmt)
-{
- uint32_t crc32 = 0;
- int stride = pixman_image_get_stride (img);
- uint32_t *data = pixman_image_get_data (img);
- int height = pixman_image_get_height (img);
-
- if (fmt != -1)
- {
- /* mask unused 'x' part */
- if (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt) &&
- PIXMAN_FORMAT_DEPTH (fmt) != 0)
- {
- int i;
- uint32_t *data = pixman_image_get_data (img);
- uint32_t mask = (1 << PIXMAN_FORMAT_DEPTH (fmt)) - 1;
-
- if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA)
- mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
-
- for (i = 0; i < 32; i++)
- mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt));
-
- for (i = 0; i < stride * height / 4; i++)
- data[i] &= mask;
- }
-
- /* swap endiannes in order to provide identical results on both big
- * and litte endian systems
- */
- image_endian_swap (img, PIXMAN_FORMAT_BPP (fmt));
- crc32 = compute_crc32 (initcrc, data, stride * height);
- }
-
- pixman_image_unref (img);
- free (data);
-
- return crc32;
-}
-
-static pixman_op_t op_list[] = {
- PIXMAN_OP_SRC,
- PIXMAN_OP_OVER,
- PIXMAN_OP_ADD,
- PIXMAN_OP_CLEAR,
- PIXMAN_OP_SRC,
- PIXMAN_OP_DST,
- PIXMAN_OP_OVER,
- PIXMAN_OP_OVER_REVERSE,
- PIXMAN_OP_IN,
- PIXMAN_OP_IN_REVERSE,
- PIXMAN_OP_OUT,
- PIXMAN_OP_OUT_REVERSE,
- PIXMAN_OP_ATOP,
- PIXMAN_OP_ATOP_REVERSE,
- PIXMAN_OP_XOR,
- PIXMAN_OP_ADD,
- PIXMAN_OP_SATURATE,
- PIXMAN_OP_DISJOINT_CLEAR,
- PIXMAN_OP_DISJOINT_SRC,
- PIXMAN_OP_DISJOINT_DST,
- PIXMAN_OP_DISJOINT_OVER,
- PIXMAN_OP_DISJOINT_OVER_REVERSE,
- PIXMAN_OP_DISJOINT_IN,
- PIXMAN_OP_DISJOINT_IN_REVERSE,
- PIXMAN_OP_DISJOINT_OUT,
- PIXMAN_OP_DISJOINT_OUT_REVERSE,
- PIXMAN_OP_DISJOINT_ATOP,
- PIXMAN_OP_DISJOINT_ATOP_REVERSE,
- PIXMAN_OP_DISJOINT_XOR,
- PIXMAN_OP_CONJOINT_CLEAR,
- PIXMAN_OP_CONJOINT_SRC,
- PIXMAN_OP_CONJOINT_DST,
- PIXMAN_OP_CONJOINT_OVER,
- PIXMAN_OP_CONJOINT_OVER_REVERSE,
- PIXMAN_OP_CONJOINT_IN,
- PIXMAN_OP_CONJOINT_IN_REVERSE,
- PIXMAN_OP_CONJOINT_OUT,
- PIXMAN_OP_CONJOINT_OUT_REVERSE,
- PIXMAN_OP_CONJOINT_ATOP,
- PIXMAN_OP_CONJOINT_ATOP_REVERSE,
- PIXMAN_OP_CONJOINT_XOR,
- PIXMAN_OP_MULTIPLY,
- PIXMAN_OP_SCREEN,
- PIXMAN_OP_OVERLAY,
- PIXMAN_OP_DARKEN,
- PIXMAN_OP_LIGHTEN,
- PIXMAN_OP_COLOR_DODGE,
- PIXMAN_OP_COLOR_BURN,
- PIXMAN_OP_HARD_LIGHT,
- PIXMAN_OP_DIFFERENCE,
- PIXMAN_OP_EXCLUSION,
-#if 0 /* these use floating point math and are not always bitexact on different platforms */
- PIXMAN_OP_SOFT_LIGHT,
- PIXMAN_OP_HSL_HUE,
- PIXMAN_OP_HSL_SATURATION,
- PIXMAN_OP_HSL_COLOR,
- PIXMAN_OP_HSL_LUMINOSITY,
-#endif
-};
-
-static pixman_format_code_t img_fmt_list[] = {
- PIXMAN_a8r8g8b8,
- PIXMAN_x8r8g8b8,
- PIXMAN_r5g6b5,
- PIXMAN_r3g3b2,
- PIXMAN_a8,
- PIXMAN_a8b8g8r8,
- PIXMAN_x8b8g8r8,
- PIXMAN_b8g8r8a8,
- PIXMAN_b8g8r8x8,
- PIXMAN_r8g8b8,
- PIXMAN_b8g8r8,
- PIXMAN_r5g6b5,
- PIXMAN_b5g6r5,
- PIXMAN_x2r10g10b10,
- PIXMAN_a2r10g10b10,
- PIXMAN_x2b10g10r10,
- PIXMAN_a2b10g10r10,
- PIXMAN_a1r5g5b5,
- PIXMAN_x1r5g5b5,
- PIXMAN_a1b5g5r5,
- PIXMAN_x1b5g5r5,
- PIXMAN_a4r4g4b4,
- PIXMAN_x4r4g4b4,
- PIXMAN_a4b4g4r4,
- PIXMAN_x4b4g4r4,
- PIXMAN_a8,
- PIXMAN_r3g3b2,
- PIXMAN_b2g3r3,
- PIXMAN_a2r2g2b2,
- PIXMAN_a2b2g2r2,
- PIXMAN_c8,
- PIXMAN_g8,
- PIXMAN_x4c4,
- PIXMAN_x4g4,
- PIXMAN_c4,
- PIXMAN_g4,
- PIXMAN_g1,
- PIXMAN_x4a4,
- PIXMAN_a4,
- PIXMAN_r1g2b1,
- PIXMAN_b1g2r1,
- PIXMAN_a1r1g1b1,
- PIXMAN_a1b1g1r1,
- PIXMAN_a1,
- -1
-};
-
-static pixman_format_code_t mask_fmt_list[] = {
- PIXMAN_a8r8g8b8,
- PIXMAN_a8,
- PIXMAN_a4,
- PIXMAN_a1,
- -1
-};
-
-
-/*
- * Composite operation with pseudorandom images
- */
-uint32_t
-test_composite (uint32_t initcrc, int testnum, int verbose)
-{
- int i;
- pixman_image_t *src_img = NULL;
- pixman_image_t *dst_img = NULL;
- pixman_image_t *mask_img = NULL;
- int src_width, src_height;
- int dst_width, dst_height;
- int src_stride, dst_stride;
- int src_x, src_y;
- int dst_x, dst_y;
- int mask_x, mask_y;
- int w, h;
- int op;
- pixman_format_code_t src_fmt, dst_fmt, mask_fmt;
- uint32_t *dstbuf, *srcbuf, *maskbuf;
- uint32_t crc32;
- int max_width, max_height, max_extra_stride;
-
- max_width = max_height = 24 + testnum / 10000;
- max_extra_stride = 4 + testnum / 1000000;
-
- if (max_width > 256)
- max_width = 256;
-
- if (max_height > 16)
- max_height = 16;
-
- if (max_extra_stride > 8)
- max_extra_stride = 8;
-
- lcg_srand (testnum);
-
- op = op_list[lcg_rand_n (sizeof (op_list) / sizeof (op_list[0]))];
-
- if (lcg_rand_n (8))
- {
- /* normal image */
- src_img = create_random_image (img_fmt_list, max_width, max_height,
- max_extra_stride, &src_fmt);
- }
- else
- {
- /* solid case */
- src_img = create_random_image (img_fmt_list, 1, 1,
- max_extra_stride, &src_fmt);
-
- pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL);
- }
-
- 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 ((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))
- {
- mask_img = create_random_image (mask_fmt_list, max_width, max_height,
- max_extra_stride, &mask_fmt);
- }
- else
- {
- /* solid case */
- mask_img = create_random_image (mask_fmt_list, 1, 1,
- max_extra_stride, &mask_fmt);
- pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL);
- }
-
- if (lcg_rand_n (2))
- pixman_image_set_component_alpha (mask_img, 1);
-
- mask_x = lcg_rand_n (pixman_image_get_width (mask_img));
- mask_y = lcg_rand_n (pixman_image_get_height (mask_img));
- }
-
-
- w = lcg_rand_n (dst_width - dst_x + 1);
- h = lcg_rand_n (dst_height - dst_y + 1);
-
- if (verbose)
- {
- printf ("op=%d, src_fmt=%08X, dst_fmt=%08X, mask_fmt=%08X\n",
- op, src_fmt, dst_fmt, mask_fmt);
- printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n",
- src_width, src_height, dst_width, dst_height);
- printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n",
- src_x, src_y, dst_x, dst_y);
- printf ("src_stride=%d, dst_stride=%d\n",
- src_stride, dst_stride);
- printf ("w=%d, h=%d\n", w, h);
- }
-
- pixman_image_composite (op, src_img, mask_img, dst_img,
- src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h);
-
- if (verbose)
- {
- int j;
-
- printf ("---\n");
- for (i = 0; i < dst_height; i++)
- {
- for (j = 0; j < dst_stride; j++)
- {
- if (j == (dst_width * PIXMAN_FORMAT_BPP (dst_fmt) + 7) / 8)
- printf ("| ");
-
- printf ("%02X ", *((uint8_t *)dstbuf + i * dst_stride + j));
- }
- printf ("\n");
- }
- printf ("---\n");
- }
-
- free_random_image (initcrc, src_img, -1);
- crc32 = free_random_image (initcrc, dst_img, dst_fmt);
-
- if (mask_img)
- {
- if (srcbuf == maskbuf)
- pixman_image_unref(mask_img);
- else
- free_random_image (initcrc, mask_img, -1);
- }
-
-
- return crc32;
-}
-
-static void
-initialize_palette (void)
-{
- int i;
-
- for (i = 0; i < PIXMAN_MAX_INDEXED; ++i)
- palette.rgba[i] = lcg_rand ();
-
- for (i = 0; i < 32768; ++i)
- palette.ent[i] = lcg_rand() & 0xff;
-}
-
-int
-main (int argc, char *argv[])
-{
- int i, n1 = 1, n2 = 0;
- uint32_t crc = 0;
- int verbose = getenv ("VERBOSE") != NULL;
-
- initialize_palette();
-
- if (argc >= 3)
- {
- n1 = atoi (argv[1]);
- n2 = atoi (argv[2]);
- }
- else if (argc >= 2)
- {
- n2 = atoi (argv[1]);
- }
- else
- {
- n1 = 1;
- n2 = 2000000;
- }
-
- if (n2 < 0)
- {
- crc = test_composite (0, abs (n2), 1);
- printf ("crc32=%08X\n", crc);
- }
- else
- {
- for (i = n1; i <= n2; i++)
- {
- crc = test_composite (crc, i, 0);
-
- if (verbose)
- printf ("%d: %08X\n", i, crc);
- }
- printf ("crc32=%08X\n", crc);
-
- if (n2 == 2000000)
- {
- /* 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 == 0x8F9F7DC1)
- {
- printf ("blitters test passed\n");
- }
- else
- {
- printf ("blitters test failed!\n");
- return 1;
- }
- }
- }
- return 0;
-}
+/*
+ * Test program, which stresses the use of different color formats and
+ * compositing operations.
+ *
+ * Script 'fuzzer-find-diff.pl' can be used to narrow down the problem in
+ * the case of test failure.
+ */
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <config.h>
+#include "utils.h"
+
+static pixman_indexed_t rgb_palette[9];
+static pixman_indexed_t y_palette[9];
+
+static void *
+aligned_malloc (size_t align, size_t size)
+{
+ void *result;
+
+#ifdef HAVE_POSIX_MEMALIGN
+ if (posix_memalign (&result, align, size) != 0)
+ result = NULL;
+#else
+ result = malloc (size);
+#endif
+
+ return result;
+}
+
+/* Create random image for testing purposes */
+static pixman_image_t *
+create_random_image (pixman_format_code_t *allowed_formats,
+ int max_width,
+ int max_height,
+ int max_extra_stride,
+ pixman_format_code_t *used_fmt)
+{
+ int n = 0, i, width, height, stride;
+ pixman_format_code_t fmt;
+ uint32_t *buf;
+ pixman_image_t *img;
+
+ while (allowed_formats[n] != -1)
+ n++;
+ fmt = allowed_formats[lcg_rand_n (n)];
+
+ width = lcg_rand_n (max_width) + 1;
+ height = lcg_rand_n (max_height) + 1;
+ stride = (width * PIXMAN_FORMAT_BPP (fmt) + 7) / 8 +
+ lcg_rand_n (max_extra_stride + 1);
+ stride = (stride + 3) & ~3;
+
+ /* do the allocation */
+ buf = aligned_malloc (64, stride * height);
+
+ /* initialize image with random data */
+ for (i = 0; i < stride * height; i++)
+ {
+ /* generation is biased to having more 0 or 255 bytes as
+ * they are more likely to be special-cased in code
+ */
+ *((uint8_t *)buf + i) = lcg_rand_n (4) ? lcg_rand_n (256) :
+ (lcg_rand_n (2) ? 0 : 255);
+ }
+
+ img = pixman_image_create_bits (fmt, width, height, buf, stride);
+
+ if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_COLOR)
+ {
+ pixman_image_set_indexed (img, &(rgb_palette[PIXMAN_FORMAT_BPP (fmt)]));
+ }
+ else if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_GRAY)
+ {
+ pixman_image_set_indexed (img, &(y_palette[PIXMAN_FORMAT_BPP (fmt)]));
+ }
+
+ image_endian_swap (img, PIXMAN_FORMAT_BPP (fmt));
+
+ if (used_fmt) *used_fmt = fmt;
+ return img;
+}
+
+/* Free random image, and optionally update crc32 based on its data */
+static uint32_t
+free_random_image (uint32_t initcrc,
+ pixman_image_t *img,
+ pixman_format_code_t fmt)
+{
+ uint32_t crc32 = 0;
+ int stride = pixman_image_get_stride (img);
+ uint32_t *data = pixman_image_get_data (img);
+ int height = pixman_image_get_height (img);
+
+ if (fmt != -1)
+ {
+ /* mask unused 'x' part */
+ if (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt) &&
+ PIXMAN_FORMAT_DEPTH (fmt) != 0)
+ {
+ int i;
+ uint32_t *data = pixman_image_get_data (img);
+ uint32_t mask = (1 << PIXMAN_FORMAT_DEPTH (fmt)) - 1;
+
+ if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA)
+ mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
+
+ for (i = 0; i < 32; i++)
+ mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt));
+
+ for (i = 0; i < stride * height / 4; i++)
+ data[i] &= mask;
+ }
+
+ /* swap endiannes in order to provide identical results on both big
+ * and litte endian systems
+ */
+ image_endian_swap (img, PIXMAN_FORMAT_BPP (fmt));
+ crc32 = compute_crc32 (initcrc, data, stride * height);
+ }
+
+ pixman_image_unref (img);
+ free (data);
+
+ return crc32;
+}
+
+static pixman_op_t op_list[] = {
+ PIXMAN_OP_SRC,
+ PIXMAN_OP_OVER,
+ PIXMAN_OP_ADD,
+ PIXMAN_OP_CLEAR,
+ PIXMAN_OP_SRC,
+ PIXMAN_OP_DST,
+ PIXMAN_OP_OVER,
+ PIXMAN_OP_OVER_REVERSE,
+ PIXMAN_OP_IN,
+ PIXMAN_OP_IN_REVERSE,
+ PIXMAN_OP_OUT,
+ PIXMAN_OP_OUT_REVERSE,
+ PIXMAN_OP_ATOP,
+ PIXMAN_OP_ATOP_REVERSE,
+ PIXMAN_OP_XOR,
+ PIXMAN_OP_ADD,
+ PIXMAN_OP_SATURATE,
+ PIXMAN_OP_DISJOINT_CLEAR,
+ PIXMAN_OP_DISJOINT_SRC,
+ PIXMAN_OP_DISJOINT_DST,
+ PIXMAN_OP_DISJOINT_OVER,
+ PIXMAN_OP_DISJOINT_OVER_REVERSE,
+ PIXMAN_OP_DISJOINT_IN,
+ PIXMAN_OP_DISJOINT_IN_REVERSE,
+ PIXMAN_OP_DISJOINT_OUT,
+ PIXMAN_OP_DISJOINT_OUT_REVERSE,
+ PIXMAN_OP_DISJOINT_ATOP,
+ PIXMAN_OP_DISJOINT_ATOP_REVERSE,
+ PIXMAN_OP_DISJOINT_XOR,
+ PIXMAN_OP_CONJOINT_CLEAR,
+ PIXMAN_OP_CONJOINT_SRC,
+ PIXMAN_OP_CONJOINT_DST,
+ PIXMAN_OP_CONJOINT_OVER,
+ PIXMAN_OP_CONJOINT_OVER_REVERSE,
+ PIXMAN_OP_CONJOINT_IN,
+ PIXMAN_OP_CONJOINT_IN_REVERSE,
+ PIXMAN_OP_CONJOINT_OUT,
+ PIXMAN_OP_CONJOINT_OUT_REVERSE,
+ PIXMAN_OP_CONJOINT_ATOP,
+ PIXMAN_OP_CONJOINT_ATOP_REVERSE,
+ PIXMAN_OP_CONJOINT_XOR,
+ PIXMAN_OP_MULTIPLY,
+ PIXMAN_OP_SCREEN,
+ PIXMAN_OP_OVERLAY,
+ PIXMAN_OP_DARKEN,
+ PIXMAN_OP_LIGHTEN,
+ PIXMAN_OP_COLOR_DODGE,
+ PIXMAN_OP_COLOR_BURN,
+ PIXMAN_OP_HARD_LIGHT,
+ PIXMAN_OP_DIFFERENCE,
+ PIXMAN_OP_EXCLUSION,
+#if 0 /* these use floating point math and are not always bitexact on different platforms */
+ PIXMAN_OP_SOFT_LIGHT,
+ PIXMAN_OP_HSL_HUE,
+ PIXMAN_OP_HSL_SATURATION,
+ PIXMAN_OP_HSL_COLOR,
+ PIXMAN_OP_HSL_LUMINOSITY,
+#endif
+};
+
+static pixman_format_code_t img_fmt_list[] = {
+ PIXMAN_a8r8g8b8,
+ PIXMAN_x8r8g8b8,
+ PIXMAN_r5g6b5,
+ PIXMAN_r3g3b2,
+ PIXMAN_a8,
+ PIXMAN_a8b8g8r8,
+ PIXMAN_x8b8g8r8,
+ PIXMAN_b8g8r8a8,
+ PIXMAN_b8g8r8x8,
+ PIXMAN_x14r6g6b6,
+ PIXMAN_r8g8b8,
+ PIXMAN_b8g8r8,
+ PIXMAN_r5g6b5,
+ PIXMAN_b5g6r5,
+ PIXMAN_x2r10g10b10,
+ PIXMAN_a2r10g10b10,
+ PIXMAN_x2b10g10r10,
+ PIXMAN_a2b10g10r10,
+ PIXMAN_a1r5g5b5,
+ PIXMAN_x1r5g5b5,
+ PIXMAN_a1b5g5r5,
+ PIXMAN_x1b5g5r5,
+ PIXMAN_a4r4g4b4,
+ PIXMAN_x4r4g4b4,
+ PIXMAN_a4b4g4r4,
+ PIXMAN_x4b4g4r4,
+ PIXMAN_a8,
+ PIXMAN_r3g3b2,
+ PIXMAN_b2g3r3,
+ PIXMAN_a2r2g2b2,
+ PIXMAN_a2b2g2r2,
+ PIXMAN_c8,
+ PIXMAN_g8,
+ PIXMAN_x4c4,
+ PIXMAN_x4g4,
+ PIXMAN_c4,
+ PIXMAN_g4,
+ PIXMAN_g1,
+ PIXMAN_x4a4,
+ PIXMAN_a4,
+ PIXMAN_r1g2b1,
+ PIXMAN_b1g2r1,
+ PIXMAN_a1r1g1b1,
+ PIXMAN_a1b1g1r1,
+ PIXMAN_a1,
+ -1
+};
+
+static pixman_format_code_t mask_fmt_list[] = {
+ PIXMAN_a8r8g8b8,
+ PIXMAN_a8,
+ PIXMAN_a4,
+ PIXMAN_a1,
+ -1
+};
+
+
+/*
+ * Composite operation with pseudorandom images
+ */
+uint32_t
+test_composite (int testnum, int verbose)
+{
+ int i;
+ pixman_image_t *src_img = NULL;
+ pixman_image_t *dst_img = NULL;
+ pixman_image_t *mask_img = NULL;
+ int src_width, src_height;
+ int dst_width, dst_height;
+ int src_stride, dst_stride;
+ int src_x, src_y;
+ int dst_x, dst_y;
+ int mask_x, mask_y;
+ int w, h;
+ int op;
+ pixman_format_code_t src_fmt, dst_fmt, mask_fmt;
+ uint32_t *dstbuf, *srcbuf, *maskbuf;
+ uint32_t crc32;
+ int max_width, max_height, max_extra_stride;
+
+ max_width = max_height = 24 + testnum / 10000;
+ max_extra_stride = 4 + testnum / 1000000;
+
+ if (max_width > 256)
+ max_width = 256;
+
+ if (max_height > 16)
+ max_height = 16;
+
+ if (max_extra_stride > 8)
+ max_extra_stride = 8;
+
+ lcg_srand (testnum);
+
+ op = op_list[lcg_rand_n (sizeof (op_list) / sizeof (op_list[0]))];
+
+ if (lcg_rand_n (8))
+ {
+ /* normal image */
+ src_img = create_random_image (img_fmt_list, max_width, max_height,
+ max_extra_stride, &src_fmt);
+ }
+ else
+ {
+ /* solid case */
+ src_img = create_random_image (img_fmt_list, 1, 1,
+ max_extra_stride, &src_fmt);
+
+ pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL);
+ }
+
+ 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 ((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))
+ {
+ mask_img = create_random_image (mask_fmt_list, max_width, max_height,
+ max_extra_stride, &mask_fmt);
+ }
+ else
+ {
+ /* solid case */
+ mask_img = create_random_image (mask_fmt_list, 1, 1,
+ max_extra_stride, &mask_fmt);
+ pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL);
+ }
+
+ if (lcg_rand_n (2))
+ pixman_image_set_component_alpha (mask_img, 1);
+
+ mask_x = lcg_rand_n (pixman_image_get_width (mask_img));
+ mask_y = lcg_rand_n (pixman_image_get_height (mask_img));
+ }
+
+
+ w = lcg_rand_n (dst_width - dst_x + 1);
+ h = lcg_rand_n (dst_height - dst_y + 1);
+
+ if (verbose)
+ {
+ printf ("op=%d, src_fmt=%08X, dst_fmt=%08X, mask_fmt=%08X\n",
+ op, src_fmt, dst_fmt, mask_fmt);
+ printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n",
+ src_width, src_height, dst_width, dst_height);
+ printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n",
+ src_x, src_y, dst_x, dst_y);
+ printf ("src_stride=%d, dst_stride=%d\n",
+ src_stride, dst_stride);
+ printf ("w=%d, h=%d\n", w, h);
+ }
+
+ pixman_image_composite (op, src_img, mask_img, dst_img,
+ src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h);
+
+ if (verbose)
+ {
+ int j;
+
+ printf ("---\n");
+ for (i = 0; i < dst_height; i++)
+ {
+ for (j = 0; j < dst_stride; j++)
+ {
+ if (j == (dst_width * PIXMAN_FORMAT_BPP (dst_fmt) + 7) / 8)
+ printf ("| ");
+
+ printf ("%02X ", *((uint8_t *)dstbuf + i * dst_stride + j));
+ }
+ printf ("\n");
+ }
+ printf ("---\n");
+ }
+
+ free_random_image (0, src_img, -1);
+ crc32 = free_random_image (0, dst_img, dst_fmt);
+
+ if (mask_img)
+ {
+ if (srcbuf == maskbuf)
+ pixman_image_unref(mask_img);
+ else
+ free_random_image (0, mask_img, -1);
+ }
+
+
+ return crc32;
+}
+
+#define CONVERT_15(c, is_rgb) \
+ (is_rgb? \
+ ((((c) >> 3) & 0x001f) | \
+ (((c) >> 6) & 0x03e0) | \
+ (((c) >> 9) & 0x7c00)) : \
+ (((((c) >> 16) & 0xff) * 153 + \
+ (((c) >> 8) & 0xff) * 301 + \
+ (((c) ) & 0xff) * 58) >> 2))
+
+static void
+initialize_palette (pixman_indexed_t *palette, uint32_t mask, int is_rgb)
+{
+ int i;
+
+ for (i = 0; i < 32768; ++i)
+ palette->ent[i] = lcg_rand() & mask;
+
+ for (i = 0; i < mask + 1; ++i)
+ {
+ uint32_t rgba24;
+ pixman_bool_t retry;
+ uint32_t i15;
+
+ /* We filled the rgb->index map with random numbers, but we
+ * do need the ability to round trip, that is if some indexed
+ * color expands to an argb24, then the 15 bit version of that
+ * color must map back to the index. Anything else, we don't
+ * care about too much.
+ */
+ do
+ {
+ uint32_t old_idx;
+
+ rgba24 = lcg_rand();
+ i15 = CONVERT_15 (rgba24, is_rgb);
+
+ old_idx = palette->ent[i15];
+ if (CONVERT_15 (palette->rgba[old_idx], is_rgb) == i15)
+ retry = 1;
+ else
+ retry = 0;
+ } while (retry);
+
+ palette->rgba[i] = rgba24;
+ palette->ent[i15] = i;
+ }
+
+ for (i = 0; i < mask + 1; ++i)
+ {
+ assert (palette->ent[CONVERT_15 (palette->rgba[i], is_rgb)] == i);
+ }
+}
+
+int
+main (int argc, const char *argv[])
+{
+ int i;
+
+ for (i = 1; i <= 8; i++)
+ {
+ initialize_palette (&(rgb_palette[i]), (1 << i) - 1, TRUE);
+ initialize_palette (&(y_palette[i]), (1 << i) - 1, FALSE);
+ }
+
+ return fuzzer_test_main("blitters", 2000000,
+ 0x217CF14A,
+ test_composite, argc, argv);
+}
diff --git a/pixman/test/fuzzer-find-diff.pl b/pixman/test/fuzzer-find-diff.pl
new file mode 100644
index 000000000..a43f6fb83
--- /dev/null
+++ b/pixman/test/fuzzer-find-diff.pl
@@ -0,0 +1,68 @@
+#!/usr/bin/env perl
+
+$usage = "Usage:
+ fuzzer-find-diff.pl reference_binary new_binary [number_of_tests_to_run]
+
+The first two input arguments are the commands to run the test programs
+based on fuzzer_test_main() function from 'util.c' (preferably they should
+be statically compiled, this can be achieved via '--disable-shared' pixman
+configure option). The third optional argument is the number of test rounds
+to run (if not specified, then testing runs infinitely or until some problem
+is detected).
+
+Usage examples:
+ fuzzer-find-diff.pl ./blitters-test-with-sse-disabled ./blitters-test 9000000
+ fuzzer-find-diff.pl ./blitters-test \"ssh ppc64_host /path/to/blitters-test\"
+";
+
+$#ARGV >= 1 or die $usage;
+
+$batch_size = 10000;
+
+if ($#ARGV >= 2) {
+ $number_of_tests = int($ARGV[2]);
+} else {
+ $number_of_tests = -1
+}
+
+sub test_range {
+ my $min = shift;
+ my $max = shift;
+
+ if (`$ARGV[0] $min $max 2>/dev/null` eq `$ARGV[1] $min $max 2>/dev/null`) {
+ return;
+ }
+
+ while ($max != $min + 1) {
+ my $avg = int(($min + $max) / 2);
+ my $res1 = `$ARGV[0] $min $avg 2>/dev/null`;
+ my $res2 = `$ARGV[1] $min $avg 2>/dev/null`;
+ if ($res1 ne $res2) {
+ $max = $avg;
+ } else {
+ $min = $avg;
+ }
+ }
+ return $max;
+}
+
+$base = 1;
+while ($number_of_tests <= 0 || $base <= $number_of_tests) {
+ printf("testing %-12d\r", $base + $batch_size - 1);
+ my $res = test_range($base, $base + $batch_size - 1);
+ if ($res) {
+ printf("Failure: results are different for test %d:\n", $res);
+
+ printf("\n-- ref --\n");
+ print `$ARGV[0] $res`;
+ printf("-- new --\n");
+ print `$ARGV[1] $res`;
+
+ printf("The problematic conditions can be reproduced by running:\n");
+ printf("$ARGV[1] %d\n", $res);
+
+ exit(1);
+ }
+ $base += $batch_size;
+}
+printf("Success: %d tests finished\n", $base - 1);
diff --git a/pixman/test/gradient-crash-test.c b/pixman/test/gradient-crash-test.c
new file mode 100644
index 000000000..88424dee9
--- /dev/null
+++ b/pixman/test/gradient-crash-test.c
@@ -0,0 +1,117 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "pixman.h"
+
+int
+main (int argc, char **argv)
+{
+#define WIDTH 400
+#define HEIGHT 200
+
+ uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
+ pixman_image_t *src_img;
+ pixman_image_t *dest_img;
+ int i, j;
+
+ pixman_gradient_stop_t onestop[1] =
+ {
+ { pixman_int_to_fixed (1), { 0xffff, 0xeeee, 0xeeee, 0xeeee } },
+ };
+
+ pixman_gradient_stop_t subsetstops[2] =
+ {
+ { pixman_int_to_fixed (1), { 0xffff, 0xeeee, 0xeeee, 0xeeee } },
+ { pixman_int_to_fixed (1), { 0xffff, 0xeeee, 0xeeee, 0xeeee } },
+ };
+
+ pixman_gradient_stop_t stops01[2] =
+ {
+ { pixman_int_to_fixed (0), { 0xffff, 0xeeee, 0xeeee, 0xeeee } },
+ { pixman_int_to_fixed (1), { 0xffff, 0x1111, 0x1111, 0x1111 } }
+ };
+
+ pixman_point_fixed_t p1 = { pixman_double_to_fixed (0), 0 };
+ pixman_point_fixed_t p2 = { pixman_double_to_fixed (WIDTH / 8.),
+ pixman_int_to_fixed (0) };
+
+#if 0
+ pixman_transform_t trans = {
+ { { pixman_double_to_fixed (2), pixman_double_to_fixed (0.5), pixman_double_to_fixed (-100), },
+ { pixman_double_to_fixed (0), pixman_double_to_fixed (3), pixman_double_to_fixed (0), },
+ { pixman_double_to_fixed (0), pixman_double_to_fixed (0.000), pixman_double_to_fixed (1.0) }
+ }
+ };
+#else
+ pixman_transform_t trans = {
+ { { pixman_fixed_1, 0, 0 },
+ { 0, pixman_fixed_1, 0 },
+ { 0, 0, pixman_fixed_1 } }
+ };
+#endif
+
+ pixman_point_fixed_t c_inner;
+ pixman_point_fixed_t c_outer;
+ pixman_fixed_t r_inner;
+ pixman_fixed_t r_outer;
+
+ for (i = 0; i < WIDTH * HEIGHT; ++i)
+ dest[i] = 0x4f00004f; /* pale blue */
+
+ dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
+ WIDTH, HEIGHT,
+ dest,
+ WIDTH * 4);
+
+ c_inner.x = pixman_double_to_fixed (50.0);
+ c_inner.y = pixman_double_to_fixed (50.0);
+ c_outer.x = pixman_double_to_fixed (50.0);
+ c_outer.y = pixman_double_to_fixed (50.0);
+ r_inner = 0;
+ r_outer = pixman_double_to_fixed (50.0);
+
+ for (i = 0; i < 3; ++i)
+ {
+ pixman_gradient_stop_t *stops;
+ int num_stops;
+ if (i == 0)
+ {
+ stops = onestop;
+ num_stops = sizeof(onestop) / sizeof(onestop[0]);
+ }
+ else if (i == 1)
+ {
+ stops = subsetstops;
+ num_stops = sizeof(subsetstops) / sizeof(subsetstops[0]);
+ }
+ else
+ {
+ stops = stops01;
+ num_stops = sizeof(stops01) / sizeof(stops01[0]);
+ }
+
+ for (j = 0; j < 3; ++j)
+ {
+ if (j == 0)
+ src_img = pixman_image_create_conical_gradient (&c_inner, r_inner,
+ stops, num_stops);
+ else if (j == 1)
+ src_img = pixman_image_create_radial_gradient (&c_inner, &c_outer,
+ r_inner, r_outer,
+ stops, num_stops);
+ else
+ src_img = pixman_image_create_linear_gradient (&p1, &p2,
+ stops, num_stops);
+ pixman_image_set_transform (src_img, &trans);
+ pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NONE);
+ pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img,
+ 0, 0, 0, 0, 0, 0, 10 * WIDTH, HEIGHT);
+
+ }
+ pixman_image_unref (src_img);
+ }
+
+ pixman_image_unref (dest_img);
+ free (dest);
+
+ return 0;
+}
diff --git a/pixman/test/gtk-utils.c b/pixman/test/gtk-utils.c
index 751a164c0..f45cdc912 100644
--- a/pixman/test/gtk-utils.c
+++ b/pixman/test/gtk-utils.c
@@ -1,113 +1,115 @@
-#include <gtk/gtk.h>
-#include <config.h>
-#include "pixman-private.h" /* For image->bits.format
- * FIXME: there should probably be public API for this
- */
-#include "gtk-utils.h"
-
-GdkPixbuf *
-pixbuf_from_argb32 (uint32_t *bits,
- gboolean has_alpha,
- int width,
- int height,
- int stride)
-{
- GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE,
- 8, width, height);
- int p_stride = gdk_pixbuf_get_rowstride (pixbuf);
- guint32 *p_bits = (guint32 *)gdk_pixbuf_get_pixels (pixbuf);
- int w, h;
-
- for (h = 0; h < height; ++h)
- {
- for (w = 0; w < width; ++w)
- {
- uint32_t argb = bits[h * (stride / 4) + w];
- guint r, g, b, a;
- char *pb = (char *)p_bits;
-
- pb += h * p_stride + w * 4;
-
- r = (argb & 0x00ff0000) >> 16;
- g = (argb & 0x0000ff00) >> 8;
- b = (argb & 0x000000ff) >> 0;
- a = has_alpha? (argb & 0xff000000) >> 24 : 0xff;
-
- if (a)
- {
- r = (r * 255) / a;
- g = (g * 255) / a;
- b = (b * 255) / a;
- }
-
- if (r > 255) r = 255;
- if (g > 255) g = 255;
- if (b > 255) b = 255;
-
- pb[0] = r;
- pb[1] = g;
- pb[2] = b;
- pb[3] = a;
- }
- }
-
- return pixbuf;
-}
-
-
-static gboolean
-on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data)
-{
- GdkPixbuf *pixbuf = data;
-
- gdk_draw_pixbuf (widget->window, NULL,
- pixbuf, 0, 0, 0, 0,
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf),
- GDK_RGB_DITHER_NONE,
- 0, 0);
-
- return TRUE;
-}
-
-void
-show_image (pixman_image_t *image)
-{
- GtkWidget *window;
- GdkPixbuf *pixbuf;
- int width, height, stride;
- int argc;
- char **argv;
- char *arg0 = g_strdup ("pixman-test-program");
- gboolean has_alpha;
- pixman_format_code_t format;
-
- argc = 1;
- argv = (char **)&arg0;
-
- gtk_init (&argc, &argv);
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- width = pixman_image_get_width (image);
- height = pixman_image_get_height (image);
- stride = pixman_image_get_stride (image);
-
- format = image->bits.format;
-
- if (format == PIXMAN_a8r8g8b8)
- has_alpha = TRUE;
- else if (format == PIXMAN_x8r8g8b8)
- has_alpha = FALSE;
- else
- g_error ("Can't deal with this format: %x\n", format);
-
- pixbuf = pixbuf_from_argb32 (pixman_image_get_data (image), has_alpha,
- width, height, stride);
-
- g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), pixbuf);
- g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
-
- gtk_widget_show (window);
-
- gtk_main ();
-}
+#include <gtk/gtk.h>
+#include <config.h>
+#include "pixman-private.h" /* For image->bits.format
+ * FIXME: there should probably be public API for this
+ */
+#include "gtk-utils.h"
+
+GdkPixbuf *
+pixbuf_from_argb32 (uint32_t *bits,
+ gboolean has_alpha,
+ int width,
+ int height,
+ int stride)
+{
+ GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE,
+ 8, width, height);
+ int p_stride = gdk_pixbuf_get_rowstride (pixbuf);
+ guint32 *p_bits = (guint32 *)gdk_pixbuf_get_pixels (pixbuf);
+ int w, h;
+
+ for (h = 0; h < height; ++h)
+ {
+ for (w = 0; w < width; ++w)
+ {
+ uint32_t argb = bits[h * (stride / 4) + w];
+ guint r, g, b, a;
+ char *pb = (char *)p_bits;
+
+ pb += h * p_stride + w * 4;
+
+ r = (argb & 0x00ff0000) >> 16;
+ g = (argb & 0x0000ff00) >> 8;
+ b = (argb & 0x000000ff) >> 0;
+ a = has_alpha? (argb & 0xff000000) >> 24 : 0xff;
+
+ if (a)
+ {
+ r = (r * 255) / a;
+ g = (g * 255) / a;
+ b = (b * 255) / a;
+ }
+
+ if (r > 255) r = 255;
+ if (g > 255) g = 255;
+ if (b > 255) b = 255;
+
+ pb[0] = r;
+ pb[1] = g;
+ pb[2] = b;
+ pb[3] = a;
+ }
+ }
+
+ return pixbuf;
+}
+
+
+static gboolean
+on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data)
+{
+ GdkPixbuf *pixbuf = data;
+
+ gdk_draw_pixbuf (widget->window, NULL,
+ pixbuf, 0, 0, 0, 0,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ GDK_RGB_DITHER_NONE,
+ 0, 0);
+
+ return TRUE;
+}
+
+void
+show_image (pixman_image_t *image)
+{
+ GtkWidget *window;
+ GdkPixbuf *pixbuf;
+ int width, height, stride;
+ int argc;
+ char **argv;
+ char *arg0 = g_strdup ("pixman-test-program");
+ gboolean has_alpha;
+ pixman_format_code_t format;
+
+ argc = 1;
+ argv = (char **)&arg0;
+
+ gtk_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ width = pixman_image_get_width (image);
+ height = pixman_image_get_height (image);
+ stride = pixman_image_get_stride (image);
+
+ gtk_window_set_default_size (GTK_WINDOW (window), width, height);
+
+ format = image->bits.format;
+
+ if (format == PIXMAN_a8r8g8b8)
+ has_alpha = TRUE;
+ else if (format == PIXMAN_x8r8g8b8)
+ has_alpha = FALSE;
+ else
+ g_error ("Can't deal with this format: %x\n", format);
+
+ pixbuf = pixbuf_from_argb32 (pixman_image_get_data (image), has_alpha,
+ width, height, stride);
+
+ g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), pixbuf);
+ g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+
+ gtk_widget_show (window);
+
+ gtk_main ();
+}
diff --git a/pixman/test/scaling-crash-test.c b/pixman/test/scaling-crash-test.c
new file mode 100644
index 000000000..7e8b6d56b
--- /dev/null
+++ b/pixman/test/scaling-crash-test.c
@@ -0,0 +1,124 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "pixman.h"
+
+/*
+ * We have a source image filled with solid color, set NORMAL or PAD repeat,
+ * and some transform which results in nearest neighbour scaling.
+ *
+ * The expected result is the destination image filled with this solid
+ * color.
+ */
+static int
+do_test (int32_t dst_size,
+ int32_t src_size,
+ int32_t src_offs,
+ int32_t scale_factor,
+ pixman_repeat_t repeat)
+{
+ int i;
+ pixman_image_t * src_img;
+ pixman_image_t * dst_img;
+ pixman_transform_t transform;
+ uint32_t * srcbuf;
+ uint32_t * dstbuf;
+
+ srcbuf = (uint32_t *)malloc (src_size * 4);
+ dstbuf = (uint32_t *)malloc (dst_size * 4);
+
+ /* horizontal test */
+ memset (srcbuf, 0xCC, src_size * 4);
+ memset (dstbuf, 0x33, dst_size * 4);
+
+ src_img = pixman_image_create_bits (
+ PIXMAN_a8r8g8b8, src_size, 1, srcbuf, src_size * 4);
+ dst_img = pixman_image_create_bits (
+ PIXMAN_a8r8g8b8, dst_size, 1, dstbuf, dst_size * 4);
+
+ pixman_transform_init_scale (&transform, scale_factor, 65536);
+ pixman_image_set_transform (src_img, &transform);
+ pixman_image_set_repeat (src_img, repeat);
+ pixman_image_set_filter (src_img, PIXMAN_FILTER_NEAREST, NULL, 0);
+
+ pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img,
+ src_offs, 0, 0, 0, 0, 0, dst_size, 1);
+
+ pixman_image_unref (src_img);
+ pixman_image_unref (dst_img);
+
+ for (i = 0; i < dst_size; i++)
+ {
+ if (dstbuf[i] != 0xCCCCCCCC)
+ {
+ free (srcbuf);
+ free (dstbuf);
+ return 1;
+ }
+ }
+
+ /* vertical test */
+ memset (srcbuf, 0xCC, src_size * 4);
+ memset (dstbuf, 0x33, dst_size * 4);
+
+ src_img = pixman_image_create_bits (
+ PIXMAN_a8r8g8b8, 1, src_size, srcbuf, 4);
+ dst_img = pixman_image_create_bits (
+ PIXMAN_a8r8g8b8, 1, dst_size, dstbuf, 4);
+
+ pixman_transform_init_scale (&transform, 65536, scale_factor);
+ pixman_image_set_transform (src_img, &transform);
+ pixman_image_set_repeat (src_img, repeat);
+ pixman_image_set_filter (src_img, PIXMAN_FILTER_NEAREST, NULL, 0);
+
+ pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img,
+ 0, src_offs, 0, 0, 0, 0, 1, dst_size);
+
+ pixman_image_unref (src_img);
+ pixman_image_unref (dst_img);
+
+ for (i = 0; i < dst_size; i++)
+ {
+ if (dstbuf[i] != 0xCCCCCCCC)
+ {
+ free (srcbuf);
+ free (dstbuf);
+ return 1;
+ }
+ }
+
+ free (srcbuf);
+ free (dstbuf);
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ pixman_disable_out_of_bounds_workaround ();
+
+ /* can potentially crash */
+ assert (do_test (
+ 48000, 32767, 1, 65536 * 128, PIXMAN_REPEAT_NORMAL) == 0);
+
+ /* can potentially get into a deadloop */
+ assert (do_test (
+ 16384, 65536, 32, 32768, PIXMAN_REPEAT_NORMAL) == 0);
+
+#if 0
+ /* can potentially access memory outside source image buffer */
+ assert (do_test (
+ 10, 10, 0, 1, PIXMAN_REPEAT_PAD) == 0);
+ assert (do_test (
+ 10, 10, 0, 0, PIXMAN_REPEAT_PAD) == 0);
+#endif
+
+#if 0
+ /* can potentially provide invalid results (out of range matrix stuff) */
+ assert (do_test (
+ 48000, 32767, 16384, 65536 * 128, PIXMAN_REPEAT_NORMAL) == 0);
+#endif
+
+ return 0;
+}
diff --git a/pixman/test/scaling-test.c b/pixman/test/scaling-test.c
index 29772906d..54236faa3 100644
--- a/pixman/test/scaling-test.c
+++ b/pixman/test/scaling-test.c
@@ -1,291 +1,247 @@
-/*
- * Test program, which can detect problems with nearest neighbout scaling
- * implementation. Also SRC and OVER opetations tested for 16bpp and 32bpp
- * images.
- *
- * Just run it without any command line arguments, and it will report either
- * "scaling test passed" - everything is ok
- * "scaling test failed!" - there is some problem
- *
- * In the case of failure, finding the problem involves the following steps:
- * 1. Get the reference 'scaling-test' binary. It makes sense to disable all
- * the cpu specific optimizations in pixman and also configure it with
- * '--disable-shared' option. Those who are paranoid can also tweak the
- * sources to disable all fastpath functions. The resulting binary
- * can be renamed to something like 'scaling-test.ref'.
- * 2. Compile the buggy binary (also with the '--disable-shared' option).
- * 3. Run 'ruby scaling-test-bisect.rb ./scaling-test.ref ./scaling-test'
- * 4. Look at the information about failed case (destination buffer content
- * will be shown) and try to figure out what is wrong. It is possible
- * to use debugging print to stderr in pixman to get more information,
- * this does not interfere with the testing script.
- */
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "utils.h"
-
-#define MAX_SRC_WIDTH 10
-#define MAX_SRC_HEIGHT 10
-#define MAX_DST_WIDTH 10
-#define MAX_DST_HEIGHT 10
-#define MAX_STRIDE 4
-
-/*
- * Composite operation with pseudorandom images
- */
-uint32_t
-test_composite (uint32_t initcrc,
- int testnum,
- int verbose)
-{
- int i;
- pixman_image_t * src_img;
- pixman_image_t * dst_img;
- pixman_transform_t transform;
- pixman_region16_t clip;
- int src_width, src_height;
- int dst_width, dst_height;
- int src_stride, dst_stride;
- int src_x, src_y;
- int dst_x, dst_y;
- int src_bpp;
- int dst_bpp;
- int w, h;
- int scale_x = 32768, scale_y = 32768;
- int op;
- int repeat = 0;
- int src_fmt, dst_fmt;
- uint32_t * srcbuf;
- uint32_t * dstbuf;
- uint32_t crc32;
-
- lcg_srand (testnum);
-
- src_bpp = (lcg_rand_n (2) == 0) ? 2 : 4;
- dst_bpp = (lcg_rand_n (2) == 0) ? 2 : 4;
- op = (lcg_rand_n (2) == 0) ? PIXMAN_OP_SRC : PIXMAN_OP_OVER;
-
- src_width = lcg_rand_n (MAX_SRC_WIDTH) + 1;
- src_height = lcg_rand_n (MAX_SRC_HEIGHT) + 1;
- dst_width = lcg_rand_n (MAX_DST_WIDTH) + 1;
- dst_height = lcg_rand_n (MAX_DST_HEIGHT) + 1;
- src_stride = src_width * src_bpp + lcg_rand_n (MAX_STRIDE) * src_bpp;
- dst_stride = dst_width * dst_bpp + lcg_rand_n (MAX_STRIDE) * dst_bpp;
-
- if (src_stride & 3)
- src_stride += 2;
-
- if (dst_stride & 3)
- dst_stride += 2;
-
- src_x = -(src_width / 4) + lcg_rand_n (src_width * 3 / 2);
- src_y = -(src_height / 4) + lcg_rand_n (src_height * 3 / 2);
- dst_x = -(dst_width / 4) + lcg_rand_n (dst_width * 3 / 2);
- dst_y = -(dst_height / 4) + lcg_rand_n (dst_height * 3 / 2);
- w = lcg_rand_n (dst_width * 3 / 2 - dst_x);
- h = lcg_rand_n (dst_height * 3 / 2 - dst_y);
-
- srcbuf = (uint32_t *)malloc (src_stride * src_height);
- dstbuf = (uint32_t *)malloc (dst_stride * dst_height);
-
- for (i = 0; i < src_stride * src_height; i++)
- *((uint8_t *)srcbuf + i) = lcg_rand_n (256);
-
- for (i = 0; i < dst_stride * dst_height; i++)
- *((uint8_t *)dstbuf + i) = lcg_rand_n (256);
-
- src_fmt = src_bpp == 4 ? (lcg_rand_n (2) == 0 ?
- PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8) : PIXMAN_r5g6b5;
-
- dst_fmt = dst_bpp == 4 ? (lcg_rand_n (2) == 0 ?
- PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8) : PIXMAN_r5g6b5;
-
- src_img = pixman_image_create_bits (
- src_fmt, src_width, src_height, srcbuf, src_stride);
-
- dst_img = pixman_image_create_bits (
- dst_fmt, dst_width, dst_height, dstbuf, dst_stride);
-
- image_endian_swap (src_img, src_bpp * 8);
- image_endian_swap (dst_img, dst_bpp * 8);
-
- if (lcg_rand_n (8) > 0)
- {
- scale_x = 32768 + lcg_rand_n (65536);
- scale_y = 32768 + lcg_rand_n (65536);
- pixman_transform_init_scale (&transform, scale_x, scale_y);
- pixman_image_set_transform (src_img, &transform);
- }
-
- switch (lcg_rand_n (4))
- {
- case 0:
- repeat = PIXMAN_REPEAT_NONE;
- break;
-
- case 1:
- repeat = PIXMAN_REPEAT_NORMAL;
- break;
-
- case 2:
- repeat = PIXMAN_REPEAT_PAD;
- break;
-
- case 3:
- repeat = PIXMAN_REPEAT_REFLECT;
- break;
-
- default:
- break;
- }
- pixman_image_set_repeat (src_img, repeat);
-
- if (lcg_rand_n (2))
- pixman_image_set_filter (src_img, PIXMAN_FILTER_NEAREST, NULL, 0);
- else
- pixman_image_set_filter (src_img, PIXMAN_FILTER_BILINEAR, NULL, 0);
-
- if (verbose)
- {
- printf ("src_fmt=%08X, dst_fmt=%08X\n", src_fmt, dst_fmt);
- printf ("op=%d, scale_x=%d, scale_y=%d, repeat=%d\n",
- op, scale_x, scale_y, repeat);
- printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n",
- src_width, src_height, dst_width, dst_height);
- printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n",
- src_x, src_y, dst_x, dst_y);
- printf ("w=%d, h=%d\n", w, h);
- }
-
- if (lcg_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[2];
- int n = lcg_rand_n (2) + 1;
-
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = lcg_rand_n (src_width);
- clip_boxes[i].y1 = lcg_rand_n (src_height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + lcg_rand_n (src_width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + lcg_rand_n (src_height - clip_boxes[i].y1);
-
- if (verbose)
- {
- printf ("source clip box: [%d,%d-%d,%d]\n",
- clip_boxes[i].x1, clip_boxes[i].y1,
- clip_boxes[i].x2, clip_boxes[i].y2);
- }
- }
-
- pixman_region_init_rects (&clip, clip_boxes, n);
- pixman_image_set_clip_region (src_img, &clip);
- pixman_image_set_source_clipping (src_img, 1);
- pixman_region_fini (&clip);
- }
-
- if (lcg_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[2];
- int n = lcg_rand_n (2) + 1;
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = lcg_rand_n (dst_width);
- clip_boxes[i].y1 = lcg_rand_n (dst_height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + lcg_rand_n (dst_width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + lcg_rand_n (dst_height - clip_boxes[i].y1);
-
- if (verbose)
- {
- printf ("destination clip box: [%d,%d-%d,%d]\n",
- clip_boxes[i].x1, clip_boxes[i].y1,
- clip_boxes[i].x2, clip_boxes[i].y2);
- }
- }
- pixman_region_init_rects (&clip, clip_boxes, n);
- pixman_image_set_clip_region (dst_img, &clip);
- pixman_region_fini (&clip);
- }
-
- pixman_image_composite (op, src_img, NULL, dst_img,
- src_x, src_y, 0, 0, dst_x, dst_y, w, h);
-
- if (dst_fmt == PIXMAN_x8r8g8b8)
- {
- /* ignore unused part */
- for (i = 0; i < dst_stride * dst_height / 4; i++)
- dstbuf[i] &= 0xFFFFFF;
- }
-
- image_endian_swap (dst_img, dst_bpp * 8);
-
- if (verbose)
- {
- int j;
-
- for (i = 0; i < dst_height; i++)
- {
- for (j = 0; j < dst_stride; j++)
- printf ("%02X ", *((uint8_t *)dstbuf + i * dst_stride + j));
-
- printf ("\n");
- }
- }
-
- pixman_image_unref (src_img);
- pixman_image_unref (dst_img);
-
- crc32 = compute_crc32 (initcrc, dstbuf, dst_stride * dst_height);
- free (srcbuf);
- free (dstbuf);
- return crc32;
-}
-
-int
-main (int argc, char *argv[])
-{
- int i, n = 0;
- uint32_t crc = 0;
-
- pixman_disable_out_of_bounds_workaround ();
-
- if (argc >= 2)
- n = atoi (argv[1]);
-
- if (n == 0) n = 3000000;
-
- if (n < 0)
- {
- crc = test_composite (0, -n, 1);
- printf ("crc32=%08X\n", crc);
- }
- else
- {
- for (i = 1; i <= n; i++)
- crc = test_composite (crc, i, 0);
-
- printf ("crc32=%08X\n", crc);
-
- if (n == 3000000)
- {
- /* predefined value for running with all the fastpath functions disabled */
- /* it needs to be updated every time changes are introduced to this program! */
-
- if (crc == 0x2168ACD1)
- {
- printf ("scaling test passed\n");
- }
- else
- {
- printf ("scaling test failed!\n");
- return 1;
- }
- }
- }
-
- return 0;
-}
+/*
+ * Test program, which can detect some problems with nearest neighbour
+ * and bilinear scaling in pixman. Testing is done by running lots
+ * of random SRC and OVER compositing operations a8r8g8b8, x8a8r8g8b8
+ * and r5g6b5 color formats.
+ *
+ * Script 'fuzzer-find-diff.pl' can be used to narrow down the problem in
+ * the case of test failure.
+ */
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "utils.h"
+
+#define MAX_SRC_WIDTH 16
+#define MAX_SRC_HEIGHT 16
+#define MAX_DST_WIDTH 16
+#define MAX_DST_HEIGHT 16
+#define MAX_STRIDE 4
+
+/*
+ * Composite operation with pseudorandom images
+ */
+uint32_t
+test_composite (int testnum,
+ int verbose)
+{
+ int i;
+ pixman_image_t * src_img;
+ pixman_image_t * dst_img;
+ pixman_transform_t transform;
+ pixman_region16_t clip;
+ int src_width, src_height;
+ int dst_width, dst_height;
+ int src_stride, dst_stride;
+ int src_x, src_y;
+ int dst_x, dst_y;
+ int src_bpp;
+ int dst_bpp;
+ int w, h;
+ pixman_fixed_t scale_x = 65536, scale_y = 65536;
+ pixman_fixed_t translate_x = 0, translate_y = 0;
+ int op;
+ int repeat = 0;
+ int src_fmt, dst_fmt;
+ uint32_t * srcbuf;
+ uint32_t * dstbuf;
+ uint32_t crc32;
+
+ lcg_srand (testnum);
+
+ src_bpp = (lcg_rand_n (2) == 0) ? 2 : 4;
+ dst_bpp = (lcg_rand_n (2) == 0) ? 2 : 4;
+ op = (lcg_rand_n (2) == 0) ? PIXMAN_OP_SRC : PIXMAN_OP_OVER;
+
+ src_width = lcg_rand_n (MAX_SRC_WIDTH) + 1;
+ src_height = lcg_rand_n (MAX_SRC_HEIGHT) + 1;
+ dst_width = lcg_rand_n (MAX_DST_WIDTH) + 1;
+ dst_height = lcg_rand_n (MAX_DST_HEIGHT) + 1;
+ src_stride = src_width * src_bpp + lcg_rand_n (MAX_STRIDE) * src_bpp;
+ dst_stride = dst_width * dst_bpp + lcg_rand_n (MAX_STRIDE) * dst_bpp;
+
+ if (src_stride & 3)
+ src_stride += 2;
+
+ if (dst_stride & 3)
+ dst_stride += 2;
+
+ src_x = -(src_width / 4) + lcg_rand_n (src_width * 3 / 2);
+ src_y = -(src_height / 4) + lcg_rand_n (src_height * 3 / 2);
+ dst_x = -(dst_width / 4) + lcg_rand_n (dst_width * 3 / 2);
+ dst_y = -(dst_height / 4) + lcg_rand_n (dst_height * 3 / 2);
+ w = lcg_rand_n (dst_width * 3 / 2 - dst_x);
+ h = lcg_rand_n (dst_height * 3 / 2 - dst_y);
+
+ srcbuf = (uint32_t *)malloc (src_stride * src_height);
+ dstbuf = (uint32_t *)malloc (dst_stride * dst_height);
+
+ for (i = 0; i < src_stride * src_height; i++)
+ *((uint8_t *)srcbuf + i) = lcg_rand_n (256);
+
+ for (i = 0; i < dst_stride * dst_height; i++)
+ *((uint8_t *)dstbuf + i) = lcg_rand_n (256);
+
+ src_fmt = src_bpp == 4 ? (lcg_rand_n (2) == 0 ?
+ PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8) : PIXMAN_r5g6b5;
+
+ dst_fmt = dst_bpp == 4 ? (lcg_rand_n (2) == 0 ?
+ PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8) : PIXMAN_r5g6b5;
+
+ src_img = pixman_image_create_bits (
+ src_fmt, src_width, src_height, srcbuf, src_stride);
+
+ dst_img = pixman_image_create_bits (
+ dst_fmt, dst_width, dst_height, dstbuf, dst_stride);
+
+ image_endian_swap (src_img, src_bpp * 8);
+ image_endian_swap (dst_img, dst_bpp * 8);
+
+ if (lcg_rand_n (8) > 0)
+ {
+ scale_x = -32768 * 3 + lcg_rand_N (65536 * 5);
+ scale_y = -32768 * 3 + lcg_rand_N (65536 * 5);
+ translate_x = lcg_rand_N (65536);
+ translate_y = lcg_rand_N (65536);
+ pixman_transform_init_scale (&transform, scale_x, scale_y);
+ pixman_transform_translate (&transform, NULL, translate_x, translate_y);
+ pixman_image_set_transform (src_img, &transform);
+ }
+
+ switch (lcg_rand_n (4))
+ {
+ case 0:
+ repeat = PIXMAN_REPEAT_NONE;
+ break;
+
+ case 1:
+ repeat = PIXMAN_REPEAT_NORMAL;
+ break;
+
+ case 2:
+ repeat = PIXMAN_REPEAT_PAD;
+ break;
+
+ case 3:
+ repeat = PIXMAN_REPEAT_REFLECT;
+ break;
+
+ default:
+ break;
+ }
+ pixman_image_set_repeat (src_img, repeat);
+
+ if (lcg_rand_n (2))
+ pixman_image_set_filter (src_img, PIXMAN_FILTER_NEAREST, NULL, 0);
+ else
+ pixman_image_set_filter (src_img, PIXMAN_FILTER_BILINEAR, NULL, 0);
+
+ if (verbose)
+ {
+ printf ("src_fmt=%08X, dst_fmt=%08X\n", src_fmt, dst_fmt);
+ printf ("op=%d, scale_x=%d, scale_y=%d, repeat=%d\n",
+ op, scale_x, scale_y, repeat);
+ printf ("translate_x=%d, translate_y=%d\n",
+ translate_x, translate_y);
+ printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n",
+ src_width, src_height, dst_width, dst_height);
+ printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n",
+ src_x, src_y, dst_x, dst_y);
+ printf ("w=%d, h=%d\n", w, h);
+ }
+
+ if (lcg_rand_n (8) == 0)
+ {
+ pixman_box16_t clip_boxes[2];
+ int n = lcg_rand_n (2) + 1;
+
+ for (i = 0; i < n; i++)
+ {
+ clip_boxes[i].x1 = lcg_rand_n (src_width);
+ clip_boxes[i].y1 = lcg_rand_n (src_height);
+ clip_boxes[i].x2 =
+ clip_boxes[i].x1 + lcg_rand_n (src_width - clip_boxes[i].x1);
+ clip_boxes[i].y2 =
+ clip_boxes[i].y1 + lcg_rand_n (src_height - clip_boxes[i].y1);
+
+ if (verbose)
+ {
+ printf ("source clip box: [%d,%d-%d,%d]\n",
+ clip_boxes[i].x1, clip_boxes[i].y1,
+ clip_boxes[i].x2, clip_boxes[i].y2);
+ }
+ }
+
+ pixman_region_init_rects (&clip, clip_boxes, n);
+ pixman_image_set_clip_region (src_img, &clip);
+ pixman_image_set_source_clipping (src_img, 1);
+ pixman_region_fini (&clip);
+ }
+
+ if (lcg_rand_n (8) == 0)
+ {
+ pixman_box16_t clip_boxes[2];
+ int n = lcg_rand_n (2) + 1;
+ for (i = 0; i < n; i++)
+ {
+ clip_boxes[i].x1 = lcg_rand_n (dst_width);
+ clip_boxes[i].y1 = lcg_rand_n (dst_height);
+ clip_boxes[i].x2 =
+ clip_boxes[i].x1 + lcg_rand_n (dst_width - clip_boxes[i].x1);
+ clip_boxes[i].y2 =
+ clip_boxes[i].y1 + lcg_rand_n (dst_height - clip_boxes[i].y1);
+
+ if (verbose)
+ {
+ printf ("destination clip box: [%d,%d-%d,%d]\n",
+ clip_boxes[i].x1, clip_boxes[i].y1,
+ clip_boxes[i].x2, clip_boxes[i].y2);
+ }
+ }
+ pixman_region_init_rects (&clip, clip_boxes, n);
+ pixman_image_set_clip_region (dst_img, &clip);
+ pixman_region_fini (&clip);
+ }
+
+ pixman_image_composite (op, src_img, NULL, dst_img,
+ src_x, src_y, 0, 0, dst_x, dst_y, w, h);
+
+ if (dst_fmt == PIXMAN_x8r8g8b8)
+ {
+ /* ignore unused part */
+ for (i = 0; i < dst_stride * dst_height / 4; i++)
+ dstbuf[i] &= 0xFFFFFF;
+ }
+
+ image_endian_swap (dst_img, dst_bpp * 8);
+
+ if (verbose)
+ {
+ int j;
+
+ for (i = 0; i < dst_height; i++)
+ {
+ for (j = 0; j < dst_stride; j++)
+ printf ("%02X ", *((uint8_t *)dstbuf + i * dst_stride + j));
+
+ printf ("\n");
+ }
+ }
+
+ pixman_image_unref (src_img);
+ pixman_image_unref (dst_img);
+
+ crc32 = compute_crc32 (0, dstbuf, dst_stride * dst_height);
+ free (srcbuf);
+ free (dstbuf);
+ return crc32;
+}
+
+int
+main (int argc, const char *argv[])
+{
+ pixman_disable_out_of_bounds_workaround ();
+
+ return fuzzer_test_main("scaling", 8000000, 0x7F1AB59F,
+ test_composite, argc, argv);
+}
diff --git a/pixman/test/utils.c b/pixman/test/utils.c
index 58cd100e2..4b68debff 100644
--- a/pixman/test/utils.c
+++ b/pixman/test/utils.c
@@ -1,208 +1,321 @@
-#include "utils.h"
-
-/* Random number seed
- */
-
-uint32_t lcg_seed;
-
-/*----------------------------------------------------------------------------*\
- * CRC-32 version 2.0.0 by Craig Bruce, 2006-04-29.
- *
- * This program generates the CRC-32 values for the files named in the
- * command-line arguments. These are the same CRC-32 values used by GZIP,
- * PKZIP, and ZMODEM. The Crc32_ComputeBuf () can also be detached and
- * used independently.
- *
- * THIS PROGRAM IS PUBLIC-DOMAIN SOFTWARE.
- *
- * Based on the byte-oriented implementation "File Verification Using CRC"
- * by Mark R. Nelson in Dr. Dobb's Journal, May 1992, pp. 64-67.
- *
- * v1.0.0: original release.
- * v1.0.1: fixed printf formats.
- * v1.0.2: fixed something else.
- * v1.0.3: replaced CRC constant table by generator function.
- * v1.0.4: reformatted code, made ANSI C. 1994-12-05.
- * v2.0.0: rewrote to use memory buffer & static table, 2006-04-29.
-\*----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------*\
- * NAME:
- * Crc32_ComputeBuf () - computes the CRC-32 value of a memory buffer
- * DESCRIPTION:
- * Computes or accumulates the CRC-32 value for a memory buffer.
- * The 'inCrc32' gives a previously accumulated CRC-32 value to allow
- * a CRC to be generated for multiple sequential buffer-fuls of data.
- * The 'inCrc32' for the first buffer must be zero.
- * ARGUMENTS:
- * inCrc32 - accumulated CRC-32 value, must be 0 on first call
- * buf - buffer to compute CRC-32 value for
- * bufLen - number of bytes in buffer
- * RETURNS:
- * crc32 - computed CRC-32 value
- * ERRORS:
- * (no errors are possible)
-\*----------------------------------------------------------------------------*/
-
-uint32_t
-compute_crc32 (uint32_t in_crc32,
- const void *buf,
- size_t buf_len)
-{
- static const uint32_t crc_table[256] = {
- 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
- 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
- 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
- 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
- 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
- 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
- 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
- 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
- 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
- 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
- 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106,
- 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
- 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
- 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
- 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950,
- 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
- 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
- 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
- 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA,
- 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
- 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
- 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
- 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84,
- 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
- 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
- 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
- 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E,
- 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
- 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
- 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
- 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28,
- 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
- 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
- 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
- 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
- 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
- 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
- 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
- 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
- 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
- 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
- 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
- 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
- };
-
- uint32_t crc32;
- unsigned char * byte_buf;
- size_t i;
-
- /* accumulate crc32 for buffer */
- crc32 = in_crc32 ^ 0xFFFFFFFF;
- byte_buf = (unsigned char*) buf;
-
- for (i = 0; i < buf_len; i++)
- crc32 = (crc32 >> 8) ^ crc_table[(crc32 ^ byte_buf[i]) & 0xFF];
-
- return (crc32 ^ 0xFFFFFFFF);
-}
-
-/* perform endian conversion of pixel data
- */
-void
-image_endian_swap (pixman_image_t *img, int bpp)
-{
- int stride = pixman_image_get_stride (img);
- uint32_t *data = pixman_image_get_data (img);
- int height = pixman_image_get_height (img);
- int i, j;
-
- /* swap bytes only on big endian systems */
- volatile uint16_t endian_check_var = 0x1234;
- if (*(volatile uint8_t *)&endian_check_var != 0x12)
- return;
-
- for (i = 0; i < height; i++)
- {
- uint8_t *line_data = (uint8_t *)data + stride * i;
- /* swap bytes only for 16, 24 and 32 bpp for now */
- switch (bpp)
- {
- case 1:
- for (j = 0; j < stride; j++)
- {
- line_data[j] =
- ((line_data[j] & 0x80) >> 7) |
- ((line_data[j] & 0x40) >> 5) |
- ((line_data[j] & 0x20) >> 3) |
- ((line_data[j] & 0x10) >> 1) |
- ((line_data[j] & 0x08) << 1) |
- ((line_data[j] & 0x04) << 3) |
- ((line_data[j] & 0x02) << 5) |
- ((line_data[j] & 0x01) << 7);
- }
- break;
- case 4:
- for (j = 0; j < stride; j++)
- {
- line_data[j] = (line_data[j] >> 4) | (line_data[j] << 4);
- }
- break;
- case 16:
- for (j = 0; j + 2 <= stride; j += 2)
- {
- char t1 = line_data[j + 0];
- char t2 = line_data[j + 1];
-
- line_data[j + 1] = t1;
- line_data[j + 0] = t2;
- }
- break;
- case 24:
- for (j = 0; j + 3 <= stride; j += 3)
- {
- char t1 = line_data[j + 0];
- char t2 = line_data[j + 1];
- char t3 = line_data[j + 2];
-
- line_data[j + 2] = t1;
- line_data[j + 1] = t2;
- line_data[j + 0] = t3;
- }
- break;
- case 32:
- for (j = 0; j + 4 <= stride; j += 4)
- {
- char t1 = line_data[j + 0];
- char t2 = line_data[j + 1];
- char t3 = line_data[j + 2];
- char t4 = line_data[j + 3];
-
- line_data[j + 3] = t1;
- line_data[j + 2] = t2;
- line_data[j + 1] = t3;
- line_data[j + 0] = t4;
- }
- break;
- default:
- break;
- }
- }
-}
-
-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;
-}
+#include "utils.h"
+
+/* Random number seed
+ */
+
+uint32_t lcg_seed;
+
+/*----------------------------------------------------------------------------*\
+ * CRC-32 version 2.0.0 by Craig Bruce, 2006-04-29.
+ *
+ * This program generates the CRC-32 values for the files named in the
+ * command-line arguments. These are the same CRC-32 values used by GZIP,
+ * PKZIP, and ZMODEM. The Crc32_ComputeBuf () can also be detached and
+ * used independently.
+ *
+ * THIS PROGRAM IS PUBLIC-DOMAIN SOFTWARE.
+ *
+ * Based on the byte-oriented implementation "File Verification Using CRC"
+ * by Mark R. Nelson in Dr. Dobb's Journal, May 1992, pp. 64-67.
+ *
+ * v1.0.0: original release.
+ * v1.0.1: fixed printf formats.
+ * v1.0.2: fixed something else.
+ * v1.0.3: replaced CRC constant table by generator function.
+ * v1.0.4: reformatted code, made ANSI C. 1994-12-05.
+ * v2.0.0: rewrote to use memory buffer & static table, 2006-04-29.
+\*----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------*\
+ * NAME:
+ * Crc32_ComputeBuf () - computes the CRC-32 value of a memory buffer
+ * DESCRIPTION:
+ * Computes or accumulates the CRC-32 value for a memory buffer.
+ * The 'inCrc32' gives a previously accumulated CRC-32 value to allow
+ * a CRC to be generated for multiple sequential buffer-fuls of data.
+ * The 'inCrc32' for the first buffer must be zero.
+ * ARGUMENTS:
+ * inCrc32 - accumulated CRC-32 value, must be 0 on first call
+ * buf - buffer to compute CRC-32 value for
+ * bufLen - number of bytes in buffer
+ * RETURNS:
+ * crc32 - computed CRC-32 value
+ * ERRORS:
+ * (no errors are possible)
+\*----------------------------------------------------------------------------*/
+
+uint32_t
+compute_crc32 (uint32_t in_crc32,
+ const void *buf,
+ size_t buf_len)
+{
+ static const uint32_t crc_table[256] = {
+ 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
+ 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
+ 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
+ 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
+ 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
+ 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
+ 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
+ 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
+ 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
+ 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
+ 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106,
+ 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
+ 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
+ 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
+ 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950,
+ 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
+ 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
+ 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
+ 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA,
+ 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
+ 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
+ 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
+ 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84,
+ 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
+ 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
+ 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
+ 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E,
+ 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
+ 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
+ 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
+ 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28,
+ 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
+ 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
+ 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
+ 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
+ 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
+ 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
+ 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
+ 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
+ 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
+ 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
+ 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
+ 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
+ };
+
+ uint32_t crc32;
+ unsigned char * byte_buf;
+ size_t i;
+
+ /* accumulate crc32 for buffer */
+ crc32 = in_crc32 ^ 0xFFFFFFFF;
+ byte_buf = (unsigned char*) buf;
+
+ for (i = 0; i < buf_len; i++)
+ crc32 = (crc32 >> 8) ^ crc_table[(crc32 ^ byte_buf[i]) & 0xFF];
+
+ return (crc32 ^ 0xFFFFFFFF);
+}
+
+/* perform endian conversion of pixel data
+ */
+void
+image_endian_swap (pixman_image_t *img, int bpp)
+{
+ int stride = pixman_image_get_stride (img);
+ uint32_t *data = pixman_image_get_data (img);
+ int height = pixman_image_get_height (img);
+ int i, j;
+
+ /* swap bytes only on big endian systems */
+ volatile uint16_t endian_check_var = 0x1234;
+ if (*(volatile uint8_t *)&endian_check_var != 0x12)
+ return;
+
+ for (i = 0; i < height; i++)
+ {
+ uint8_t *line_data = (uint8_t *)data + stride * i;
+ /* swap bytes only for 16, 24 and 32 bpp for now */
+ switch (bpp)
+ {
+ case 1:
+ for (j = 0; j < stride; j++)
+ {
+ line_data[j] =
+ ((line_data[j] & 0x80) >> 7) |
+ ((line_data[j] & 0x40) >> 5) |
+ ((line_data[j] & 0x20) >> 3) |
+ ((line_data[j] & 0x10) >> 1) |
+ ((line_data[j] & 0x08) << 1) |
+ ((line_data[j] & 0x04) << 3) |
+ ((line_data[j] & 0x02) << 5) |
+ ((line_data[j] & 0x01) << 7);
+ }
+ break;
+ case 4:
+ for (j = 0; j < stride; j++)
+ {
+ line_data[j] = (line_data[j] >> 4) | (line_data[j] << 4);
+ }
+ break;
+ case 16:
+ for (j = 0; j + 2 <= stride; j += 2)
+ {
+ char t1 = line_data[j + 0];
+ char t2 = line_data[j + 1];
+
+ line_data[j + 1] = t1;
+ line_data[j + 0] = t2;
+ }
+ break;
+ case 24:
+ for (j = 0; j + 3 <= stride; j += 3)
+ {
+ char t1 = line_data[j + 0];
+ char t2 = line_data[j + 1];
+ char t3 = line_data[j + 2];
+
+ line_data[j + 2] = t1;
+ line_data[j + 1] = t2;
+ line_data[j + 0] = t3;
+ }
+ break;
+ case 32:
+ for (j = 0; j + 4 <= stride; j += 4)
+ {
+ char t1 = line_data[j + 0];
+ char t2 = line_data[j + 1];
+ char t3 = line_data[j + 2];
+ char t4 = line_data[j + 3];
+
+ line_data[j + 3] = t1;
+ line_data[j + 2] = t2;
+ line_data[j + 1] = t3;
+ line_data[j + 0] = t4;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+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;
+}
+
+/*
+ * A function, which can be used as a core part of the test programs,
+ * intended to detect various problems with the help of fuzzing input
+ * to pixman API (according to some templates, aka "smart" fuzzing).
+ * Some general information about such testing can be found here:
+ * http://en.wikipedia.org/wiki/Fuzz_testing
+ *
+ * It may help detecting:
+ * - crashes on bad handling of valid or reasonably invalid input to
+ * pixman API.
+ * - deviations from the behavior of older pixman releases.
+ * - deviations from the behavior of the same pixman release, but
+ * configured in a different way (for example with SIMD optimizations
+ * disabled), or running on a different OS or hardware.
+ *
+ * The test is performed by calling a callback function a huge number
+ * of times. The callback function is expected to run some snippet of
+ * pixman code with pseudorandom variations to the data feeded to
+ * pixman API. A result of running each callback function should be
+ * some deterministic value which depends on test number (test number
+ * can be used as a seed for PRNG). When 'verbose' argument is nonzero,
+ * callback function is expected to print to stdout some information
+ * about what it does.
+ *
+ * Return values from many small tests are accumulated together and
+ * used as final checksum, which can be compared to some expected
+ * value. Running the tests not individually, but in a batch helps
+ * to reduce process start overhead and also allows to parallelize
+ * testing and utilize multiple CPU cores.
+ *
+ * The resulting executable can be run without any arguments. In
+ * this case it runs a batch of tests starting from 1 and up to
+ * 'default_number_of_iterations'. The resulting checksum is
+ * compared with 'expected_checksum' and FAIL or PASS verdict
+ * depends on the result of this comparison.
+ *
+ * If the executable is run with 2 numbers provided as command line
+ * arguments, they specify the starting and ending numbers for a test
+ * batch.
+ *
+ * If the executable is run with only one number provided as a command
+ * line argument, then this number is used to call the callback function
+ * once, and also with verbose flag set.
+ */
+int
+fuzzer_test_main (const char *test_name,
+ int default_number_of_iterations,
+ uint32_t expected_checksum,
+ uint32_t (*test_function)(int testnum, int verbose),
+ int argc,
+ const char *argv[])
+{
+ int i, n1 = 1, n2 = 0;
+ uint32_t checksum = 0;
+ int verbose = getenv ("VERBOSE") != NULL;
+
+ if (argc >= 3)
+ {
+ n1 = atoi (argv[1]);
+ n2 = atoi (argv[2]);
+ if (n2 < n1)
+ {
+ printf ("invalid test range\n");
+ return 1;
+ }
+ }
+ else if (argc >= 2)
+ {
+ n2 = atoi (argv[1]);
+ checksum = test_function (n2, 1);
+ printf ("%d: checksum=%08X\n", n2, checksum);
+ return 0;
+ }
+ else
+ {
+ n1 = 1;
+ n2 = default_number_of_iterations;
+ }
+
+#ifdef USE_OPENMP
+ #pragma omp parallel for reduction(+:checksum) default(none) \
+ shared(n1, n2, test_function, verbose)
+#endif
+ for (i = n1; i <= n2; i++)
+ {
+ uint32_t crc = test_function (i, 0);
+ if (verbose)
+ printf ("%d: %08X\n", i, crc);
+ checksum += crc;
+ }
+
+ if (n1 == 1 && n2 == default_number_of_iterations)
+ {
+ if (checksum == expected_checksum)
+ {
+ printf ("%s test passed (checksum=%08X)\n",
+ test_name, checksum);
+ }
+ else
+ {
+ printf ("%s test failed! (checksum=%08X, expected %08X)\n",
+ test_name, checksum, expected_checksum);
+ return 1;
+ }
+ }
+ else
+ {
+ printf ("%d-%d: checksum=%08X\n", n1, n2, checksum);
+ }
+
+ return 0;
+}
diff --git a/pixman/test/utils.h b/pixman/test/utils.h
index fb1ccec48..39b49b2c1 100644
--- a/pixman/test/utils.h
+++ b/pixman/test/utils.h
@@ -1,45 +1,64 @@
-#include <stdlib.h>
-#include <config.h>
-#include "pixman-private.h" /* For 'inline' definition */
-
-/* A primitive pseudorandom number generator,
- * taken from POSIX.1-2001 example
- */
-
-extern uint32_t lcg_seed;
-
-static inline uint32_t
-lcg_rand (void)
-{
- lcg_seed = lcg_seed * 1103515245 + 12345;
- return ((uint32_t)(lcg_seed / 65536) % 32768);
-}
-
-static inline void
-lcg_srand (uint32_t seed)
-{
- lcg_seed = seed;
-}
-
-static inline uint32_t
-lcg_rand_n (int max)
-{
- return lcg_rand () % max;
-}
-
-
-/* CRC 32 computation
- */
-uint32_t
-compute_crc32 (uint32_t in_crc32,
- const void *buf,
- size_t buf_len);
-
-/* perform endian conversion of pixel data
- */
-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);
+#include <stdlib.h>
+#include <config.h>
+#include "pixman-private.h" /* For 'inline' definition */
+
+/* A primitive pseudorandom number generator,
+ * taken from POSIX.1-2001 example
+ */
+
+extern uint32_t lcg_seed;
+#ifdef USE_OPENMP
+#pragma omp threadprivate(lcg_seed)
+#endif
+
+static inline uint32_t
+lcg_rand (void)
+{
+ lcg_seed = lcg_seed * 1103515245 + 12345;
+ return ((uint32_t)(lcg_seed / 65536) % 32768);
+}
+
+static inline void
+lcg_srand (uint32_t seed)
+{
+ lcg_seed = seed;
+}
+
+static inline uint32_t
+lcg_rand_n (int max)
+{
+ return lcg_rand () % max;
+}
+
+static inline uint32_t
+lcg_rand_N (int max)
+{
+ uint32_t lo = lcg_rand ();
+ uint32_t hi = lcg_rand () << 15;
+ return (lo | hi) % max;
+}
+
+/* CRC 32 computation
+ */
+uint32_t
+compute_crc32 (uint32_t in_crc32,
+ const void *buf,
+ size_t buf_len);
+
+/* perform endian conversion of pixel data
+ */
+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);
+
+/* main body of the fuzzer test */
+int
+fuzzer_test_main (const char *test_name,
+ int default_number_of_iterations,
+ uint32_t expected_checksum,
+ uint32_t (*test_function)(int testnum, int verbose),
+ int argc,
+ const char *argv[]);