aboutsummaryrefslogtreecommitdiff
path: root/pixman/test
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-11-20 13:20:24 +0000
committermarha <marha@users.sourceforge.net>2009-11-20 13:20:24 +0000
commit4ac4a5b7ce8cc8f195d69a42da10d386eaa5c056 (patch)
treefb29d9eeba83a773d22cf396d1b0a549fb95cc11 /pixman/test
parent2e4def74ad9278c142d07ffa91f51035dc49cf77 (diff)
downloadvcxsrv-4ac4a5b7ce8cc8f195d69a42da10d386eaa5c056.tar.gz
vcxsrv-4ac4a5b7ce8cc8f195d69a42da10d386eaa5c056.tar.bz2
vcxsrv-4ac4a5b7ce8cc8f195d69a42da10d386eaa5c056.zip
Update to pixman-0.17.2
Diffstat (limited to 'pixman/test')
-rw-r--r--pixman/test/Makefile.am27
-rw-r--r--pixman/test/Makefile.in138
-rw-r--r--pixman/test/alpha-test.c12
-rw-r--r--pixman/test/blitters-test.c224
-rw-r--r--pixman/test/clip-in.c2
-rw-r--r--pixman/test/clip-test.c4
-rw-r--r--pixman/test/composite-test.c7
-rw-r--r--pixman/test/composite.c901
-rw-r--r--pixman/test/convolution-test.c2
-rw-r--r--pixman/test/gradient-test.c10
-rw-r--r--pixman/test/gtk-utils.c113
-rw-r--r--pixman/test/gtk-utils.h13
-rw-r--r--pixman/test/scaling-test.c207
-rw-r--r--pixman/test/screen-test.c2
-rw-r--r--pixman/test/trap-test.c2
-rw-r--r--pixman/test/utils.c281
-rw-r--r--pixman/test/utils.h43
-rw-r--r--pixman/test/window-test.c2
18 files changed, 1391 insertions, 599 deletions
diff --git a/pixman/test/Makefile.am b/pixman/test/Makefile.am
index c56f62de7..89d32e96f 100644
--- a/pixman/test/Makefile.am
+++ b/pixman/test/Makefile.am
@@ -5,6 +5,7 @@ TESTPROGRAMS = \
region-test \
scaling-test \
blitters-test \
+ composite \
fetch-test \
oob-test \
window-test \
@@ -12,17 +13,23 @@ TESTPROGRAMS = \
fetch_test_LDADD = $(TEST_LDADD)
region_test_LDADD = $(TEST_LDADD)
-scaling_test_LDADD = $(TEST_LDADD)
-blitters_test_LDADD = $(TEST_LDADD)
+composite_LDADD = $(TEST_LDADD)
trap_crasher_LDADD = $(TEST_LDADD)
oob_test_LDADD = $(TEST_LDADD)
window_test_LDADD = $(TEST_LDADD)
+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
+
# GTK using test programs
if HAVE_GTK
GTK_LDADD = $(TEST_LDADD) $(GTK_LIBS)
+GTK_UTILS = gtk-utils.c gtk-utils.h
TESTPROGRAMS += \
clip-test \
@@ -37,28 +44,28 @@ TESTPROGRAMS += \
INCLUDES += $(GTK_CFLAGS)
gradient_test_LDADD = $(GTK_LDADD)
-gradient_test_SOURCES = gradient-test.c utils.c utils.h
+gradient_test_SOURCES = gradient-test.c $(GTK_UTILS)
alpha_test_LDADD = $(GTK_LDADD)
-alpha_test_SOURCES = alpha-test.c utils.c utils.h
+alpha_test_SOURCES = alpha-test.c $(GTK_UTILS)
composite_test_LDADD = $(GTK_LDADD)
-composite_test_SOURCES = composite-test.c utils.c utils.h
+composite_test_SOURCES = composite-test.c $(GTK_UTILS)
clip_test_LDADD = $(GTK_LDADD)
-clip_test_SOURCES = clip-test.c utils.c utils.h
+clip_test_SOURCES = clip-test.c $(GTK_UTILS)
clip_in_LDADD = $(GTK_LDADD)
-clip_in_SOURCES = clip-in.c utils.c utils.h
+clip_in_SOURCES = clip-in.c $(GTK_UTILS)
trap_test_LDADD = $(GTK_LDADD)
-trap_test_SOURCES = trap-test.c utils.c utils.h
+trap_test_SOURCES = trap-test.c $(GTK_UTILS)
screen_test_LDADD = $(GTK_LDADD)
-screen_test_SOURCES = screen-test.c utils.c utils.h
+screen_test_SOURCES = screen-test.c $(GTK_UTILS)
convolution_test_LDADD = $(GTK_LDADD)
-convolution_test_SOURCES = convolution-test.c utils.c utils.h
+convolution_test_SOURCES = convolution-test.c $(GTK_UTILS)
endif
diff --git a/pixman/test/Makefile.in b/pixman/test/Makefile.in
index f05356b02..4c19caf94 100644
--- a/pixman/test/Makefile.in
+++ b/pixman/test/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -58,45 +58,53 @@ CONFIG_CLEAN_FILES =
@HAVE_GTK_TRUE@ alpha-test$(EXEEXT) screen-test$(EXEEXT) \
@HAVE_GTK_TRUE@ convolution-test$(EXEEXT) trap-test$(EXEEXT)
am__EXEEXT_2 = region-test$(EXEEXT) scaling-test$(EXEEXT) \
- blitters-test$(EXEEXT) fetch-test$(EXEEXT) oob-test$(EXEEXT) \
- window-test$(EXEEXT) trap-crasher$(EXEEXT) $(am__EXEEXT_1)
+ blitters-test$(EXEEXT) composite$(EXEEXT) fetch-test$(EXEEXT) \
+ oob-test$(EXEEXT) window-test$(EXEEXT) trap-crasher$(EXEEXT) \
+ $(am__EXEEXT_1)
PROGRAMS = $(noinst_PROGRAMS)
-am__alpha_test_SOURCES_DIST = alpha-test.c utils.c utils.h
+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@ utils.$(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)
-blitters_test_SOURCES = blitters-test.c
-blitters_test_OBJECTS = blitters-test.$(OBJEXT)
+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 utils.c utils.h
-@HAVE_GTK_TRUE@am_clip_in_OBJECTS = clip-in.$(OBJEXT) utils.$(OBJEXT)
+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 utils.c utils.h
+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@ utils.$(OBJEXT)
+@HAVE_GTK_TRUE@ $(am__objects_1)
clip_test_OBJECTS = $(am_clip_test_OBJECTS)
@HAVE_GTK_TRUE@clip_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-am__composite_test_SOURCES_DIST = composite-test.c utils.c utils.h
+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@ utils.$(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 utils.c utils.h
+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) utils.$(OBJEXT)
+@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 utils.c utils.h
+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@ utils.$(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
@@ -105,20 +113,20 @@ oob_test_DEPENDENCIES = $(TEST_LDADD)
region_test_SOURCES = region-test.c
region_test_OBJECTS = region-test.$(OBJEXT)
region_test_DEPENDENCIES = $(TEST_LDADD)
-scaling_test_SOURCES = scaling-test.c
-scaling_test_OBJECTS = scaling-test.$(OBJEXT)
+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 utils.c utils.h
+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@ utils.$(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 utils.c utils.h
+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@ utils.$(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
@@ -136,49 +144,56 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
-SOURCES = $(alpha_test_SOURCES) blitters-test.c $(clip_in_SOURCES) \
- $(clip_test_SOURCES) $(composite_test_SOURCES) \
- $(convolution_test_SOURCES) fetch-test.c \
- $(gradient_test_SOURCES) oob-test.c region-test.c \
- scaling-test.c $(screen_test_SOURCES) trap-crasher.c \
+SOURCES = $(alpha_test_SOURCES) $(blitters_test_SOURCES) \
+ $(clip_in_SOURCES) $(clip_test_SOURCES) composite.c \
+ $(composite_test_SOURCES) $(convolution_test_SOURCES) \
+ fetch-test.c $(gradient_test_SOURCES) oob-test.c region-test.c \
+ $(scaling_test_SOURCES) $(screen_test_SOURCES) trap-crasher.c \
$(trap_test_SOURCES) window-test.c
-DIST_SOURCES = $(am__alpha_test_SOURCES_DIST) blitters-test.c \
+DIST_SOURCES = $(am__alpha_test_SOURCES_DIST) $(blitters_test_SOURCES) \
$(am__clip_in_SOURCES_DIST) $(am__clip_test_SOURCES_DIST) \
- $(am__composite_test_SOURCES_DIST) \
+ composite.c $(am__composite_test_SOURCES_DIST) \
$(am__convolution_test_SOURCES_DIST) fetch-test.c \
$(am__gradient_test_SOURCES_DIST) oob-test.c region-test.c \
- scaling-test.c $(am__screen_test_SOURCES_DIST) trap-crasher.c \
- $(am__trap_test_SOURCES_DIST) window-test.c
+ $(scaling_test_SOURCES) $(am__screen_test_SOURCES_DIST) \
+ trap-crasher.c $(am__trap_test_SOURCES_DIST) window-test.c
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
-ARM_NEON_CFLAGS = @ARM_NEON_CFLAGS@
ARM_SIMD_CFLAGS = @ARM_SIMD_CFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEP_CFLAGS = @DEP_CFLAGS@
DEP_LIBS = @DEP_LIBS@
DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
+ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
-FGREP = @FGREP@
+F77 = @F77@
+FFLAGS = @FFLAGS@
GREP = @GREP@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_LIBS = @GTK_LIBS@
@@ -187,12 +202,10 @@ 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@
@@ -200,12 +213,8 @@ 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@
@@ -233,7 +242,8 @@ 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@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -264,7 +274,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
@@ -283,34 +292,38 @@ top_srcdir = @top_srcdir@
TEST_LDADD = $(top_builddir)/pixman/libpixman-1.la
INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman \
$(am__append_2)
-TESTPROGRAMS = region-test scaling-test blitters-test fetch-test \
- oob-test window-test trap-crasher $(am__append_1)
+TESTPROGRAMS = region-test scaling-test blitters-test composite \
+ fetch-test oob-test window-test trap-crasher $(am__append_1)
fetch_test_LDADD = $(TEST_LDADD)
region_test_LDADD = $(TEST_LDADD)
-scaling_test_LDADD = $(TEST_LDADD)
-blitters_test_LDADD = $(TEST_LDADD)
+composite_LDADD = $(TEST_LDADD)
trap_crasher_LDADD = $(TEST_LDADD)
oob_test_LDADD = $(TEST_LDADD)
window_test_LDADD = $(TEST_LDADD)
+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
# 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@gradient_test_LDADD = $(GTK_LDADD)
-@HAVE_GTK_TRUE@gradient_test_SOURCES = gradient-test.c utils.c utils.h
+@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 utils.c utils.h
+@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 utils.c utils.h
+@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 utils.c utils.h
+@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 utils.c utils.h
+@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 utils.c utils.h
+@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 utils.c utils.h
+@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 utils.c utils.h
+@HAVE_GTK_TRUE@convolution_test_SOURCES = convolution-test.c $(GTK_UTILS)
all: all-am
.SUFFIXES:
@@ -319,14 +332,14 @@ $(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; }; \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
exit 1;; \
esac; \
done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \
cd $(top_srcdir) && \
- $(AUTOMAKE) --gnu test/Makefile
+ $(AUTOMAKE) --foreign test/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -363,6 +376,9 @@ clip-in$(EXEEXT): $(clip_in_OBJECTS) $(clip_in_DEPENDENCIES)
clip-test$(EXEEXT): $(clip_test_OBJECTS) $(clip_test_DEPENDENCIES)
@rm -f clip-test$(EXEEXT)
$(LINK) $(clip_test_OBJECTS) $(clip_test_LDADD) $(LIBS)
+composite$(EXEEXT): $(composite_OBJECTS) $(composite_DEPENDENCIES)
+ @rm -f composite$(EXEEXT)
+ $(LINK) $(composite_OBJECTS) $(composite_LDADD) $(LIBS)
composite-test$(EXEEXT): $(composite_test_OBJECTS) $(composite_test_DEPENDENCIES)
@rm -f composite-test$(EXEEXT)
$(LINK) $(composite_test_OBJECTS) $(composite_test_LDADD) $(LIBS)
@@ -408,9 +424,11 @@ distclean-compile:
@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@
@@ -452,7 +470,7 @@ ID: $(HEADERS) $(SOURCES) $(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; } \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
diff --git a/pixman/test/alpha-test.c b/pixman/test/alpha-test.c
index e2b97c789..92c208142 100644
--- a/pixman/test/alpha-test.c
+++ b/pixman/test/alpha-test.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "pixman.h"
-#include "utils.h"
+#include "gtk-utils.h"
int
main (int argc, char **argv)
@@ -14,7 +14,6 @@ main (int argc, char **argv)
uint32_t *src = malloc (WIDTH * HEIGHT * 4);
pixman_image_t *grad_img;
pixman_image_t *alpha_img;
- pixman_image_t *solid_img;
pixman_image_t *dest_img;
pixman_image_t *src_img;
int i;
@@ -26,24 +25,25 @@ main (int argc, char **argv)
pixman_point_fixed_t p1 = { pixman_double_to_fixed (0), 0 };
pixman_point_fixed_t p2 = { pixman_double_to_fixed (WIDTH),
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) }
}
};
-
- pixman_transform_t id = {
+#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;
- pixman_color_t red = { 0xffff, 0x0000, 0x0000, 0xffff };
for (i = 0; i < WIDTH * HEIGHT; ++i)
alpha[i] = 0x4f00004f; /* pale blue */
@@ -91,7 +91,7 @@ main (int argc, char **argv)
grad_img = pixman_image_create_linear_gradient (&p1, &p2,
stops, 2);
- pixman_image_set_transform (grad_img, &id);
+ pixman_image_set_transform (grad_img, &trans);
pixman_image_set_repeat (grad_img, PIXMAN_REPEAT_PAD);
pixman_image_composite (PIXMAN_OP_OVER, grad_img, NULL, alpha_img,
diff --git a/pixman/test/blitters-test.c b/pixman/test/blitters-test.c
index ba9900a79..ac816eba1 100644
--- a/pixman/test/blitters-test.c
+++ b/pixman/test/blitters-test.c
@@ -25,38 +25,18 @@
#include <stdlib.h>
#include <stdio.h>
#include <config.h>
-#include "pixman.h"
+#include "utils.h"
/* A primitive pseudorandom number generator, taken from POSIX.1-2001 example */
-static 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;
-}
-
static void *
aligned_malloc (size_t align, size_t size)
{
void *result;
#ifdef HAVE_POSIX_MEMALIGN
- posix_memalign (&result, align, size);
+ if (posix_memalign (&result, align, size) != 0)
+ result = NULL;
#else
result = malloc (size);
#endif
@@ -64,192 +44,6 @@ aligned_malloc (size_t align, size_t size)
return result;
}
-/*----------------------------------------------------------------------------*\
- * 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)
-\*----------------------------------------------------------------------------*/
-
-static 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 */
-static 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;
- }
- }
-}
-
/* Create random image for testing purposes */
static pixman_image_t *
create_random_image (pixman_format_code_t *allowed_formats,
@@ -302,7 +96,7 @@ free_random_image (uint32_t initcrc,
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);;
+ int height = pixman_image_get_height (img);
if (fmt != -1)
{
@@ -472,6 +266,7 @@ test_composite (uint32_t initcrc, int testnum, int verbose)
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;
@@ -515,6 +310,8 @@ test_composite (uint32_t initcrc, int testnum, int verbose)
mask_img = NULL;
mask_fmt = -1;
+ mask_x = 0;
+ mask_y = 0;
if (lcg_rand_n (2))
{
@@ -533,6 +330,9 @@ test_composite (uint32_t initcrc, int testnum, int verbose)
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));
}
src_width = pixman_image_get_width (src_img);
@@ -567,7 +367,7 @@ test_composite (uint32_t initcrc, int testnum, int verbose)
}
pixman_image_composite (op, src_img, mask_img, dst_img,
- src_x, src_y, src_x, src_y, dst_x, dst_y, w, h);
+ src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h);
if (verbose)
{
@@ -640,7 +440,7 @@ main (int argc, char *argv[])
/* Predefined value for running with all the fastpath functions
disabled. It needs to be updated every time when changes are
introduced to this program or behavior of pixman changes! */
- if (crc == 0x06D8EDB6)
+ if (crc == 0x1911E2C3)
{
printf ("blitters test passed\n");
}
diff --git a/pixman/test/clip-in.c b/pixman/test/clip-in.c
index 55459b204..51579811f 100644
--- a/pixman/test/clip-in.c
+++ b/pixman/test/clip-in.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include "pixman.h"
-#include "utils.h"
+#include "gtk-utils.h"
/* This test demonstrates that clipping is done totally different depending
* on whether the source is transformed or not.
diff --git a/pixman/test/clip-test.c b/pixman/test/clip-test.c
index 900013718..aa0df4482 100644
--- a/pixman/test/clip-test.c
+++ b/pixman/test/clip-test.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "pixman.h"
-#include "utils.h"
+#include "gtk-utils.h"
#define WIDTH 200
#define HEIGHT 200
@@ -31,9 +31,11 @@ main (int argc, char **argv)
{ pixman_int_to_fixed (0), { 0xffff, 0x0000, 0x0000, 0xffff } },
{ pixman_int_to_fixed (1), { 0xffff, 0xffff, 0x0000, 0xffff } }
};
+#if 0
pixman_point_fixed_t p1 = { 0, 0 };
pixman_point_fixed_t p2 = { pixman_int_to_fixed (WIDTH),
pixman_int_to_fixed (HEIGHT) };
+#endif
pixman_point_fixed_t c_inner;
pixman_point_fixed_t c_outer;
pixman_fixed_t r_inner;
diff --git a/pixman/test/composite-test.c b/pixman/test/composite-test.c
index 49e0220a4..5401abfdf 100644
--- a/pixman/test/composite-test.c
+++ b/pixman/test/composite-test.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "pixman.h"
-#include "utils.h"
+#include "gtk-utils.h"
#define WIDTH 60
#define HEIGHT 60
@@ -77,6 +77,9 @@ writer (void *src, uint32_t value, int size)
case 4:
*(uint32_t *)src = value;
break;
+
+ default:
+ break;
}
}
@@ -113,7 +116,7 @@ main (int argc, char **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size (window, 800, 600);
+ gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_main_quit),
diff --git a/pixman/test/composite.c b/pixman/test/composite.c
new file mode 100644
index 000000000..0624cd37d
--- /dev/null
+++ b/pixman/test/composite.c
@@ -0,0 +1,901 @@
+/*
+ * Copyright © 2005 Eric Anholt
+ * Copyright © 2009 Chris Wilson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <pixman.h>
+#include <stdio.h>
+#include <stdlib.h> /* abort() */
+#include <math.h>
+#include <config.h>
+
+#define FALSE 0
+#define TRUE !FALSE
+
+#define ARRAY_LENGTH(A) ((int) (sizeof (A) / sizeof ((A) [0])))
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+
+typedef struct color_t color_t;
+typedef struct format_t format_t;
+typedef struct image_t image_t;
+typedef struct operator_t operator_t;
+
+struct color_t
+{
+ double r, g, b, a;
+};
+
+struct format_t
+{
+ pixman_format_code_t format;
+ const char *name;
+};
+
+static color_t colors[] =
+{
+ /* these are premultiplied in main() */
+ { 1.0, 1.0, 1.0, 1.0 },
+ { 1.0, 0.0, 0.0, 1.0 },
+ { 0.0, 1.0, 0.0, 1.0 },
+ { 0.0, 0.0, 1.0, 1.0 },
+ { 0.0, 0.0, 0.0, 1.0 },
+ { 0.5, 0.0, 0.0, 0.5 },
+};
+
+static uint16_t
+_color_double_to_short (double d)
+{
+ uint32_t i;
+
+ i = (uint32_t) (d * 65536);
+ i -= (i >> 16);
+
+ return i;
+}
+
+static void
+compute_pixman_color (const color_t *color,
+ pixman_color_t *out)
+{
+ out->red = _color_double_to_short (color->r);
+ out->green = _color_double_to_short (color->g);
+ out->blue = _color_double_to_short (color->b);
+ out->alpha = _color_double_to_short (color->a);
+}
+
+static const format_t formats[] =
+{
+#define P(x) { PIXMAN_##x, #x }
+ P(a8),
+
+ /* 32bpp formats */
+ P(a8r8g8b8),
+ P(x8r8g8b8),
+ P(a8b8g8r8),
+ P(x8b8g8r8),
+ P(b8g8r8a8),
+ P(b8g8r8x8),
+
+ /* XXX: and here the errors begin! */
+#if 0
+ P(x2r10g10b10),
+ P(a2r10g10b10),
+ P(x2b10g10r10),
+ P(a2b10g10r10),
+
+ /* 24bpp formats */
+ P(r8g8b8),
+ P(b8g8r8),
+
+ /* 16bpp formats */
+ P(r5g6b5),
+ P(b5g6r5),
+
+ P(a1r5g5b5),
+ P(x1r5g5b5),
+ P(a1b5g5r5),
+ P(x1b5g5r5),
+ P(a4r4g4b4),
+ P(x4r4g4b4),
+ P(a4b4g4r4),
+ P(x4b4g4r4),
+
+ /* 8bpp formats */
+ P(a8),
+ P(r3g3b2),
+ P(b2g3r3),
+ P(a2r2g2b2),
+ P(a2b2g2r2),
+
+ P(x4a4),
+
+ /* 4bpp formats */
+ P(a4),
+ P(r1g2b1),
+ P(b1g2r1),
+ P(a1r1g1b1),
+ P(a1b1g1r1),
+
+ /* 1bpp formats */
+ P(a1)
+#endif
+#undef P
+};
+
+struct image_t
+{
+ pixman_image_t *image;
+ const format_t *format;
+ const color_t *color;
+ pixman_repeat_t repeat;
+ int size;
+};
+
+struct operator_t
+{
+ pixman_op_t op;
+ const char *name;
+};
+
+static const operator_t operators[] =
+{
+#define P(x) { PIXMAN_OP_##x, #x }
+ P(CLEAR),
+ P(SRC),
+ P(DST),
+ P(OVER),
+ P(OVER_REVERSE),
+ P(IN),
+ P(IN_REVERSE),
+ P(OUT),
+ P(OUT_REVERSE),
+ P(ATOP),
+ P(ATOP_REVERSE),
+ P(XOR),
+ P(ADD),
+ P(SATURATE),
+
+ P(DISJOINT_CLEAR),
+ P(DISJOINT_SRC),
+ P(DISJOINT_DST),
+ P(DISJOINT_OVER),
+ P(DISJOINT_OVER_REVERSE),
+ P(DISJOINT_IN),
+ P(DISJOINT_IN_REVERSE),
+ P(DISJOINT_OUT),
+ P(DISJOINT_OUT_REVERSE),
+ P(DISJOINT_ATOP),
+ P(DISJOINT_ATOP_REVERSE),
+ P(DISJOINT_XOR),
+
+ P(CONJOINT_CLEAR),
+ P(CONJOINT_SRC),
+ P(CONJOINT_DST),
+ P(CONJOINT_OVER),
+ P(CONJOINT_OVER_REVERSE),
+ P(CONJOINT_IN),
+ P(CONJOINT_IN_REVERSE),
+ P(CONJOINT_OUT),
+ P(CONJOINT_OUT_REVERSE),
+ P(CONJOINT_ATOP),
+ P(CONJOINT_ATOP_REVERSE),
+ P(CONJOINT_XOR),
+#undef P
+};
+
+static double
+calc_op (pixman_op_t op, double src, double dst, double srca, double dsta)
+{
+#define mult_chan(src, dst, Fa, Fb) min ((src) * (Fa) + (dst) * (Fb), 1.0)
+
+ double Fa, Fb;
+
+ switch (op)
+ {
+ case PIXMAN_OP_CLEAR:
+ case PIXMAN_OP_DISJOINT_CLEAR:
+ case PIXMAN_OP_CONJOINT_CLEAR:
+ return mult_chan (src, dst, 0.0, 0.0);
+
+ case PIXMAN_OP_SRC:
+ case PIXMAN_OP_DISJOINT_SRC:
+ case PIXMAN_OP_CONJOINT_SRC:
+ return mult_chan (src, dst, 1.0, 0.0);
+
+ case PIXMAN_OP_DST:
+ case PIXMAN_OP_DISJOINT_DST:
+ case PIXMAN_OP_CONJOINT_DST:
+ return mult_chan (src, dst, 0.0, 1.0);
+
+ case PIXMAN_OP_OVER:
+ return mult_chan (src, dst, 1.0, 1.0 - srca);
+
+ case PIXMAN_OP_OVER_REVERSE:
+ return mult_chan (src, dst, 1.0 - dsta, 1.0);
+
+ case PIXMAN_OP_IN:
+ return mult_chan (src, dst, dsta, 0.0);
+
+ case PIXMAN_OP_IN_REVERSE:
+ return mult_chan (src, dst, 0.0, srca);
+
+ case PIXMAN_OP_OUT:
+ return mult_chan (src, dst, 1.0 - dsta, 0.0);
+
+ case PIXMAN_OP_OUT_REVERSE:
+ return mult_chan (src, dst, 0.0, 1.0 - srca);
+
+ case PIXMAN_OP_ATOP:
+ return mult_chan (src, dst, dsta, 1.0 - srca);
+
+ case PIXMAN_OP_ATOP_REVERSE:
+ return mult_chan (src, dst, 1.0 - dsta, srca);
+
+ case PIXMAN_OP_XOR:
+ return mult_chan (src, dst, 1.0 - dsta, 1.0 - srca);
+
+ case PIXMAN_OP_ADD:
+ return mult_chan (src, dst, 1.0, 1.0);
+
+ case PIXMAN_OP_SATURATE:
+ case PIXMAN_OP_DISJOINT_OVER_REVERSE:
+ if (srca == 0.0)
+ Fa = 1.0;
+ else
+ Fa = min (1.0, (1.0 - dsta) / srca);
+ return mult_chan (src, dst, Fa, 1.0);
+
+ case PIXMAN_OP_DISJOINT_OVER:
+ if (dsta == 0.0)
+ Fb = 1.0;
+ else
+ Fb = min (1.0, (1.0 - srca) / dsta);
+ return mult_chan (src, dst, 1.0, Fb);
+
+ case PIXMAN_OP_DISJOINT_IN:
+ if (srca == 0.0)
+ Fa = 0.0;
+ else
+ Fa = max (0.0, 1.0 - (1.0 - dsta) / srca);
+ return mult_chan (src, dst, Fa, 0.0);
+
+ case PIXMAN_OP_DISJOINT_IN_REVERSE:
+ if (dsta == 0.0)
+ Fb = 0.0;
+ else
+ Fb = max (0.0, 1.0 - (1.0 - srca) / dsta);
+ return mult_chan (src, dst, 0.0, Fb);
+
+ case PIXMAN_OP_DISJOINT_OUT:
+ if (srca == 0.0)
+ Fa = 1.0;
+ else
+ Fa = min (1.0, (1.0 - dsta) / srca);
+ return mult_chan (src, dst, Fa, 0.0);
+
+ case PIXMAN_OP_DISJOINT_OUT_REVERSE:
+ if (dsta == 0.0)
+ Fb = 1.0;
+ else
+ Fb = min (1.0, (1.0 - srca) / dsta);
+ return mult_chan (src, dst, 0.0, Fb);
+
+ case PIXMAN_OP_DISJOINT_ATOP:
+ if (srca == 0.0)
+ Fa = 0.0;
+ else
+ Fa = max (0.0, 1.0 - (1.0 - dsta) / srca);
+ if (dsta == 0.0)
+ Fb = 1.0;
+ else
+ Fb = min (1.0, (1.0 - srca) / dsta);
+ return mult_chan (src, dst, Fa, Fb);
+
+ case PIXMAN_OP_DISJOINT_ATOP_REVERSE:
+ if (srca == 0.0)
+ Fa = 1.0;
+ else
+ Fa = min (1.0, (1.0 - dsta) / srca);
+ if (dsta == 0.0)
+ Fb = 0.0;
+ else
+ Fb = max (0.0, 1.0 - (1.0 - srca) / dsta);
+ return mult_chan (src, dst, Fa, Fb);
+
+ case PIXMAN_OP_DISJOINT_XOR:
+ if (srca == 0.0)
+ Fa = 1.0;
+ else
+ Fa = min (1.0, (1.0 - dsta) / srca);
+ if (dsta == 0.0)
+ Fb = 1.0;
+ else
+ Fb = min (1.0, (1.0 - srca) / dsta);
+ return mult_chan (src, dst, Fa, Fb);
+
+ case PIXMAN_OP_CONJOINT_OVER:
+ if (dsta == 0.0)
+ Fb = 0.0;
+ else
+ Fb = max (0.0, 1.0 - srca / dsta);
+ return mult_chan (src, dst, 1.0, Fb);
+
+ case PIXMAN_OP_CONJOINT_OVER_REVERSE:
+ if (srca == 0.0)
+ Fa = 0.0;
+ else
+ Fa = max (0.0, 1.0 - dsta / srca);
+ return mult_chan (src, dst, Fa, 1.0);
+
+ case PIXMAN_OP_CONJOINT_IN:
+ if (srca == 0.0)
+ Fa = 1.0;
+ else
+ Fa = min (1.0, dsta / srca);
+ return mult_chan (src, dst, Fa, 0.0);
+
+ case PIXMAN_OP_CONJOINT_IN_REVERSE:
+ if (dsta == 0.0)
+ Fb = 1.0;
+ else
+ Fb = min (1.0, srca / dsta);
+ return mult_chan (src, dst, 0.0, Fb);
+
+ case PIXMAN_OP_CONJOINT_OUT:
+ if (srca == 0.0)
+ Fa = 0.0;
+ else
+ Fa = max (0.0, 1.0 - dsta / srca);
+ return mult_chan (src, dst, Fa, 0.0);
+
+ case PIXMAN_OP_CONJOINT_OUT_REVERSE:
+ if (dsta == 0.0)
+ Fb = 0.0;
+ else
+ Fb = max (0.0, 1.0 - srca / dsta);
+ return mult_chan (src, dst, 0.0, Fb);
+
+ case PIXMAN_OP_CONJOINT_ATOP:
+ if (srca == 0.0)
+ Fa = 1.0;
+ else
+ Fa = min (1.0, dsta / srca);
+ if (dsta == 0.0)
+ Fb = 0.0;
+ else
+ Fb = max (0.0, 1.0 - srca / dsta);
+ return mult_chan (src, dst, Fa, Fb);
+
+ case PIXMAN_OP_CONJOINT_ATOP_REVERSE:
+ if (srca == 0.0)
+ Fa = 0.0;
+ else
+ Fa = max (0.0, 1.0 - dsta / srca);
+ if (dsta == 0.0)
+ Fb = 1.0;
+ else
+ Fb = min (1.0, srca / dsta);
+ return mult_chan (src, dst, Fa, Fb);
+
+ case PIXMAN_OP_CONJOINT_XOR:
+ if (srca == 0.0)
+ Fa = 0.0;
+ else
+ Fa = max (0.0, 1.0 - dsta / srca);
+ if (dsta == 0.0)
+ Fb = 0.0;
+ else
+ Fb = max (0.0, 1.0 - srca / dsta);
+ return mult_chan (src, dst, Fa, Fb);
+
+ case PIXMAN_OP_MULTIPLY:
+ case PIXMAN_OP_SCREEN:
+ case PIXMAN_OP_OVERLAY:
+ case PIXMAN_OP_DARKEN:
+ case PIXMAN_OP_LIGHTEN:
+ case PIXMAN_OP_COLOR_DODGE:
+ case PIXMAN_OP_COLOR_BURN:
+ case PIXMAN_OP_HARD_LIGHT:
+ case PIXMAN_OP_SOFT_LIGHT:
+ case PIXMAN_OP_DIFFERENCE:
+ case PIXMAN_OP_EXCLUSION:
+ case PIXMAN_OP_HSL_HUE:
+ case PIXMAN_OP_HSL_SATURATION:
+ case PIXMAN_OP_HSL_COLOR:
+ case PIXMAN_OP_HSL_LUMINOSITY:
+ default:
+ abort();
+ }
+#undef mult_chan
+}
+
+static void
+do_composite (pixman_op_t op,
+ const color_t *src,
+ const color_t *mask,
+ const color_t *dst,
+ color_t *result,
+ pixman_bool_t component_alpha)
+{
+ color_t srcval, srcalpha;
+
+ if (mask == NULL)
+ {
+ srcval = *src;
+
+ srcalpha.r = src->a;
+ srcalpha.g = src->a;
+ srcalpha.b = src->a;
+ srcalpha.a = src->a;
+ }
+ else if (component_alpha)
+ {
+ srcval.r = src->r * mask->r;
+ srcval.g = src->g * mask->g;
+ srcval.b = src->b * mask->b;
+ srcval.a = src->a * mask->a;
+
+ srcalpha.r = src->a * mask->r;
+ srcalpha.g = src->a * mask->g;
+ srcalpha.b = src->a * mask->b;
+ srcalpha.a = src->a * mask->a;
+ }
+ else
+ {
+ srcval.r = src->r * mask->a;
+ srcval.g = src->g * mask->a;
+ srcval.b = src->b * mask->a;
+ srcval.a = src->a * mask->a;
+
+ srcalpha.r = src->a * mask->a;
+ srcalpha.g = src->a * mask->a;
+ srcalpha.b = src->a * mask->a;
+ srcalpha.a = src->a * mask->a;
+ }
+
+ result->r = calc_op (op, srcval.r, dst->r, srcalpha.r, dst->a);
+ result->g = calc_op (op, srcval.g, dst->g, srcalpha.g, dst->a);
+ result->b = calc_op (op, srcval.b, dst->b, srcalpha.b, dst->a);
+ result->a = calc_op (op, srcval.a, dst->a, srcalpha.a, dst->a);
+}
+
+static void
+color_correct (pixman_format_code_t format,
+ color_t *color)
+{
+#define round_pix(pix, mask) \
+ ((int)((pix) * (mask) + .5) / (double) (mask))
+
+ if (PIXMAN_FORMAT_R (format) == 0)
+ {
+ color->r = 0.0;
+ color->g = 0.0;
+ color->b = 0.0;
+ }
+ else
+ {
+ color->r = round_pix (color->r, PIXMAN_FORMAT_R (format));
+ color->g = round_pix (color->g, PIXMAN_FORMAT_G (format));
+ color->b = round_pix (color->b, PIXMAN_FORMAT_B (format));
+ }
+
+ if (PIXMAN_FORMAT_A (format) == 0)
+ color->a = 1.0;
+ else
+ color->a = round_pix (color->a, PIXMAN_FORMAT_A (format));
+
+#undef round_pix
+}
+
+static void
+get_pixel (pixman_image_t *image,
+ pixman_format_code_t format,
+ color_t *color)
+{
+#define MASK(N) ((1UL << (N))-1)
+
+ unsigned long rs, gs, bs, as;
+ int a, r, g, b;
+ unsigned long val;
+
+ val = *(unsigned long *) pixman_image_get_data (image);
+#ifdef WORDS_BIGENDIAN
+ val >>= 8 * sizeof(val) - PIXMAN_FORMAT_BPP (format);
+#endif
+
+ /* Number of bits in each channel */
+ a = PIXMAN_FORMAT_A (format);
+ r = PIXMAN_FORMAT_R (format);
+ g = PIXMAN_FORMAT_G (format);
+ b = PIXMAN_FORMAT_B (format);
+
+ switch (PIXMAN_FORMAT_TYPE (format))
+ {
+ case PIXMAN_TYPE_ARGB:
+ bs = 0;
+ gs = b + bs;
+ rs = g + gs;
+ as = r + rs;
+ break;
+
+ case PIXMAN_TYPE_ABGR:
+ rs = 0;
+ gs = r + rs;
+ bs = g + gs;
+ as = b + bs;
+ break;
+
+ case PIXMAN_TYPE_BGRA:
+ as = 0;
+ rs = PIXMAN_FORMAT_BPP (format) - (b + g + r);
+ gs = r + rs;
+ bs = g + gs;
+ break;
+
+ case PIXMAN_TYPE_A:
+ as = 0;
+ rs = 0;
+ gs = 0;
+ bs = 0;
+ break;
+
+ case PIXMAN_TYPE_OTHER:
+ case PIXMAN_TYPE_COLOR:
+ case PIXMAN_TYPE_GRAY:
+ case PIXMAN_TYPE_YUY2:
+ case PIXMAN_TYPE_YV12:
+ default:
+ abort ();
+ as = 0;
+ rs = 0;
+ gs = 0;
+ bs = 0;
+ break;
+ }
+
+ if (MASK (a) != 0)
+ color->a = ((val >> as) & MASK (a)) / (double) MASK (a);
+ else
+ color->a = 1.0;
+
+ if (MASK (r) != 0)
+ {
+ color->r = ((val >> rs) & MASK (r)) / (double) MASK (r);
+ color->g = ((val >> gs) & MASK (g)) / (double) MASK (g);
+ color->b = ((val >> bs) & MASK (b)) / (double) MASK (b);
+ }
+ else
+ {
+ color->r = 0.0;
+ color->g = 0.0;
+ color->b = 0.0;
+ }
+
+#undef MASK
+}
+
+static double
+eval_diff (color_t *expected, color_t *test)
+{
+ double rscale, gscale, bscale, ascale;
+ double rdiff, gdiff, bdiff, adiff;
+
+ /* XXX: Need to be provided mask shifts so we can produce useful error
+ * values.
+ */
+ rscale = 1.0 * (1 << 5);
+ gscale = 1.0 * (1 << 6);
+ bscale = 1.0 * (1 << 5);
+ ascale = 1.0 * 32;
+
+ rdiff = fabs (test->r - expected->r) * rscale;
+ bdiff = fabs (test->g - expected->g) * gscale;
+ gdiff = fabs (test->b - expected->b) * bscale;
+ adiff = fabs (test->a - expected->a) * ascale;
+
+ return max (max (max (rdiff, gdiff), bdiff), adiff);
+}
+
+static char *
+describe_image (image_t *info, char *buf, int buflen)
+{
+ if (info->size)
+ {
+ snprintf (buf, buflen, "%s %dx%d%s",
+ info->format->name,
+ info->size, info->size,
+ info->repeat ? "R" :"");
+ }
+ else
+ {
+ snprintf (buf, buflen, "solid");
+ }
+
+ return buf;
+}
+
+/* Test a composite of a given operation, source, mask, and destination
+ * picture.
+ * Fills the window, and samples from the 0,0 pixel corner.
+ */
+static pixman_bool_t
+composite_test (image_t *dst,
+ const operator_t *op,
+ image_t *src,
+ image_t *mask,
+ pixman_bool_t component_alpha)
+{
+ pixman_color_t fill;
+ pixman_rectangle16_t rect;
+ color_t expected, result, tdst, tsrc, tmsk;
+ double diff;
+ pixman_bool_t success = TRUE;
+
+ compute_pixman_color (dst->color, &fill);
+ rect.x = rect.y = 0;
+ rect.width = rect.height = dst->size;
+ pixman_image_fill_rectangles (PIXMAN_OP_SRC, dst->image,
+ &fill, 1, &rect);
+
+ if (mask != NULL)
+ {
+ pixman_image_set_component_alpha (mask->image, component_alpha);
+ pixman_image_composite (op->op, src->image, mask->image, dst->image,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ dst->size, dst->size);
+
+ tmsk = *mask->color;
+ if (mask->size)
+ {
+ color_correct (mask->format->format, &tmsk);
+
+ if (component_alpha &&
+ PIXMAN_FORMAT_R (mask->format->format) == 0)
+ {
+ /* Ax component-alpha masks expand alpha into
+ * all color channels.
+ */
+ tmsk.r = tmsk.g = tmsk.b = tmsk.a;
+ }
+ }
+ }
+ else
+ {
+ pixman_image_composite (op->op, src->image, NULL, dst->image,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ dst->size, dst->size);
+ }
+ get_pixel (dst->image, dst->format->format, &result);
+
+ tdst = *dst->color;
+ color_correct (dst->format->format, &tdst);
+ tsrc = *src->color;
+ if (src->size)
+ color_correct (src->format->format, &tsrc);
+ do_composite (op->op, &tsrc, mask ? &tmsk : NULL, &tdst,
+ &expected, component_alpha);
+ color_correct (dst->format->format, &expected);
+
+ diff = eval_diff (&expected, &result);
+ if (diff > 3.0)
+ {
+ char buf[40];
+
+ snprintf (buf, sizeof (buf),
+ "%s %scomposite",
+ op->name,
+ component_alpha ? "CA " : "");
+
+ printf ("%s test error of %.4f --\n"
+ " R G B A\n"
+ "got: %.2f %.2f %.2f %.2f [%08lx]\n"
+ "expected: %.2f %.2f %.2f %.2f\n",
+ buf, diff,
+ result.r, result.g, result.b, result.a,
+ *(unsigned long *) pixman_image_get_data (dst->image),
+ expected.r, expected.g, expected.b, expected.a);
+
+ if (mask != NULL)
+ {
+ printf ("src color: %.2f %.2f %.2f %.2f\n"
+ "msk color: %.2f %.2f %.2f %.2f\n"
+ "dst color: %.2f %.2f %.2f %.2f\n",
+ src->color->r, src->color->g,
+ src->color->b, src->color->a,
+ mask->color->r, mask->color->g,
+ mask->color->b, mask->color->a,
+ dst->color->r, dst->color->g,
+ dst->color->b, dst->color->a);
+ printf ("src: %s, ", describe_image (src, buf, sizeof (buf)));
+ printf ("mask: %s, ", describe_image (mask, buf, sizeof (buf)));
+ printf ("dst: %s\n\n", describe_image (dst, buf, sizeof (buf)));
+ }
+ else
+ {
+ printf ("src color: %.2f %.2f %.2f %.2f\n"
+ "dst color: %.2f %.2f %.2f %.2f\n",
+ src->color->r, src->color->g,
+ src->color->b, src->color->a,
+ dst->color->r, dst->color->g,
+ dst->color->b, dst->color->a);
+ printf ("src: %s, ", describe_image (src, buf, sizeof (buf)));
+ printf ("dst: %s\n\n", describe_image (dst, buf, sizeof (buf)));
+ }
+
+ success = FALSE;
+ }
+
+ return success;
+}
+
+#define REPEAT 0x01000000
+#define FLAGS 0xff000000
+
+static void
+image_init (image_t *info,
+ int color,
+ int format,
+ int size)
+{
+ pixman_color_t fill;
+
+ info->color = &colors[color];
+ compute_pixman_color (info->color, &fill);
+
+ info->format = &formats[format];
+ info->size = size & ~FLAGS;
+ info->repeat = PIXMAN_REPEAT_NONE;
+
+ if (info->size)
+ {
+ pixman_rectangle16_t rect;
+
+ info->image = pixman_image_create_bits (info->format->format,
+ info->size, info->size,
+ NULL, 0);
+
+ rect.x = rect.y = 0;
+ rect.width = rect.height = info->size;
+ pixman_image_fill_rectangles (PIXMAN_OP_SRC, info->image, &fill,
+ 1, &rect);
+
+ if (size & REPEAT)
+ {
+ pixman_image_set_repeat (info->image, PIXMAN_REPEAT_NORMAL);
+ info->repeat = PIXMAN_REPEAT_NORMAL;
+ }
+ }
+ else
+ {
+ info->image = pixman_image_create_solid_fill (&fill);
+ }
+}
+
+static void
+image_fini (image_t *info)
+{
+ pixman_image_unref (info->image);
+}
+
+int
+main (void)
+{
+ pixman_bool_t ok, group_ok = TRUE, ca;
+ int i, d, m, s;
+ int tests_passed = 0, tests_total = 0;
+ int sizes[] = { 1, 1 | REPEAT, 10 };
+ int num_tests;
+
+ for (i = 0; i < ARRAY_LENGTH (colors); i++)
+ {
+ colors[i].r *= colors[i].a;
+ colors[i].g *= colors[i].a;
+ colors[i].b *= colors[i].a;
+ }
+
+ num_tests = ARRAY_LENGTH (colors) * ARRAY_LENGTH (formats);
+
+ for (d = 0; d < num_tests; d++)
+ {
+ image_t dst;
+
+ image_init (
+ &dst, d / ARRAY_LENGTH (formats), d % ARRAY_LENGTH (formats), 1);
+
+
+ for (s = -ARRAY_LENGTH (colors);
+ s < ARRAY_LENGTH (sizes) * num_tests;
+ s++)
+ {
+ image_t src;
+
+ if (s < 0)
+ {
+ image_init (&src, -s - 1, 0, 0);
+ }
+ else
+ {
+ image_init (&src,
+ s / ARRAY_LENGTH (sizes) / ARRAY_LENGTH (formats),
+ s / ARRAY_LENGTH (sizes) % ARRAY_LENGTH (formats),
+ sizes[s % ARRAY_LENGTH (sizes)]);
+ }
+
+ for (m = -ARRAY_LENGTH (colors);
+ m < ARRAY_LENGTH (sizes) * num_tests;
+ m++)
+ {
+ image_t mask;
+
+ if (m < 0)
+ {
+ image_init (&mask, -m - 1, 0, 0);
+ }
+ else
+ {
+ image_init (
+ &mask,
+ m / ARRAY_LENGTH (sizes) / ARRAY_LENGTH (formats),
+ m / ARRAY_LENGTH (sizes) % ARRAY_LENGTH (formats),
+ sizes[m % ARRAY_LENGTH (sizes)]);
+ }
+
+ for (ca = -1; ca <= 1; ca++)
+ {
+ for (i = 0; i < ARRAY_LENGTH (operators); i++)
+ {
+ const operator_t *op = &operators[i];
+
+ switch (ca)
+ {
+ case -1:
+ ok = composite_test (&dst, op, &src, NULL, FALSE);
+ break;
+ case 0:
+ ok = composite_test (&dst, op, &src, &mask, FALSE);
+ break;
+ case 1:
+ ok = composite_test (&dst, op, &src, &mask,
+ mask.size? TRUE : FALSE);
+ break;
+ default:
+ break;
+ }
+ group_ok = group_ok && ok;
+ tests_passed += ok;
+ tests_total++;
+ }
+ }
+
+ image_fini (&mask);
+ }
+ image_fini (&src);
+ }
+ image_fini (&dst);
+ }
+
+ return group_ok == FALSE;
+}
diff --git a/pixman/test/convolution-test.c b/pixman/test/convolution-test.c
index 8609d38a0..da284af7b 100644
--- a/pixman/test/convolution-test.c
+++ b/pixman/test/convolution-test.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "pixman.h"
-#include "utils.h"
+#include "gtk-utils.h"
int
main (int argc, char **argv)
diff --git a/pixman/test/gradient-test.c b/pixman/test/gradient-test.c
index 2593ee38a..fc84844b0 100644
--- a/pixman/test/gradient-test.c
+++ b/pixman/test/gradient-test.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "pixman.h"
-#include "utils.h"
+#include "gtk-utils.h"
int
main (int argc, char **argv)
@@ -21,18 +21,20 @@ main (int argc, char **argv)
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) }
}
};
-
- pixman_transform_t id = {
+#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;
@@ -67,7 +69,7 @@ main (int argc, char **argv)
src_img = pixman_image_create_linear_gradient (&p1, &p2,
stops, 2);
- pixman_image_set_transform (src_img, &id);
+ pixman_image_set_transform (src_img, &trans);
pixman_image_set_repeat (src_img, PIXMAN_REPEAT_PAD);
pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img,
diff --git a/pixman/test/gtk-utils.c b/pixman/test/gtk-utils.c
new file mode 100644
index 000000000..751a164c0
--- /dev/null
+++ b/pixman/test/gtk-utils.c
@@ -0,0 +1,113 @@
+#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 ();
+}
diff --git a/pixman/test/gtk-utils.h b/pixman/test/gtk-utils.h
new file mode 100644
index 000000000..2cb13bcf0
--- /dev/null
+++ b/pixman/test/gtk-utils.h
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include "pixman.h"
+
+void show_image (pixman_image_t *image);
+
+GdkPixbuf *pixbuf_from_argb32 (uint32_t *bits,
+ gboolean has_alpha,
+ int width,
+ int height,
+ int stride);
diff --git a/pixman/test/scaling-test.c b/pixman/test/scaling-test.c
index 8899c594f..29772906d 100644
--- a/pixman/test/scaling-test.c
+++ b/pixman/test/scaling-test.c
@@ -23,198 +23,7 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
-#include "pixman.h"
-
-/* A primitive pseudorandom number generator, taken from POSIX.1-2001 example */
-
-static uint32_t lcg_seed;
-
-uint32_t
-lcg_rand (void)
-{
- lcg_seed = lcg_seed * 1103515245 + 12345;
- return ((uint32_t)(lcg_seed / 65536) % 32768);
-}
-
-void
-lcg_srand (uint32_t seed)
-{
- lcg_seed = seed;
-}
-
-uint32_t
-lcg_rand_n (int max)
-{
- return lcg_rand () % max;
-}
-
-/*----------------------------------------------------------------------------*\
-* 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 compute_crc32() 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:
-* compute_crc32() - computes the CRC-32 value of a memory buffer
-* DESCRIPTION:
-* Computes or accumulates the CRC-32 value for a memory buffer.
-* The 'in_crc32' gives a previously accumulated CRC-32 value to allow
-* a CRC to be generated for multiple sequential buffer-fuls of data.
-* The 'in_crc32' for the first buffer must be zero.
-* ARGUMENTS:
-* in_crc32 - accumulated CRC-32 value, must be 0 on first call
-* buf - buffer to compute CRC-32 value for
-* buf_len - number of bytes in buffer
-* RETURNS:
-* crc32 - computed CRC-32 value
-* ERRORS:
-* (no errors are possible)
-\*----------------------------------------------------------------------------*/
-
-static 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 */
-static 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++)
- {
- char *line_data = (char *)data + stride * i;
-
- /* swap bytes only for 16, 24 and 32 bpp for now */
- switch (bpp)
- {
- 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;
- }
- }
-}
+#include "utils.h"
#define MAX_SRC_WIDTH 10
#define MAX_SRC_HEIGHT 10
@@ -266,7 +75,7 @@ test_composite (uint32_t initcrc,
if (src_stride & 3)
src_stride += 2;
-
+
if (dst_stride & 3)
dst_stride += 2;
@@ -326,9 +135,17 @@ test_composite (uint32_t initcrc,
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);
@@ -362,7 +179,7 @@ test_composite (uint32_t initcrc,
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);
@@ -458,7 +275,7 @@ main (int argc, char *argv[])
/* 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 == 0x0B633CF4)
+ if (crc == 0x2168ACD1)
{
printf ("scaling test passed\n");
}
diff --git a/pixman/test/screen-test.c b/pixman/test/screen-test.c
index 5e02eee08..e69dba3de 100644
--- a/pixman/test/screen-test.c
+++ b/pixman/test/screen-test.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "pixman.h"
-#include "utils.h"
+#include "gtk-utils.h"
int
main (int argc, char **argv)
diff --git a/pixman/test/trap-test.c b/pixman/test/trap-test.c
index 1da439bd6..19295e7a5 100644
--- a/pixman/test/trap-test.c
+++ b/pixman/test/trap-test.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include "pixman.h"
-#include "utils.h"
+#include "gtk-utils.h"
int
main (int argc, char **argv)
diff --git a/pixman/test/utils.c b/pixman/test/utils.c
index a609315c5..1e42d89d8 100644
--- a/pixman/test/utils.c
+++ b/pixman/test/utils.c
@@ -1,113 +1,194 @@
-#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 "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;
+/* Random number seed
+ */
- pb += h * p_stride + w * 4;
+uint32_t lcg_seed;
- r = (argb & 0x00ff0000) >> 16;
- g = (argb & 0x0000ff00) >> 8;
- b = (argb & 0x000000ff) >> 0;
- a = has_alpha? (argb & 0xff000000) >> 24 : 0xff;
+/*----------------------------------------------------------------------------*\
+ * 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.
+\*----------------------------------------------------------------------------*/
- if (a)
- {
- r = (r * 255) / a;
- g = (g * 255) / a;
- b = (b * 255) / a;
- }
+/*----------------------------------------------------------------------------*\
+ * 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)
+\*----------------------------------------------------------------------------*/
- 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;
-}
+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;
-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;
+ /* 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
-show_image (pixman_image_t *image)
+image_endian_swap (pixman_image_t *img, int bpp)
{
- 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 ();
+ 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;
+ }
+ }
}
+
diff --git a/pixman/test/utils.h b/pixman/test/utils.h
index bc110d847..8fdb2ce4f 100644
--- a/pixman/test/utils.h
+++ b/pixman/test/utils.h
@@ -1,6 +1,41 @@
-#include <stdio.h>
#include <stdlib.h>
-#include <glib.h>
-#include "pixman.h"
+#include <config.h>
+#include "pixman-private.h" /* For 'inline' definition */
-void show_image (pixman_image_t *image);
+/* 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);
diff --git a/pixman/test/window-test.c b/pixman/test/window-test.c
index bbaa3e211..084e23a22 100644
--- a/pixman/test/window-test.c
+++ b/pixman/test/window-test.c
@@ -1,8 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <config.h>
-#include "pixman.h"
#include "pixman-private.h"
+#include "pixman.h"
#define FALSE 0
#define TRUE 1