upload tizen 2.0 source
authorSeongwon Cho <seongwon1.cho@samsung.com>
Wed, 22 Aug 2012 11:40:25 +0000 (20:40 +0900)
committerSeongwon Cho <seongwon1.cho@samsung.com>
Wed, 22 Aug 2012 11:40:25 +0000 (20:40 +0900)
97 files changed:
.gitignore [new file with mode: 0644]
Makefile.am
TC/_export_env.sh [new file with mode: 0755]
TC/_export_target_env.sh [new file with mode: 0755]
TC/build.sh [new file with mode: 0755]
TC/clean.sh [new file with mode: 0755]
TC/config [new file with mode: 0755]
TC/execute.sh [new file with mode: 0755]
TC/testcase/pixman-compiler.h [new file with mode: 0644]
TC/testcase/pixman-private.h [new file with mode: 0644]
TC/testcase/pixman-version.h [new file with mode: 0644]
TC/testcase/pixman.h [new file with mode: 0644]
TC/testcase/tslist [new file with mode: 0644]
TC/testcase/utc_a1_trap_test.c [new file with mode: 0644]
TC/testcase/utc_affine_test.c [new file with mode: 0644]
TC/testcase/utc_blitters_test.c [new file with mode: 0644]
TC/testcase/utc_composite_traps_test.c [new file with mode: 0644]
TC/testcase/utc_fetch_test.c [new file with mode: 0644]
TC/testcase/utc_gradient_crash_test.c [new file with mode: 0644]
TC/testcase/utc_oob_test.c [new file with mode: 0644]
TC/testcase/utc_pdf_op_test.c [new file with mode: 0644]
TC/testcase/utc_region_contains_test.c [new file with mode: 0644]
TC/testcase/utc_region_test.c [new file with mode: 0644]
TC/testcase/utc_region_translate_test.c [new file with mode: 0644]
TC/testcase/utc_scaling_crash_test.c [new file with mode: 0644]
TC/testcase/utc_scaling_helpers_test.c [new file with mode: 0644]
TC/testcase/utc_scaling_test.c [new file with mode: 0644]
TC/testcase/utils.c [new file with mode: 0644]
TC/testcase/utils.h [new file with mode: 0644]
TC/tet_scen [new file with mode: 0755]
TC/tetbuild.cfg [new file with mode: 0755]
TC/tetclean.cfg [new file with mode: 0755]
TC/tetexec.cfg [new file with mode: 0755]
autogen.sh
configure.ac [changed mode: 0755->0644]
debian/changelog
debian/rules
demos/Makefile.am
demos/checkerboard.c [new file with mode: 0644]
demos/composite-test.c
demos/gradient-test.c
demos/gtk-utils.c
demos/parrot.c [new file with mode: 0644]
demos/parrot.jpg [new file with mode: 0644]
demos/quad2quad.c [new file with mode: 0644]
packaging/pixman.spec
pixman/Makefile.am
pixman/loongson-mmintrin.h [new file with mode: 0644]
pixman/pixman-access.c
pixman/pixman-accessor.h
pixman/pixman-arm-neon-asm.S
pixman/pixman-arm-simd-asm.S
pixman/pixman-bits-image.c
pixman/pixman-combine.c.template
pixman/pixman-combine.h.template
pixman/pixman-compiler.h
pixman/pixman-cpu.c
pixman/pixman-fast-path.c
pixman/pixman-general.c
pixman/pixman-gradient-walker.c
pixman/pixman-image.c
pixman/pixman-implementation.c
pixman/pixman-mips-dspr2-asm.S [new file with mode: 0644]
pixman/pixman-mips-dspr2-asm.h [new file with mode: 0644]
pixman/pixman-mips-dspr2.c [new file with mode: 0644]
pixman/pixman-mips-dspr2.h [new file with mode: 0644]
pixman/pixman-mips-memcpy-asm.S [new file with mode: 0644]
pixman/pixman-mmx.c
pixman/pixman-noop.c
pixman/pixman-private.h
pixman/pixman-region.c
pixman/pixman-sse2.c
pixman/pixman-trap.c
pixman/pixman-utils.c
pixman/pixman.h
test/Makefile.am [changed mode: 0755->0644]
test/Makefile.win32 [changed mode: 0755->0644]
test/a1-trap-test.c
test/affine-test.c [changed mode: 0755->0644]
test/alphamap.c
test/blitters-test.c [changed mode: 0755->0644]
test/composite-traps-test.c [changed mode: 0755->0644]
test/composite.c [changed mode: 0755->0644]
test/fetch-test.c [changed mode: 0755->0644]
test/fuzzer-find-diff.pl [changed mode: 0644->0755]
test/gradient-crash-test.c
test/lowlevel-blt-bench.c
test/oob-test.c
test/region-contains-test.c
test/region-translate-test.c
test/scaling-crash-test.c
test/scaling-helpers-test.c [changed mode: 0755->0644]
test/scaling-test.c [changed mode: 0755->0644]
test/stress-test.c [changed mode: 0755->0644]
test/trap-crasher.c [changed mode: 0755->0644]
test/utils.c [changed mode: 0755->0644]
test/utils.h [changed mode: 0755->0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..98612c9
--- /dev/null
@@ -0,0 +1,81 @@
+Makefile
+Makefile.in
+.deps
+.libs
+.msg
+*.pc
+*.lo
+*.la
+*.a
+*.o
+*~
+aclocal.m4
+autom4te.cache
+compile
+config.guess
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libtool
+ltmain.sh
+missing
+stamp-h?
+config.h
+config.h.in
+.*.swp
+demos/alpha-test
+demos/checkerboard
+demos/clip-in
+demos/clip-test
+demos/composite-test
+demos/convolution-test
+demos/gradient-test
+demos/quad2quad
+demos/radial-test
+demos/screen-test
+demos/trap-test
+demos/tri-test
+pixman/pixman-combine32.c
+pixman/pixman-combine32.h
+pixman/pixman-combine64.c
+pixman/pixman-combine64.h
+pixman/pixman-version.h
+test/a1-trap-test
+test/affine-test
+test/alpha-loop
+test/alphamap
+test/alpha-test
+test/blitters-test
+test/clip-in
+test/clip-test
+test/composite
+test/composite-test
+test/composite-traps-test
+test/convolution-test
+test/fetch-test
+test/gradient-crash-test
+test/gradient-test
+test/lowlevel-blt-bench
+test/oob-test
+test/pdf-op-test
+test/region-contains-test
+test/region-test
+test/region-translate
+test/region-translate-test
+test/scaling-crash-test
+test/scaling-helpers-test
+test/scaling-test
+test/screen-test
+test/stress-test
+test/trap-crasher
+test/trap-test
+test/window-test
+*.pdb
+*.dll
+*.lib
+*.ilk
+*.obj
+*.exe
index ff87e26..88ff897 100644 (file)
@@ -21,6 +21,10 @@ RELEASE_XORG_HOST =  $(USERNAME)@xorg.freedesktop.org
 RELEASE_XORG_DIR =     /srv/xorg.freedesktop.org/archive/individual/lib
 RELEASE_ANNOUNCE_LIST = cairo-announce@cairographics.org, xorg-announce@lists.freedesktop.org, pixman@lists.freedesktop.org
 
+EXTRA_DIST =                           \
+       Makefile.win32                  \
+       Makefile.win32.common
+
 tar_gz = $(PACKAGE)-$(VERSION).tar.gz
 tar_bz2 = $(PACKAGE)-$(VERSION).tar.bz2
 
@@ -87,6 +91,8 @@ release-upload: release-check $(tar_gz) $(tar_bz2) $(sha1_tgz) $(sha1_tbz2) $(md
        scp $(tar_gz) $(tar_bz2) $(RELEASE_XORG_HOST):$(RELEASE_XORG_DIR)
        ssh $(RELEASE_CAIRO_HOST) "rm -f $(RELEASE_CAIRO_DIR)/LATEST-$(PACKAGE)-[0-9]* && ln -s $(tar_gz) $(RELEASE_CAIRO_DIR)/LATEST-$(PACKAGE)-$(VERSION)"
 
+RELEASE_TYPE = $$(if test "x$(PIXMAN_VERSION_MINOR)" = "x$$(echo "$(PIXMAN_VERSION_MINOR)/2*2" | bc)" ; then echo "stable release in the" ; else echo "development snapshot leading up to a stable"; fi)
+
 release-publish-message: $(HASHFILES) ensure-prev
        @echo "Please follow the instructions in RELEASING to push stuff out and"
        @echo "send out the announcement mails.  Here is the excerpt you need:"
@@ -94,7 +100,7 @@ release-publish-message: $(HASHFILES) ensure-prev
        @echo "Lists:  $(RELEASE_ANNOUNCE_LIST)"
        @echo "Subject: [ANNOUNCE] $(PACKAGE) release $(VERSION) now available"
        @echo "============================== CUT HERE =============================="
-       @echo "A new $(PACKAGE) release $(VERSION) is now available"
+       @echo "A new $(PACKAGE) release $(VERSION) is now available. This is a $(RELEASE_TYPE)"
        @echo ""
        @echo "tar.gz:"
        @echo " $(RELEASE_CAIRO_URL)/$(tar_gz)"
diff --git a/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100755 (executable)
index 0000000..4431684
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
+export PIXMAN_TC_ROOT_PATH=/home/seongwon/workspace/00_cairo_pixman/00_private/pixman/TC/testcase
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
new file mode 100755 (executable)
index 0000000..5ddaa53
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..d440663
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+. ./_export_env.sh                              # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+cd ./testcase && make utils && cd ../
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/clean.sh b/TC/clean.sh
new file mode 100755 (executable)
index 0000000..e990c20
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. ./_export_env.sh                              # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+RESULT_DIR=results
+
+tcc -c -p ./                                # executing tcc, with clean option (-c)
+rm -r $RESULT_DIR
+rm -r tet_tmp_dir
+rm testcase/tet_captured
+rm -f testcase/*.o
diff --git a/TC/config b/TC/config
new file mode 100755 (executable)
index 0000000..4b8bd22
--- /dev/null
+++ b/TC/config
@@ -0,0 +1,2 @@
+TET_INSTALL_HOST_PATH=/home/seongwon/workspace/00_cairo_pixman/05_TETware/
+TET_INSTALL_TARGET_PATH=/home/seongwon/workspace/00_cairo_pixman/05_TETware/
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755 (executable)
index 0000000..a4f6095
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. ./_export_target_env.sh                    # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/testcase/pixman-compiler.h b/TC/testcase/pixman-compiler.h
new file mode 100644 (file)
index 0000000..ffd5172
--- /dev/null
@@ -0,0 +1,218 @@
+/* Pixman uses some non-standard compiler features. This file ensures
+ * they exist
+ *
+ * The features are:
+ *
+ *    FUNC          must be defined to expand to the current function
+ *    PIXMAN_EXPORT  should be defined to whatever is required to
+ *                   export functions from a shared library
+ *    limits        limits for various types must be defined
+ *    inline         must be defined
+ *    force_inline   must be defined
+ */
+#if defined (__GNUC__)
+#  define FUNC     ((const char*) (__PRETTY_FUNCTION__))
+#elif defined (__sun) || (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
+#  define FUNC     ((const char*) (__func__))
+#else
+#  define FUNC     ((const char*) ("???"))
+#endif
+
+#if defined (__GNUC__)
+#  define MAYBE_UNUSED  __attribute__((unused))
+#else
+#  define MAYBE_UNUSED
+#endif
+
+#ifndef INT16_MIN
+# define INT16_MIN              (-32767-1)
+#endif
+
+#ifndef INT16_MAX
+# define INT16_MAX              (32767)
+#endif
+
+#ifndef INT32_MIN
+# define INT32_MIN              (-2147483647-1)
+#endif
+
+#ifndef INT32_MAX
+# define INT32_MAX              (2147483647)
+#endif
+
+#ifndef UINT32_MIN
+# define UINT32_MIN             (0)
+#endif
+
+#ifndef UINT32_MAX
+# define UINT32_MAX             (4294967295U)
+#endif
+
+#ifndef INT64_MIN
+# define INT64_MIN              (-9223372036854775807-1)
+#endif
+
+#ifndef INT64_MAX
+# define INT64_MAX              (9223372036854775807)
+#endif
+
+
+#ifndef M_PI
+# define M_PI                  3.14159265358979323846
+#endif
+
+#ifdef _MSC_VER
+/* 'inline' is available only in C++ in MSVC */
+#   define inline __inline
+#   define force_inline __forceinline
+#   define noinline __declspec(noinline)
+#elif defined __GNUC__ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+#   define inline __inline__
+#   define force_inline __inline__ __attribute__ ((__always_inline__))
+#   define noinline __attribute__((noinline))
+#else
+#   ifndef force_inline
+#      define force_inline inline
+#   endif
+#   ifndef noinline
+#      define noinline
+#   endif
+#endif
+
+/* GCC visibility */
+#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(_WIN32)
+#   define PIXMAN_EXPORT __attribute__ ((visibility("default")))
+/* Sun Studio 8 visibility */
+#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+#   define PIXMAN_EXPORT __global
+#else
+#   define PIXMAN_EXPORT
+#endif
+
+/* TLS */
+#if defined(PIXMAN_NO_TLS)
+
+#   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)                      \
+    static type name
+#   define PIXMAN_GET_THREAD_LOCAL(name)                               \
+    (&name)
+
+#elif defined(TLS)
+
+#   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)                      \
+    static TLS type name
+#   define PIXMAN_GET_THREAD_LOCAL(name)                               \
+    (&name)
+
+#elif defined(__MINGW32__)
+
+#   define _NO_W32_PSEUDO_MODIFIERS
+#   include <windows.h>
+
+#   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)                      \
+    static volatile int tls_ ## name ## _initialized = 0;              \
+    static void *tls_ ## name ## _mutex = NULL;                                \
+    static unsigned tls_ ## name ## _index;                            \
+                                                                       \
+    static type *                                                      \
+    tls_ ## name ## _alloc (void)                                      \
+    {                                                                  \
+        type *value = calloc (1, sizeof (type));                       \
+        if (value)                                                     \
+            TlsSetValue (tls_ ## name ## _index, value);               \
+        return value;                                                  \
+    }                                                                  \
+                                                                       \
+    static force_inline type *                                         \
+    tls_ ## name ## _get (void)                                                \
+    {                                                                  \
+       type *value;                                                    \
+       if (!tls_ ## name ## _initialized)                              \
+       {                                                               \
+           if (!tls_ ## name ## _mutex)                                \
+           {                                                           \
+               void *mutex = CreateMutexA (NULL, 0, NULL);             \
+               if (InterlockedCompareExchangePointer (                 \
+                       &tls_ ## name ## _mutex, mutex, NULL) != NULL)  \
+               {                                                       \
+                   CloseHandle (mutex);                                \
+               }                                                       \
+           }                                                           \
+           WaitForSingleObject (tls_ ## name ## _mutex, 0xFFFFFFFF);   \
+           if (!tls_ ## name ## _initialized)                          \
+           {                                                           \
+               tls_ ## name ## _index = TlsAlloc ();                   \
+               tls_ ## name ## _initialized = 1;                       \
+           }                                                           \
+           ReleaseMutex (tls_ ## name ## _mutex);                      \
+       }                                                               \
+       if (tls_ ## name ## _index == 0xFFFFFFFF)                       \
+           return NULL;                                                \
+       value = TlsGetValue (tls_ ## name ## _index);                   \
+       if (!value)                                                     \
+           value = tls_ ## name ## _alloc ();                          \
+       return value;                                                   \
+    }
+
+#   define PIXMAN_GET_THREAD_LOCAL(name)                               \
+    tls_ ## name ## _get ()
+
+#elif defined(_MSC_VER)
+
+#   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)                      \
+    static __declspec(thread) type name
+#   define PIXMAN_GET_THREAD_LOCAL(name)                               \
+    (&name)
+
+#elif defined(HAVE_PTHREAD_SETSPECIFIC)
+
+#include <pthread.h>
+
+#  define PIXMAN_DEFINE_THREAD_LOCAL(type, name)                       \
+    static pthread_once_t tls_ ## name ## _once_control = PTHREAD_ONCE_INIT; \
+    static pthread_key_t tls_ ## name ## _key;                         \
+                                                                       \
+    static void                                                                \
+    tls_ ## name ## _destroy_value (void *value)                       \
+    {                                                                  \
+       free (value);                                                   \
+    }                                                                  \
+                                                                       \
+    static void                                                                \
+    tls_ ## name ## _make_key (void)                                   \
+    {                                                                  \
+       pthread_key_create (&tls_ ## name ## _key,                      \
+                           tls_ ## name ## _destroy_value);            \
+    }                                                                  \
+                                                                       \
+    static type *                                                      \
+    tls_ ## name ## _alloc (void)                                      \
+    {                                                                  \
+       type *value = calloc (1, sizeof (type));                        \
+       if (value)                                                      \
+           pthread_setspecific (tls_ ## name ## _key, value);          \
+       return value;                                                   \
+    }                                                                  \
+                                                                       \
+    static force_inline type *                                         \
+    tls_ ## name ## _get (void)                                                \
+    {                                                                  \
+       type *value = NULL;                                             \
+       if (pthread_once (&tls_ ## name ## _once_control,               \
+                         tls_ ## name ## _make_key) == 0)              \
+       {                                                               \
+           value = pthread_getspecific (tls_ ## name ## _key);         \
+           if (!value)                                                 \
+               value = tls_ ## name ## _alloc ();                      \
+       }                                                               \
+       return value;                                                   \
+    }
+
+#   define PIXMAN_GET_THREAD_LOCAL(name)                               \
+    tls_ ## name ## _get ()
+
+#else
+
+#    error "Unknown thread local support for this system. Pixman will not work with multiple threads. Define PIXMAN_NO_TLS to acknowledge and accept this limitation and compile pixman without thread-safety support."
+
+#endif
diff --git a/TC/testcase/pixman-private.h b/TC/testcase/pixman-private.h
new file mode 100644 (file)
index 0000000..826b7a3
--- /dev/null
@@ -0,0 +1,987 @@
+#ifndef PACKAGE
+#  error config.h must be included before pixman-private.h
+#endif
+
+#ifndef PIXMAN_PRIVATE_H
+#define PIXMAN_PRIVATE_H
+
+#define PIXMAN_DISABLE_DEPRECATED
+#define PIXMAN_USE_INTERNAL_API
+
+#include "pixman.h"
+#include <time.h>
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "pixman-compiler.h"
+
+/*
+ * Images
+ */
+typedef struct image_common image_common_t;
+typedef struct solid_fill solid_fill_t;
+typedef struct gradient gradient_t;
+typedef struct linear_gradient linear_gradient_t;
+typedef struct horizontal_gradient horizontal_gradient_t;
+typedef struct vertical_gradient vertical_gradient_t;
+typedef struct conical_gradient conical_gradient_t;
+typedef struct radial_gradient radial_gradient_t;
+typedef struct bits_image bits_image_t;
+typedef struct circle circle_t;
+
+typedef void (*fetch_scanline_t) (pixman_image_t *image,
+                                 int             x,
+                                 int             y,
+                                 int             width,
+                                 uint32_t       *buffer,
+                                 const uint32_t *mask);
+
+typedef uint32_t (*fetch_pixel_32_t) (bits_image_t *image,
+                                     int           x,
+                                     int           y);
+
+typedef uint64_t (*fetch_pixel_64_t) (bits_image_t *image,
+                                     int           x,
+                                     int           y);
+
+typedef void (*store_scanline_t) (bits_image_t *  image,
+                                 int             x,
+                                 int             y,
+                                 int             width,
+                                 const uint32_t *values);
+
+typedef enum
+{
+    BITS,
+    LINEAR,
+    CONICAL,
+    RADIAL,
+    SOLID
+} image_type_t;
+
+typedef void (*property_changed_func_t) (pixman_image_t *image);
+
+struct image_common
+{
+    image_type_t                type;
+    int32_t                     ref_count;
+    pixman_region32_t           clip_region;
+    int32_t                    alpha_count;        /* How many times this image is being used as an alpha map */
+    pixman_bool_t               have_clip_region;   /* FALSE if there is no clip */
+    pixman_bool_t               client_clip;        /* Whether the source clip was
+                                                      set by a client */
+    pixman_bool_t               clip_sources;       /* Whether the clip applies when
+                                                    * the image is used as a source
+                                                    */
+    pixman_bool_t              dirty;
+    pixman_transform_t *        transform;
+    pixman_repeat_t             repeat;
+    pixman_filter_t             filter;
+    pixman_fixed_t *            filter_params;
+    int                         n_filter_params;
+    bits_image_t *              alpha_map;
+    int                         alpha_origin_x;
+    int                         alpha_origin_y;
+    pixman_bool_t               component_alpha;
+    property_changed_func_t     property_changed;
+
+    pixman_image_destroy_func_t destroy_func;
+    void *                      destroy_data;
+
+    uint32_t                   flags;
+    pixman_format_code_t       extended_format_code;
+};
+
+struct solid_fill
+{
+    image_common_t common;
+    pixman_color_t color;
+    
+    uint32_t      color_32;
+    uint64_t      color_64;
+};
+
+struct gradient
+{
+    image_common_t         common;
+    int                     n_stops;
+    pixman_gradient_stop_t *stops;
+};
+
+struct linear_gradient
+{
+    gradient_t           common;
+    pixman_point_fixed_t p1;
+    pixman_point_fixed_t p2;
+};
+
+struct circle
+{
+    pixman_fixed_t x;
+    pixman_fixed_t y;
+    pixman_fixed_t radius;
+};
+
+struct radial_gradient
+{
+    gradient_t common;
+
+    circle_t   c1;
+    circle_t   c2;
+
+    circle_t   delta;
+    double     a;
+    double     inva;
+    double     mindr;
+};
+
+struct conical_gradient
+{
+    gradient_t           common;
+    pixman_point_fixed_t center;
+    double              angle;
+};
+
+struct bits_image
+{
+    image_common_t             common;
+    pixman_format_code_t       format;
+    const pixman_indexed_t *   indexed;
+    int                        width;
+    int                        height;
+    uint32_t *                 bits;
+    uint32_t *                 free_me;
+    int                        rowstride;  /* in number of uint32_t's */
+
+    fetch_scanline_t           get_scanline_32;
+    fetch_scanline_t           get_scanline_64;
+
+    fetch_scanline_t           fetch_scanline_32;
+    fetch_pixel_32_t          fetch_pixel_32;
+    store_scanline_t           store_scanline_32;
+
+    fetch_scanline_t           fetch_scanline_64;
+    fetch_pixel_64_t          fetch_pixel_64;
+    store_scanline_t           store_scanline_64;
+
+    /* Used for indirect access to the bits */
+    pixman_read_memory_func_t  read_func;
+    pixman_write_memory_func_t write_func;
+};
+
+union pixman_image
+{
+    image_type_t       type;
+    image_common_t     common;
+    bits_image_t       bits;
+    gradient_t         gradient;
+    linear_gradient_t  linear;
+    conical_gradient_t conical;
+    radial_gradient_t  radial;
+    solid_fill_t       solid;
+};
+
+typedef struct pixman_iter_t pixman_iter_t;
+typedef uint32_t *(* pixman_iter_get_scanline_t) (pixman_iter_t *iter, const uint32_t *mask);
+typedef void      (* pixman_iter_write_back_t)   (pixman_iter_t *iter);
+
+typedef enum
+{
+    ITER_NARROW =              (1 << 0),
+
+    /* "Localized alpha" is when the alpha channel is used only to compute
+     * the alpha value of the destination. This means that the computation
+     * of the RGB values of the result is independent of the alpha value.
+     *
+     * For example, the OVER operator has localized alpha for the
+     * destination, because the RGB values of the result can be computed
+     * without knowing the destination alpha. Similarly, ADD has localized
+     * alpha for both source and destination because the RGB values of the
+     * result can be computed without knowing the alpha value of source or
+     * destination.
+     *
+     * When he destination is xRGB, this is useful knowledge, because then
+     * we can treat it as if it were ARGB, which means in some cases we can
+     * avoid copying it to a temporary buffer.
+     */
+    ITER_LOCALIZED_ALPHA =     (1 << 1),
+    ITER_IGNORE_ALPHA =                (1 << 2),
+    ITER_IGNORE_RGB =          (1 << 3)
+} iter_flags_t;
+
+struct pixman_iter_t
+{
+    /* These are initialized by _pixman_implementation_{src,dest}_init */
+    pixman_image_t *           image;
+    uint32_t *                 buffer;
+    int                                x, y;
+    int                                width;
+    int                                height;
+    iter_flags_t               flags;
+
+    /* These function pointers are initialized by the implementation */
+    pixman_iter_get_scanline_t get_scanline;
+    pixman_iter_write_back_t   write_back;
+
+    /* These fields are scratch data that implementations can use */
+    uint8_t *                  bits;
+    int                                stride;
+};
+
+void
+_pixman_bits_image_setup_accessors (bits_image_t *image);
+
+void
+_pixman_bits_image_src_iter_init (pixman_image_t *image, pixman_iter_t *iter);
+
+void
+_pixman_bits_image_dest_iter_init (pixman_image_t *image, pixman_iter_t *iter);
+
+void
+_pixman_solid_fill_iter_init (pixman_image_t *image, pixman_iter_t  *iter);
+
+void
+_pixman_linear_gradient_iter_init (pixman_image_t *image, pixman_iter_t  *iter);
+
+void
+_pixman_radial_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter);
+
+void
+_pixman_conical_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter);
+
+void
+_pixman_image_init (pixman_image_t *image);
+
+pixman_bool_t
+_pixman_bits_image_init (pixman_image_t *     image,
+                         pixman_format_code_t format,
+                         int                  width,
+                         int                  height,
+                         uint32_t *           bits,
+                         int                  rowstride);
+pixman_bool_t
+_pixman_image_fini (pixman_image_t *image);
+
+pixman_image_t *
+_pixman_image_allocate (void);
+
+pixman_bool_t
+_pixman_init_gradient (gradient_t *                  gradient,
+                       const pixman_gradient_stop_t *stops,
+                       int                           n_stops);
+void
+_pixman_image_reset_clip_region (pixman_image_t *image);
+
+void
+_pixman_image_validate (pixman_image_t *image);
+
+#define PIXMAN_IMAGE_GET_LINE(image, x, y, type, out_stride, line, mul)        \
+    do                                                                 \
+    {                                                                  \
+       uint32_t *__bits__;                                             \
+       int       __stride__;                                           \
+                                                                       \
+       __bits__ = image->bits.bits;                                    \
+       __stride__ = image->bits.rowstride;                             \
+       (out_stride) =                                                  \
+           __stride__ * (int) sizeof (uint32_t) / (int) sizeof (type); \
+       (line) =                                                        \
+           ((type *) __bits__) + (out_stride) * (y) + (mul) * (x);     \
+    } while (0)
+
+/*
+ * Gradient walker
+ */
+typedef struct
+{
+    uint32_t                left_ag;
+    uint32_t                left_rb;
+    uint32_t                right_ag;
+    uint32_t                right_rb;
+    pixman_fixed_t         left_x;
+    pixman_fixed_t          right_x;
+    pixman_fixed_t          stepper;
+
+    pixman_gradient_stop_t *stops;
+    int                     num_stops;
+    pixman_repeat_t        repeat;
+
+    pixman_bool_t           need_reset;
+} pixman_gradient_walker_t;
+
+void
+_pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
+                              gradient_t *              gradient,
+                             pixman_repeat_t           repeat);
+
+void
+_pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
+                               pixman_fixed_48_16_t      pos);
+
+uint32_t
+_pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker,
+                               pixman_fixed_48_16_t      x);
+
+/*
+ * Edges
+ */
+
+#define MAX_ALPHA(n)    ((1 << (n)) - 1)
+#define N_Y_FRAC(n)     ((n) == 1 ? 1 : (1 << ((n) / 2)) - 1)
+#define N_X_FRAC(n)     ((n) == 1 ? 1 : (1 << ((n) / 2)) + 1)
+
+#define STEP_Y_SMALL(n) (pixman_fixed_1 / N_Y_FRAC (n))
+#define STEP_Y_BIG(n)   (pixman_fixed_1 - (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n))
+
+#define Y_FRAC_FIRST(n) (STEP_Y_BIG (n) / 2)
+#define Y_FRAC_LAST(n)  (Y_FRAC_FIRST (n) + (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n))
+
+#define STEP_X_SMALL(n) (pixman_fixed_1 / N_X_FRAC (n))
+#define STEP_X_BIG(n)   (pixman_fixed_1 - (N_X_FRAC (n) - 1) * STEP_X_SMALL (n))
+
+#define X_FRAC_FIRST(n) (STEP_X_BIG (n) / 2)
+#define X_FRAC_LAST(n)  (X_FRAC_FIRST (n) + (N_X_FRAC (n) - 1) * STEP_X_SMALL (n))
+
+#define RENDER_SAMPLES_X(x, n)                                         \
+    ((n) == 1? 0 : (pixman_fixed_frac (x) +                            \
+                   X_FRAC_FIRST (n)) / STEP_X_SMALL (n))
+
+void
+pixman_rasterize_edges_accessors (pixman_image_t *image,
+                                  pixman_edge_t * l,
+                                  pixman_edge_t * r,
+                                  pixman_fixed_t  t,
+                                  pixman_fixed_t  b);
+
+/*
+ * Implementations
+ */
+typedef struct pixman_implementation_t pixman_implementation_t;
+
+typedef struct
+{
+    pixman_op_t              op;
+    pixman_image_t *         src_image;
+    pixman_image_t *         mask_image;
+    pixman_image_t *         dest_image;
+    int32_t                  src_x;
+    int32_t                  src_y;
+    int32_t                  mask_x;
+    int32_t                  mask_y;
+    int32_t                  dest_x;
+    int32_t                  dest_y;
+    int32_t                  width;
+    int32_t                  height;
+
+    uint32_t                 src_flags;
+    uint32_t                 mask_flags;
+    uint32_t                 dest_flags;
+} pixman_composite_info_t;
+
+#define PIXMAN_COMPOSITE_ARGS(info)                                    \
+    MAYBE_UNUSED pixman_op_t        op = info->op;                     \
+    MAYBE_UNUSED pixman_image_t *   src_image = info->src_image;       \
+    MAYBE_UNUSED pixman_image_t *   mask_image = info->mask_image;     \
+    MAYBE_UNUSED pixman_image_t *   dest_image = info->dest_image;     \
+    MAYBE_UNUSED int32_t            src_x = info->src_x;               \
+    MAYBE_UNUSED int32_t            src_y = info->src_y;               \
+    MAYBE_UNUSED int32_t            mask_x = info->mask_x;             \
+    MAYBE_UNUSED int32_t            mask_y = info->mask_y;             \
+    MAYBE_UNUSED int32_t            dest_x = info->dest_x;             \
+    MAYBE_UNUSED int32_t            dest_y = info->dest_y;             \
+    MAYBE_UNUSED int32_t            width = info->width;               \
+    MAYBE_UNUSED int32_t            height = info->height
+
+typedef void (*pixman_combine_32_func_t) (pixman_implementation_t *imp,
+                                         pixman_op_t              op,
+                                         uint32_t *               dest,
+                                         const uint32_t *         src,
+                                         const uint32_t *         mask,
+                                         int                      width);
+
+typedef void (*pixman_combine_64_func_t) (pixman_implementation_t *imp,
+                                         pixman_op_t              op,
+                                         uint64_t *               dest,
+                                         const uint64_t *         src,
+                                         const uint64_t *         mask,
+                                         int                      width);
+
+typedef void (*pixman_composite_func_t) (pixman_implementation_t *imp,
+                                        pixman_composite_info_t *info);
+typedef pixman_bool_t (*pixman_blt_func_t) (pixman_implementation_t *imp,
+                                           uint32_t *               src_bits,
+                                           uint32_t *               dst_bits,
+                                           int                      src_stride,
+                                           int                      dst_stride,
+                                           int                      src_bpp,
+                                           int                      dst_bpp,
+                                           int                      src_x,
+                                           int                      src_y,
+                                           int                      dest_x,
+                                           int                      dest_y,
+                                           int                      width,
+                                           int                      height);
+typedef pixman_bool_t (*pixman_fill_func_t) (pixman_implementation_t *imp,
+                                            uint32_t *               bits,
+                                            int                      stride,
+                                            int                      bpp,
+                                            int                      x,
+                                            int                      y,
+                                            int                      width,
+                                            int                      height,
+                                            uint32_t                 xor);
+typedef void (*pixman_iter_init_func_t) (pixman_implementation_t *imp,
+                                         pixman_iter_t           *iter);
+
+void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp);
+void _pixman_setup_combiner_functions_64 (pixman_implementation_t *imp);
+
+typedef struct
+{
+    pixman_op_t             op;
+    pixman_format_code_t    src_format;
+    uint32_t               src_flags;
+    pixman_format_code_t    mask_format;
+    uint32_t               mask_flags;
+    pixman_format_code_t    dest_format;
+    uint32_t               dest_flags;
+    pixman_composite_func_t func;
+} pixman_fast_path_t;
+
+struct pixman_implementation_t
+{
+    pixman_implementation_t *  toplevel;
+    pixman_implementation_t *  delegate;
+    const pixman_fast_path_t * fast_paths;
+
+    pixman_blt_func_t          blt;
+    pixman_fill_func_t         fill;
+    pixman_iter_init_func_t     src_iter_init;
+    pixman_iter_init_func_t     dest_iter_init;
+
+    pixman_combine_32_func_t   combine_32[PIXMAN_N_OPERATORS];
+    pixman_combine_32_func_t   combine_32_ca[PIXMAN_N_OPERATORS];
+    pixman_combine_64_func_t   combine_64[PIXMAN_N_OPERATORS];
+    pixman_combine_64_func_t   combine_64_ca[PIXMAN_N_OPERATORS];
+};
+
+uint32_t
+_pixman_image_get_solid (pixman_implementation_t *imp,
+                        pixman_image_t *         image,
+                         pixman_format_code_t     format);
+
+pixman_implementation_t *
+_pixman_implementation_create (pixman_implementation_t *delegate,
+                              const pixman_fast_path_t *fast_paths);
+
+pixman_combine_32_func_t
+_pixman_implementation_lookup_combiner (pixman_implementation_t *imp,
+                                       pixman_op_t              op,
+                                       pixman_bool_t            component_alpha,
+                                       pixman_bool_t            wide);
+
+pixman_bool_t
+_pixman_implementation_blt (pixman_implementation_t *imp,
+                            uint32_t *               src_bits,
+                            uint32_t *               dst_bits,
+                            int                      src_stride,
+                            int                      dst_stride,
+                            int                      src_bpp,
+                            int                      dst_bpp,
+                            int                      src_x,
+                            int                      src_y,
+                            int                      dest_x,
+                            int                      dest_y,
+                            int                      width,
+                            int                      height);
+
+pixman_bool_t
+_pixman_implementation_fill (pixman_implementation_t *imp,
+                             uint32_t *               bits,
+                             int                      stride,
+                             int                      bpp,
+                             int                      x,
+                             int                      y,
+                             int                      width,
+                             int                      height,
+                             uint32_t                 xor);
+
+void
+_pixman_implementation_src_iter_init (pixman_implementation_t       *imp,
+                                     pixman_iter_t                 *iter,
+                                     pixman_image_t                *image,
+                                     int                            x,
+                                     int                            y,
+                                     int                            width,
+                                     int                            height,
+                                     uint8_t                       *buffer,
+                                     iter_flags_t                   flags);
+
+void
+_pixman_implementation_dest_iter_init (pixman_implementation_t       *imp,
+                                      pixman_iter_t                 *iter,
+                                      pixman_image_t                *image,
+                                      int                            x,
+                                      int                            y,
+                                      int                            width,
+                                      int                            height,
+                                      uint8_t                       *buffer,
+                                      iter_flags_t                   flags);
+
+/* Specific implementations */
+pixman_implementation_t *
+_pixman_implementation_create_general (void);
+
+pixman_implementation_t *
+_pixman_implementation_create_fast_path (pixman_implementation_t *fallback);
+
+pixman_implementation_t *
+_pixman_implementation_create_noop (pixman_implementation_t *fallback);
+
+#if defined USE_X86_MMX || defined USE_ARM_IWMMXT || defined USE_LOONGSON_MMI
+pixman_implementation_t *
+_pixman_implementation_create_mmx (pixman_implementation_t *fallback);
+#endif
+
+#ifdef USE_SSE2
+pixman_implementation_t *
+_pixman_implementation_create_sse2 (pixman_implementation_t *fallback);
+#endif
+
+#ifdef USE_ARM_SIMD
+pixman_implementation_t *
+_pixman_implementation_create_arm_simd (pixman_implementation_t *fallback);
+#endif
+
+#ifdef USE_ARM_NEON
+pixman_implementation_t *
+_pixman_implementation_create_arm_neon (pixman_implementation_t *fallback);
+#endif
+
+#ifdef USE_MIPS_DSPR2
+pixman_implementation_t *
+_pixman_implementation_create_mips_dspr2 (pixman_implementation_t *fallback);
+#endif
+
+#ifdef USE_VMX
+pixman_implementation_t *
+_pixman_implementation_create_vmx (pixman_implementation_t *fallback);
+#endif
+
+pixman_implementation_t *
+_pixman_choose_implementation (void);
+
+
+
+/*
+ * Utilities
+ */
+uint32_t *
+_pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask);
+
+/* These "formats" all have depth 0, so they
+ * will never clash with any real ones
+ */
+#define PIXMAN_null             PIXMAN_FORMAT (0, 0, 0, 0, 0, 0)
+#define PIXMAN_solid            PIXMAN_FORMAT (0, 1, 0, 0, 0, 0)
+#define PIXMAN_pixbuf          PIXMAN_FORMAT (0, 2, 0, 0, 0, 0)
+#define PIXMAN_rpixbuf         PIXMAN_FORMAT (0, 3, 0, 0, 0, 0)
+#define PIXMAN_unknown         PIXMAN_FORMAT (0, 4, 0, 0, 0, 0)
+#define PIXMAN_any             PIXMAN_FORMAT (0, 5, 0, 0, 0, 0)
+
+#define PIXMAN_OP_any          (PIXMAN_N_OPERATORS + 1)
+
+#define FAST_PATH_ID_TRANSFORM                 (1 <<  0)
+#define FAST_PATH_NO_ALPHA_MAP                 (1 <<  1)
+#define FAST_PATH_NO_CONVOLUTION_FILTER                (1 <<  2)
+#define FAST_PATH_NO_PAD_REPEAT                        (1 <<  3)
+#define FAST_PATH_NO_REFLECT_REPEAT            (1 <<  4)
+#define FAST_PATH_NO_ACCESSORS                 (1 <<  5)
+#define FAST_PATH_NARROW_FORMAT                        (1 <<  6)
+#define FAST_PATH_COMPONENT_ALPHA              (1 <<  8)
+#define FAST_PATH_SAMPLES_OPAQUE               (1 <<  7)
+#define FAST_PATH_UNIFIED_ALPHA                        (1 <<  9)
+#define FAST_PATH_SCALE_TRANSFORM              (1 << 10)
+#define FAST_PATH_NEAREST_FILTER               (1 << 11)
+#define FAST_PATH_HAS_TRANSFORM                        (1 << 12)
+#define FAST_PATH_IS_OPAQUE                    (1 << 13)
+#define FAST_PATH_NO_NORMAL_REPEAT             (1 << 14)
+#define FAST_PATH_NO_NONE_REPEAT               (1 << 15)
+#define FAST_PATH_X_UNIT_POSITIVE              (1 << 16)
+#define FAST_PATH_AFFINE_TRANSFORM             (1 << 17)
+#define FAST_PATH_Y_UNIT_ZERO                  (1 << 18)
+#define FAST_PATH_BILINEAR_FILTER              (1 << 19)
+#define FAST_PATH_ROTATE_90_TRANSFORM          (1 << 20)
+#define FAST_PATH_ROTATE_180_TRANSFORM         (1 << 21)
+#define FAST_PATH_ROTATE_270_TRANSFORM         (1 << 22)
+#define FAST_PATH_SAMPLES_COVER_CLIP_NEAREST   (1 << 23)
+#define FAST_PATH_SAMPLES_COVER_CLIP_BILINEAR  (1 << 24)
+#define FAST_PATH_BITS_IMAGE                   (1 << 25)
+
+#define FAST_PATH_PAD_REPEAT                                           \
+    (FAST_PATH_NO_NONE_REPEAT          |                               \
+     FAST_PATH_NO_NORMAL_REPEAT                |                               \
+     FAST_PATH_NO_REFLECT_REPEAT)
+
+#define FAST_PATH_NORMAL_REPEAT                                                \
+    (FAST_PATH_NO_NONE_REPEAT          |                               \
+     FAST_PATH_NO_PAD_REPEAT           |                               \
+     FAST_PATH_NO_REFLECT_REPEAT)
+
+#define FAST_PATH_NONE_REPEAT                                          \
+    (FAST_PATH_NO_NORMAL_REPEAT                |                               \
+     FAST_PATH_NO_PAD_REPEAT           |                               \
+     FAST_PATH_NO_REFLECT_REPEAT)
+
+#define FAST_PATH_REFLECT_REPEAT                                       \
+    (FAST_PATH_NO_NONE_REPEAT          |                               \
+     FAST_PATH_NO_NORMAL_REPEAT                |                               \
+     FAST_PATH_NO_PAD_REPEAT)
+
+#define FAST_PATH_STANDARD_FLAGS                                       \
+    (FAST_PATH_NO_CONVOLUTION_FILTER   |                               \
+     FAST_PATH_NO_ACCESSORS            |                               \
+     FAST_PATH_NO_ALPHA_MAP            |                               \
+     FAST_PATH_NARROW_FORMAT)
+
+#define FAST_PATH_STD_DEST_FLAGS                                       \
+    (FAST_PATH_NO_ACCESSORS            |                               \
+     FAST_PATH_NO_ALPHA_MAP            |                               \
+     FAST_PATH_NARROW_FORMAT)
+
+#define SOURCE_FLAGS(format)                                           \
+    (FAST_PATH_STANDARD_FLAGS |                                                \
+     ((PIXMAN_ ## format == PIXMAN_solid) ?                            \
+      0 : (FAST_PATH_SAMPLES_COVER_CLIP_NEAREST | FAST_PATH_NEAREST_FILTER | FAST_PATH_ID_TRANSFORM)))
+
+#define MASK_FLAGS(format, extra)                                      \
+    ((PIXMAN_ ## format == PIXMAN_null) ? 0 : (SOURCE_FLAGS (format) | extra))
+
+#define FAST_PATH(op, src, src_flags, mask, mask_flags, dest, dest_flags, func) \
+    PIXMAN_OP_ ## op,                                                  \
+    PIXMAN_ ## src,                                                    \
+    src_flags,                                                         \
+    PIXMAN_ ## mask,                                                   \
+    mask_flags,                                                                \
+    PIXMAN_ ## dest,                                                   \
+    dest_flags,                                                                \
+    func
+
+#define PIXMAN_STD_FAST_PATH(op, src, mask, dest, func)                        \
+    { FAST_PATH (                                                      \
+           op,                                                         \
+           src,  SOURCE_FLAGS (src),                                   \
+           mask, MASK_FLAGS (mask, FAST_PATH_UNIFIED_ALPHA),           \
+           dest, FAST_PATH_STD_DEST_FLAGS,                             \
+           func) }
+
+#define PIXMAN_STD_FAST_PATH_CA(op, src, mask, dest, func)             \
+    { FAST_PATH (                                                      \
+           op,                                                         \
+           src,  SOURCE_FLAGS (src),                                   \
+           mask, MASK_FLAGS (mask, FAST_PATH_COMPONENT_ALPHA),         \
+           dest, FAST_PATH_STD_DEST_FLAGS,                             \
+           func) }
+
+/* Memory allocation helpers */
+void *
+pixman_malloc_ab (unsigned int n, unsigned int b);
+
+void *
+pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
+
+pixman_bool_t
+_pixman_multiply_overflows_size (size_t a, size_t b);
+
+pixman_bool_t
+_pixman_multiply_overflows_int (unsigned int a, unsigned int b);
+
+pixman_bool_t
+_pixman_addition_overflows_int (unsigned int a, unsigned int b);
+
+/* Compositing utilities */
+void
+pixman_expand (uint64_t *           dst,
+               const uint32_t *     src,
+               pixman_format_code_t format,
+               int                  width);
+
+void
+pixman_contract (uint32_t *      dst,
+                 const uint64_t *src,
+                 int             width);
+
+pixman_bool_t
+_pixman_lookup_composite_function (pixman_implementation_t     *toplevel,
+                                  pixman_op_t                  op,
+                                  pixman_format_code_t         src_format,
+                                  uint32_t                     src_flags,
+                                  pixman_format_code_t         mask_format,
+                                  uint32_t                     mask_flags,
+                                  pixman_format_code_t         dest_format,
+                                  uint32_t                     dest_flags,
+                                  pixman_implementation_t    **out_imp,
+                                  pixman_composite_func_t     *out_func);
+
+/* Region Helpers */
+pixman_bool_t
+pixman_region32_copy_from_region16 (pixman_region32_t *dst,
+                                    pixman_region16_t *src);
+
+pixman_bool_t
+pixman_region16_copy_from_region32 (pixman_region16_t *dst,
+                                    pixman_region32_t *src);
+
+
+/* Misc macros */
+
+#ifndef FALSE
+#   define FALSE 0
+#endif
+
+#ifndef TRUE
+#   define TRUE 1
+#endif
+
+#ifndef MIN
+#  define MIN(a, b) ((a < b) ? a : b)
+#endif
+
+#ifndef MAX
+#  define MAX(a, b) ((a > b) ? a : b)
+#endif
+
+/* Integer division that rounds towards -infinity */
+#define DIV(a, b)                                         \
+    ((((a) < 0) == ((b) < 0)) ? (a) / (b) :                \
+     ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
+
+/* Modulus that produces the remainder wrt. DIV */
+#define MOD(a, b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
+
+#define CLIP(v, low, high) ((v) < (low) ? (low) : ((v) > (high) ? (high) : (v)))
+
+/* Conversion between 8888 and 0565 */
+
+#define CONVERT_8888_TO_0565(s)                                                \
+    ((((s) >> 3) & 0x001f) |                                           \
+     (((s) >> 5) & 0x07e0) |                                           \
+     (((s) >> 8) & 0xf800))
+
+#define CONVERT_0565_TO_0888(s)                                                \
+    (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) |                      \
+     ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) |                  \
+     ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
+
+#define CONVERT_0565_TO_8888(s) (CONVERT_0565_TO_0888(s) | 0xff000000)
+
+/* Trivial versions that are useful in macros */
+#define CONVERT_8888_TO_8888(s) (s)
+#define CONVERT_x888_TO_8888(s) ((s) | 0xff000000)
+#define CONVERT_0565_TO_0565(s) (s)
+
+#define PIXMAN_FORMAT_IS_WIDE(f)                                       \
+    (PIXMAN_FORMAT_A (f) > 8 ||                                                \
+     PIXMAN_FORMAT_R (f) > 8 ||                                                \
+     PIXMAN_FORMAT_G (f) > 8 ||                                                \
+     PIXMAN_FORMAT_B (f) > 8)
+
+#ifdef WORDS_BIGENDIAN
+#   define SCREEN_SHIFT_LEFT(x,n)      ((x) << (n))
+#   define SCREEN_SHIFT_RIGHT(x,n)     ((x) >> (n))
+#else
+#   define SCREEN_SHIFT_LEFT(x,n)      ((x) >> (n))
+#   define SCREEN_SHIFT_RIGHT(x,n)     ((x) << (n))
+#endif
+
+static force_inline uint32_t
+unorm_to_unorm (uint32_t val, int from_bits, int to_bits)
+{
+    uint32_t result;
+
+    if (from_bits == 0)
+       return 0;
+
+    /* Delete any extra bits */
+    val &= ((1 << from_bits) - 1);
+
+    if (from_bits >= to_bits)
+       return val >> (from_bits - to_bits);
+
+    /* Start out with the high bit of val in the high bit of result. */
+    result = val << (to_bits - from_bits);
+
+    /* Copy the bits in result, doubling the number of bits each time, until
+     * we fill all to_bits. Unrolled manually because from_bits and to_bits
+     * are usually known statically, so the compiler can turn all of this
+     * into a few shifts.
+     */
+#define REPLICATE()                                                    \
+    do                                                                 \
+    {                                                                  \
+       if (from_bits < to_bits)                                        \
+       {                                                               \
+           result |= result >> from_bits;                              \
+                                                                       \
+           from_bits *= 2;                                             \
+       }                                                               \
+    }                                                                  \
+    while (0)
+
+    REPLICATE();
+    REPLICATE();
+    REPLICATE();
+    REPLICATE();
+    REPLICATE();
+
+    return result;
+}
+
+/*
+ * Various debugging code
+ */
+
+#undef DEBUG
+
+#define COMPILE_TIME_ASSERT(x)                                         \
+    do { typedef int compile_time_assertion [(x)?1:-1]; } while (0)
+
+/* Turn on debugging depending on what type of release this is
+ */
+#if (((PIXMAN_VERSION_MICRO % 2) == 0) && ((PIXMAN_VERSION_MINOR % 2) == 1))
+
+/* Debugging gets turned on for development releases because these
+ * are the things that end up in bleeding edge distributions such
+ * as Rawhide etc.
+ *
+ * For performance reasons we don't turn it on for stable releases or
+ * random git checkouts. (Random git checkouts are often used for
+ * performance work).
+ */
+
+#    define DEBUG
+
+#endif
+
+#ifdef DEBUG
+
+void
+_pixman_log_error (const char *function, const char *message);
+
+#define return_if_fail(expr)                                            \
+    do                                                                  \
+    {                                                                   \
+       if (!(expr))                                                    \
+       {                                                               \
+           _pixman_log_error (FUNC, "The expression " # expr " was false"); \
+           return;                                                     \
+       }                                                               \
+    }                                                                   \
+    while (0)
+
+#define return_val_if_fail(expr, retval)                                \
+    do                                                                  \
+    {                                                                   \
+       if (!(expr))                                                    \
+       {                                                               \
+           _pixman_log_error (FUNC, "The expression " # expr " was false"); \
+           return (retval);                                            \
+       }                                                               \
+    }                                                                   \
+    while (0)
+
+#define critical_if_fail(expr)                                         \
+    do                                                                 \
+    {                                                                  \
+       if (!(expr))                                                    \
+           _pixman_log_error (FUNC, "The expression " # expr " was false"); \
+    }                                                                  \
+    while (0)
+
+
+#else
+
+#define _pixman_log_error(f,m) do { } while (0)                                \
+
+#define return_if_fail(expr)                                           \
+    do                                                                  \
+    {                                                                   \
+       if (!(expr))                                                    \
+           return;                                                     \
+    }                                                                   \
+    while (0)
+
+#define return_val_if_fail(expr, retval)                                \
+    do                                                                  \
+    {                                                                   \
+       if (!(expr))                                                    \
+           return (retval);                                            \
+    }                                                                   \
+    while (0)
+
+#define critical_if_fail(expr)                                         \
+    do                                                                 \
+    {                                                                  \
+    }                                                                  \
+    while (0)
+#endif
+
+/*
+ * Timers
+ */
+
+#ifdef PIXMAN_TIMERS
+
+static inline uint64_t
+oil_profile_stamp_rdtsc (void)
+{
+    uint32_t hi, lo;
+
+    __asm__ __volatile__ ("rdtsc\n" : "=a" (lo), "=d" (hi));
+
+    return lo | (((uint64_t)hi) << 32);
+}
+
+#define OIL_STAMP oil_profile_stamp_rdtsc
+
+typedef struct pixman_timer_t pixman_timer_t;
+
+struct pixman_timer_t
+{
+    int             initialized;
+    const char *    name;
+    uint64_t        n_times;
+    uint64_t        total;
+    pixman_timer_t *next;
+};
+
+extern int timer_defined;
+
+void pixman_timer_register (pixman_timer_t *timer);
+
+#define TIMER_BEGIN(tname)                                              \
+    {                                                                   \
+       static pixman_timer_t timer ## tname;                           \
+       uint64_t              begin ## tname;                           \
+                                                                       \
+       if (!timer ## tname.initialized)                                \
+       {                                                               \
+           timer ## tname.initialized = 1;                             \
+           timer ## tname.name = # tname;                              \
+           pixman_timer_register (&timer ## tname);                    \
+       }                                                               \
+                                                                       \
+       timer ## tname.n_times++;                                       \
+       begin ## tname = OIL_STAMP ();
+
+#define TIMER_END(tname)                                                \
+    timer ## tname.total += OIL_STAMP () - begin ## tname;             \
+    }
+
+#endif /* PIXMAN_TIMERS */
+
+void _pixman_arm_check_neon(void);
+void _pixman_arm_check_v6(void);
+
+#endif /* PIXMAN_PRIVATE_H */
diff --git a/TC/testcase/pixman-version.h b/TC/testcase/pixman-version.h
new file mode 100644 (file)
index 0000000..93a5d4e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright Â© 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#ifndef PIXMAN_VERSION_H__
+#define PIXMAN_VERSION_H__
+
+#ifndef PIXMAN_H__
+#  error pixman-version.h should only be included by pixman.h
+#endif
+
+#define PIXMAN_VERSION_MAJOR 0
+#define PIXMAN_VERSION_MINOR 26
+#define PIXMAN_VERSION_MICRO 0
+
+#define PIXMAN_VERSION_STRING "0.26.0"
+
+#define PIXMAN_VERSION_ENCODE(major, minor, micro) (   \
+         ((major) * 10000)                             \
+       + ((minor) *   100)                             \
+       + ((micro) *     1))
+
+#define PIXMAN_VERSION PIXMAN_VERSION_ENCODE(  \
+       PIXMAN_VERSION_MAJOR,                   \
+       PIXMAN_VERSION_MINOR,                   \
+       PIXMAN_VERSION_MICRO)
+
+#endif /* PIXMAN_VERSION_H__ */
diff --git a/TC/testcase/pixman.h b/TC/testcase/pixman.h
new file mode 100644 (file)
index 0000000..18d9513
--- /dev/null
@@ -0,0 +1,992 @@
+/***********************************************************
+
+Copyright 1987, 1998  The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+/*
+ * Copyright Â© 1998, 2004 Keith Packard
+ * Copyright   2007 Red Hat, Inc.
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef PIXMAN_H__
+#define PIXMAN_H__
+
+#include <pixman-version.h>
+
+#ifdef  __cplusplus
+#define PIXMAN_BEGIN_DECLS extern "C" {
+#define PIXMAN_END_DECLS }
+#else
+#define PIXMAN_BEGIN_DECLS
+#define PIXMAN_END_DECLS
+#endif
+
+PIXMAN_BEGIN_DECLS
+
+/*
+ * Standard integers
+ */
+
+#if !defined (PIXMAN_DONT_DEFINE_STDINT)
+
+#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || defined (_sgi) || defined (__sun) || defined (sun) || defined (__digital__) || defined (__HP_cc)
+#  include <inttypes.h>
+/* VS 2010 (_MSC_VER 1600) has stdint.h */
+#elif defined (_MSC_VER) && _MSC_VER < 1600
+typedef __int8 int8_t;
+typedef unsigned __int8 uint8_t;
+typedef __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#elif defined (_AIX)
+#  include <sys/inttypes.h>
+#else
+#  include <stdint.h>
+#endif
+
+#endif
+
+/*
+ * Boolean
+ */
+typedef int pixman_bool_t;
+
+/*
+ * Fixpoint numbers
+ */
+typedef int64_t                        pixman_fixed_32_32_t;
+typedef pixman_fixed_32_32_t   pixman_fixed_48_16_t;
+typedef uint32_t               pixman_fixed_1_31_t;
+typedef uint32_t               pixman_fixed_1_16_t;
+typedef int32_t                        pixman_fixed_16_16_t;
+typedef pixman_fixed_16_16_t   pixman_fixed_t;
+
+#define pixman_fixed_e                 ((pixman_fixed_t) 1)
+#define pixman_fixed_1                 (pixman_int_to_fixed(1))
+#define pixman_fixed_1_minus_e         (pixman_fixed_1 - pixman_fixed_e)
+#define pixman_fixed_minus_1           (pixman_int_to_fixed(-1))
+#define pixman_fixed_to_int(f)         ((int) ((f) >> 16))
+#define pixman_int_to_fixed(i)         ((pixman_fixed_t) ((i) << 16))
+#define pixman_fixed_to_double(f)      (double) ((f) / (double) pixman_fixed_1)
+#define pixman_double_to_fixed(d)      ((pixman_fixed_t) ((d) * 65536.0))
+#define pixman_fixed_frac(f)           ((f) & pixman_fixed_1_minus_e)
+#define pixman_fixed_floor(f)          ((f) & ~pixman_fixed_1_minus_e)
+#define pixman_fixed_ceil(f)           pixman_fixed_floor ((f) + pixman_fixed_1_minus_e)
+#define pixman_fixed_fraction(f)       ((f) & pixman_fixed_1_minus_e)
+#define pixman_fixed_mod_2(f)          ((f) & (pixman_fixed1 | pixman_fixed_1_minus_e))
+#define pixman_max_fixed_48_16         ((pixman_fixed_48_16_t) 0x7fffffff)
+#define pixman_min_fixed_48_16         (-((pixman_fixed_48_16_t) 1 << 31))
+
+/*
+ * Misc structs
+ */
+typedef struct pixman_color pixman_color_t;
+typedef struct pixman_point_fixed pixman_point_fixed_t;
+typedef struct pixman_line_fixed pixman_line_fixed_t;
+typedef struct pixman_vector pixman_vector_t;
+typedef struct pixman_transform pixman_transform_t;
+
+struct pixman_color
+{
+    uint16_t   red;
+    uint16_t    green;
+    uint16_t    blue;
+    uint16_t    alpha;
+};
+
+struct pixman_point_fixed
+{
+    pixman_fixed_t     x;
+    pixman_fixed_t     y;
+};
+
+struct pixman_line_fixed
+{
+    pixman_point_fixed_t       p1, p2;
+};
+
+/*
+ * Fixed point matrices
+ */
+
+struct pixman_vector
+{
+    pixman_fixed_t     vector[3];
+};
+
+struct pixman_transform
+{
+    pixman_fixed_t     matrix[3][3];
+};
+
+/* forward declaration (sorry) */
+struct pixman_box16;
+typedef  union pixman_image            pixman_image_t;
+
+void          pixman_transform_init_identity    (struct pixman_transform       *matrix);
+pixman_bool_t pixman_transform_point_3d         (const struct pixman_transform *transform,
+                                                struct pixman_vector          *vector);
+pixman_bool_t pixman_transform_point            (const struct pixman_transform *transform,
+                                                struct pixman_vector          *vector);
+pixman_bool_t pixman_transform_multiply         (struct pixman_transform       *dst,
+                                                const struct pixman_transform *l,
+                                                const struct pixman_transform *r);
+void          pixman_transform_init_scale       (struct pixman_transform       *t,
+                                                pixman_fixed_t                 sx,
+                                                pixman_fixed_t                 sy);
+pixman_bool_t pixman_transform_scale            (struct pixman_transform       *forward,
+                                                struct pixman_transform       *reverse,
+                                                pixman_fixed_t                 sx,
+                                                pixman_fixed_t                 sy);
+void          pixman_transform_init_rotate      (struct pixman_transform       *t,
+                                                pixman_fixed_t                 cos,
+                                                pixman_fixed_t                 sin);
+pixman_bool_t pixman_transform_rotate           (struct pixman_transform       *forward,
+                                                struct pixman_transform       *reverse,
+                                                pixman_fixed_t                 c,
+                                                pixman_fixed_t                 s);
+void          pixman_transform_init_translate   (struct pixman_transform       *t,
+                                                pixman_fixed_t                 tx,
+                                                pixman_fixed_t                 ty);
+pixman_bool_t pixman_transform_translate        (struct pixman_transform       *forward,
+                                                struct pixman_transform       *reverse,
+                                                pixman_fixed_t                 tx,
+                                                pixman_fixed_t                 ty);
+pixman_bool_t pixman_transform_bounds           (const struct pixman_transform *matrix,
+                                                struct pixman_box16           *b);
+pixman_bool_t pixman_transform_invert           (struct pixman_transform       *dst,
+                                                const struct pixman_transform *src);
+pixman_bool_t pixman_transform_is_identity      (const struct pixman_transform *t);
+pixman_bool_t pixman_transform_is_scale         (const struct pixman_transform *t);
+pixman_bool_t pixman_transform_is_int_translate (const struct pixman_transform *t);
+pixman_bool_t pixman_transform_is_inverse       (const struct pixman_transform *a,
+                                                const struct pixman_transform *b);
+
+/*
+ * Floating point matrices
+ */
+struct pixman_f_vector
+{
+    double  v[3];
+};
+
+struct pixman_f_transform
+{
+    double  m[3][3];
+};
+
+pixman_bool_t pixman_transform_from_pixman_f_transform (struct pixman_transform         *t,
+                                                       const struct pixman_f_transform *ft);
+void          pixman_f_transform_from_pixman_transform (struct pixman_f_transform       *ft,
+                                                       const struct pixman_transform   *t);
+pixman_bool_t pixman_f_transform_invert                (struct pixman_f_transform       *dst,
+                                                       const struct pixman_f_transform *src);
+pixman_bool_t pixman_f_transform_point                 (const struct pixman_f_transform *t,
+                                                       struct pixman_f_vector          *v);
+void          pixman_f_transform_point_3d              (const struct pixman_f_transform *t,
+                                                       struct pixman_f_vector          *v);
+void          pixman_f_transform_multiply              (struct pixman_f_transform       *dst,
+                                                       const struct pixman_f_transform *l,
+                                                       const struct pixman_f_transform *r);
+void          pixman_f_transform_init_scale            (struct pixman_f_transform       *t,
+                                                       double                           sx,
+                                                       double                           sy);
+pixman_bool_t pixman_f_transform_scale                 (struct pixman_f_transform       *forward,
+                                                       struct pixman_f_transform       *reverse,
+                                                       double                           sx,
+                                                       double                           sy);
+void          pixman_f_transform_init_rotate           (struct pixman_f_transform       *t,
+                                                       double                           cos,
+                                                       double                           sin);
+pixman_bool_t pixman_f_transform_rotate                (struct pixman_f_transform       *forward,
+                                                       struct pixman_f_transform       *reverse,
+                                                       double                           c,
+                                                       double                           s);
+void          pixman_f_transform_init_translate        (struct pixman_f_transform       *t,
+                                                       double                           tx,
+                                                       double                           ty);
+pixman_bool_t pixman_f_transform_translate             (struct pixman_f_transform       *forward,
+                                                       struct pixman_f_transform       *reverse,
+                                                       double                           tx,
+                                                       double                           ty);
+pixman_bool_t pixman_f_transform_bounds                (const struct pixman_f_transform *t,
+                                                       struct pixman_box16             *b);
+void          pixman_f_transform_init_identity         (struct pixman_f_transform       *t);
+
+typedef enum
+{
+    PIXMAN_REPEAT_NONE,
+    PIXMAN_REPEAT_NORMAL,
+    PIXMAN_REPEAT_PAD,
+    PIXMAN_REPEAT_REFLECT
+} pixman_repeat_t;
+
+typedef enum
+{
+    PIXMAN_FILTER_FAST,
+    PIXMAN_FILTER_GOOD,
+    PIXMAN_FILTER_BEST,
+    PIXMAN_FILTER_NEAREST,
+    PIXMAN_FILTER_BILINEAR,
+    PIXMAN_FILTER_CONVOLUTION
+} pixman_filter_t;
+
+typedef enum
+{
+    PIXMAN_OP_CLEAR                    = 0x00,
+    PIXMAN_OP_SRC                      = 0x01,
+    PIXMAN_OP_DST                      = 0x02,
+    PIXMAN_OP_OVER                     = 0x03,
+    PIXMAN_OP_OVER_REVERSE             = 0x04,
+    PIXMAN_OP_IN                       = 0x05,
+    PIXMAN_OP_IN_REVERSE               = 0x06,
+    PIXMAN_OP_OUT                      = 0x07,
+    PIXMAN_OP_OUT_REVERSE              = 0x08,
+    PIXMAN_OP_ATOP                     = 0x09,
+    PIXMAN_OP_ATOP_REVERSE             = 0x0a,
+    PIXMAN_OP_XOR                      = 0x0b,
+    PIXMAN_OP_ADD                      = 0x0c,
+    PIXMAN_OP_SATURATE                 = 0x0d,
+
+    PIXMAN_OP_DISJOINT_CLEAR           = 0x10,
+    PIXMAN_OP_DISJOINT_SRC             = 0x11,
+    PIXMAN_OP_DISJOINT_DST             = 0x12,
+    PIXMAN_OP_DISJOINT_OVER            = 0x13,
+    PIXMAN_OP_DISJOINT_OVER_REVERSE    = 0x14,
+    PIXMAN_OP_DISJOINT_IN              = 0x15,
+    PIXMAN_OP_DISJOINT_IN_REVERSE      = 0x16,
+    PIXMAN_OP_DISJOINT_OUT             = 0x17,
+    PIXMAN_OP_DISJOINT_OUT_REVERSE     = 0x18,
+    PIXMAN_OP_DISJOINT_ATOP            = 0x19,
+    PIXMAN_OP_DISJOINT_ATOP_REVERSE    = 0x1a,
+    PIXMAN_OP_DISJOINT_XOR             = 0x1b,
+
+    PIXMAN_OP_CONJOINT_CLEAR           = 0x20,
+    PIXMAN_OP_CONJOINT_SRC             = 0x21,
+    PIXMAN_OP_CONJOINT_DST             = 0x22,
+    PIXMAN_OP_CONJOINT_OVER            = 0x23,
+    PIXMAN_OP_CONJOINT_OVER_REVERSE    = 0x24,
+    PIXMAN_OP_CONJOINT_IN              = 0x25,
+    PIXMAN_OP_CONJOINT_IN_REVERSE      = 0x26,
+    PIXMAN_OP_CONJOINT_OUT             = 0x27,
+    PIXMAN_OP_CONJOINT_OUT_REVERSE     = 0x28,
+    PIXMAN_OP_CONJOINT_ATOP            = 0x29,
+    PIXMAN_OP_CONJOINT_ATOP_REVERSE    = 0x2a,
+    PIXMAN_OP_CONJOINT_XOR             = 0x2b,
+
+    PIXMAN_OP_MULTIPLY                  = 0x30,
+    PIXMAN_OP_SCREEN                    = 0x31,
+    PIXMAN_OP_OVERLAY                   = 0x32,
+    PIXMAN_OP_DARKEN                    = 0x33,
+    PIXMAN_OP_LIGHTEN                   = 0x34,
+    PIXMAN_OP_COLOR_DODGE               = 0x35,
+    PIXMAN_OP_COLOR_BURN                = 0x36,
+    PIXMAN_OP_HARD_LIGHT                = 0x37,
+    PIXMAN_OP_SOFT_LIGHT                = 0x38,
+    PIXMAN_OP_DIFFERENCE                = 0x39,
+    PIXMAN_OP_EXCLUSION                 = 0x3a,
+    PIXMAN_OP_HSL_HUE                  = 0x3b,
+    PIXMAN_OP_HSL_SATURATION           = 0x3c,
+    PIXMAN_OP_HSL_COLOR                        = 0x3d,
+    PIXMAN_OP_HSL_LUMINOSITY           = 0x3e
+
+#ifdef PIXMAN_USE_INTERNAL_API
+    ,
+    PIXMAN_N_OPERATORS,
+    PIXMAN_OP_NONE = PIXMAN_N_OPERATORS
+#endif
+} pixman_op_t;
+
+/*
+ * Regions
+ */
+typedef struct pixman_region16_data    pixman_region16_data_t;
+typedef struct pixman_box16            pixman_box16_t;
+typedef struct pixman_rectangle16      pixman_rectangle16_t;
+typedef struct pixman_region16         pixman_region16_t;
+
+struct pixman_region16_data {
+    long               size;
+    long               numRects;
+/*  pixman_box16_t     rects[size];   in memory but not explicitly declared */
+};
+
+struct pixman_rectangle16
+{
+    int16_t    x, y;
+    uint16_t   width, height;
+};
+
+struct pixman_box16
+{
+    int16_t x1, y1, x2, y2;
+};
+
+struct pixman_region16
+{
+    pixman_box16_t          extents;
+    pixman_region16_data_t *data;
+};
+
+typedef enum
+{
+    PIXMAN_REGION_OUT,
+    PIXMAN_REGION_IN,
+    PIXMAN_REGION_PART
+} pixman_region_overlap_t;
+
+/* This function exists only to make it possible to preserve
+ * the X ABI - it should go away at first opportunity.
+ */
+void pixman_region_set_static_pointers (pixman_box16_t         *empty_box,
+                                       pixman_region16_data_t *empty_data,
+                                       pixman_region16_data_t *broken_data);
+
+/* creation/destruction */
+void                    pixman_region_init               (pixman_region16_t *region);
+void                    pixman_region_init_rect          (pixman_region16_t *region,
+                                                         int                x,
+                                                         int                y,
+                                                         unsigned int       width,
+                                                         unsigned int       height);
+pixman_bool_t           pixman_region_init_rects         (pixman_region16_t *region,
+                                                         const pixman_box16_t *boxes,
+                                                         int                count);
+void                    pixman_region_init_with_extents  (pixman_region16_t *region,
+                                                         pixman_box16_t    *extents);
+void                    pixman_region_init_from_image    (pixman_region16_t *region,
+                                                         pixman_image_t    *image);
+void                    pixman_region_fini               (pixman_region16_t *region);
+
+
+/* manipulation */
+void                    pixman_region_translate          (pixman_region16_t *region,
+                                                         int                x,
+                                                         int                y);
+pixman_bool_t           pixman_region_copy               (pixman_region16_t *dest,
+                                                         pixman_region16_t *source);
+pixman_bool_t           pixman_region_intersect          (pixman_region16_t *new_reg,
+                                                         pixman_region16_t *reg1,
+                                                         pixman_region16_t *reg2);
+pixman_bool_t           pixman_region_union              (pixman_region16_t *new_reg,
+                                                         pixman_region16_t *reg1,
+                                                         pixman_region16_t *reg2);
+pixman_bool_t           pixman_region_union_rect         (pixman_region16_t *dest,
+                                                         pixman_region16_t *source,
+                                                         int                x,
+                                                         int                y,
+                                                         unsigned int       width,
+                                                         unsigned int       height);
+pixman_bool_t          pixman_region_intersect_rect     (pixman_region16_t *dest,
+                                                         pixman_region16_t *source,
+                                                         int                x,
+                                                         int                y,
+                                                         unsigned int       width,
+                                                         unsigned int       height);
+pixman_bool_t           pixman_region_subtract           (pixman_region16_t *reg_d,
+                                                         pixman_region16_t *reg_m,
+                                                         pixman_region16_t *reg_s);
+pixman_bool_t           pixman_region_inverse            (pixman_region16_t *new_reg,
+                                                         pixman_region16_t *reg1,
+                                                         pixman_box16_t    *inv_rect);
+pixman_bool_t           pixman_region_contains_point     (pixman_region16_t *region,
+                                                         int                x,
+                                                         int                y,
+                                                         pixman_box16_t    *box);
+pixman_region_overlap_t pixman_region_contains_rectangle (pixman_region16_t *region,
+                                                         pixman_box16_t    *prect);
+pixman_bool_t           pixman_region_not_empty          (pixman_region16_t *region);
+pixman_box16_t *        pixman_region_extents            (pixman_region16_t *region);
+int                     pixman_region_n_rects            (pixman_region16_t *region);
+pixman_box16_t *        pixman_region_rectangles         (pixman_region16_t *region,
+                                                         int               *n_rects);
+pixman_bool_t           pixman_region_equal              (pixman_region16_t *region1,
+                                                         pixman_region16_t *region2);
+pixman_bool_t           pixman_region_selfcheck          (pixman_region16_t *region);
+void                    pixman_region_reset              (pixman_region16_t *region,
+                                                         pixman_box16_t    *box);
+void                   pixman_region_clear              (pixman_region16_t *region);
+/*
+ * 32 bit regions
+ */
+typedef struct pixman_region32_data    pixman_region32_data_t;
+typedef struct pixman_box32            pixman_box32_t;
+typedef struct pixman_rectangle32      pixman_rectangle32_t;
+typedef struct pixman_region32         pixman_region32_t;
+
+struct pixman_region32_data {
+    long               size;
+    long               numRects;
+/*  pixman_box32_t     rects[size];   in memory but not explicitly declared */
+};
+
+struct pixman_rectangle32
+{
+    int32_t x, y;
+    uint32_t width, height;
+};
+
+struct pixman_box32
+{
+    int32_t x1, y1, x2, y2;
+};
+
+struct pixman_region32
+{
+    pixman_box32_t          extents;
+    pixman_region32_data_t  *data;
+};
+
+/* creation/destruction */
+void                    pixman_region32_init               (pixman_region32_t *region);
+void                    pixman_region32_init_rect          (pixman_region32_t *region,
+                                                           int                x,
+                                                           int                y,
+                                                           unsigned int       width,
+                                                           unsigned int       height);
+pixman_bool_t           pixman_region32_init_rects         (pixman_region32_t *region,
+                                                           const pixman_box32_t *boxes,
+                                                           int                count);
+void                    pixman_region32_init_with_extents  (pixman_region32_t *region,
+                                                           pixman_box32_t    *extents);
+void                    pixman_region32_init_from_image    (pixman_region32_t *region,
+                                                           pixman_image_t    *image);
+void                    pixman_region32_fini               (pixman_region32_t *region);
+
+
+/* manipulation */
+void                    pixman_region32_translate          (pixman_region32_t *region,
+                                                           int                x,
+                                                           int                y);
+pixman_bool_t           pixman_region32_copy               (pixman_region32_t *dest,
+                                                           pixman_region32_t *source);
+pixman_bool_t           pixman_region32_intersect          (pixman_region32_t *new_reg,
+                                                           pixman_region32_t *reg1,
+                                                           pixman_region32_t *reg2);
+pixman_bool_t           pixman_region32_union              (pixman_region32_t *new_reg,
+                                                           pixman_region32_t *reg1,
+                                                           pixman_region32_t *reg2);
+pixman_bool_t          pixman_region32_intersect_rect     (pixman_region32_t *dest,
+                                                           pixman_region32_t *source,
+                                                           int                x,
+                                                           int                y,
+                                                           unsigned int       width,
+                                                           unsigned int       height);
+pixman_bool_t           pixman_region32_union_rect         (pixman_region32_t *dest,
+                                                           pixman_region32_t *source,
+                                                           int                x,
+                                                           int                y,
+                                                           unsigned int       width,
+                                                           unsigned int       height);
+pixman_bool_t           pixman_region32_subtract           (pixman_region32_t *reg_d,
+                                                           pixman_region32_t *reg_m,
+                                                           pixman_region32_t *reg_s);
+pixman_bool_t           pixman_region32_inverse            (pixman_region32_t *new_reg,
+                                                           pixman_region32_t *reg1,
+                                                           pixman_box32_t    *inv_rect);
+pixman_bool_t           pixman_region32_contains_point     (pixman_region32_t *region,
+                                                           int                x,
+                                                           int                y,
+                                                           pixman_box32_t    *box);
+pixman_region_overlap_t pixman_region32_contains_rectangle (pixman_region32_t *region,
+                                                           pixman_box32_t    *prect);
+pixman_bool_t           pixman_region32_not_empty          (pixman_region32_t *region);
+pixman_box32_t *        pixman_region32_extents            (pixman_region32_t *region);
+int                     pixman_region32_n_rects            (pixman_region32_t *region);
+pixman_box32_t *        pixman_region32_rectangles         (pixman_region32_t *region,
+                                                           int               *n_rects);
+pixman_bool_t           pixman_region32_equal              (pixman_region32_t *region1,
+                                                           pixman_region32_t *region2);
+pixman_bool_t           pixman_region32_selfcheck          (pixman_region32_t *region);
+void                    pixman_region32_reset              (pixman_region32_t *region,
+                                                           pixman_box32_t    *box);
+void                   pixman_region32_clear              (pixman_region32_t *region);
+
+
+/* Copy / Fill / Misc */
+pixman_bool_t pixman_blt                (uint32_t           *src_bits,
+                                        uint32_t           *dst_bits,
+                                        int                 src_stride,
+                                        int                 dst_stride,
+                                        int                 src_bpp,
+                                        int                 dst_bpp,
+                                        int                 src_x,
+                                        int                 src_y,
+                                        int                 dest_x,
+                                        int                 dest_y,
+                                        int                 width,
+                                        int                 height);
+pixman_bool_t pixman_fill               (uint32_t           *bits,
+                                        int                 stride,
+                                        int                 bpp,
+                                        int                 x,
+                                        int                 y,
+                                        int                 width,
+                                        int                 height,
+                                        uint32_t            _xor);
+
+int           pixman_version            (void);
+const char*   pixman_version_string     (void);
+
+/*
+ * Images
+ */
+typedef struct pixman_indexed          pixman_indexed_t;
+typedef struct pixman_gradient_stop    pixman_gradient_stop_t;
+
+typedef uint32_t (* pixman_read_memory_func_t) (const void *src, int size);
+typedef void     (* pixman_write_memory_func_t) (void *dst, uint32_t value, int size);
+
+typedef void     (* pixman_image_destroy_func_t) (pixman_image_t *image, void *data);
+
+struct pixman_gradient_stop {
+    pixman_fixed_t x;
+    pixman_color_t color;
+};
+
+#define PIXMAN_MAX_INDEXED  256 /* XXX depth must be <= 8 */
+
+#if PIXMAN_MAX_INDEXED <= 256
+typedef uint8_t pixman_index_type;
+#endif
+
+struct pixman_indexed
+{
+    pixman_bool_t       color;
+    uint32_t           rgba[PIXMAN_MAX_INDEXED];
+    pixman_index_type  ent[32768];
+};
+
+/*
+ * While the protocol is generous in format support, the
+ * sample implementation allows only packed RGB and GBR
+ * representations for data to simplify software rendering,
+ */
+#define PIXMAN_FORMAT(bpp,type,a,r,g,b)        (((bpp) << 24) |  \
+                                        ((type) << 16) | \
+                                        ((a) << 12) |    \
+                                        ((r) << 8) |     \
+                                        ((g) << 4) |     \
+                                        ((b)))
+
+#define PIXMAN_FORMAT_BPP(f)   (((f) >> 24)       )
+#define PIXMAN_FORMAT_TYPE(f)  (((f) >> 16) & 0xff)
+#define PIXMAN_FORMAT_A(f)     (((f) >> 12) & 0x0f)
+#define PIXMAN_FORMAT_R(f)     (((f) >>  8) & 0x0f)
+#define PIXMAN_FORMAT_G(f)     (((f) >>  4) & 0x0f)
+#define PIXMAN_FORMAT_B(f)     (((f)      ) & 0x0f)
+#define PIXMAN_FORMAT_RGB(f)   (((f)      ) & 0xfff)
+#define PIXMAN_FORMAT_VIS(f)   (((f)      ) & 0xffff)
+#define PIXMAN_FORMAT_DEPTH(f) (PIXMAN_FORMAT_A(f) +   \
+                                PIXMAN_FORMAT_R(f) +   \
+                                PIXMAN_FORMAT_G(f) +   \
+                                PIXMAN_FORMAT_B(f))
+
+#define PIXMAN_TYPE_OTHER      0
+#define PIXMAN_TYPE_A          1
+#define PIXMAN_TYPE_ARGB       2
+#define PIXMAN_TYPE_ABGR       3
+#define PIXMAN_TYPE_COLOR      4
+#define PIXMAN_TYPE_GRAY       5
+#define PIXMAN_TYPE_YUY2       6
+#define PIXMAN_TYPE_YV12       7
+#define PIXMAN_TYPE_BGRA       8
+#define PIXMAN_TYPE_RGBA       9
+
+#define PIXMAN_FORMAT_COLOR(f)                         \
+       (PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ARGB ||   \
+        PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ABGR ||   \
+        PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_BGRA ||   \
+        PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_RGBA)
+
+/* 32bpp formats */
+typedef enum {
+    PIXMAN_a8r8g8b8 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8),
+    PIXMAN_x8r8g8b8 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8),
+    PIXMAN_a8b8g8r8 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8),
+    PIXMAN_x8b8g8r8 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8),
+    PIXMAN_b8g8r8a8 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8),
+    PIXMAN_b8g8r8x8 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8),
+    PIXMAN_r8g8b8a8 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8),
+    PIXMAN_r8g8b8x8 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8),
+    PIXMAN_x14r6g6b6 =  PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6),
+    PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10),
+    PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10),
+    PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10),
+    PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10),
+
+/* 24bpp formats */
+    PIXMAN_r8g8b8 =     PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8),
+    PIXMAN_b8g8r8 =     PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8),
+
+/* 16bpp formats */
+    PIXMAN_r5g6b5 =     PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5),
+    PIXMAN_b5g6r5 =     PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5),
+
+    PIXMAN_a1r5g5b5 =   PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5),
+    PIXMAN_x1r5g5b5 =   PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5),
+    PIXMAN_a1b5g5r5 =   PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5),
+    PIXMAN_x1b5g5r5 =   PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5),
+    PIXMAN_a4r4g4b4 =   PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4),
+    PIXMAN_x4r4g4b4 =   PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4),
+    PIXMAN_a4b4g4r4 =   PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4),
+    PIXMAN_x4b4g4r4 =   PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4),
+
+/* 8bpp formats */
+    PIXMAN_a8 =                 PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0),
+    PIXMAN_r3g3b2 =     PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2),
+    PIXMAN_b2g3r3 =     PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2),
+    PIXMAN_a2r2g2b2 =   PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2),
+    PIXMAN_a2b2g2r2 =   PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2),
+
+    PIXMAN_c8 =                 PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
+    PIXMAN_g8 =                 PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
+
+    PIXMAN_x4a4 =       PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0),
+
+    PIXMAN_x4c4 =       PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
+    PIXMAN_x4g4 =       PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
+
+/* 4bpp formats */
+    PIXMAN_a4 =                 PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0),
+    PIXMAN_r1g2b1 =     PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1),
+    PIXMAN_b1g2r1 =     PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1),
+    PIXMAN_a1r1g1b1 =   PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1),
+    PIXMAN_a1b1g1r1 =   PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1),
+
+    PIXMAN_c4 =                 PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0),
+    PIXMAN_g4 =                 PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0),
+
+/* 1bpp formats */
+    PIXMAN_a1 =                 PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0),
+
+    PIXMAN_g1 =                 PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0),
+
+/* YUV formats */
+    PIXMAN_yuy2 =       PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0),
+    PIXMAN_yv12 =       PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0)
+} pixman_format_code_t;
+
+/* Querying supported format values. */
+pixman_bool_t pixman_format_supported_destination (pixman_format_code_t format);
+pixman_bool_t pixman_format_supported_source      (pixman_format_code_t format);
+
+/* Constructors */
+pixman_image_t *pixman_image_create_solid_fill       (pixman_color_t               *color);
+pixman_image_t *pixman_image_create_linear_gradient  (pixman_point_fixed_t         *p1,
+                                                     pixman_point_fixed_t         *p2,
+                                                     const pixman_gradient_stop_t *stops,
+                                                     int                           n_stops);
+pixman_image_t *pixman_image_create_radial_gradient  (pixman_point_fixed_t         *inner,
+                                                     pixman_point_fixed_t         *outer,
+                                                     pixman_fixed_t                inner_radius,
+                                                     pixman_fixed_t                outer_radius,
+                                                     const pixman_gradient_stop_t *stops,
+                                                     int                           n_stops);
+pixman_image_t *pixman_image_create_conical_gradient (pixman_point_fixed_t         *center,
+                                                     pixman_fixed_t                angle,
+                                                     const pixman_gradient_stop_t *stops,
+                                                     int                           n_stops);
+pixman_image_t *pixman_image_create_bits             (pixman_format_code_t          format,
+                                                     int                           width,
+                                                     int                           height,
+                                                     uint32_t                     *bits,
+                                                     int                           rowstride_bytes);
+
+/* Destructor */
+pixman_image_t *pixman_image_ref                     (pixman_image_t               *image);
+pixman_bool_t   pixman_image_unref                   (pixman_image_t               *image);
+
+void           pixman_image_set_destroy_function    (pixman_image_t               *image,
+                                                     pixman_image_destroy_func_t   function,
+                                                     void                         *data);
+void *         pixman_image_get_destroy_data        (pixman_image_t               *image);
+
+/* Set properties */
+pixman_bool_t   pixman_image_set_clip_region         (pixman_image_t               *image,
+                                                     pixman_region16_t            *region);
+pixman_bool_t   pixman_image_set_clip_region32       (pixman_image_t               *image,
+                                                     pixman_region32_t            *region);
+void           pixman_image_set_has_client_clip     (pixman_image_t               *image,
+                                                     pixman_bool_t                 clien_clip);
+pixman_bool_t   pixman_image_set_transform           (pixman_image_t               *image,
+                                                     const pixman_transform_t     *transform);
+void            pixman_image_set_repeat              (pixman_image_t               *image,
+                                                     pixman_repeat_t               repeat);
+pixman_bool_t   pixman_image_set_filter              (pixman_image_t               *image,
+                                                     pixman_filter_t               filter,
+                                                     const pixman_fixed_t         *filter_params,
+                                                     int                           n_filter_params);
+void           pixman_image_set_source_clipping     (pixman_image_t               *image,
+                                                     pixman_bool_t                 source_clipping);
+void            pixman_image_set_alpha_map           (pixman_image_t               *image,
+                                                     pixman_image_t               *alpha_map,
+                                                     int16_t                       x,
+                                                     int16_t                       y);
+void            pixman_image_set_component_alpha     (pixman_image_t               *image,
+                                                     pixman_bool_t                 component_alpha);
+pixman_bool_t   pixman_image_get_component_alpha     (pixman_image_t               *image);
+void           pixman_image_set_accessors           (pixman_image_t               *image,
+                                                     pixman_read_memory_func_t     read_func,
+                                                     pixman_write_memory_func_t    write_func);
+void           pixman_image_set_indexed             (pixman_image_t               *image,
+                                                     const pixman_indexed_t       *indexed);
+uint32_t       *pixman_image_get_data                (pixman_image_t               *image);
+int            pixman_image_get_width               (pixman_image_t               *image);
+int             pixman_image_get_height              (pixman_image_t               *image);
+int            pixman_image_get_stride              (pixman_image_t               *image); /* in bytes */
+int            pixman_image_get_depth               (pixman_image_t               *image);
+pixman_format_code_t pixman_image_get_format        (pixman_image_t               *image);
+pixman_bool_t  pixman_image_fill_rectangles         (pixman_op_t                   op,
+                                                     pixman_image_t               *image,
+                                                     pixman_color_t               *color,
+                                                     int                           n_rects,
+                                                     const pixman_rectangle16_t   *rects);
+pixman_bool_t   pixman_image_fill_boxes              (pixman_op_t                   op,
+                                                      pixman_image_t               *dest,
+                                                      pixman_color_t               *color,
+                                                      int                           n_boxes,
+                                                      const pixman_box32_t         *boxes);
+
+/* Composite */
+pixman_bool_t pixman_compute_composite_region (pixman_region16_t *region,
+                                              pixman_image_t    *src_image,
+                                              pixman_image_t    *mask_image,
+                                              pixman_image_t    *dest_image,
+                                              int16_t            src_x,
+                                              int16_t            src_y,
+                                              int16_t            mask_x,
+                                              int16_t            mask_y,
+                                              int16_t            dest_x,
+                                              int16_t            dest_y,
+                                              uint16_t           width,
+                                              uint16_t           height);
+void          pixman_image_composite          (pixman_op_t        op,
+                                              pixman_image_t    *src,
+                                              pixman_image_t    *mask,
+                                              pixman_image_t    *dest,
+                                              int16_t            src_x,
+                                              int16_t            src_y,
+                                              int16_t            mask_x,
+                                              int16_t            mask_y,
+                                              int16_t            dest_x,
+                                              int16_t            dest_y,
+                                              uint16_t           width,
+                                              uint16_t           height);
+void          pixman_image_composite32        (pixman_op_t        op,
+                                              pixman_image_t    *src,
+                                              pixman_image_t    *mask,
+                                              pixman_image_t    *dest,
+                                              int32_t            src_x,
+                                              int32_t            src_y,
+                                              int32_t            mask_x,
+                                              int32_t            mask_y,
+                                              int32_t            dest_x,
+                                              int32_t            dest_y,
+                                              int32_t            width,
+                                              int32_t            height);
+
+/* Executive Summary: This function is a no-op that only exists
+ * for historical reasons.
+ *
+ * There used to be a bug in the X server where it would rely on
+ * out-of-bounds accesses when it was asked to composite with a
+ * window as the source. It would create a pixman image pointing
+ * to some bogus position in memory, but then set a clip region
+ * to the position where the actual bits were.
+ *
+ * Due to a bug in old versions of pixman, where it would not clip
+ * against the image bounds when a clip region was set, this would
+ * actually work. So when the pixman bug was fixed, a workaround was
+ * added to allow certain out-of-bound accesses. This function disabled
+ * those workarounds.
+ *
+ * Since 0.21.2, pixman doesn't do these workarounds anymore, so now this
+ * function is a no-op.
+ */
+void pixman_disable_out_of_bounds_workaround (void);
+
+/*
+ * Trapezoids
+ */
+typedef struct pixman_edge pixman_edge_t;
+typedef struct pixman_trapezoid pixman_trapezoid_t;
+typedef struct pixman_trap pixman_trap_t;
+typedef struct pixman_span_fix pixman_span_fix_t;
+typedef struct pixman_triangle pixman_triangle_t;
+
+/*
+ * An edge structure.  This represents a single polygon edge
+ * and can be quickly stepped across small or large gaps in the
+ * sample grid
+ */
+struct pixman_edge
+{
+    pixman_fixed_t     x;
+    pixman_fixed_t     e;
+    pixman_fixed_t     stepx;
+    pixman_fixed_t     signdx;
+    pixman_fixed_t     dy;
+    pixman_fixed_t     dx;
+
+    pixman_fixed_t     stepx_small;
+    pixman_fixed_t     stepx_big;
+    pixman_fixed_t     dx_small;
+    pixman_fixed_t     dx_big;
+};
+
+struct pixman_trapezoid
+{
+    pixman_fixed_t     top, bottom;
+    pixman_line_fixed_t        left, right;
+};
+
+struct pixman_triangle
+{
+    pixman_point_fixed_t p1, p2, p3;
+};
+
+/* whether 't' is a well defined not obviously empty trapezoid */
+#define pixman_trapezoid_valid(t)                                 \
+    ((t)->left.p1.y != (t)->left.p2.y &&                          \
+     (t)->right.p1.y != (t)->right.p2.y &&                        \
+     (int) ((t)->bottom - (t)->top) > 0)
+
+struct pixman_span_fix
+{
+    pixman_fixed_t     l, r, y;
+};
+
+struct pixman_trap
+{
+    pixman_span_fix_t  top, bot;
+};
+
+pixman_fixed_t pixman_sample_ceil_y        (pixman_fixed_t             y,
+                                           int                        bpp);
+pixman_fixed_t pixman_sample_floor_y       (pixman_fixed_t             y,
+                                           int                        bpp);
+void           pixman_edge_step            (pixman_edge_t             *e,
+                                           int                        n);
+void           pixman_edge_init            (pixman_edge_t             *e,
+                                           int                        bpp,
+                                           pixman_fixed_t             y_start,
+                                           pixman_fixed_t             x_top,
+                                           pixman_fixed_t             y_top,
+                                           pixman_fixed_t             x_bot,
+                                           pixman_fixed_t             y_bot);
+void           pixman_line_fixed_edge_init (pixman_edge_t             *e,
+                                           int                        bpp,
+                                           pixman_fixed_t             y,
+                                           const pixman_line_fixed_t *line,
+                                           int                        x_off,
+                                           int                        y_off);
+void           pixman_rasterize_edges      (pixman_image_t            *image,
+                                           pixman_edge_t             *l,
+                                           pixman_edge_t             *r,
+                                           pixman_fixed_t             t,
+                                           pixman_fixed_t             b);
+void           pixman_add_traps            (pixman_image_t            *image,
+                                           int16_t                    x_off,
+                                           int16_t                    y_off,
+                                           int                        ntrap,
+                                           pixman_trap_t             *traps);
+void           pixman_add_trapezoids       (pixman_image_t            *image,
+                                           int16_t                    x_off,
+                                           int                        y_off,
+                                           int                        ntraps,
+                                           const pixman_trapezoid_t  *traps);
+void           pixman_rasterize_trapezoid  (pixman_image_t            *image,
+                                           const pixman_trapezoid_t  *trap,
+                                           int                        x_off,
+                                           int                        y_off);
+void          pixman_composite_trapezoids (pixman_op_t                op,
+                                          pixman_image_t *            src,
+                                          pixman_image_t *            dst,
+                                          pixman_format_code_t        mask_format,
+                                          int                         x_src,
+                                          int                         y_src,
+                                          int                         x_dst,
+                                          int                         y_dst,
+                                          int                         n_traps,
+                                          const pixman_trapezoid_t *  traps);
+void          pixman_composite_triangles (pixman_op_t                 op,
+                                         pixman_image_t *             src,
+                                         pixman_image_t *             dst,
+                                         pixman_format_code_t         mask_format,
+                                         int                          x_src,
+                                         int                          y_src,
+                                         int                          x_dst,
+                                         int                          y_dst,
+                                         int                          n_tris,
+                                         const pixman_triangle_t *    tris);
+void         pixman_add_triangles       (pixman_image_t              *image,
+                                         int32_t                      x_off,
+                                         int32_t                      y_off,
+                                         int                          n_tris,
+                                         const pixman_triangle_t     *tris);
+
+PIXMAN_END_DECLS
+
+#endif /* PIXMAN_H__ */
diff --git a/TC/testcase/tslist b/TC/testcase/tslist
new file mode 100644 (file)
index 0000000..350571a
--- /dev/null
@@ -0,0 +1,14 @@
+/testcase/utc_a1_trap_test
+/testcase/utc_affine_test
+/testcase/utc_blitters_test
+/testcase/utc_composite_traps_test
+/testcase/utc_fetch_test
+/testcase/utc_gradient_crash_test
+/testcase/utc_oob_test
+/testcase/utc_pdf_op_test
+/testcase/utc_region_contains_test
+/testcase/utc_region_test
+/testcase/utc_region_translate_test
+/testcase/utc_scaling_crash_test
+/testcase/utc_scaling_helpers_test
+/testcase/utc_scaling_test
diff --git a/TC/testcase/utc_a1_trap_test.c b/TC/testcase/utc_a1_trap_test.c
new file mode 100644 (file)
index 0000000..0c30225
--- /dev/null
@@ -0,0 +1,78 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pixman.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_a1_trap(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_a1_trap, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+static void utc_pixman_a1_trap(void)
+{
+
+#define WIDTH 20
+#define HEIGHT 20
+
+    pixman_image_t *src_img;
+    pixman_image_t *mask_img;
+    pixman_image_t *dest_img;
+    pixman_trap_t trap;
+    pixman_color_t red = { 0xffff, 0x0000, 0x0000, 0xffff };
+    uint32_t *bits = malloc (WIDTH * HEIGHT * 4);
+    uint32_t *mbits = malloc (WIDTH * HEIGHT);
+
+    memset (mbits, 0, WIDTH * HEIGHT);
+    memset (bits, 0xff, WIDTH * HEIGHT * 4);
+
+    trap.top.l = pixman_double_to_fixed (0.5);
+    trap.top.r = pixman_double_to_fixed (1.5);
+    trap.top.y = pixman_double_to_fixed (0.5);
+
+    trap.bot.l = pixman_double_to_fixed (0.5);
+    trap.bot.r = pixman_double_to_fixed (1.5);
+    trap.bot.y = pixman_double_to_fixed (1.5);
+
+    mask_img = pixman_image_create_bits (
+       PIXMAN_a1, WIDTH, HEIGHT, mbits, WIDTH);
+    src_img = pixman_image_create_solid_fill (&red);
+    dest_img = pixman_image_create_bits (
+       PIXMAN_a8r8g8b8, WIDTH, HEIGHT, bits, WIDTH * 4);
+
+    pixman_add_traps (mask_img, 0, 0, 1, &trap);
+
+    pixman_image_composite (PIXMAN_OP_OVER,
+                           src_img, mask_img, dest_img,
+                           0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+
+    if (bits[0] != 0xffff0000)
+        dts_fail("utc_pixman_a1_trap");
+    if (bits[1] != 0xffffffff)
+        dts_fail("utc_pixman_a1_trap");
+    if (bits[1 * WIDTH + 0] != 0xffffffff)
+        dts_fail("utc_pixman_a1_trap");
+    if (bits[1 * WIDTH + 1] != 0xffffffff)
+        dts_fail("utc_pixman_a1_trap");
+
+    dts_pass("utc_pixman_a1_trap");
+}
diff --git a/TC/testcase/utc_affine_test.c b/TC/testcase/utc_affine_test.c
new file mode 100644 (file)
index 0000000..b0346f7
--- /dev/null
@@ -0,0 +1,333 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.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
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_affine(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_affine, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+/*
+ * 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;
+    pixman_op_t        op;
+    pixman_repeat_t    repeat = PIXMAN_REPEAT_NONE;
+    pixman_format_code_t src_fmt, dst_fmt;
+    uint32_t *         srcbuf;
+    uint32_t *         dstbuf;
+    uint32_t           crc32;
+    FLOAT_REGS_CORRUPTION_DETECTOR_START ();
+
+    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);
+    image_endian_swap (dst_img);
+
+    pixman_transform_init_identity (&transform);
+
+    if (lcg_rand_n (3) > 0)
+    {
+       scale_x = -65536 * 3 + lcg_rand_N (65536 * 6);
+       if (lcg_rand_n (2))
+           scale_y = -65536 * 3 + lcg_rand_N (65536 * 6);
+       else
+           scale_y = scale_x;
+       pixman_transform_init_scale (&transform, scale_x, scale_y);
+    }
+    if (lcg_rand_n (3) > 0)
+    {
+       translate_x = -65536 * 3 + lcg_rand_N (6 * 65536);
+       if (lcg_rand_n (2))
+           translate_y = -65536 * 3 + lcg_rand_N (6 * 65536);
+       else
+           translate_y = translate_x;
+       pixman_transform_translate (&transform, NULL, translate_x, translate_y);
+    }
+
+    if (lcg_rand_n (4) > 0)
+    {
+       int c, s, tx = 0, ty = 0;
+       switch (lcg_rand_n (4))
+       {
+       case 0:
+           /* 90 degrees */
+           c = 0;
+           s = pixman_fixed_1;
+           tx = pixman_int_to_fixed (MAX_SRC_HEIGHT);
+           break;
+       case 1:
+           /* 180 degrees */
+           c = -pixman_fixed_1;
+           s = 0;
+           tx = pixman_int_to_fixed (MAX_SRC_WIDTH);
+           ty = pixman_int_to_fixed (MAX_SRC_HEIGHT);
+           break;
+       case 2:
+           /* 270 degrees */
+           c = 0;
+           s = -pixman_fixed_1;
+           ty = pixman_int_to_fixed (MAX_SRC_WIDTH);
+           break;
+       default:
+           /* arbitrary rotation */
+           c = lcg_rand_N (2 * 65536) - 65536;
+           s = lcg_rand_N (2 * 65536) - 65536;
+           break;
+       }
+       pixman_transform_rotate (&transform, NULL, c, s);
+       pixman_transform_translate (&transform, NULL, tx, ty);
+    }
+
+    if (lcg_rand_n (8) == 0)
+    {
+       /* Flip random bits */
+       int maxflipcount = 8;
+       while (maxflipcount--)
+       {
+           int i = lcg_rand_n (2);
+           int j = lcg_rand_n (3);
+           int bitnum = lcg_rand_n (32);
+           transform.matrix[i][j] ^= 1 << bitnum;
+           if (lcg_rand_n (2))
+               break;
+       }
+    }
+
+    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);
+
+    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);
+
+    FLOAT_REGS_CORRUPTION_DETECTOR_FINISH ();
+    return crc32;
+}
+
+static void utc_pixman_affine(void)
+{
+    int ret;
+
+    pixman_disable_out_of_bounds_workaround ();
+
+    ret = fuzzer_test_main ("affine", 8000000, 0x1EF2175A,
+                            test_composite, 1, NULL);
+    if(ret)
+        dts_fail("utc_pixman_affine");
+
+    dts_pass("utc_pixman_affine");
+}
diff --git a/TC/testcase/utc_blitters_test.c b/TC/testcase/utc_blitters_test.c
new file mode 100644 (file)
index 0000000..7675b1d
--- /dev/null
@@ -0,0 +1,456 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "utils.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_blitters(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_blitters, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+static pixman_indexed_t rgb_palette[9];
+static pixman_indexed_t y_palette[9];
+
+/* The first eight format in the list are by far the most widely
+ * used formats, so we test those more than the others
+ */
+#define N_MOST_LIKELY_FORMATS 8
+
+/* 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] != PIXMAN_null)
+       n++;
+
+    if (n > N_MOST_LIKELY_FORMATS && lcg_rand_n (4) != 0)
+       n = N_MOST_LIKELY_FORMATS;
+    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)]));
+    }
+
+    if (lcg_rand_n (16) == 0)
+       pixman_image_set_filter (img, PIXMAN_FILTER_BILINEAR, NULL, 0);
+
+    image_endian_swap (img);
+
+    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 != PIXMAN_null)
+    {
+       /* 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 ||
+               PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_RGBA)
+           {
+               mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
+           }
+
+           for (i = 0; i * PIXMAN_FORMAT_BPP (fmt) < 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);
+       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_a8b8g8r8,
+    PIXMAN_x8r8g8b8,
+    PIXMAN_x8b8g8r8,
+    PIXMAN_r5g6b5,
+    PIXMAN_b5g6r5,
+    PIXMAN_a8,
+    PIXMAN_a1,
+    PIXMAN_r3g3b2,
+    PIXMAN_b8g8r8a8,
+    PIXMAN_b8g8r8x8,
+    PIXMAN_r8g8b8a8,
+    PIXMAN_r8g8b8x8,
+    PIXMAN_x14r6g6b6,
+    PIXMAN_r8g8b8,
+    PIXMAN_b8g8r8,
+    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_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_null
+};
+
+static pixman_format_code_t mask_fmt_list[] = {
+    PIXMAN_a8r8g8b8,
+    PIXMAN_a8,
+    PIXMAN_a4,
+    PIXMAN_a1,
+    PIXMAN_null
+};
+
+
+/*
+ * 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;
+    pixman_op_t 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;
+    FLOAT_REGS_CORRUPTION_DETECTOR_START ();
+
+    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 (ARRAY_LENGTH (op_list))];
+
+    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 = PIXMAN_null;
+    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, PIXMAN_null);
+    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, PIXMAN_null);
+    }
+
+    FLOAT_REGS_CORRUPTION_DETECTOR_FINISH ();
+    return crc32;
+}
+
+
+static void utc_pixman_blitters(void)
+{
+
+    int i;
+    int ret;
+
+    for (i = 1; i <= 8; i++)
+    {
+       initialize_palette (&(rgb_palette[i]), i, TRUE);
+       initialize_palette (&(y_palette[i]), i, FALSE);
+    }
+
+    ret = fuzzer_test_main("blitters", 2000000,
+                           0xA364B5BF,
+                           test_composite, 1, NULL);
+
+    if(ret)
+        dts_fail("utc_pixman_blitters");
+
+    dts_pass("utc_pixman_blitters");
+}
diff --git a/TC/testcase/utc_composite_traps_test.c b/TC/testcase/utc_composite_traps_test.c
new file mode 100644 (file)
index 0000000..67bbe8e
--- /dev/null
@@ -0,0 +1,287 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "utils.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_composite_traps(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_composite_traps, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+#define MAX_SRC_WIDTH  48
+#define MAX_SRC_HEIGHT 48
+#define MAX_DST_WIDTH  48
+#define MAX_DST_HEIGHT 48
+#define MAX_STRIDE     4
+
+static pixman_format_code_t formats[] =
+{
+    PIXMAN_a8r8g8b8, PIXMAN_a8, PIXMAN_r5g6b5, PIXMAN_a1, PIXMAN_a4
+};
+
+static pixman_format_code_t mask_formats[] =
+{
+    PIXMAN_a1, PIXMAN_a4, PIXMAN_a8,
+};
+
+static pixman_op_t operators[] =
+{
+    PIXMAN_OP_OVER, PIXMAN_OP_ADD, PIXMAN_OP_SRC, PIXMAN_OP_IN
+};
+
+#define RANDOM_ELT(array)                                              \
+    ((array)[lcg_rand_n(ARRAY_LENGTH((array)))])
+
+static void
+destroy_bits (pixman_image_t *image, void *data)
+{
+    fence_free (data);
+}
+
+static pixman_fixed_t
+random_fixed (int n)
+{
+    return lcg_rand_N (n << 16);
+}
+
+/*
+ * 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_region16_t  clip;
+    int                dst_width, dst_height;
+    int                dst_stride;
+    int                dst_x, dst_y;
+    int                dst_bpp;
+    pixman_op_t        op;
+    uint32_t *         dst_bits;
+    uint32_t           crc32;
+    pixman_format_code_t mask_format, dst_format;
+    pixman_trapezoid_t *traps;
+    int src_x, src_y;
+    int n_traps;
+
+    static pixman_color_t colors[] =
+    {
+       { 0xffff, 0xffff, 0xffff, 0xffff },
+       { 0x0000, 0x0000, 0x0000, 0x0000 },
+       { 0xabcd, 0xabcd, 0x0000, 0xabcd },
+       { 0x0000, 0x0000, 0x0000, 0xffff },
+       { 0x0101, 0x0101, 0x0101, 0x0101 },
+       { 0x7777, 0x6666, 0x5555, 0x9999 },
+    };
+
+    FLOAT_REGS_CORRUPTION_DETECTOR_START ();
+
+    lcg_srand (testnum);
+
+    op = RANDOM_ELT (operators);
+    mask_format = RANDOM_ELT (mask_formats);
+
+    /* Create source image */
+
+    if (lcg_rand_n (4) == 0)
+    {
+       src_img = pixman_image_create_solid_fill (
+           &(colors[lcg_rand_n (ARRAY_LENGTH (colors))]));
+
+       src_x = 10;
+       src_y = 234;
+    }
+    else
+    {
+       pixman_format_code_t src_format = RANDOM_ELT(formats);
+       int src_bpp = (PIXMAN_FORMAT_BPP (src_format) + 7) / 8;
+       int src_width = lcg_rand_n (MAX_SRC_WIDTH) + 1;
+       int src_height = lcg_rand_n (MAX_SRC_HEIGHT) + 1;
+       int src_stride = src_width * src_bpp + lcg_rand_n (MAX_STRIDE) * src_bpp;
+       uint32_t *bits;
+
+       src_x = -(src_width / 4) + lcg_rand_n (src_width * 3 / 2);
+       src_y = -(src_height / 4) + lcg_rand_n (src_height * 3 / 2);
+
+       src_stride = (src_stride + 3) & ~3;
+
+       bits = (uint32_t *)make_random_bytes (src_stride * src_height);
+
+       src_img = pixman_image_create_bits (
+           src_format, src_width, src_height, bits, src_stride);
+
+       pixman_image_set_destroy_function (src_img, destroy_bits, bits);
+
+       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);
+       }
+
+       image_endian_swap (src_img);
+    }
+
+    /* Create destination image */
+    {
+       dst_format = RANDOM_ELT(formats);
+       dst_bpp = (PIXMAN_FORMAT_BPP (dst_format) + 7) / 8;
+       dst_width = lcg_rand_n (MAX_DST_WIDTH) + 1;
+       dst_height = lcg_rand_n (MAX_DST_HEIGHT) + 1;
+       dst_stride = dst_width * dst_bpp + lcg_rand_n (MAX_STRIDE) * dst_bpp;
+       dst_stride = (dst_stride + 3) & ~3;
+
+       dst_bits = (uint32_t *)make_random_bytes (dst_stride * dst_height);
+
+       dst_x = -(dst_width / 4) + lcg_rand_n (dst_width * 3 / 2);
+       dst_y = -(dst_height / 4) + lcg_rand_n (dst_height * 3 / 2);
+
+       dst_img = pixman_image_create_bits (
+           dst_format, dst_width, dst_height, dst_bits, dst_stride);
+
+       image_endian_swap (dst_img);
+    }
+
+    /* Create traps */
+    {
+       int i;
+
+       n_traps = lcg_rand_n (25);
+       traps = fence_malloc (n_traps * sizeof (pixman_trapezoid_t));
+
+       for (i = 0; i < n_traps; ++i)
+       {
+           pixman_trapezoid_t *t = &(traps[i]);
+
+           t->top = random_fixed (MAX_DST_HEIGHT) - MAX_DST_HEIGHT / 2;
+           t->bottom = t->top + random_fixed (MAX_DST_HEIGHT);
+           t->left.p1.x = random_fixed (MAX_DST_WIDTH) - MAX_DST_WIDTH / 2;
+           t->left.p1.y = t->top - random_fixed (50);
+           t->left.p2.x = random_fixed (MAX_DST_WIDTH) - MAX_DST_WIDTH / 2;
+           t->left.p2.y = t->bottom + random_fixed (50);
+           t->right.p1.x = t->left.p1.x + random_fixed (MAX_DST_WIDTH);
+           t->right.p1.y = t->top - random_fixed (50);
+           t->right.p2.x = t->left.p2.x + random_fixed (MAX_DST_WIDTH);
+           t->right.p2.y = t->bottom - random_fixed (50);
+       }
+    }
+
+    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_composite_trapezoids (op, src_img, dst_img, mask_format,
+                                src_x, src_y, dst_x, dst_y, n_traps, traps);
+
+    if (dst_format == PIXMAN_x8r8g8b8)
+    {
+       /* ignore unused part */
+       for (i = 0; i < dst_stride * dst_height / 4; i++)
+           dst_bits[i] &= 0xFFFFFF;
+    }
+
+    image_endian_swap (dst_img);
+
+    if (verbose)
+    {
+       int j;
+
+       for (i = 0; i < dst_height; i++)
+       {
+           for (j = 0; j < dst_stride; j++)
+               printf ("%02X ", *((uint8_t *)dst_bits + i * dst_stride + j));
+
+           printf ("\n");
+       }
+    }
+
+    crc32 = compute_crc32 (0, dst_bits, dst_stride * dst_height);
+
+    fence_free (dst_bits);
+
+    pixman_image_unref (src_img);
+    pixman_image_unref (dst_img);
+    fence_free (traps);
+
+    FLOAT_REGS_CORRUPTION_DETECTOR_FINISH ();
+    return crc32;
+}
+
+static void utc_pixman_composite_traps(void)
+{
+    int ret;
+
+    ret = fuzzer_test_main("composite traps", 40000, 0xE3112106,
+                           test_composite, 1, NULL);
+
+    if(ret)
+        dts_fail("utc_pixman_composite_traps");
+
+    dts_pass("utc_pixman_composite_traps");
+}
diff --git a/TC/testcase/utc_fetch_test.c b/TC/testcase/utc_fetch_test.c
new file mode 100644 (file)
index 0000000..4a44b49
--- /dev/null
@@ -0,0 +1,234 @@
+#include <tet_api.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pixman.h>
+
+#include "utils.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_fetch(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_fetch, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+#define SIZE 1024
+
+static pixman_indexed_t mono_palette =
+{
+    0, { 0x00000000, 0x00ffffff },
+};
+
+
+typedef struct {
+    pixman_format_code_t format;
+    int width, height;
+    int stride;
+    uint32_t src[SIZE];
+    uint32_t dst[SIZE];
+    pixman_indexed_t *indexed;
+} testcase_t;
+
+static testcase_t testcases[] =
+{
+    {
+       PIXMAN_a8r8g8b8,
+       2, 2,
+       8,
+       { 0x00112233, 0x44556677,
+         0x8899aabb, 0xccddeeff },
+       { 0x00112233, 0x44556677,
+         0x8899aabb, 0xccddeeff },
+       NULL,
+    },
+    {
+       PIXMAN_r8g8b8a8,
+       2, 2,
+       8,
+       { 0x11223300, 0x55667744,
+         0x99aabb88, 0xddeeffcc },
+       { 0x00112233, 0x44556677,
+         0x8899aabb, 0xccddeeff },
+       NULL,
+    },
+    {
+       PIXMAN_g1,
+       8, 2,
+       4,
+#ifdef WORDS_BIGENDIAN
+       {
+           0xaa000000,
+           0x55000000
+       },
+#else
+       {
+           0x00000055,
+           0x000000aa
+       },
+#endif
+       {
+           0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000,
+           0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff
+       },
+       &mono_palette,
+    },
+#if 0
+    {
+       PIXMAN_g8,
+       4, 2,
+       4,
+       { 0x01234567,
+         0x89abcdef },
+       { 0x00010101, 0x00232323, 0x00454545, 0x00676767,
+         0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, },
+    },
+#endif
+    /* FIXME: make this work on big endian */
+    {
+       PIXMAN_yv12,
+       8, 2,
+       8,
+#ifdef WORDS_BIGENDIAN
+       {
+           0x00ff00ff, 0x00ff00ff,
+           0xff00ff00, 0xff00ff00,
+           0x80ff8000,
+           0x800080ff
+       },
+#else
+       {
+           0xff00ff00, 0xff00ff00,
+           0x00ff00ff, 0x00ff00ff,
+           0x0080ff80,
+           0xff800080
+       },
+#endif
+       {
+           0xff000000, 0xffffffff, 0xffb80000, 0xffffe113,
+           0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff,
+           0xffffffff, 0xff000000, 0xffffe113, 0xffb80000,
+           0xffffffff, 0xff000000, 0xff4affff, 0xff0023ee,
+       },
+    },
+};
+
+int n_test_cases = ARRAY_LENGTH (testcases);
+
+
+static uint32_t
+reader (const void *src, int size)
+{
+    switch (size)
+    {
+    case 1:
+       return *(uint8_t *)src;
+    case 2:
+       return *(uint16_t *)src;
+    case 4:
+       return *(uint32_t *)src;
+    default:
+       assert(0);
+       return 0; /* silence MSVC */
+    }
+}
+
+
+static void
+writer (void *src, uint32_t value, int size)
+{
+    switch (size)
+    {
+    case 1:
+       *(uint8_t *)src = value;
+       break;
+    case 2:
+       *(uint16_t *)src = value;
+       break;
+    case 4:
+       *(uint32_t *)src = value;
+       break;
+    default:
+       assert(0);
+    }
+}
+
+static void utc_pixman_fetch(void)
+{
+    uint32_t dst[SIZE];
+    pixman_image_t *src_img;
+    pixman_image_t *dst_img;
+    int i, j, x, y;
+    int ret = 0;
+
+    for (i = 0; i < n_test_cases; ++i)
+    {
+       for (j = 0; j < 2; ++j)
+       {
+           src_img = pixman_image_create_bits (testcases[i].format,
+                                               testcases[i].width,
+                                               testcases[i].height,
+                                               testcases[i].src,
+                                               testcases[i].stride);
+           pixman_image_set_indexed(src_img, testcases[i].indexed);
+
+           dst_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
+                                               testcases[i].width,
+                                               testcases[i].height,
+                                               dst,
+                                               testcases[i].width*4);
+
+           if (j)
+           {
+               pixman_image_set_accessors (src_img, reader, writer);
+               pixman_image_set_accessors (dst_img, reader, writer);
+           }
+
+           pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img,
+                                   0, 0, 0, 0, 0, 0, testcases[i].width, testcases[i].height);
+
+           pixman_image_unref (src_img);
+           pixman_image_unref (dst_img);
+
+           for (y = 0; y < testcases[i].height; ++y)
+           {
+               for (x = 0; x < testcases[i].width; ++x)
+               {
+                   int offset = y * testcases[i].width + x;
+
+                   if (dst[offset] != testcases[i].dst[offset])
+                   {
+                       printf ("test %i%c: pixel mismatch at (x=%d,y=%d): %08x expected, %08x obtained\n",
+                               i + 1, 'a' + j,
+                               x, y,
+                               testcases[i].dst[offset], dst[offset]);
+                       ret = 1;
+                   }
+               }
+           }
+       }
+    }
+
+    if(ret)
+        dts_fail("utc_pixman_fetch");
+
+    dts_pass("utc_pixman_fetch");
+}
diff --git a/TC/testcase/utc_gradient_crash_test.c b/TC/testcase/utc_gradient_crash_test.c
new file mode 100644 (file)
index 0000000..8981e6d
--- /dev/null
@@ -0,0 +1,187 @@
+#include <tet_api.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "utils.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_a1_trap1(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_a1_trap1, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+static void utc_pixman_a1_trap1(void)
+{
+#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, k, p;
+
+    typedef struct
+    {
+       pixman_point_fixed_t p0;
+       pixman_point_fixed_t p1;
+    } point_pair_t;
+
+    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 } }
+       };
+
+    point_pair_t point_pairs [] =
+       { { { pixman_double_to_fixed (0), 0 },
+           { pixman_double_to_fixed (WIDTH / 8.), pixman_int_to_fixed (0) } },
+         { { pixman_double_to_fixed (WIDTH / 2.0), pixman_double_to_fixed (HEIGHT / 2.0) },
+           { pixman_double_to_fixed (WIDTH / 2.0), pixman_double_to_fixed (HEIGHT / 2.0) } }
+       };
+
+    pixman_transform_t transformations[] = {
+       {
+           { { 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_double_to_fixed (1), pixman_double_to_fixed (0), pixman_double_to_fixed (0), },
+             { pixman_double_to_fixed (0), pixman_double_to_fixed (1), pixman_double_to_fixed (0), },
+             { pixman_double_to_fixed (0), pixman_double_to_fixed (0.000), pixman_double_to_fixed (1.0) }
+           }
+       },
+       {
+           { { pixman_double_to_fixed (2), pixman_double_to_fixed (1), pixman_double_to_fixed (0), },
+             { pixman_double_to_fixed (1), pixman_double_to_fixed (1), pixman_double_to_fixed (0), },
+             { pixman_double_to_fixed (2), pixman_double_to_fixed (1.000), pixman_double_to_fixed (1.0) }
+           }
+       },
+       {
+           { { pixman_double_to_fixed (2), pixman_double_to_fixed (1), pixman_double_to_fixed (0), },
+             { pixman_double_to_fixed (1), pixman_double_to_fixed (1), pixman_double_to_fixed (0), },
+             { pixman_double_to_fixed (0), pixman_double_to_fixed (0), pixman_double_to_fixed (0) }
+           }
+       },
+       {
+           { { pixman_double_to_fixed (2), pixman_double_to_fixed (1), pixman_double_to_fixed (0), },
+             { pixman_double_to_fixed (1), pixman_double_to_fixed (1), pixman_double_to_fixed (0), },
+             { pixman_double_to_fixed (2), pixman_double_to_fixed (-1), pixman_double_to_fixed (0) }
+           }
+       },
+       {
+           { { pixman_double_to_fixed (2), pixman_double_to_fixed (1), pixman_double_to_fixed (3), },
+             { pixman_double_to_fixed (1), pixman_double_to_fixed (1), pixman_double_to_fixed (0), },
+             { pixman_double_to_fixed (2), pixman_double_to_fixed (-1), pixman_double_to_fixed (0) }
+           }
+       },
+    };
+
+    pixman_fixed_t r_inner;
+    pixman_fixed_t r_outer;
+
+    enable_fp_exceptions();
+
+    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);
+
+    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 = ARRAY_LENGTH (onestop);
+       }
+       else if (i == 1)
+       {
+           stops = subsetstops;
+           num_stops = ARRAY_LENGTH (subsetstops);
+       }
+       else
+       {
+           stops = stops01;
+           num_stops = ARRAY_LENGTH (stops01);
+       }
+
+       for (j = 0; j < 3; ++j)
+       {
+           for (p = 0; p < ARRAY_LENGTH (point_pairs); ++p)
+           {
+               point_pair_t *pair = &(point_pairs[p]);
+
+               if (j == 0)
+                   src_img = pixman_image_create_conical_gradient (&(pair->p0), r_inner,
+                                                                   stops, num_stops);
+               else if (j == 1)
+                   src_img = pixman_image_create_radial_gradient  (&(pair->p0), &(pair->p1),
+                                                                   r_inner, r_outer,
+                                                                   stops, num_stops);
+               else
+                   src_img = pixman_image_create_linear_gradient  (&(pair->p0), &(pair->p1),
+                                                                   stops, num_stops);
+
+               for (k = 0; k < ARRAY_LENGTH (transformations); ++k)
+               {
+                   pixman_image_set_transform (src_img, &transformations[k]);
+
+                   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);
+
+
+/*FIXME : when fail?*/
+    //dts_fail("utc_pixman_a1_trap1");
+
+    dts_pass("utc_pixman_a1_trap1");
+}
diff --git a/TC/testcase/utc_oob_test.c b/TC/testcase/utc_oob_test.c
new file mode 100644 (file)
index 0000000..b452f9a
--- /dev/null
@@ -0,0 +1,130 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pixman.h>
+
+#include "utils.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_oob(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_oob, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+typedef struct
+{
+    int                                width;
+    int                                height;
+    int                                stride;
+    pixman_format_code_t       format;
+
+} image_info_t;
+
+typedef struct
+{
+    pixman_op_t                op;
+
+    image_info_t       src;
+    image_info_t       dest;
+
+    int                        src_x;
+    int                        src_y;
+    int                        dest_x;
+    int                        dest_y;
+    int                        width;
+    int                        height;
+} composite_info_t;
+
+const composite_info_t info[] =
+{
+    {
+       PIXMAN_OP_SRC,
+       {  3, 6, 16, PIXMAN_a8r8g8b8 },
+       {  5, 7, 20, PIXMAN_x8r8g8b8 },
+       1, 8,
+       1, -1,
+       1, 8
+    },
+    {
+       PIXMAN_OP_SRC,
+       { 7, 5, 36, PIXMAN_a8r8g8b8 },
+       { 6, 5, 28, PIXMAN_x8r8g8b8 },
+       8, 5,
+       5, 3,
+       1, 2
+    },
+    {
+       PIXMAN_OP_OVER,
+       { 10, 10, 40, PIXMAN_a2b10g10r10 },
+       { 10, 10, 40, PIXMAN_a2b10g10r10 },
+       0, 0,
+       0, 0,
+       10, 10
+    },
+    {
+       PIXMAN_OP_OVER,
+       { 10, 10, 40, PIXMAN_x2b10g10r10 },
+       { 10, 10, 40, PIXMAN_x2b10g10r10 },
+       0, 0,
+       0, 0,
+       10, 10
+    },
+};
+
+static pixman_image_t *
+make_image (const image_info_t *info)
+{
+    char *data = malloc (info->stride * info->height);
+    int i;
+
+    for (i = 0; i < info->height * info->stride; ++i)
+       data[i] = (i % 255) ^ (((i % 16) << 4) | (i & 0xf0));
+
+    return pixman_image_create_bits (info->format, info->width, info->height, (uint32_t *)data, info->stride);
+}
+
+static void
+test_composite (const composite_info_t *info)
+{
+    pixman_image_t *src = make_image (&info->src);
+    pixman_image_t *dest = make_image (&info->dest);
+
+    pixman_image_composite (PIXMAN_OP_SRC, src, NULL, dest,
+                           info->src_x, info->src_y,
+                           0, 0,
+                           info->dest_x, info->dest_y,
+                           info->width, info->height);
+}
+
+static void utc_pixman_oob(void)
+{
+
+    int i;
+
+    for (i = 0; i < ARRAY_LENGTH (info); ++i)
+       test_composite (&info[i]);
+
+/*FIXME : when fail???*/
+    //    dts_fail("utc_pixman_oob");
+
+    dts_pass("utc_pixman_oob");
+}
diff --git a/TC/testcase/utc_pdf_op_test.c b/TC/testcase/utc_pdf_op_test.c
new file mode 100644 (file)
index 0000000..426f9b3
--- /dev/null
@@ -0,0 +1,111 @@
+#include <tet_api.h>
+#include <stdlib.h>
+
+#include "utils.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_pdf_op(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_pdf_op, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+static const pixman_op_t pdf_ops[] =
+{
+    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_SOFT_LIGHT,
+    PIXMAN_OP_DIFFERENCE,
+    PIXMAN_OP_EXCLUSION,
+    PIXMAN_OP_HSL_HUE,
+    PIXMAN_OP_HSL_SATURATION,
+    PIXMAN_OP_HSL_COLOR,
+    PIXMAN_OP_HSL_LUMINOSITY
+};
+
+static const uint32_t pixels[] =
+{
+    0x00808080,
+    0x80123456,
+    0x00000000,
+    0xffffffff,
+    0x00ffffff,
+    0x80808080,
+    0x00123456,
+};
+
+static void utc_pixman_pdf_op(void)
+{
+
+    int o, s, m, d;
+
+    enable_fp_exceptions();
+
+    for (o = 0; o < ARRAY_LENGTH (pdf_ops); ++o)
+    {
+       pixman_op_t op = pdf_ops[o];
+
+       for (s = 0; s < ARRAY_LENGTH (pixels); ++s)
+       {
+           pixman_image_t *src;
+
+           src = pixman_image_create_bits (
+               PIXMAN_a8r8g8b8, 1, 1, (uint32_t *)&(pixels[s]), 4);
+
+           for (m = -1; m < ARRAY_LENGTH (pixels); ++m)
+           {
+               pixman_image_t *msk = NULL;
+               if (m >= 0)
+               {
+                   msk = pixman_image_create_bits (
+                       PIXMAN_a8r8g8b8, 1, 1, (uint32_t *)&(pixels[m]), 4);
+               }
+
+               for (d = 0; d < ARRAY_LENGTH (pixels); ++d)
+               {
+                   pixman_image_t *dst;
+                   uint32_t dp = pixels[d];
+
+                   dst = pixman_image_create_bits (
+                       PIXMAN_a8r8g8b8, 1, 1, &dp, 4);
+
+                   pixman_image_composite (op, src, msk, dst,
+                                           0, 0, 0, 0, 0, 0, 1, 1);
+
+                   pixman_image_unref (dst);
+               }
+               if (msk)
+                   pixman_image_unref (msk);
+           }
+
+           pixman_image_unref (src);
+       }
+    }
+
+/*FIXME : when fail?*/
+    //    dts_fail("utc_pixman_pdf_op");
+
+    dts_pass("utc_pixman_pdf_op");
+}
diff --git a/TC/testcase/utc_region_contains_test.c b/TC/testcase/utc_region_contains_test.c
new file mode 100644 (file)
index 0000000..a01b069
--- /dev/null
@@ -0,0 +1,201 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "utils.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_region_contains(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_region_contains, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+static void
+make_random_region (pixman_region32_t *region)
+{
+    int n_boxes;
+
+    pixman_region32_init (region);
+
+    n_boxes = lcg_rand_n (64);
+    while (n_boxes--)
+    {
+       int32_t x, y;
+       uint32_t w, h;
+
+       x = (int32_t)lcg_rand_u32() >> 2;
+       y = (int32_t)lcg_rand_u32() >> 2;
+       w = lcg_rand_u32() >> 2;
+       h = lcg_rand_u32() >> 2;
+
+       pixman_region32_union_rect (region, region, x, y, w, h);
+    }
+}
+
+static void
+print_box (pixman_box32_t *box)
+{
+    printf ("    %d %d %d %d\n", box->x1, box->y1, box->x2, box->y2);
+}
+
+static int32_t
+random_coord (pixman_region32_t *region, pixman_bool_t x)
+{
+    pixman_box32_t *b, *bb;
+    int n_boxes;
+    int begin, end;
+
+    if (lcg_rand_n (14))
+    {
+       bb = pixman_region32_rectangles (region, &n_boxes);
+       if (n_boxes == 0)
+           goto use_extent;
+       b = bb + lcg_rand_n (n_boxes);
+    }
+    else
+    {
+    use_extent:
+       b = pixman_region32_extents (region);
+       n_boxes = 1;
+    }
+
+    if (x)
+    {
+       begin = b->x1;
+       end = b->x2;
+    }
+    else
+    {
+       begin = b->y1;
+       end = b->y2;
+    }
+
+    switch (lcg_rand_n (5))
+    {
+    case 0:
+       return begin - lcg_rand_u32();
+    case 1:
+       return end + lcg_rand_u32 ();
+    case 2:
+       return end;
+    case 3:
+       return begin;
+    default:
+       return (end - begin) / 2 + begin;
+    }
+    return 0;
+}
+
+static uint32_t
+compute_crc32_u32 (uint32_t crc32, uint32_t v)
+{
+    if (!is_little_endian())
+    {
+       v = ((v & 0xff000000) >> 24)    |
+           ((v & 0x00ff0000) >> 8)     |
+           ((v & 0x0000ff00) << 8)     |
+           ((v & 0x000000ff) << 24);
+    }
+
+    return compute_crc32 (crc32, &v, sizeof (int32_t));
+}
+
+static uint32_t
+crc32_box32 (uint32_t crc32, pixman_box32_t *box)
+{
+    crc32 = compute_crc32_u32 (crc32, box->x1);
+    crc32 = compute_crc32_u32 (crc32, box->y1);
+    crc32 = compute_crc32_u32 (crc32, box->x2);
+    crc32 = compute_crc32_u32 (crc32, box->y2);
+
+    return crc32;
+}
+
+static uint32_t
+test_region_contains_rectangle (int i, int verbose)
+{
+    pixman_box32_t box;
+    pixman_box32_t rbox = { 0, 0, 0, 0 };
+    pixman_region32_t region;
+    uint32_t r, r1, r2, r3, r4, crc32;
+
+    lcg_srand (i);
+
+    make_random_region (&region);
+
+    box.x1 = random_coord (&region, TRUE);
+    box.x2 = box.x1 + lcg_rand_u32 ();
+    box.y1 = random_coord (&region, FALSE);
+    box.y2 = box.y1 + lcg_rand_u32 ();
+
+    if (verbose)
+    {
+       int n_rects;
+       pixman_box32_t *boxes;
+
+       boxes = pixman_region32_rectangles (&region, &n_rects);
+
+       printf ("region:\n");
+       while (n_rects--)
+           print_box (boxes++);
+       printf ("box:\n");
+       print_box (&box);
+    }
+
+    crc32 = 0;
+
+    r1 = pixman_region32_contains_point (&region, box.x1, box.y1, &rbox);
+    crc32 = crc32_box32 (crc32, &rbox);
+    r2 = pixman_region32_contains_point (&region, box.x1, box.y2, &rbox);
+    crc32 = crc32_box32 (crc32, &rbox);
+    r3 = pixman_region32_contains_point (&region, box.x2, box.y1, &rbox);
+    crc32 = crc32_box32 (crc32, &rbox);
+    r4 = pixman_region32_contains_point (&region, box.x2, box.y2, &rbox);
+    crc32 = crc32_box32 (crc32, &rbox);
+
+    r = pixman_region32_contains_rectangle (&region, &box);
+    r = (i << 8) | (r << 4) | (r1 << 3) | (r2 << 2) | (r3 << 1) | (r4 << 0);
+
+    crc32 = compute_crc32_u32 (crc32, r);
+
+    if (verbose)
+       printf ("results: %d %d %d %d %d\n", (r & 0xf0) >> 4, r1, r2, r3, r4);
+
+    pixman_region32_fini (&region);
+
+    return crc32;
+}
+
+static void utc_pixman_region_contains(void)
+{
+    int ret;
+
+    ret = fuzzer_test_main ("region_contains",
+                            1000000,
+                            0xD2BF8C73,
+                            test_region_contains_rectangle,
+                            1, NULL);
+
+    if(ret)
+        dts_fail("utc_pixman_region_contains");
+
+    dts_pass("utc_pixman_region_contains");
+}
diff --git a/TC/testcase/utc_region_test.c b/TC/testcase/utc_region_test.c
new file mode 100644 (file)
index 0000000..38b3780
--- /dev/null
@@ -0,0 +1,151 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "utils.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_region(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_region, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+static void utc_pixman_region(void)
+{
+
+    pixman_region32_t r1;
+    pixman_region32_t r2;
+    pixman_region32_t r3;
+    pixman_box32_t boxes[] = {
+       { 10, 10, 20, 20 },
+       { 30, 30, 30, 40 },
+       { 50, 45, 60, 44 },
+    };
+    pixman_box32_t boxes2[] = {
+       { 2, 6, 7, 6 },
+       { 4, 1, 6, 7 },
+    };
+    pixman_box32_t boxes3[] = {
+       { 2, 6, 7, 6 },
+       { 4, 1, 6, 1 },
+    };
+    int i, j;
+    pixman_box32_t *b;
+    pixman_image_t *image, *fill;
+    pixman_color_t white = {
+       0xffff,
+       0xffff,
+       0xffff,
+       0xffff
+    };
+
+    /* This used to go into an infinite loop before pixman-region.c
+     * was fixed to not use explict "short" variables
+     */
+    pixman_region32_init_rect (&r1, 0, 0, 20, 64000);
+    pixman_region32_init_rect (&r2, 0, 0, 20, 64000);
+    pixman_region32_init_rect (&r3, 0, 0, 20, 64000);
+
+    pixman_region32_subtract (&r1, &r2, &r3);
+
+
+    /* This would produce a region containing an empty
+     * rectangle in it. Such regions are considered malformed,
+     * but using an empty rectangle for initialization should
+     * work.
+     */
+    pixman_region32_init_rects (&r1, boxes, 3);
+
+    b = pixman_region32_rectangles (&r1, &i);
+
+    assert (i == 1);
+
+    while (i--)
+    {
+       assert (b[i].x1 < b[i].x2);
+       assert (b[i].y1 < b[i].y2);
+    }
+
+    /* This would produce a rectangle containing the bounding box
+     * of the two rectangles. The correct result is to eliminate
+     * the broken rectangle.
+     */
+    pixman_region32_init_rects (&r1, boxes2, 2);
+
+    b = pixman_region32_rectangles (&r1, &i);
+
+    assert (i == 1);
+
+    assert (b[0].x1 == 4);
+    assert (b[0].y1 == 1);
+    assert (b[0].x2 == 6);
+    assert (b[0].y2 == 7);
+
+    /* This should produce an empty region */
+    pixman_region32_init_rects (&r1, boxes3, 2);
+
+    b = pixman_region32_rectangles (&r1, &i);
+
+    assert (i == 0);
+
+    fill = pixman_image_create_solid_fill (&white);
+    for (i = 0; i < 100; i++)
+    {
+       int image_size = 128;
+
+       pixman_region32_init (&r1);
+
+       /* Add some random rectangles */
+       for (j = 0; j < 64; j++)
+           pixman_region32_union_rect (&r1, &r1,
+                                       lcg_rand_n (image_size),
+                                       lcg_rand_n (image_size),
+                                       lcg_rand_n (25),
+                                       lcg_rand_n (25));
+
+       /* Clip to image size */
+       pixman_region32_init_rect (&r2, 0, 0, image_size, image_size);
+       pixman_region32_intersect (&r1, &r1, &r2);
+       pixman_region32_fini (&r2);
+
+       /* render region to a1 mask */
+       image = pixman_image_create_bits (PIXMAN_a1, image_size, image_size, NULL, 0);
+       pixman_image_set_clip_region32 (image, &r1);
+       pixman_image_composite32 (PIXMAN_OP_SRC,
+                                 fill, NULL, image,
+                                 0, 0, 0, 0, 0, 0,
+                                 image_size, image_size);
+       pixman_region32_init_from_image (&r2, image);
+
+       pixman_image_unref (image);
+
+       assert (pixman_region32_equal (&r1, &r2));
+       pixman_region32_fini (&r1);
+       pixman_region32_fini (&r2);
+
+    }
+    pixman_image_unref (fill);
+
+/*FIXME : when fail???*/
+//        dts_fail("utc_pixman_region");
+
+    dts_pass("utc_pixman_region");
+}
diff --git a/TC/testcase/utc_region_translate_test.c b/TC/testcase/utc_region_translate_test.c
new file mode 100644 (file)
index 0000000..4611dc9
--- /dev/null
@@ -0,0 +1,57 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <pixman.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_region_translate(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_region_translate, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+/* Pixman had a bug where 32bit regions where clipped to 16bit sizes when
+ * pixman_region32_translate() was called. This test exercises that bug.
+ */
+
+#define LARGE 32000
+
+static void utc_pixman_region_translate(void)
+{
+
+  pixman_box32_t rect = { -LARGE, -LARGE, LARGE, LARGE };
+  pixman_region32_t r1, r2;
+
+  pixman_region32_init_rects (&r1, &rect, 1);
+  pixman_region32_init_rect (&r2, rect.x1, rect.y1, rect.x2 - rect.x1, rect.y2 - rect.y1);
+
+  assert (pixman_region32_equal (&r1,  &r2));
+
+  pixman_region32_translate (&r1, -LARGE, LARGE);
+  pixman_region32_translate (&r1, LARGE, -LARGE);
+
+  assert (pixman_region32_equal (&r1,  &r2));
+
+  pixman_region32_fini (&r1);
+  pixman_region32_fini (&r2);
+
+/*FIXME : when fail???*/
+//        dts_fail("utc_pixman_region_translate");
+
+    dts_pass("utc_pixman_region_translate");
+}
diff --git a/TC/testcase/utc_scaling_crash_test.c b/TC/testcase/utc_scaling_crash_test.c
new file mode 100644 (file)
index 0000000..dc1b5f5
--- /dev/null
@@ -0,0 +1,248 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pixman.h>
+
+#include "utils.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_scaling_crash(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_scaling_crash, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+/*
+ * 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 either that the destination image filled with this solid
+ * color or, if the transformation is such that we can't composite anything at
+ * all, that nothing has changed in the destination.
+ *
+ * The surrounding memory of the source image is a different solid color so that
+ * we are sure to get failures if we access it.
+ */
+static int
+run_test (int32_t              dst_width,
+         int32_t               dst_height,
+         int32_t               src_width,
+         int32_t               src_height,
+         int32_t               src_x,
+         int32_t               src_y,
+         int32_t               scale_x,
+         int32_t               scale_y,
+         pixman_filter_t       filter,
+         pixman_repeat_t       repeat)
+{
+    pixman_image_t *   src_img;
+    pixman_image_t *   dst_img;
+    pixman_transform_t transform;
+    uint32_t *         srcbuf;
+    uint32_t *         dstbuf;
+    pixman_color_t     color_cc = { 0xcccc, 0xcccc, 0xcccc, 0xcccc };
+    pixman_image_t *   solid;
+    int result;
+    int i;
+
+    static const pixman_fixed_t kernel[] =
+    {
+#define D(f)   (pixman_double_to_fixed (f) + 0x0001)
+
+       pixman_int_to_fixed (5),
+       pixman_int_to_fixed (5),
+       D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0),
+       D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0),
+       D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0),
+       D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0),
+       D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0), D(1/25.0)
+    };
+
+    result = 0;
+
+    srcbuf = (uint32_t *)malloc ((src_width + 10) * (src_height + 10) * 4);
+    dstbuf = (uint32_t *)malloc (dst_width * dst_height * 4);
+
+    memset (srcbuf, 0x88, src_width * src_height * 4);
+    memset (dstbuf, 0x33, dst_width * dst_height * 4);
+
+    src_img = pixman_image_create_bits (
+        PIXMAN_a8r8g8b8, src_width, src_height,
+       srcbuf + (src_width + 10) * 5 + 5, (src_width + 10) * 4);
+
+    solid = pixman_image_create_solid_fill (&color_cc);
+    pixman_image_composite32 (PIXMAN_OP_SRC, solid, NULL, src_img,
+                             0, 0, 0, 0, 0, 0, src_width, src_height);
+    pixman_image_unref (solid);
+
+    dst_img = pixman_image_create_bits (
+        PIXMAN_a8r8g8b8, dst_width, dst_height, dstbuf, dst_width * 4);
+
+    pixman_transform_init_scale (&transform, scale_x, scale_y);
+    pixman_image_set_transform (src_img, &transform);
+    pixman_image_set_repeat (src_img, repeat);
+    if (filter == PIXMAN_FILTER_CONVOLUTION)
+       pixman_image_set_filter (src_img, filter, kernel, 27);
+    else
+       pixman_image_set_filter (src_img, filter, NULL, 0);
+
+    pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img,
+                            src_x, src_y, 0, 0, 0, 0, dst_width, dst_height);
+
+    pixman_image_unref (src_img);
+    pixman_image_unref (dst_img);
+
+    for (i = 0; i < dst_width * dst_height; i++)
+    {
+       if (dstbuf[i] != 0xCCCCCCCC && dstbuf[i] != 0x33333333)
+       {
+           result = 1;
+           break;
+       }
+    }
+
+    free (srcbuf);
+    free (dstbuf);
+    return result;
+}
+
+typedef struct filter_info_t filter_info_t;
+struct filter_info_t
+{
+    pixman_filter_t value;
+    char name[28];
+};
+
+static const filter_info_t filters[] =
+{
+    { PIXMAN_FILTER_NEAREST, "NEAREST" },
+    { PIXMAN_FILTER_BILINEAR, "BILINEAR" },
+    { PIXMAN_FILTER_CONVOLUTION, "CONVOLUTION" },
+};
+
+typedef struct repeat_info_t repeat_info_t;
+struct repeat_info_t
+{
+    pixman_repeat_t value;
+    char name[28];
+};
+
+
+static const repeat_info_t repeats[] =
+{
+    { PIXMAN_REPEAT_PAD, "PAD" },
+    { PIXMAN_REPEAT_REFLECT, "REFLECT" },
+    { PIXMAN_REPEAT_NORMAL, "NORMAL" }
+};
+
+static int
+do_test (int32_t               dst_size,
+        int32_t                src_size,
+        int32_t                src_offs,
+        int32_t                scale_factor)
+{
+    int i, j;
+
+    for (i = 0; i < ARRAY_LENGTH (filters); ++i)
+    {
+       for (j = 0; j < ARRAY_LENGTH (repeats); ++j)
+       {
+           /* horizontal test */
+           if (run_test (dst_size, 1,
+                         src_size, 1,
+                         src_offs, 0,
+                         scale_factor, 65536,
+                         filters[i].value,
+                         repeats[j].value) != 0)
+           {
+               printf ("Vertical test failed with %s filter and repeat mode %s\n",
+                       filters[i].name, repeats[j].name);
+
+               return 1;
+           }
+
+           /* vertical test */
+           if (run_test (1, dst_size,
+                         1, src_size,
+                         0, src_offs,
+                         65536, scale_factor,
+                         filters[i].value,
+                         repeats[j].value) != 0)
+           {
+               printf ("Vertical test failed with %s filter and repeat mode %s\n",
+                       filters[i].name, repeats[j].name);
+
+               return 1;
+           }
+       }
+    }
+
+    return 0;
+}
+
+static void utc_pixman_scaling_crash(void)
+{
+
+    int i;
+
+    pixman_disable_out_of_bounds_workaround ();
+
+    /* can potentially crash */
+    assert (do_test (
+               48000, 32767, 1, 65536 * 128) == 0);
+
+    /* can potentially get into a deadloop */
+    assert (do_test (
+               16384, 65536, 32, 32768) == 0);
+
+    /* can potentially access memory outside source image buffer */
+    assert (do_test (
+               10, 10, 0, 1) == 0);
+    assert (do_test (
+               10, 10, 0, 0) == 0);
+
+    for (i = 0; i < 100; ++i)
+    {
+       pixman_fixed_t one_seventh =
+           (((pixman_fixed_48_16_t)pixman_fixed_1) << 16) / (7 << 16);
+
+       assert (do_test (
+                   1, 7, 3, one_seventh + i - 50) == 0);
+    }
+
+    for (i = 0; i < 100; ++i)
+    {
+       pixman_fixed_t scale =
+           (((pixman_fixed_48_16_t)pixman_fixed_1) << 16) / (32767 << 16);
+
+       assert (do_test (
+                   1, 32767, 16383, scale + i - 50) == 0);
+    }
+
+    /* can potentially provide invalid results (out of range matrix stuff) */
+    assert (do_test (
+       48000, 32767, 16384, 65536 * 128) == 0);
+
+    /*FIXME : when fail???*/
+//        dts_fail("utc_pixman_scaling_crash");
+
+    dts_pass("utc_pixman_scaling_crash");
+}
diff --git a/TC/testcase/utc_scaling_helpers_test.c b/TC/testcase/utc_scaling_helpers_test.c
new file mode 100644 (file)
index 0000000..001d50e
--- /dev/null
@@ -0,0 +1,120 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "utils.h"
+#include "pixman-inlines.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_scaling_helpers(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_scaling_helpers, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+/* A trivial reference implementation for
+ * 'bilinear_pad_repeat_get_scanline_bounds'
+ */
+static void
+bilinear_pad_repeat_get_scanline_bounds_ref (int32_t        source_image_width,
+                                            pixman_fixed_t vx_,
+                                            pixman_fixed_t unit_x,
+                                            int32_t *      left_pad,
+                                            int32_t *      left_tz,
+                                            int32_t *      width,
+                                            int32_t *      right_tz,
+                                            int32_t *      right_pad)
+{
+    int w = *width;
+    int64_t vx = vx_;
+    *left_pad = 0;
+    *left_tz = 0;
+    *width = 0;
+    *right_tz = 0;
+    *right_pad = 0;
+    while (--w >= 0)
+    {
+       if (vx < 0)
+       {
+           if (vx + pixman_fixed_1 < 0)
+               *left_pad += 1;
+           else
+               *left_tz += 1;
+       }
+       else if (vx + pixman_fixed_1 >= pixman_int_to_fixed (source_image_width))
+       {
+           if (vx >= pixman_int_to_fixed (source_image_width))
+               *right_pad += 1;
+           else
+               *right_tz += 1;
+       }
+       else
+       {
+           *width += 1;
+       }
+       vx += unit_x;
+    }
+}
+
+static void utc_pixman_scaling_helpers(void)
+{
+
+    int i;
+    for (i = 0; i < 10000; i++)
+    {
+       int32_t left_pad1, left_tz1, width1, right_tz1, right_pad1;
+       int32_t left_pad2, left_tz2, width2, right_tz2, right_pad2;
+       pixman_fixed_t vx = lcg_rand_N(10000 << 16) - (3000 << 16);
+       int32_t width = lcg_rand_N(10000);
+       int32_t source_image_width = lcg_rand_N(10000) + 1;
+       pixman_fixed_t unit_x = lcg_rand_N(10 << 16) + 1;
+       width1 = width2 = width;
+
+       bilinear_pad_repeat_get_scanline_bounds_ref (source_image_width,
+                                                    vx,
+                                                    unit_x,
+                                                    &left_pad1,
+                                                    &left_tz1,
+                                                    &width1,
+                                                    &right_tz1,
+                                                    &right_pad1);
+
+       bilinear_pad_repeat_get_scanline_bounds (source_image_width,
+                                                vx,
+                                                unit_x,
+                                                &left_pad2,
+                                                &left_tz2,
+                                                &width2,
+                                                &right_tz2,
+                                                &right_pad2);
+
+       assert (left_pad1 == left_pad2);
+       assert (left_tz1 == left_tz2);
+       assert (width1 == width2);
+       assert (right_tz1 == right_tz2);
+       assert (right_pad1 == right_pad2);
+    }
+
+/*FIXME : when fail???*/
+//        dts_fail("utc_pixman_scaling_helpers");
+
+    dts_pass("utc_pixman_scaling_helpers");
+}
diff --git a/TC/testcase/utc_scaling_test.c b/TC/testcase/utc_scaling_test.c
new file mode 100644 (file)
index 0000000..f8a9014
--- /dev/null
@@ -0,0 +1,400 @@
+#include <tet_api.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "utils.h"
+
+/*
+ * 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.
+ */
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_pixman_scaling(void);
+
+struct tet_testlist tet_testlist[] = {
+       { utc_pixman_scaling, 1 },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* end of TC */
+}
+
+#define MAX_SRC_WIDTH  48
+#define MAX_SRC_HEIGHT 8
+#define MAX_DST_WIDTH  48
+#define MAX_DST_HEIGHT 8
+#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 *   mask_img;
+    pixman_image_t *   dst_img;
+    pixman_transform_t transform;
+    pixman_region16_t  clip;
+    int                src_width, src_height;
+    int                mask_width, mask_height;
+    int                dst_width, dst_height;
+    int                src_stride, mask_stride, dst_stride;
+    int                src_x, src_y;
+    int                mask_x, mask_y;
+    int                dst_x, dst_y;
+    int                src_bpp;
+    int                mask_bpp = 1;
+    int                dst_bpp;
+    int                w, h;
+    pixman_fixed_t     scale_x = 65536, scale_y = 65536;
+    pixman_fixed_t     translate_x = 0, translate_y = 0;
+    pixman_fixed_t     mask_scale_x = 65536, mask_scale_y = 65536;
+    pixman_fixed_t     mask_translate_x = 0, mask_translate_y = 0;
+    pixman_op_t        op;
+    pixman_repeat_t    repeat = PIXMAN_REPEAT_NONE;
+    pixman_repeat_t    mask_repeat = PIXMAN_REPEAT_NONE;
+    pixman_format_code_t src_fmt, dst_fmt;
+    uint32_t *         srcbuf;
+    uint32_t *         dstbuf;
+    uint32_t *         maskbuf;
+    uint32_t           crc32;
+    FLOAT_REGS_CORRUPTION_DETECTOR_START ();
+
+    lcg_srand (testnum);
+
+    src_bpp = (lcg_rand_n (2) == 0) ? 2 : 4;
+    dst_bpp = (lcg_rand_n (2) == 0) ? 2 : 4;
+    switch (lcg_rand_n (3))
+    {
+    case 0:
+       op = PIXMAN_OP_SRC;
+       break;
+    case 1:
+       op = PIXMAN_OP_OVER;
+       break;
+    default:
+       op = PIXMAN_OP_ADD;
+       break;
+    }
+
+    src_width = lcg_rand_n (MAX_SRC_WIDTH) + 1;
+    src_height = lcg_rand_n (MAX_SRC_HEIGHT) + 1;
+
+    if (lcg_rand_n (2))
+    {
+       mask_width = lcg_rand_n (MAX_SRC_WIDTH) + 1;
+       mask_height = lcg_rand_n (MAX_SRC_HEIGHT) + 1;
+    }
+    else
+    {
+       mask_width = mask_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;
+    mask_stride = mask_width * mask_bpp + lcg_rand_n (MAX_STRIDE) * mask_bpp;
+    dst_stride = dst_width * dst_bpp + lcg_rand_n (MAX_STRIDE) * dst_bpp;
+
+    if (src_stride & 3)
+       src_stride += 2;
+
+    if (mask_stride & 1)
+       mask_stride += 1;
+    if (mask_stride & 2)
+       mask_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);
+    mask_x = -(mask_width / 4) + lcg_rand_n (mask_width * 3 / 2);
+    mask_y = -(mask_height / 4) + lcg_rand_n (mask_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);
+    maskbuf = (uint32_t *)malloc (mask_stride * mask_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 < mask_stride * mask_height; i++)
+       *((uint8_t *)maskbuf + 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);
+
+    mask_img = pixman_image_create_bits (
+        PIXMAN_a8, mask_width, mask_height, maskbuf, mask_stride);
+
+    dst_img = pixman_image_create_bits (
+        dst_fmt, dst_width, dst_height, dstbuf, dst_stride);
+
+    image_endian_swap (src_img);
+    image_endian_swap (dst_img);
+
+    if (lcg_rand_n (4) > 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);
+    }
+
+    if (lcg_rand_n (2) > 0)
+    {
+       mask_scale_x = -32768 * 3 + lcg_rand_N (65536 * 5);
+       mask_scale_y = -32768 * 3 + lcg_rand_N (65536 * 5);
+       mask_translate_x = lcg_rand_N (65536);
+       mask_translate_y = lcg_rand_N (65536);
+       pixman_transform_init_scale (&transform, mask_scale_x, mask_scale_y);
+       pixman_transform_translate (&transform, NULL, mask_translate_x, mask_translate_y);
+       pixman_image_set_transform (mask_img, &transform);
+    }
+
+    switch (lcg_rand_n (4))
+    {
+    case 0:
+       mask_repeat = PIXMAN_REPEAT_NONE;
+       break;
+
+    case 1:
+       mask_repeat = PIXMAN_REPEAT_NORMAL;
+       break;
+
+    case 2:
+       mask_repeat = PIXMAN_REPEAT_PAD;
+       break;
+
+    case 3:
+       mask_repeat = PIXMAN_REPEAT_REFLECT;
+       break;
+
+    default:
+        break;
+    }
+    pixman_image_set_repeat (mask_img, mask_repeat);
+
+    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 (lcg_rand_n (2))
+       pixman_image_set_filter (mask_img, PIXMAN_FILTER_NEAREST, NULL, 0);
+    else
+       pixman_image_set_filter (mask_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 (mask_width);
+           clip_boxes[i].y1 = lcg_rand_n (mask_height);
+           clip_boxes[i].x2 =
+               clip_boxes[i].x1 + lcg_rand_n (mask_width - clip_boxes[i].x1);
+           clip_boxes[i].y2 =
+               clip_boxes[i].y1 + lcg_rand_n (mask_height - clip_boxes[i].y1);
+
+           if (verbose)
+           {
+               printf ("mask 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 (mask_img, &clip);
+       pixman_image_set_source_clipping (mask_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);
+    }
+
+    if (lcg_rand_n (2) == 0)
+       pixman_image_composite (op, src_img, NULL, dst_img,
+                            src_x, src_y, 0, 0, dst_x, dst_y, w, h);
+    else
+       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 (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);
+
+    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 (mask_img);
+    pixman_image_unref (dst_img);
+
+    crc32 = compute_crc32 (0, dstbuf, dst_stride * dst_height);
+    free (srcbuf);
+    free (maskbuf);
+    free (dstbuf);
+
+    FLOAT_REGS_CORRUPTION_DETECTOR_FINISH ();
+    return crc32;
+}
+
+static void utc_pixman_scaling(void)
+{
+
+    int ret;
+    pixman_disable_out_of_bounds_workaround ();
+
+    ret = fuzzer_test_main("scaling", 8000000, 0x80DF1CB2,
+                           test_composite, 1, NULL);
+
+    if(ret)
+        dts_fail("utc_pixman_scaling");
+
+    dts_pass("utc_pixman_scaling");
+}
diff --git a/TC/testcase/utils.c b/TC/testcase/utils.c
new file mode 100644 (file)
index 0000000..c1bf6dc
--- /dev/null
@@ -0,0 +1,887 @@
+#define _GNU_SOURCE
+
+#include "utils.h"
+#include <signal.h>
+#include <stdlib.h>
+
+#ifdef HAVE_GETTIMEOFDAY
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+#ifdef HAVE_FENV_H
+#include <fenv.h>
+#endif
+
+#ifdef HAVE_LIBPNG
+#include <png.h>
+#endif
+
+/* 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);
+}
+
+pixman_bool_t
+is_little_endian (void)
+{
+    volatile uint16_t endian_check_var = 0x1234;
+
+    return (*(volatile uint8_t *)&endian_check_var == 0x34);
+}
+
+/* perform endian conversion of pixel data
+ */
+void
+image_endian_swap (pixman_image_t *img)
+{
+    int stride = pixman_image_get_stride (img);
+    uint32_t *data = pixman_image_get_data (img);
+    int height = pixman_image_get_height (img);
+    int bpp = PIXMAN_FORMAT_BPP (pixman_image_get_format (img));
+    int i, j;
+
+    /* swap bytes only on big endian systems */
+    if (is_little_endian())
+       return;
+
+    if (bpp == 8)
+       return;
+
+    for (i = 0; i < height; i++)
+    {
+       uint8_t *line_data = (uint8_t *)data + stride * i;
+       
+       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:
+           assert (FALSE);
+           break;
+       }
+    }
+}
+
+#define N_LEADING_PROTECTED    10
+#define N_TRAILING_PROTECTED   10
+
+typedef struct
+{
+    void *addr;
+    uint32_t len;
+    uint8_t *trailing;
+    int n_bytes;
+} info_t;
+
+#if defined(HAVE_MPROTECT) && defined(HAVE_GETPAGESIZE) && defined(HAVE_SYS_MMAN_H) && defined(HAVE_MMAP)
+
+/* This is apparently necessary on at least OS X */
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+void *
+fence_malloc (int64_t len)
+{
+    unsigned long page_size = getpagesize();
+    unsigned long page_mask = page_size - 1;
+    uint32_t n_payload_bytes = (len + page_mask) & ~page_mask;
+    uint32_t n_bytes =
+       (page_size * (N_LEADING_PROTECTED + N_TRAILING_PROTECTED + 2) +
+        n_payload_bytes) & ~page_mask;
+    uint8_t *initial_page;
+    uint8_t *leading_protected;
+    uint8_t *trailing_protected;
+    uint8_t *payload;
+    uint8_t *addr;
+
+    if (len < 0)
+       abort();
+    
+    addr = mmap (NULL, n_bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
+                -1, 0);
+
+    if (addr == MAP_FAILED)
+    {
+       printf ("mmap failed on %lld %u\n", (long long int)len, n_bytes);
+       return NULL;
+    }
+
+    initial_page = (uint8_t *)(((unsigned long)addr + page_mask) & ~page_mask);
+    leading_protected = initial_page + page_size;
+    payload = leading_protected + N_LEADING_PROTECTED * page_size;
+    trailing_protected = payload + n_payload_bytes;
+
+    ((info_t *)initial_page)->addr = addr;
+    ((info_t *)initial_page)->len = len;
+    ((info_t *)initial_page)->trailing = trailing_protected;
+    ((info_t *)initial_page)->n_bytes = n_bytes;
+
+    if ((mprotect (leading_protected, N_LEADING_PROTECTED * page_size,
+                 PROT_NONE) == -1) ||
+       (mprotect (trailing_protected, N_TRAILING_PROTECTED * page_size,
+                 PROT_NONE) == -1))
+    {
+       munmap (addr, n_bytes);
+       return NULL;
+    }
+
+    return payload;
+}
+
+void
+fence_free (void *data)
+{
+    uint32_t page_size = getpagesize();
+    uint8_t *payload = data;
+    uint8_t *leading_protected = payload - N_LEADING_PROTECTED * page_size;
+    uint8_t *initial_page = leading_protected - page_size;
+    info_t *info = (info_t *)initial_page;
+
+    munmap (info->addr, info->n_bytes);
+}
+
+#else
+
+void *
+fence_malloc (int64_t len)
+{
+    return malloc (len);
+}
+
+void
+fence_free (void *data)
+{
+    free (data);
+}
+
+#endif
+
+uint8_t *
+make_random_bytes (int n_bytes)
+{
+    uint8_t *bytes = fence_malloc (n_bytes);
+    int i;
+
+    if (!bytes)
+       return NULL;
+
+    for (i = 0; i < n_bytes; ++i)
+       bytes[i] = lcg_rand () & 0xff;
+
+    return bytes;
+}
+
+void
+a8r8g8b8_to_rgba_np (uint32_t *dst, uint32_t *src, int n_pixels)
+{
+    uint8_t *dst8 = (uint8_t *)dst;
+    int i;
+
+    for (i = 0; i < n_pixels; ++i)
+    {
+       uint32_t p = src[i];
+       uint8_t a, r, g, b;
+
+       a = (p & 0xff000000) >> 24;
+       r = (p & 0x00ff0000) >> 16;
+       g = (p & 0x0000ff00) >> 8;
+       b = (p & 0x000000ff) >> 0;
+
+       if (a != 0)
+       {
+#define DIVIDE(c, a)                                                   \
+           do                                                          \
+           {                                                           \
+               int t = ((c) * 255) / a;                                \
+               (c) = t < 0? 0 : t > 255? 255 : t;                      \
+           } while (0)
+
+           DIVIDE (r, a);
+           DIVIDE (g, a);
+           DIVIDE (b, a);
+       }
+
+       *dst8++ = r;
+       *dst8++ = g;
+       *dst8++ = b;
+       *dst8++ = a;
+    }
+}
+
+#ifdef HAVE_LIBPNG
+
+pixman_bool_t
+write_png (pixman_image_t *image, const char *filename)
+{
+    int width = pixman_image_get_width (image);
+    int height = pixman_image_get_height (image);
+    int stride = width * 4;
+    uint32_t *data = malloc (height * stride);
+    pixman_image_t *copy;
+    png_struct *write_struct;
+    png_info *info_struct;
+    pixman_bool_t result = FALSE;
+    FILE *f = fopen (filename, "wb");
+    png_bytep *row_pointers;
+    int i;
+
+    if (!f)
+       return FALSE;
+
+    row_pointers = malloc (height * sizeof (png_bytep));
+
+    copy = pixman_image_create_bits (
+       PIXMAN_a8r8g8b8, width, height, data, stride);
+
+    pixman_image_composite32 (
+       PIXMAN_OP_SRC, image, NULL, copy, 0, 0, 0, 0, 0, 0, width, height);
+
+    a8r8g8b8_to_rgba_np (data, data, height * width);
+
+    for (i = 0; i < height; ++i)
+       row_pointers[i] = (png_bytep)(data + i * width);
+
+    if (!(write_struct = png_create_write_struct (
+             PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)))
+       goto out1;
+
+    if (!(info_struct = png_create_info_struct (write_struct)))
+       goto out2;
+
+    png_init_io (write_struct, f);
+
+    png_set_IHDR (write_struct, info_struct, width, height,
+                 8, PNG_COLOR_TYPE_RGB_ALPHA,
+                 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
+                 PNG_FILTER_TYPE_BASE);
+
+    png_write_info (write_struct, info_struct);
+
+    png_write_image (write_struct, row_pointers);
+
+    png_write_end (write_struct, NULL);
+
+    result = TRUE;
+
+out2:
+    png_destroy_write_struct (&write_struct, &info_struct);
+
+out1:
+    if (fclose (f) != 0)
+       result = FALSE;
+
+    pixman_image_unref (copy);
+    free (row_pointers);
+    free (data);
+    return result;
+}
+
+#else /* no libpng */
+
+pixman_bool_t
+write_png (pixman_image_t *image, const char *filename)
+{
+    return FALSE;
+}
+
+#endif
+
+/*
+ * 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;
+}
+
+/* Try to obtain current time in seconds */
+double
+gettime (void)
+{
+#ifdef HAVE_GETTIMEOFDAY
+    struct timeval tv;
+
+    gettimeofday (&tv, NULL);
+    return (double)((int64_t)tv.tv_sec * 1000000 + tv.tv_usec) / 1000000.;
+#else
+    return (double)clock() / (double)CLOCKS_PER_SEC;
+#endif
+}
+
+uint32_t
+get_random_seed (void)
+{
+    double d = gettime();
+
+    lcg_srand (*(uint32_t *)&d);
+
+    return lcg_rand_u32 ();
+}
+
+static const char *global_msg;
+
+static void
+on_alarm (int signo)
+{
+    printf ("%s\n", global_msg);
+    exit (1);
+}
+
+void
+fail_after (int seconds, const char *msg)
+{
+#ifdef HAVE_SIGACTION
+#ifdef HAVE_ALARM
+    struct sigaction action;
+
+    global_msg = msg;
+
+    memset (&action, 0, sizeof (action));
+    action.sa_handler = on_alarm;
+
+    alarm (seconds);
+
+    sigaction (SIGALRM, &action, NULL);
+#endif
+#endif
+}
+
+void
+enable_fp_exceptions (void)
+{
+#ifdef HAVE_FENV_H
+#ifdef HAVE_FEENABLEEXCEPT
+    /* Note: we don't enable the FE_INEXACT trap because
+     * that happens quite commonly. It is possible that
+     * over- and underflow should similarly be considered
+     * okay, but for now the test suite passes with them
+     * enabled, and it's useful to know if they start
+     * occuring.
+     */
+    feenableexcept (FE_DIVBYZERO       |
+                   FE_INVALID          |
+                   FE_OVERFLOW         |
+                   FE_UNDERFLOW);
+#endif
+#endif
+}
+
+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;
+}
+
+#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))
+
+void
+initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb)
+{
+    int i;
+    uint32_t mask = (1 << depth) - 1;
+
+    for (i = 0; i < 32768; ++i)
+       palette->ent[i] = lcg_rand() & mask;
+
+    memset (palette->rgba, 0, sizeof (palette->rgba));
+
+    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);
+    }
+}
+
+static double
+round_channel (double p, int m)
+{
+    int t;
+    double r;
+
+    t = p * ((1 << m));
+    t -= t >> m;
+
+    r = t / (double)((1 << m) - 1);
+
+    return r;
+}
+
+void
+round_color (pixman_format_code_t format, color_t *color)
+{
+    if (PIXMAN_FORMAT_R (format) == 0)
+    {
+       color->r = 0.0;
+       color->g = 0.0;
+       color->b = 0.0;
+    }
+    else
+    {
+       color->r = round_channel (color->r, PIXMAN_FORMAT_R (format));
+       color->g = round_channel (color->g, PIXMAN_FORMAT_G (format));
+       color->b = round_channel (color->b, PIXMAN_FORMAT_B (format));
+    }
+
+    if (PIXMAN_FORMAT_A (format) == 0)
+       color->a = 1;
+    else
+       color->a = round_channel (color->a, PIXMAN_FORMAT_A (format));
+}
+
+/* Check whether @pixel is a valid quantization of the a, r, g, b
+ * parameters. Some slack is permitted.
+ */
+void
+pixel_checker_init (pixel_checker_t *checker, pixman_format_code_t format)
+{
+    assert (PIXMAN_FORMAT_VIS (format));
+
+    checker->format = format;
+
+    switch (PIXMAN_FORMAT_TYPE (format))
+    {
+    case PIXMAN_TYPE_A:
+       checker->bs = 0;
+       checker->gs = 0;
+       checker->rs = 0;
+       checker->as = 0;
+       break;
+
+    case PIXMAN_TYPE_ARGB:
+       checker->bs = 0;
+       checker->gs = checker->bs + PIXMAN_FORMAT_B (format);
+       checker->rs = checker->gs + PIXMAN_FORMAT_G (format);
+       checker->as = checker->rs + PIXMAN_FORMAT_R (format);
+       break;
+
+    case PIXMAN_TYPE_ABGR:
+       checker->rs = 0;
+       checker->gs = checker->rs + PIXMAN_FORMAT_R (format);
+       checker->bs = checker->gs + PIXMAN_FORMAT_G (format);
+       checker->as = checker->bs + PIXMAN_FORMAT_B (format);
+       break;
+
+    case PIXMAN_TYPE_BGRA:
+       /* With BGRA formats we start counting at the high end of the pixel */
+       checker->bs = PIXMAN_FORMAT_BPP (format) - PIXMAN_FORMAT_B (format);
+       checker->gs = checker->bs - PIXMAN_FORMAT_B (format);
+       checker->rs = checker->gs - PIXMAN_FORMAT_G (format);
+       checker->as = checker->rs - PIXMAN_FORMAT_R (format);
+       break;
+
+    case PIXMAN_TYPE_RGBA:
+       /* With BGRA formats we start counting at the high end of the pixel */
+       checker->rs = PIXMAN_FORMAT_BPP (format) - PIXMAN_FORMAT_R (format);
+       checker->gs = checker->rs - PIXMAN_FORMAT_R (format);
+       checker->bs = checker->gs - PIXMAN_FORMAT_G (format);
+       checker->as = checker->bs - PIXMAN_FORMAT_B (format);
+       break;
+
+    default:
+       assert (0);
+       break;
+    }
+
+    checker->am = ((1 << PIXMAN_FORMAT_A (format)) - 1) << checker->as;
+    checker->rm = ((1 << PIXMAN_FORMAT_R (format)) - 1) << checker->rs;
+    checker->gm = ((1 << PIXMAN_FORMAT_G (format)) - 1) << checker->gs;
+    checker->bm = ((1 << PIXMAN_FORMAT_B (format)) - 1) << checker->bs;
+
+    checker->aw = PIXMAN_FORMAT_A (format);
+    checker->rw = PIXMAN_FORMAT_R (format);
+    checker->gw = PIXMAN_FORMAT_G (format);
+    checker->bw = PIXMAN_FORMAT_B (format);
+}
+
+void
+pixel_checker_split_pixel (const pixel_checker_t *checker, uint32_t pixel,
+                          int *a, int *r, int *g, int *b)
+{
+    *a = (pixel & checker->am) >> checker->as;
+    *r = (pixel & checker->rm) >> checker->rs;
+    *g = (pixel & checker->gm) >> checker->gs;
+    *b = (pixel & checker->bm) >> checker->bs;
+}
+
+static int32_t
+convert (double v, uint32_t width, uint32_t mask, uint32_t shift, double def)
+{
+    int32_t r;
+
+    if (!mask)
+       v = def;
+
+    r = (v * ((mask >> shift) + 1));
+    r -= r >> width;
+
+    return r;
+}
+
+static void
+get_limits (const pixel_checker_t *checker, double limit,
+           color_t *color,
+           int *ao, int *ro, int *go, int *bo)
+{
+    *ao = convert (color->a + limit, checker->aw, checker->am, checker->as, 1.0);
+    *ro = convert (color->r + limit, checker->rw, checker->rm, checker->rs, 0.0);
+    *go = convert (color->g + limit, checker->gw, checker->gm, checker->gs, 0.0);
+    *bo = convert (color->b + limit, checker->bw, checker->bm, checker->bs, 0.0);
+}
+
+/* The acceptable deviation in units of [0.0, 1.0]
+ */
+#define DEVIATION (0.004)
+
+void
+pixel_checker_get_max (const pixel_checker_t *checker, color_t *color,
+                      int *am, int *rm, int *gm, int *bm)
+{
+    get_limits (checker, DEVIATION, color, am, rm, gm, bm);
+}
+
+void
+pixel_checker_get_min (const pixel_checker_t *checker, color_t *color,
+                      int *am, int *rm, int *gm, int *bm)
+{
+    get_limits (checker, - DEVIATION, color, am, rm, gm, bm);
+}
+
+pixman_bool_t
+pixel_checker_check (const pixel_checker_t *checker, uint32_t pixel,
+                    color_t *color)
+{
+    int32_t a_lo, a_hi, r_lo, r_hi, g_lo, g_hi, b_lo, b_hi;
+    int32_t ai, ri, gi, bi;
+    pixman_bool_t result;
+
+    pixel_checker_get_min (checker, color, &a_lo, &r_lo, &g_lo, &b_lo);
+    pixel_checker_get_max (checker, color, &a_hi, &r_hi, &g_hi, &b_hi);
+    pixel_checker_split_pixel (checker, pixel, &ai, &ri, &gi, &bi);
+
+    result =
+       a_lo <= ai && ai <= a_hi        &&
+       r_lo <= ri && ri <= r_hi        &&
+       g_lo <= gi && gi <= g_hi        &&
+       b_lo <= bi && bi <= b_hi;
+
+    return result;
+}
diff --git a/TC/testcase/utils.h b/TC/testcase/utils.h
new file mode 100644 (file)
index 0000000..b274db5
--- /dev/null
@@ -0,0 +1,195 @@
+#include "config.h"
+
+#include <assert.h>
+#include "pixman-private.h" /* For 'inline' definition */
+
+#define ARRAY_LENGTH(A) ((int) (sizeof (A) / sizeof ((A) [0])))
+
+/* 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;
+}
+
+static inline uint32_t
+lcg_rand_u32 (void)
+{
+    /* This uses the 10/11 most significant bits from the 3 lcg results
+     * (and mixes them with the low from the adjacent one).
+     */
+    uint32_t lo = lcg_rand() >> -(32 - 15 - 11 * 2);
+    uint32_t mid = lcg_rand() << (32 - 15 - 11 * 1);
+    uint32_t hi = lcg_rand() << (32 - 15 - 11 * 0);
+
+    return (hi ^ mid ^ lo);
+}
+
+/* CRC 32 computation
+ */
+uint32_t
+compute_crc32 (uint32_t    in_crc32,
+              const void *buf,
+              size_t      buf_len);
+
+/* Returns TRUE if running on a little endian system */
+pixman_bool_t
+is_little_endian (void);
+
+/* perform endian conversion of pixel data
+ */
+void
+image_endian_swap (pixman_image_t *img);
+
+/* Allocate memory that is bounded by protected pages,
+ * so that out-of-bounds access will cause segfaults
+ */
+void *
+fence_malloc (int64_t len);
+
+void
+fence_free (void *data);
+
+/* Generate n_bytes random bytes in fence_malloced memory */
+uint8_t *
+make_random_bytes (int n_bytes);
+
+/* Return current time in seconds */
+double
+gettime (void);
+
+uint32_t
+get_random_seed (void);
+
+/* 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[]);
+
+void
+fail_after (int seconds, const char *msg);
+
+/* If possible, enable traps for floating point exceptions */
+void enable_fp_exceptions(void);
+
+/* Converts a8r8g8b8 pixels to pixels that
+ *  - are not premultiplied,
+ *  - are stored in this order in memory: R, G, B, A, regardless of
+ *    the endianness of the computer.
+ * It is allowed for @src and @dst to point to the same memory buffer.
+ */
+void
+a8r8g8b8_to_rgba_np (uint32_t *dst, uint32_t *src, int n_pixels);
+
+pixman_bool_t
+write_png (pixman_image_t *image, const char *filename);
+
+/* A pair of macros which can help to detect corruption of
+ * floating point registers after a function call. This may
+ * happen if _mm_empty() call is forgotten in MMX/SSE2 fast
+ * path code, or ARM NEON assembly optimized function forgets
+ * to save/restore d8-d15 registers before use.
+ */
+
+#define FLOAT_REGS_CORRUPTION_DETECTOR_START()                 \
+    static volatile double frcd_volatile_constant1 = 123451;   \
+    static volatile double frcd_volatile_constant2 = 123452;   \
+    static volatile double frcd_volatile_constant3 = 123453;   \
+    static volatile double frcd_volatile_constant4 = 123454;   \
+    static volatile double frcd_volatile_constant5 = 123455;   \
+    static volatile double frcd_volatile_constant6 = 123456;   \
+    static volatile double frcd_volatile_constant7 = 123457;   \
+    static volatile double frcd_volatile_constant8 = 123458;   \
+    double frcd_canary_variable1 = frcd_volatile_constant1;    \
+    double frcd_canary_variable2 = frcd_volatile_constant2;    \
+    double frcd_canary_variable3 = frcd_volatile_constant3;    \
+    double frcd_canary_variable4 = frcd_volatile_constant4;    \
+    double frcd_canary_variable5 = frcd_volatile_constant5;    \
+    double frcd_canary_variable6 = frcd_volatile_constant6;    \
+    double frcd_canary_variable7 = frcd_volatile_constant7;    \
+    double frcd_canary_variable8 = frcd_volatile_constant8;
+
+#define FLOAT_REGS_CORRUPTION_DETECTOR_FINISH()                \
+    assert (frcd_canary_variable1 == frcd_volatile_constant1); \
+    assert (frcd_canary_variable2 == frcd_volatile_constant2); \
+    assert (frcd_canary_variable3 == frcd_volatile_constant3); \
+    assert (frcd_canary_variable4 == frcd_volatile_constant4); \
+    assert (frcd_canary_variable5 == frcd_volatile_constant5); \
+    assert (frcd_canary_variable6 == frcd_volatile_constant6); \
+    assert (frcd_canary_variable7 == frcd_volatile_constant7); \
+    assert (frcd_canary_variable8 == frcd_volatile_constant8);
+
+/* Try to get an aligned memory chunk */
+void *
+aligned_malloc (size_t align, size_t size);
+
+void
+initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb);
+
+typedef struct
+{
+    double r, g, b, a;
+} color_t;
+
+void
+round_color (pixman_format_code_t format, color_t *color);
+
+typedef struct
+{
+    pixman_format_code_t format;
+    uint32_t am, rm, gm, bm;
+    uint32_t as, rs, gs, bs;
+    uint32_t aw, rw, gw, bw;
+} pixel_checker_t;
+
+void
+pixel_checker_init (pixel_checker_t *checker, pixman_format_code_t format);
+
+void
+pixel_checker_split_pixel (const pixel_checker_t *checker, uint32_t pixel,
+                          int *a, int *r, int *g, int *b);
+
+void
+pixel_checker_get_max (const pixel_checker_t *checker, color_t *color,
+                      int *a, int *r, int *g, int *b);
+
+void
+pixel_checker_get_min (const pixel_checker_t *checker, color_t *color,
+                      int *a, int *r, int *g, int *b);
+
+pixman_bool_t
+pixel_checker_check (const pixel_checker_t *checker,
+                    uint32_t pixel, color_t *color);
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100755 (executable)
index 0000000..03f029a
--- /dev/null
@@ -0,0 +1,7 @@
+all
+       ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+       :include:/testcase/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100755 (executable)
index 0000000..f7eda55
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100755 (executable)
index 0000000..02d7030
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage 
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100755 (executable)
index 0000000..ef3e452
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL=  # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE=   # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
index 354f254..fc34bd5 100755 (executable)
@@ -9,4 +9,6 @@ cd $srcdir
 autoreconf -v --install || exit 1
 cd $ORIGDIR || exit $?
 
-$srcdir/configure "$@"
+if test -z "$NOCONFIGURE"; then
+    $srcdir/configure "$@"
+fi
old mode 100755 (executable)
new mode 100644 (file)
index 6c88c84..6cafab3
@@ -53,8 +53,8 @@ AC_PREREQ([2.57])
 #
 
 m4_define([pixman_major], 0)
-m4_define([pixman_minor], 23)
-m4_define([pixman_micro], 7)
+m4_define([pixman_minor], 26)
+m4_define([pixman_micro], 0)
 
 m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro])
 
@@ -150,7 +150,7 @@ AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"])
 # if we're using Sun Studio and neither the user nor a config.site
 # has set CFLAGS.
 if test $SUNCC = yes &&                        \
-   test "$test_CFLAGS" == "" &&                \
+   test "x$test_CFLAGS" = "x" &&       \
    test "$CFLAGS" = "-g"
 then
   CFLAGS="-O -g"
@@ -259,18 +259,71 @@ PIXMAN_CHECK_CFLAG([-fvisibility=hidden], [dnl
 #error Have -fvisibility but it is ignored and generates a warning
 #endif
 #else
-error Need GCC 4.0 for visibility
+#error Need GCC 4.0 for visibility
 #endif
 ])
 
 PIXMAN_CHECK_CFLAG([-xldscope=hidden], [dnl
 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
 #else
-error Need Sun Studio 8 for visibility
+#error Need Sun Studio 8 for visibility
 #endif
 ])
 
 dnl ===========================================================================
+dnl Check for Loongson Multimedia Instructions
+
+if test "x$LS_CFLAGS" = "x" ; then
+    LS_CFLAGS="-march=loongson2f"
+fi
+
+have_loongson_mmi=no
+AC_MSG_CHECKING(whether to use Loongson MMI assembler)
+
+xserver_save_CFLAGS=$CFLAGS
+CFLAGS=" $LS_CFLAGS $CFLAGS -I$srcdir"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#ifndef __mips_loongson_vector_rev
+#error "Loongson Multimedia Instructions are only available on Loongson"
+#endif
+#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
+#error "Need GCC >= 4.4 for Loongson MMI compilation"
+#endif
+#include "pixman/loongson-mmintrin.h"
+int main () {
+    union {
+        __m64 v;
+        char c[8];
+    } a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} };
+    int b = 4;
+    __m64 c = _mm_srli_pi16 (a.v, b);
+    return 0;
+}]])], have_loongson_mmi=yes)
+CFLAGS=$xserver_save_CFLAGS
+
+AC_ARG_ENABLE(loongson-mmi,
+   [AC_HELP_STRING([--disable-loongson-mmi],
+                   [disable Loongson MMI fast paths])],
+   [enable_loongson_mmi=$enableval], [enable_loongson_mmi=auto])
+
+if test $enable_loongson_mmi = no ; then
+   have_loongson_mmi=disabled
+fi
+
+if test $have_loongson_mmi = yes ; then
+   AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia Instructions])
+else
+   LS_CFLAGS=
+fi
+
+AC_MSG_RESULT($have_loongson_mmi)
+if test $enable_loongson_mmi = yes && test $have_loongson_mmi = no ; then
+   AC_MSG_ERROR([Loongson MMI not detected])
+fi
+
+AM_CONDITIONAL(USE_LOONGSON_MMI, test $have_loongson_mmi = yes)
+
+dnl ===========================================================================
 dnl Check for MMX
 
 if test "x$MMX_CFLAGS" = "x" ; then
@@ -292,11 +345,20 @@ xserver_save_CFLAGS=$CFLAGS
 CFLAGS="$MMX_CFLAGS $CFLAGS"
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
-error "Need GCC >= 3.4 for MMX intrinsics"
+#error "Need GCC >= 3.4 for MMX intrinsics"
 #endif
 #include <mmintrin.h>
 int main () {
     __m64 v = _mm_cvtsi32_si64 (1);
+    __m64 w;
+    signed char x = 0;
+
+    /* Some versions of clang will choke on K */
+    asm ("pshufw %2, %1, %0\n\t"
+        : "=y" (w)
+        : "y" (v), "K" (x)
+    );
+
     return _mm_cvtsi64_si32 (v);
 }]])], have_mmx_intrinsics=yes)
 CFLAGS=$xserver_save_CFLAGS
@@ -407,6 +469,8 @@ case $host_os in
       ;;
 esac
 
+AC_SUBST(LS_CFLAGS)
+AC_SUBST(IWMMXT_CFLAGS)
 AC_SUBST(MMX_CFLAGS)
 AC_SUBST(MMX_LDFLAGS)
 AC_SUBST(SSE2_CFLAGS)
@@ -426,7 +490,7 @@ xserver_save_CFLAGS=$CFLAGS
 CFLAGS="$VMX_CFLAGS $CFLAGS"
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
-error "Need GCC >= 3.4 for sane altivec support"
+#error "Need GCC >= 3.4 for sane altivec support"
 #endif
 #include <altivec.h>
 int main () {
@@ -551,22 +615,25 @@ have_iwmmxt_intrinsics=no
 AC_MSG_CHECKING(whether to use ARM IWMMXT intrinsics)
 xserver_save_CFLAGS=$CFLAGS
 CFLAGS="$IWMMXT_CFLAGS $CFLAGS"
-AC_COMPILE_IFELSE([
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 #ifndef __arm__
 #error "IWMMXT is only available on ARM"
 #endif
-#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
-#error "Need GCC >= 4.6 for IWMMXT intrinsics"
+#ifndef __IWMMXT__
+#error "IWMMXT not enabled (with -march=iwmmxt)"
+#endif
+#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5))
+#error "Need GCC >= 4.5 for IWMMXT intrinsics"
 #endif
 #include <mmintrin.h>
 int main () {
        union {
                __m64 v;
-               [char c[8];]
+               char c[8];
        } a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} };
        int b = 4;
        __m64 c = _mm_srli_si64 (a.v, b);
-}], have_iwmmxt_intrinsics=yes)
+}]])], have_iwmmxt_intrinsics=yes)
 CFLAGS=$xserver_save_CFLAGS
 
 AC_ARG_ENABLE(arm-iwmmxt,
@@ -591,6 +658,51 @@ fi
 
 AM_CONDITIONAL(USE_ARM_IWMMXT, test $have_iwmmxt_intrinsics = yes)
 
+dnl ==========================================================================
+dnl Check if assembler is gas compatible and supports MIPS DSPr2 instructions
+
+have_mips_dspr2=no
+AC_MSG_CHECKING(whether to use MIPS DSPr2 assembler)
+xserver_save_CFLAGS=$CFLAGS
+CFLAGS="-mdspr2 $CFLAGS"
+
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#if !(defined(__mips__) &&  __mips_isa_rev >= 2)
+#error MIPS DSPr2 is currently only available on MIPS32r2 platforms.
+#endif
+int
+main ()
+{
+    int c = 0, a = 0, b = 0;
+    __asm__ __volatile__ (
+        "precr.qb.ph %[c], %[a], %[b]          \n\t"
+        : [c] "=r" (c)
+        : [a] "r" (a), [b] "r" (b)
+    );
+    return c;
+}]])], have_mips_dspr2=yes)
+CFLAGS=$xserver_save_CFLAGS
+
+AC_ARG_ENABLE(mips-dspr2,
+   [AC_HELP_STRING([--disable-mips-dspr2],
+                   [disable MIPS DSPr2 fast paths])],
+   [enable_mips_dspr2=$enableval], [enable_mips_dspr2=auto])
+
+if test $enable_mips_dspr2 = no ; then
+   have_mips_dspr2=disabled
+fi
+
+if test $have_mips_dspr2 = yes ; then
+   AC_DEFINE(USE_MIPS_DSPR2, 1, [use MIPS DSPr2 assembly optimizations])
+fi
+
+AM_CONDITIONAL(USE_MIPS_DSPR2, test $have_mips_dspr2 = yes)
+
+AC_MSG_RESULT($have_mips_dspr2)
+if test $enable_mips_dspr2 = yes && test $have_mips_dspr2 = no ; then
+   AC_MSG_ERROR([MIPS DSPr2 instructions not detected])
+fi
+
 dnl =========================================================================================
 dnl Check for GNU-style inline assembly support
 
@@ -733,25 +845,27 @@ fi
 dnl =====================================
 dnl Thread local storage
 
-support_for__thread=no
-
-AC_MSG_CHECKING(for __thread)
-AC_LINK_IFELSE([AC_LANG_SOURCE([[
+AC_MSG_CHECKING(for thread local storage (TLS) support)
+AC_CACHE_VAL(ac_cv_tls, [
+    ac_cv_tls=none
+    keywords="__thread __declspec(thread)"
+    for kw in $keywords ; do
+        AC_TRY_COMPILE([
 #if defined(__MINGW32__) && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
 #error This MinGW version has broken __thread support
 #endif
 #ifdef __OpenBSD__
 #error OpenBSD has broken __thread support
 #endif
-static __thread int x ;
-int main () { x = 123; return x; }
-]])], support_for__thread=yes)
 
-if test $support_for__thread = yes; then 
-   AC_DEFINE([TOOLCHAIN_SUPPORTS__THREAD],[],[Whether the tool chain supports __thread])
-fi
+int $kw test;], [], ac_cv_tls=$kw)
+    done
+])
+AC_MSG_RESULT($ac_cv_tls)
 
-AC_MSG_RESULT($support_for__thread)
+if test "$ac_cv_tls" != "none"; then
+    AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [The compiler supported TLS storage class])
+fi
 
 dnl
 dnl posix tls
@@ -803,7 +917,7 @@ AC_DEFUN([PIXMAN_CHECK_PTHREAD],[dnl
     fi
 ])
 
-if test $support_for__thread = no; then
+if test $ac_cv_tls = none ; then
     support_for_pthread_setspecific=no
 
     AC_MSG_CHECKING(for pthread_setspecific)
@@ -855,7 +969,14 @@ AC_SUBST(TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR)
 dnl ==================
 dnl libpng
 
-PKG_CHECK_MODULES(PNG, [libpng], have_libpng=yes, have_libpng=no)
+AC_ARG_ENABLE(libpng, AS_HELP_STRING([--enable-libpng], [Build support for libpng (default: auto)]),
+                      [have_libpng=$enableval], [have_libpng=auto])
+
+case x$have_libpng in
+       xyes) PKG_CHECK_MODULES(PNG, [libpng]) ;;
+       xno) ;;
+       *) PKG_CHECK_MODULES(PNG, [libpng], have_libpng=yes, have_libpng=no) ;;
+esac
 
 if test x$have_libpng = xyes; then
     AC_DEFINE([HAVE_LIBPNG], [1], [Whether we have libpng])
index 7593eeb..1bd32ad 100755 (executable)
@@ -1,7 +1,475 @@
+pixman (0.26.0-1slp2+3) unstable; urgency=low
+
+  * Fix Build fail of DTS on OBS
+  * Git: framework/graphics/pixman
+  * Tag: pixman_0.26.0-1slp2+3
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Tue, 14 Aug 2012 15:57:40 +0900
+
+pixman (0.26.0-1slp2+2) unstable; urgency=low
+
+  * Update latest code to OBS
+  * Git: slp/pkgs/p/pixman
+  * Tag: pixman_0.26.0-1slp2+2
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Thu, 09 Aug 2012 13:22:55 +0900
+
+pixman (0.26.0-1slp2+1) unstable; urgency=low
+
+  * Update pixman version to 0.26.0
+  * Git: slp/pkgs/p/pixman
+  * Tag: pixman_0.26.0-1slp2+1
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Thu, 31 May 2012 09:02:48 +0900
+
+pixman (0.23.7-1slp2+2) unstable; urgency=low
+
+  * Check for NEON using a signal handler to catch SIGILL
+  * Git: slp/pkgs/p/pixman
+  * Tag: pixman_0.23.7-1slp2+2
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Wed, 07 Mar 2012 17:23:12 +0900
+
 pixman (0.23.7-1slp2+1) unstable; urgency=low
 
-  * Initial version
-  * Git: pkgs/p/pixman
+  * Update pixman version to 0.23.7
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
   * Tag: pixman_0.23.7-1slp2+1
 
- -- Seongwon Cho <seongwon1.cho@samsung.com>  Thu, 08 Dec 2011 13:45:27 +0900
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Tue, 18 Oct 2011 17:00:09 +0900
+
+pixman (0.21.6-1slp2+14) unstable; urgency=low
+
+  * ARM: NEON better instruction scheduling of over_n_8_8888
+  * ARM: NEON better instruction scheduling of over_n_8888
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+14
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Wed, 21 Sep 2011 09:55:15 +0900
+
+pixman (0.21.6-1slp2+13) unstable; urgency=low
+
+  * Patch standard fast path out_reverse_8_8888 
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+13
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Tue, 21 Jun 2011 11:53:56 +0900
+
+pixman (0.21.6-1slp2+12) unstable; urgency=low
+
+  * Fix CPU detection code & remove --disable-arm-simd
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+12
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Wed, 15 Jun 2011 10:48:52 +0900
+
+pixman (0.21.6-1slp2+11) unstable; urgency=low
+
+  * Some more improvement for bilinear REPEAT_NORMAL 
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+11
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Tue, 14 Jun 2011 13:53:41 +0900
+
+pixman (0.21.6-1slp2+10) unstable; urgency=low
+
+  * Disable arm simd because sbs doesn't support armv6 any more
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+10
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Thu, 09 Jun 2011 19:32:14 +0900
+
+pixman (0.21.6-1slp2+9) unstable; urgency=low
+
+  * NEON and ARM SIMD optimizations for REPEAT_NORMAL bilinear fast path.
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+9
+
+ -- Seongwon Cho <seongwon1.cho@samsung.com>  Thu, 02 Jun 2011 09:31:37 +0900
+
+pixman (0.21.6-1slp2+8) unstable; urgency=low
+
+  * NEON optimizations for bilinear scaled scanline functions.
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+8
+
+ -- HyunJu Shin <hyunjushin@samsung.com>  Thu, 21 Apr 2011 11:12:31 +0900
+
+pixman (0.21.6-1slp2+7) unstable; urgency=low
+
+  * Tmax's patch was applied upon the request of Browser Team.
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+7
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Thu, 24 Mar 2011 18:34:48 +0900
+
+pixman (0.21.6-1slp2+6) unstable; urgency=low
+
+  * added "-mfpu=vfp -mfloat-abi=softfp" upon the request from Browser Team.
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+6
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Wed, 23 Mar 2011 16:55:14 +0900
+
+pixman (0.21.6-1slp2+5) unstable; urgency=low
+
+  * Pixman upgrade to 0.21.6
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+5
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Fri, 04 Mar 2011 11:58:06 +0900
+
+pixman (0.21.6-1slp2+4) unstable; urgency=low
+
+  * Trying to upgrade pixman to 0.21.6 with source code ;)
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+4
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Fri, 04 Mar 2011 11:44:34 +0900
+
+pixman (0.21.6-1slp2+3) unstable; urgency=low
+
+  * Trying to upgrade pixman to 0.21.6 with source code ;)
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+3
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Fri, 04 Mar 2011 11:40:02 +0900
+
+pixman (0.21.6-1slp2+2) unstable; urgency=low
+
+  * Trying to upgrade pixman to 0.21.6
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.6-1slp2+2
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Fri, 04 Mar 2011 11:36:15 +0900
+
+pixman (0.21.6-1slp2+1) unstable; urgency=low
+
+  * upgrade and scale patch
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Wed, 23 Feb 2011 19:44:18 +0900
+
+pixman (0.21.2-1slp2+8) unstable; urgency=low
+
+  * to avoid clobbering d0.
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.2-1slp2+8
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Tue, 14 Dec 2010 11:31:47 +0900
+
+pixman (0.21.2-1slp2+7) unstable; urgency=low
+
+  * Check for NEON using a signal handler to catch SIGILL
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.2-1slp2+7
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Fri, 10 Dec 2010 17:44:10 +0900
+
+pixman (0.21.2-1slp2+6) unstable; urgency=low
+
+  * Check for NEON using a signal handler to catch SIGILL
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.2-1slp2+6
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Thu, 09 Dec 2010 19:43:56 +0900
+
+pixman (0.21.2-1slp2+5) unstable; urgency=low
+
+  * removed libeppl dependency
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.2-1slp2+5
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Wed, 08 Dec 2010 11:58:14 +0900
+
+pixman (0.21.2-1slp2+4) unstable; urgency=low
+
+  * removed libeppl dependency
+  * Git: 165.213.180.234:slp/pkgs/p/pixman
+  * Tag: pixman_0.21.2-1slp2+4
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Wed, 08 Dec 2010 11:56:42 +0900
+
+pixman (0.21.2-1slp2+3) unstable; urgency=low
+
+  * Removed libeppl dependencies
+  * Git: 165.213.180.234:/git/slp/pkgs/pixman
+  * Tag: pixman_0.21.2-1slp2+3
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Wed, 08 Dec 2010 11:52:30 +0900
+
+pixman (0.21.2-1slp2+2) unstable; urgency=low
+
+  * To sync git and dpkg
+  * Git: 165.213.180.234:/git/slp/pkgs/pixman
+  * Tag: pixman_0.21.2-1slp2+2
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Fri, 03 Dec 2010 16:08:08 +0900
+
+pixman (0.21.2-1slp2+1) unstable; urgency=low
+
+  * upgraded
+  * Git: 165.213.180.234:/git/slp/pkgs/pixman
+  * Tag: pixman_0.18.0-1slp2+7
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Fri, 03 Dec 2010 16:02:31 +0900
+
+pixman (0.18.0-1slp2+6) unstable; urgency=low
+
+  * applied strip.
+  * Git: 165.213.180.234:/git/slp/pkgs/pixman
+  * Tag: pixman_0.18.0-1slp2+6
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Wed, 01 Dec 2010 17:06:03 +0900
+
+pixman (0.18.0-1slp2+5) unstable; urgency=low
+
+  * An eppl bug was fixed.
+  * Git: 165.213.180.234:/git/slp/pkgs/pixman
+  * Tag: pixman_0.18.0-1slp2+5
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Wed, 04 Aug 2010 10:57:13 +0900
+
+pixman (0.18.0-1slp2+1) unstable; urgency=low
+
+  * version fixed by scm
+  * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/pixman
+  * Tag: pixman_0.18.0-1slp2+1
+
+ -- Youngdae Koo <youngdae.koo@samsung.com>  Tue, 29 Jun 2010 19:29:59 +0900
+
+pixman (0.18.0slp2+3) unstable; urgency=low
+
+  * Updated newly released pixman-eppl from SoC Lab.
+     (Seems to be trying to support 565->888 composite)
+  * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/pixman
+  * Tag: pixman_0.18.0slp2+3
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Mon, 28 Jun 2010 14:16:47 +0900
+
+pixman (0.18.0slp2+2) unstable; urgency=low
+
+  * fixed the build break in ix86 env.
+  * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/pixman
+  * Tag: pixman_0.18.0slp2+2
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Wed, 02 Jun 2010 20:46:13 +0900
+
+pixman (0.18.0slp2+1) unstable; urgency=low
+
+  * Upgraded to 0.18.0-eppl.
+  * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/pixman
+  * Tag: pixman_0.18.0slp2+1
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Tue, 01 Jun 2010 15:19:48 +0900
+
+pixman (0.17.10-slp2+2) unstable; urgency=low
+
+  * install .la file
+
+ -- SooChan Lim <sc1.lim@samsung.com>  Tue, 30 Mar 2010 22:36:11 +0900
+
+pixman (0.17.10-slp2+1) unstable; urgency=low
+
+  * Changed revision. Uploaded source code for i386 and arm.
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Tue, 30 Mar 2010 15:34:31 +0900
+
+pixman (0.17.10-0) unstable; urgency=low
+
+  * Upgraded to pixman-0.17.10
+
+ -- YoungHoon Jung <yhoon.jung@samsung.com>  Tue, 09 Mar 2010 14:20:17 +0900
+
+pixman (0.17.6-3) unstable; urgency=low
+
+  * Change package to support armel
+
+ -- Sung-Jin Park <sj76.park@samsung.com>  Thu, 18 Feb 2010 20:11:52 +0900
+
+pixman (0.17.6-2) unstable; urgency=low
+
+  * Change package to support i686
+
+ -- Sung-Jin Park <sj76.park@samsung.com>  Thu, 18 Feb 2010 20:05:32 +0900
+
+pixman (0.17.6-1) unstable; urgency=low
+
+  * Initial release.
+
+ -- Sung-Jin Park <sj76.park@samsung.com>  Wed, 10 Feb 2010 16:07:44 +0900
+
+pixman (0.16.4-1) unstable; urgency=low
+
+  * New upstream release.
+  * Add dependencies on ${misc:Depends} (lintian).
+  * Bump Standards-Version to 3.8.3.
+
+ -- Julien Cristau <jcristau@debian.org>  Sat, 02 Jan 2010 11:26:29 +0000
+
+pixman (0.16.2-1) unstable; urgency=low
+
+  * New upstream release (closes: #546849).
+  * Upload to unstable.
+
+ -- Julien Cristau <jcristau@debian.org>  Mon, 28 Sep 2009 18:12:47 +0200
+
+pixman (0.15.20-1) experimental; urgency=low
+
+  * New upstream release candidate.
+  * Bump shlibs and update symbols file for
+    pixman_disable_out_of_bounds_workaround and new formats.
+  * Add patch to disable use of env vars to force hwcap and platform on arm.
+  * Add README.source with a pointer to the quilt package.
+
+ -- Julien Cristau <jcristau@debian.org>  Sun, 23 Aug 2009 12:44:59 +0200
+
+pixman (0.15.14-1) experimental; urgency=low
+
+  * Update debian/copyright from upstream COPYING (closes: #519078).  Thanks,
+    Jo Shields!
+  * New upstream development release.
+  * Enable arm simd, we can do runtime detection now.
+  * Update symbols file and bump shlibs for new version.
+  * Run dh_shlibdeps after dh_installdeb to avoid a dpkg-shlibdeps warning.
+  * Move libpixman-1-0-dbg to new 'debug' section.
+  * Add ~ to pixman_image_set_source_clipping version in symbols file, to make
+    lintian happy.
+  * Don't handle nostrip explicitly in debian/rules, dh_strip does that for
+    us.
+  * Use filter instead of findstring for DEB_BUILD_OPTIONS parsing, as
+    standardized by policy 3.8.0.
+  * Handle parallel=n in DEB_BUILD_OPTIONS.
+  * Bump Standards-Version to 3.8.2.
+  * Version the build-dep on debhelper to silence lintian.
+
+ -- Julien Cristau <jcristau@debian.org>  Wed, 24 Jun 2009 21:13:07 +0200
+
+pixman (0.14.0-1) unstable; urgency=low
+
+  [ Brice Goglin ]
+  * Update upstream URL in debian/copyright.
+  * Install the upstream ChangeLog.
+
+  [ Julien Cristau ]
+  * New upstream release.
+
+ -- Julien Cristau <jcristau@debian.org>  Sun, 15 Feb 2009 23:01:14 +0100
+
+pixman (0.13.2-1) experimental; urgency=low
+
+  [ Timo Aaltonen ]
+  * New upstream release.
+  * Update libpixman-1-0.symbols with new symbols.
+
+  [ Julien Cristau ]
+  * Don't use ARM SIMD code.  It doesn't do runtime detection, and will only
+    work on ARMv6.
+  * Fix shlibs for the udeb.
+
+ -- Julien Cristau <jcristau@debian.org>  Sun, 04 Jan 2009 21:39:31 +0100
+
+pixman (0.12.0-1) experimental; urgency=low
+
+  * New upstream release.
+  * Bump pixman_format_supported_source's version in the symbols file, depth
+    30 formats were added in 0.11.10.
+  * Bump shlibs to 0.11.10 as well.
+
+ -- Julien Cristau <jcristau@debian.org>  Sun, 21 Sep 2008 17:01:01 +0200
+
+pixman (0.11.8-1) experimental; urgency=low
+
+  * New upstream development release.
+  * Bump versions for pixman_image_create_bits and
+    pixman_format_supported_destination, as some formats were added in 0.11.6.
+
+ -- Julien Cristau <jcristau@debian.org>  Fri, 18 Jul 2008 15:21:17 +0200
+
+pixman (0.11.6-1) experimental; urgency=low
+
+  * New upstream development release.
+  * Bump shlibs and update symbols files.
+
+ -- Julien Cristau <jcristau@debian.org>  Tue, 15 Jul 2008 21:36:11 +0200
+
+pixman (0.10.0-2) unstable; urgency=low
+
+  [ Frans Pop ]
+  * Add libpixman-1-0-udeb (needed for cairo).  Closes: #476480.
+
+ -- Julien Cristau <jcristau@debian.org>  Thu, 17 Apr 2008 14:08:20 +0200
+
+pixman (0.10.0-1) unstable; urgency=low
+
+  * New upstream release.
+  * Bump shlibs to 0.10.0.
+  * Run autoreconf at build-time.
+    Build-depend on automake, autoconf, libtool and pkg-config.  Drop patch
+    for maintainer mode, and drop build-dep on quilt and corresponding code in
+    debian/rules.  Add new rules autogen and config, where we run autoreconf
+    and configure, respectively.  Update clean rule to remove files generated
+    by autogen.
+  * Add symbols file for libpixman-1-0.
+  * Bump Standards-Version to 3.7.3.
+  * Add Vcs-Git and Vcs-Browser control fields.
+
+ -- Julien Cristau <jcristau@debian.org>  Fri, 04 Apr 2008 14:31:30 +0200
+
+pixman (0.9.6-1) unstable; urgency=low
+
+  * New upstream release (closes: #452734).
+    + 02_no-sse.diff: remove, fix included upstream;
+    + 03_fbFetchTransformed_64bit_fix.diff: remove, 64bit issues should be
+      fixed too.
+
+ -- Julien Cristau <jcristau@debian.org>  Sun, 25 Nov 2007 00:41:31 +0100
+
+pixman (0.9.5-3) unstable; urgency=low
+
+  * Add patch by Francis Whittle from upstream bug#12398
+    (https://bugs.freedesktop.org/attachment.cgi?id=11896) to fix arithmetic
+    bug in fbFetchTransformed (causing X crashes on 64bit); closes: #444457.
+
+ -- Julien Cristau <jcristau@debian.org>  Tue, 16 Oct 2007 09:52:16 +0200
+
+pixman (0.9.5-2) unstable; urgency=high
+
+  * High urgency for RC bugfix.
+  * Don't use -msse, to prevent gcc 4.2 from generating SSE instructions for
+    its builtin functions, the X server from going SIGILL on CPUs supporting
+    MMX but not SSE, and us from losing (closes: #442829).
+  * Enable maintainer mode in configure.ac.
+
+ -- Julien Cristau <jcristau@debian.org>  Wed, 19 Sep 2007 23:21:46 +0200
+
+pixman (0.9.5-1) unstable; urgency=low
+
+  * New upstream release (no actual changes since 0.9.4-2, just new upstream
+    tarball).
+  * Add watch file.
+  * Upload to unstable for X.Org 7.3.
+
+ -- Julien Cristau <jcristau@debian.org>  Wed, 05 Sep 2007 21:43:58 +0200
+
+pixman (0.9.4-2) experimental; urgency=low
+
+  * Update from git master branch (commit 8ff7213f).
+  * Bump shlibs.
+
+ -- Julien Cristau <jcristau@debian.org>  Mon, 03 Sep 2007 17:11:24 +0200
+
+pixman (0.9.4-1) experimental; urgency=low
+
+  * New upstream version
+  * Update packaging for the name change. It's now pixman-1, so we use
+    libpixman-1-0 for the package names
+  * Add myself to uploaders
+  * Pull upstream fix for the .pc file for the library name change
+
+ -- David Nusinow <dnusinow@debian.org>  Thu, 09 Aug 2007 22:15:45 -0400
+
+pixman (0.9.3~git20070729-1) experimental; urgency=low
+
+  * First upload (closes: 428774).
+
+ -- Julien Cristau <jcristau@debian.org>  Wed, 01 Aug 2007 13:24:36 +0200
index 11a0b83..4b2fe95 100755 (executable)
@@ -46,6 +46,7 @@ config-stamp: autogen-stamp
          --mandir=\$${prefix}/share/man \
          --infodir=\$${prefix}/share/info \
          $(confflags) \
+         --disable-arm-iwmmxt \
          CFLAGS="$(CFLAGS)"
        touch $@
 
index 070c2d7..9aac1f5 100644 (file)
@@ -6,7 +6,7 @@ AM_LDFLAGS = $(OPENMP_CFLAGS)
 LDADD = $(top_builddir)/pixman/libpixman-1.la -lm $(GTK_LIBS) $(PNG_LIBS)
 INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman $(GTK_CFLAGS) $(PNG_CFLAGS)
 
-GTK_UTILS = gtk-utils.c gtk-utils.h
+GTK_UTILS = gtk-utils.c gtk-utils.h ../test/utils.c ../test/utils.h
 
 DEMOS =                                \
        clip-test               \
@@ -18,7 +18,11 @@ DEMOS =                              \
        screen-test             \
        convolution-test        \
        trap-test               \
-       tri-test
+       tri-test                \
+       quad2quad               \
+       checkerboard
+
+EXTRA_DIST = parrot.c parrot.jpg
 
 gradient_test_SOURCES = gradient-test.c $(GTK_UTILS)
 alpha_test_SOURCES = alpha-test.c $(GTK_UTILS)
@@ -28,8 +32,9 @@ clip_in_SOURCES = clip-in.c $(GTK_UTILS)
 trap_test_SOURCES = trap-test.c $(GTK_UTILS)
 screen_test_SOURCES = screen-test.c $(GTK_UTILS)
 convolution_test_SOURCES = convolution-test.c $(GTK_UTILS)
-radial_test_SOURCES = radial-test.c ../test/utils.c ../test/utils.h $(GTK_UTILS)
-tri_test_SOURCES = tri-test.c ../test/utils.c ../test/utils.h $(GTK_UTILS)
+radial_test_SOURCES = radial-test.c $(GTK_UTILS)
+tri_test_SOURCES = tri-test.c $(GTK_UTILS)
+checkerboard_SOURCES = checkerboard.c $(GTK_UTILS)
 
 noinst_PROGRAMS = $(DEMOS)
 
diff --git a/demos/checkerboard.c b/demos/checkerboard.c
new file mode 100644 (file)
index 0000000..449fedb
--- /dev/null
@@ -0,0 +1,71 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "pixman.h"
+#include "gtk-utils.h"
+
+int
+main (int argc, char **argv)
+{
+#define WIDTH 400
+#define HEIGHT 400
+#define TILE_SIZE 25
+
+    pixman_image_t *checkerboard;
+    pixman_image_t *destination;
+#define D2F(d) (pixman_double_to_fixed(d))
+    pixman_transform_t trans = { {
+           { D2F (-1.96830), D2F (-1.82250), D2F (512.12250)},
+           { D2F (0.00000), D2F (-7.29000), D2F (1458.00000)},
+           { D2F (0.00000), D2F (-0.00911), D2F (0.59231)},
+       }};
+    int i, j;
+
+    checkerboard = pixman_image_create_bits (PIXMAN_a8r8g8b8,
+                                            WIDTH, HEIGHT,
+                                            NULL, 0);
+
+    destination = pixman_image_create_bits (PIXMAN_a8r8g8b8,
+                                           WIDTH, HEIGHT,
+                                           NULL, 0);
+
+    for (i = 0; i < HEIGHT / TILE_SIZE; ++i)
+    {
+       for (j = 0; j < WIDTH / TILE_SIZE; ++j)
+       {
+           double u = (double)(j + 1) / (WIDTH / TILE_SIZE);
+           double v = (double)(i + 1) / (HEIGHT / TILE_SIZE);
+           pixman_color_t black = { 0, 0, 0, 0xffff };
+           pixman_color_t white = {
+               v * 0xffff,
+               u * 0xffff,
+               (1 - (double)u) * 0xffff,
+               0xffff };
+           pixman_color_t *c;
+           pixman_image_t *fill;
+
+           if ((j & 1) != (i & 1))
+               c = &black;
+           else
+               c = &white;
+
+           fill = pixman_image_create_solid_fill (c);
+
+           pixman_image_composite (PIXMAN_OP_SRC, fill, NULL, checkerboard,
+                                   0, 0, 0, 0, j * TILE_SIZE, i * TILE_SIZE,
+                                   TILE_SIZE, TILE_SIZE);
+       }
+    }
+
+    pixman_image_set_transform (checkerboard, &trans);
+    pixman_image_set_filter (checkerboard, PIXMAN_FILTER_BEST, NULL, 0);
+    pixman_image_set_repeat (checkerboard, PIXMAN_REPEAT_NONE);
+
+    pixman_image_composite (PIXMAN_OP_SRC,
+                           checkerboard, NULL, destination,
+                           0, 0, 0, 0, 0, 0,
+                           WIDTH, HEIGHT);
+
+    show_image (destination);
+
+    return 0;
+}
index f5f352f..dc24f8e 100644 (file)
@@ -3,9 +3,10 @@
 #include <stdio.h>
 #include "pixman.h"
 #include "gtk-utils.h"
+#include "parrot.c"
 
-#define WIDTH  60
-#define HEIGHT 60
+#define WIDTH  80
+#define HEIGHT 80
 
 typedef struct {
     const char *name;
@@ -87,26 +88,24 @@ int
 main (int argc, char **argv)
 {
 #define d2f pixman_double_to_fixed
-    
+
     GtkWidget *window, *swindow;
     GtkWidget *table;
     uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
     uint32_t *src = malloc (WIDTH * HEIGHT * 4);
-    pixman_image_t *src_img;
+    pixman_image_t *gradient, *parrot;
     pixman_image_t *dest_img;
-    pixman_point_fixed_t p1 = { -10 << 0, 0 };
-    pixman_point_fixed_t p2 = { WIDTH << 16, (HEIGHT - 10) << 16 };
-    uint16_t full = 0xcfff;
-    uint16_t low  = 0x5000;
-    uint16_t alpha = 0xffff;
+    pixman_point_fixed_t p1 = { -10 << 16, 10 << 16 };
+    pixman_point_fixed_t p2 = { (WIDTH + 10) << 16, (HEIGHT - 10) << 16 };
+    uint16_t alpha = 0xdddd;
     pixman_gradient_stop_t stops[6] =
     {
-       { d2f (0.0), { full, low, low, alpha } },
-       { d2f (0.25), { full, full, low, alpha } },
-       { d2f (0.4), { low, full, low, alpha } },
-       { d2f (0.6), { low, full, full, alpha } },
-       { d2f (0.8), { low, low, full, alpha } },
-       { d2f (1.0), { full, low, full, alpha } },
+       { d2f (0.0), { 0xf2f2, 0x8787, 0x7d7d, alpha } },
+       { d2f (0.22), { 0xf3f3, 0xeaea, 0x8383, alpha } },
+       { d2f (0.42), { 0x6b6b, 0xc0c0, 0x7777, alpha } },
+       { d2f (0.57), { 0x4b4b, 0xc9c9, 0xf5f5, alpha } },
+       { d2f (0.75), { 0x6a6a, 0x7f7f, 0xbebe, alpha } },
+       { d2f (1.0), { 0xeded, 0x8282, 0xb0b0, alpha } },
     };
 
     int i;
@@ -116,20 +115,20 @@ main (int argc, char **argv)
     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
     gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
-    
+
     g_signal_connect (window, "delete-event",
                      G_CALLBACK (gtk_main_quit),
                      NULL);
     table = gtk_table_new (G_N_ELEMENTS (operators) / 6, 6, TRUE);
 
-    src_img = pixman_image_create_linear_gradient (&p1, &p2, stops,
-                                                  sizeof (stops) / sizeof (stops[0]));
+    gradient = pixman_image_create_linear_gradient (&p1, &p2, stops, G_N_ELEMENTS (stops));
+    parrot = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, (uint32_t *)parrot_bits, WIDTH * 4);
+
+    pixman_image_set_repeat (gradient, PIXMAN_REPEAT_PAD);
 
-    pixman_image_set_repeat (src_img, PIXMAN_REPEAT_PAD);
-    
     dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
                                         WIDTH, HEIGHT,
-                                        dest,
+                                        NULL,
                                         WIDTH * 4);
     pixman_image_set_accessors (dest_img, reader, writer);
 
@@ -139,7 +138,6 @@ main (int argc, char **argv)
        GdkPixbuf *pixbuf;
        GtkWidget *vbox;
        GtkWidget *label;
-       int j, k;
 
        vbox = gtk_vbox_new (FALSE, 0);
 
@@ -147,12 +145,9 @@ main (int argc, char **argv)
        gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 6);
        gtk_widget_show (label);
 
-       for (j = 0; j < HEIGHT; ++j)
-       {
-           for (k = 0; k < WIDTH; ++k)
-               dest[j * WIDTH + k] = 0x7f6f6f00;
-       }
-       pixman_image_composite (operators[i].op, src_img, NULL, dest_img,
+       pixman_image_composite (PIXMAN_OP_SRC, gradient, NULL, dest_img,
+                               0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+       pixman_image_composite (operators[i].op, parrot, NULL, dest_img,
                                0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
        pixbuf = pixbuf_from_argb32 (pixman_image_get_data (dest_img), TRUE,
                                     WIDTH, HEIGHT, WIDTH * 4);
@@ -167,7 +162,7 @@ main (int argc, char **argv)
        g_object_unref (pixbuf);
     }
 
-    pixman_image_unref (src_img);
+    pixman_image_unref (gradient);
     free (src);
     pixman_image_unref (dest_img);
     free (dest);
@@ -176,7 +171,7 @@ main (int argc, char **argv)
     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
-    
+
     gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow), table);
     gtk_widget_show (table);
 
index 20f78a6..e68f69a 100644 (file)
@@ -15,12 +15,11 @@ main (int argc, char **argv)
     int i;
     pixman_gradient_stop_t stops[2] =
        {
-           { pixman_int_to_fixed (0), { 0xffff, 0xeeee, 0xeeee, 0xeeee } },
-           { pixman_int_to_fixed (1), { 0xffff, 0x1111, 0x1111, 0x1111 } }
+           { pixman_int_to_fixed (0), { 0x0000, 0x0000, 0xffff, 0xffff } },
+           { pixman_int_to_fixed (1), { 0xffff, 0x1111, 0x1111, 0xffff } }
        };
-    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) };
+    pixman_point_fixed_t p1 = { pixman_double_to_fixed (50), 0 };
+    pixman_point_fixed_t p2 = { pixman_double_to_fixed (200), 0 };
 #if 0
     pixman_transform_t trans = {
        { { pixman_double_to_fixed (2), pixman_double_to_fixed (0.5), pixman_double_to_fixed (-100), },
@@ -44,7 +43,7 @@ main (int argc, char **argv)
 #endif
     
     for (i = 0; i < WIDTH * HEIGHT; ++i)
-       dest[i] = 0x4f00004f; /* pale blue */
+       dest[i] = 0xff00ff00;
     
     dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
                                         WIDTH, HEIGHT, 
@@ -74,7 +73,7 @@ main (int argc, char **argv)
                                                    stops, 2);
     
     pixman_image_set_transform (src_img, &trans);
-    pixman_image_set_repeat (src_img, PIXMAN_REPEAT_PAD);
+    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);
index 0e7cb5c..1ff89eb 100644 (file)
@@ -1,8 +1,6 @@
 #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 "../test/utils.h"
 #include "gtk-utils.h"
 
 GdkPixbuf *
@@ -16,45 +14,19 @@ pixbuf_from_argb32 (uint32_t *bits,
                                        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;
+    int i;
 
-           if (a)
-           {
-               r = (r * 255) / a;
-               g = (g * 255) / a;
-               b = (b * 255) / a;
-           }
+    for (i = 0; i < height; ++i)
+    {
+       uint32_t *src_row = &bits[i * (stride / 4)];
+       uint32_t *dst_row = p_bits + i * (p_stride / 4);
 
-           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;
-       }
+       a8r8g8b8_to_rgba_np (dst_row, src_row, width);
     }
-    
+
     return pixbuf;
 }
 
-
 static gboolean
 on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data)
 {
@@ -94,7 +66,7 @@ show_image (pixman_image_t *image)
 
     gtk_window_set_default_size (GTK_WINDOW (window), width, height);
     
-    format = image->bits.format;
+    format = pixman_image_get_format (image);
     
     if (format == PIXMAN_a8r8g8b8)
        has_alpha = TRUE;
diff --git a/demos/parrot.c b/demos/parrot.c
new file mode 100644 (file)
index 0000000..60fd270
--- /dev/null
@@ -0,0 +1,1079 @@
+/* This parrot is a finger painting by Rubens LP:
+ *
+ *     http://www.flickr.com/photos/dorubens/4030604504/in/set-72157622586088192/
+ *
+ * Used here under Creative Commons Attribution. The artist's web site:
+ *
+ *     http://www.rubenslp.com.br/
+ *
+ */
+static const uint32_t parrot_bits[] =
+{
+    0x716f7070, 0x1c1b1b1b, 0x110f1010, 0x16151415, 0x14121313, 0x2c292b2b,
+    0x403e3f3f, 0x19181818, 0x06050605, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02010101, 0x08070707,
+    0x05040404, 0x0a060908, 0x27262426, 0xb3b0b1b2, 0x99979897, 0x2b2a2929,
+    0x100f0f0f, 0x0f0d0e0e, 0x0e0e0c0d, 0x0d0d0b0c, 0x12111111, 0x10100e0f,
+    0x0e0e0c0d, 0x0e0e0c0d, 0x12101211, 0x13121212, 0x17151516, 0x100f0e0f,
+    0x15141414, 0x423f4042, 0x3b393a3a, 0x13121212, 0x16151515, 0x2b282b29,
+    0x13121112, 0x100f0f0f, 0x0f0d0f0e, 0x08070807, 0x0d0c0c0c, 0x0a090a09,
+    0x0e0e0c0d, 0x0c0c0a0b, 0x10100f0f, 0x0f0e0e0e, 0x07060706, 0x0d0c0d0c,
+    0x0e0d0e0d, 0x05040504, 0x08070807, 0x0c0b0c0b, 0x0d0c0d0c, 0x05040504,
+    0x110f1110, 0x08070707, 0x04030303, 0x09080808, 0x06050605, 0x01000000,
+    0x08070707, 0x06050505, 0x05040504, 0x100e100f, 0x0b0a0b0a, 0x01000100,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04030403,
+    0x03020302, 0x0b0a0b0a, 0x14131313, 0x0e0d0d0d, 0x0e0d0e0d, 0x231f2222,
+    0x4d4b4b4d, 0xa7a5a6a6, 0x5b595a5a, 0x07060606, 0x00000000, 0x00000000,
+    0x01000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02010201,
+    0x05040404, 0x07050706, 0x04020303, 0x403e3e3f, 0xb6b3b5b5, 0x84828283,
+    0x1a191819, 0x0e0d0d0d, 0x0d0c0b0c, 0x0f0f0d0e, 0x0e0d0d0d, 0x0f0f0e0e,
+    0x0e0e0c0d, 0x0c0b0a0b, 0x0b0a090a, 0x11111010, 0x100f0f0f, 0x100f0f0f,
+    0x1b19191a, 0x1f1e1e1e, 0x46434544, 0x3a37383a, 0x1c1b1a1b, 0x1e1d1d1d,
+    0x29272828, 0x19171818, 0x0e0d0d0d, 0x0f0e0e0e, 0x06050505, 0x0c0b0b0b,
+    0x100e100f, 0x09080908, 0x0c0c0a0b, 0x0f0f0e0e, 0x0c0c0a0b, 0x05040404,
+    0x08070807, 0x0c0b0c0b, 0x05040504, 0x06050605, 0x100e100f, 0x09080908,
+    0x09080908, 0x12101211, 0x09080908, 0x03020202, 0x08070707, 0x01000100,
+    0x04030403, 0x07060606, 0x08070707, 0x08070707, 0x0f0e0f0e, 0x0b0a0b0a,
+    0x03020302, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03020202,
+    0x09080908, 0x05040504, 0x00000000, 0x00000000, 0x0b0a0b0a, 0x0f0e0f0e,
+    0x1a191a19, 0x77757576, 0xc3c1c2c2, 0x75737374, 0x1f1e1e1f, 0x06050505,
+    0x07030605, 0x00000000, 0x03020302, 0x00000000, 0x00000000, 0x00000000,
+    0x03020202, 0x04030403, 0x04030303, 0x02010101, 0x5b5a5959, 0xafacaeae,
+    0x5a575859, 0x1b19191a, 0x0e0d0d0d, 0x100e100f, 0x100f0f0f, 0x11101010,
+    0x12121111, 0x0c0c0a0b, 0x09090708, 0x0d0d0b0c, 0x0f0e0d0e, 0x0d0d0b0c,
+    0x14131313, 0x1c1b1b1b, 0x322f3132, 0x514f504f, 0x2d2b2b2b, 0x2e2b2c2e,
+    0x21202020, 0x201f1f1f, 0x15141414, 0x12101211, 0x0e0d0d0d, 0x08070807,
+    0x0b0a0a0a, 0x100e0f0f, 0x07060706, 0x0a090a09, 0x0f0f0d0e, 0x0c0c0a0b,
+    0x09090708, 0x0d0c0c0c, 0x0b0a0b0a, 0x06050605, 0x0b0a0b0a, 0x0c0b0c0b,
+    0x08070807, 0x07060706, 0x0f0e0f0e, 0x0a090a09, 0x01000000, 0x05040504,
+    0x03020202, 0x01000000, 0x08070707, 0x05040504, 0x09080908, 0x0d0c0d0c,
+    0x07060606, 0x04030403, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x02010201, 0x06050505, 0x08070807, 0x01000100, 0x00000000, 0x00000000,
+    0x0f0d0e0e, 0x2c2a2a2b, 0x9c9a9b9b, 0xcac7cac9, 0x4d4c4b4d, 0x1b19181a,
+    0x0a090909, 0x00000000, 0x02010201, 0x05040504, 0x00000000, 0x00000000,
+    0x00000000, 0x02010101, 0x06040605, 0x03020302, 0x100d0e10, 0x615f5f60,
+    0x9d9a9c9c, 0x32313131, 0x14131313, 0x0d0c0c0c, 0x0f0e0e0e, 0x0e0d0d0d,
+    0x100f0f0f, 0x11101010, 0x08070807, 0x06050405, 0x0f0e0e0e, 0x100e0f0f,
+    0x0d0d0c0c, 0x2a282929, 0x3d3c3b3c, 0x38373637, 0x4f4d4d4f, 0x19181718,
+    0x27262626, 0x14131313, 0x29272828, 0x2e2b2c2d, 0x201d1e20, 0x15121414,
+    0x04030403, 0x07060606, 0x0c0b0c0b, 0x0a090a09, 0x08070707, 0x0e0d0e0d,
+    0x0b0a0a0a, 0x07060606, 0x0c0b0b0b, 0x0a090909, 0x04030403, 0x0a090909,
+    0x0e0d0e0d, 0x0a090a09, 0x09080908, 0x0e0d0e0d, 0x07060706, 0x08070807,
+    0x08070807, 0x00000000, 0x01000000, 0x07060606, 0x04030403, 0x08070807,
+    0x0e0d0e0d, 0x07060706, 0x06050605, 0x01000100, 0x00000000, 0x00000000,
+    0x00000000, 0x02010201, 0x07060706, 0x01000100, 0x00000000, 0x00000000,
+    0x01000100, 0x01000100, 0x322e3131, 0xa9a8a8a8, 0xb9b8b8b8, 0x39383639,
+    0x1d1b1b1c, 0x0c0b0b0b, 0x04030303, 0x05040404, 0x07060706, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x06030605, 0x09060807, 0x0e0d0c0d,
+    0x605e5e5f, 0x99959898, 0x2e2c2c2e, 0x13121212, 0x0d0d0b0c, 0x11111010,
+    0x12121111, 0x13131212, 0x0f0e0e0e, 0x09080908, 0x03020302, 0x0c0b0b0b,
+    0x0e0d0d0d, 0x11101010, 0x38363737, 0x514f4f50, 0x34333134, 0x46434546,
+    0x24222124, 0x29262827, 0x04030303, 0x05040404, 0x14131313, 0x15151414,
+    0x100f100f, 0x07060706, 0x07060606, 0x0d0c0d0c, 0x0a090909, 0x07060706,
+    0x0f0e0f0e, 0x0c0b0c0b, 0x01000100, 0x0c0b0c0b, 0x0a090a09, 0x01000100,
+    0x08070707, 0x12101211, 0x0b0a0b0a, 0x06050605, 0x0f0e0f0e, 0x07060706,
+    0x04030403, 0x06050605, 0x02010201, 0x00000000, 0x05040504, 0x03020302,
+    0x06050605, 0x0d0c0d0c, 0x08070707, 0x07060706, 0x100e100f, 0x05040504,
+    0x01000100, 0x00000000, 0x02010201, 0x07060606, 0x03020202, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x06050605, 0xb8b6b6b7, 0xa4a2a3a3,
+    0x2c2b2b2b, 0x1c191a1b, 0x0e0c0d0d, 0x08070707, 0x35323433, 0x1a191919,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04020403,
+    0x1b19191a, 0x68666667, 0x7d7a7c7c, 0x23212023, 0x1c191a1c, 0x0f0e0d0e,
+    0x11111010, 0x11111010, 0x10100f0f, 0x0c0b0b0b, 0x09080908, 0x04030403,
+    0x0e0d0e0d, 0x0e0d0d0d, 0x18171717, 0x52505150, 0x5d5a5b5c, 0x3b3a383a,
+    0x3d3a3b3d, 0x24212224, 0x29252729, 0x06050505, 0x04030303, 0x04030403,
+    0x06050505, 0x0c0b0b0b, 0x09080908, 0x04030303, 0x0d0c0c0c, 0x06050605,
+    0x05040504, 0x0c0b0b0b, 0x08070807, 0x06050605, 0x09080908, 0x0c0b0c0b,
+    0x05040504, 0x0a090909, 0x0e0d0e0d, 0x0a090a09, 0x09080908, 0x0f0e0e0e,
+    0x09080908, 0x04030403, 0x09080908, 0x02010201, 0x00000000, 0x07060706,
+    0x05040504, 0x07060606, 0x0f0d0f0e, 0x06050605, 0x08070807, 0x11101010,
+    0x0c0b0b0b, 0x11101010, 0x09080808, 0x03020302, 0x05040404, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x7c7a7b7b, 0x1d1c1c1d, 0x100f0f0f, 0x110e1010, 0x07070607, 0x5b585a59,
+    0x3e3b3d3c, 0x05040404, 0x00000000, 0x01010001, 0x00000000, 0x00000000,
+    0x02010101, 0x1d1b1b1c, 0x615f6060, 0x54525253, 0x1e1c1b1e, 0x18151617,
+    0x1b18181b, 0x1a171819, 0x1b181a1a, 0x1b18191a, 0x100e0f0f, 0x03020302,
+    0x07060606, 0x0d0c0c0c, 0x120f1111, 0x27252626, 0x73727272, 0x706e6f6f,
+    0x524f5152, 0x2f2c2d2f, 0x1e1c1d1d, 0x1f1c1e1e, 0x09070808, 0x03020202,
+    0x04030303, 0x03020302, 0x0b0a0a0a, 0x08070807, 0x02010101, 0x0b0a0b0a,
+    0x0b0a0b0a, 0x04030303, 0x0d0c0d0c, 0x09080808, 0x05040504, 0x0b0a0b0a,
+    0x08070807, 0x02010201, 0x0c0b0c0b, 0x0c0b0b0b, 0x0a090a09, 0x08070807,
+    0x100e100f, 0x06050605, 0x04030403, 0x07060706, 0x02010201, 0x00000000,
+    0x06050605, 0x03020302, 0x09080908, 0x0d0c0d0c, 0x0d0c0c0c, 0x0a090909,
+    0x0d0c0c0c, 0x15131314, 0x1b19191a, 0x1d1b1b1c, 0x11101010, 0x02010201,
+    0x01000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x02010201, 0x1c1b1b1b, 0x100f0f0f, 0x07060606, 0x0b0b090b,
+    0x8f898e8c, 0x37353636, 0x01010001, 0x00000000, 0x00000000, 0x01000000,
+    0x00000000, 0x00000000, 0x14121313, 0x57545557, 0x43414142, 0x211e1f21,
+    0x18161517, 0x18161518, 0x1f1d1c1f, 0x1b191a1a, 0x13111212, 0x0c0b0b0b,
+    0x02010101, 0x08070807, 0x0f0e0e0e, 0x14121313, 0x403e3e40, 0x8b888a8a,
+    0x68666767, 0x4c4a4a4c, 0x28252628, 0x23202123, 0x16141615, 0x03020202,
+    0x06050605, 0x04030403, 0x04030403, 0x0d0c0c0c, 0x0c0b0c0b, 0x00000000,
+    0x0a090a09, 0x0b0a0b0a, 0x03020302, 0x09080908, 0x0c0b0b0b, 0x04030403,
+    0x0c0b0c0b, 0x0b0a0b0a, 0x01000100, 0x09080908, 0x0f0e0e0e, 0x09080908,
+    0x0c0b0b0b, 0x0b0a0909, 0x03020202, 0x06050605, 0x08070707, 0x04030303,
+    0x00000000, 0x06050605, 0x02010201, 0x0c0b0c0b, 0x0f0d0e0e, 0x05040504,
+    0x0c0c0a0b, 0x100f0f0f, 0x0f0f0d0e, 0x14121313, 0x18161717, 0x100e0f0f,
+    0x02010101, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x0b0a0a0a, 0x0d0c0c0c, 0x08070707,
+    0x201f1f1f, 0xa29ca19f, 0x27262626, 0x00000000, 0x09080808, 0x05040404,
+    0x02010101, 0x03010302, 0x03020302, 0x1b19191a, 0x35323335, 0x39373738,
+    0x1c1a1a1c, 0x19161718, 0x1c1a191c, 0x211f1f21, 0x201d1d20, 0x14121313,
+    0x09080808, 0x04030403, 0x09080908, 0x0b0a0a0a, 0x1d1b1b1c, 0x4f4c4d4e,
+    0x87838685, 0x4a494749, 0x32303031, 0x1b1a1a1a, 0x1a191919, 0x13121312,
+    0x03020302, 0x09080908, 0x0d0c0d0c, 0x0d0c0d0c, 0x100e0f0f, 0x09080908,
+    0x01000000, 0x09080808, 0x09080808, 0x02010201, 0x0a090a09, 0x09080908,
+    0x04030403, 0x0c0b0c0b, 0x07060706, 0x00000000, 0x08070807, 0x0a090909,
+    0x09080808, 0x08070707, 0x0c0b090a, 0x03020000, 0x04030101, 0x06050405,
+    0x03020202, 0x00000000, 0x05040504, 0x04030403, 0x07060606, 0x100e100f,
+    0x07060706, 0x09080808, 0x11111010, 0x0d0d0b0c, 0x0e0e0c0d, 0x100f0f0f,
+    0x0f0e0f0e, 0x03020302, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08070707, 0x10100f0f,
+    0x0c0a0b0b, 0x41403f40, 0x89858887, 0x1e1c1d1d, 0x00000000, 0x110f1010,
+    0x37353636, 0x1f1e1e1e, 0x05040404, 0x06050505, 0x201d1f1f, 0x322f3031,
+    0x33303132, 0x18151618, 0x19161719, 0x1f1d1c1f, 0x1c1a1a1b, 0x1c1a1a1b,
+    0x17151516, 0x09080808, 0x04030403, 0x09080908, 0x0f0d0e0e, 0x1a191819,
+    0x66646465, 0x77747676, 0x2b292a29, 0x07050706, 0x07060606, 0x27242726,
+    0x25232424, 0x08070707, 0x09080808, 0x11101010, 0x12111111, 0x15131414,
+    0x0b0a0b0a, 0x04030403, 0x04030203, 0x06050304, 0x01000000, 0x06050505,
+    0x07060606, 0x07060606, 0x09080808, 0x09080808, 0x02010101, 0x07060606,
+    0x100e0f0f, 0x09080808, 0x0c0b090a, 0x0a090708, 0x05040203, 0x03020000,
+    0x05040203, 0x04030102, 0x03020000, 0x05040304, 0x03020202, 0x09080808,
+    0x0a090a09, 0x08070807, 0x0a090a09, 0x110f1110, 0x0d0d0b0c, 0x0e0e0c0d,
+    0x11110f10, 0x0c0b0b0b, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04030303,
+    0x0d0c0c0c, 0x0a090909, 0x504d4e4f, 0x78757776, 0x1a191919, 0x00000000,
+    0x16151515, 0x31303030, 0x312f3030, 0x100f0f0f, 0x0b0a0b0a, 0x14121313,
+    0x2c292a2c, 0x26232426, 0x19171619, 0x1b171a1b, 0x1f1c1d1f, 0x201d1d20,
+    0x0d0c0c0c, 0x0a090909, 0x06050505, 0x05040504, 0x0c0b0b0b, 0x0b0a0a0a,
+    0x22212121, 0x817d7f7e, 0x59575857, 0x17161616, 0x04030303, 0x01000000,
+    0x07060706, 0x0c0b0b0b, 0x02010201, 0x04030403, 0x0b0a0a0a, 0x201e1e1f,
+    0x17151616, 0x0d0c0c0c, 0x02010201, 0x04030303, 0x04030102, 0x04030101,
+    0x05040202, 0x06050304, 0x05040203, 0x09080707, 0x05040303, 0x03020102,
+    0x07060405, 0x09080607, 0x09080506, 0x0a090708, 0x0c0b090a, 0x06050303,
+    0x04030101, 0x06050302, 0x03020000, 0x03020001, 0x04030102, 0x05040202,
+    0x06050304, 0x0a090808, 0x07060505, 0x08070707, 0x0a090909, 0x0a090909,
+    0x09080808, 0x12111111, 0x09080808, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03020202,
+    0x03020302, 0x09080908, 0x0a090a09, 0x110f1110, 0x66646465, 0x100e0f0f,
+    0x05030504, 0x1f1d1e1f, 0x25242424, 0x22212121, 0x0f0e0e0e, 0x17151616,
+    0x0f0e0e0e, 0x1e1d1d1d, 0x211e1e21, 0x1a18171a, 0x17151417, 0x1d1a1a1d,
+    0x201d1e20, 0x19161719, 0x00000000, 0x00000000, 0x01000100, 0x15121414,
+    0x16141415, 0x32303031, 0x78747776, 0x2f2e2d2d, 0x09080808, 0x06030605,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x09080808, 0x18171617, 0x11101010, 0x02010201, 0x01000000, 0x05040303,
+    0x03020000, 0x05040202, 0x06050203, 0x04030102, 0x06050304, 0x04030001,
+    0x03020001, 0x09090605, 0x09090607, 0x09080608, 0x16131216, 0x0a0a0709,
+    0x06050305, 0x05040204, 0x07060406, 0x03020002, 0x03020001, 0x04030102,
+    0x02010000, 0x06050304, 0x06050304, 0x03020001, 0x09080607, 0x100f0c0d,
+    0x0e0d0a0b, 0x0d0c090a, 0x0d0c0b0b, 0x05040303, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x03020302, 0x0b0a0a0a, 0x09080908, 0x0e0d0e0d, 0x0f0e0f0e,
+    0x0f0c0d0e, 0x07060606, 0x18171717, 0x27242526, 0x1d1b1c1c, 0x0b0a0a0a,
+    0x16141515, 0x0d0c0c0c, 0x17161617, 0x1a18191a, 0x1a17181a, 0x18151618,
+    0x1e1b1d1d, 0x201e1e1f, 0x17141516, 0x0e0b0c0e, 0x00000000, 0x00000000,
+    0x03020202, 0x15121314, 0x2f2c2d2e, 0x58565657, 0x18161717, 0x06030505,
+    0x01000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x08070707, 0x0c0b0b0b, 0x15131314, 0x07060606, 0x01000000,
+    0x03020001, 0x03020000, 0x05040202, 0x09080607, 0x05040102, 0x0b0a0809,
+    0x0e0c0b0c, 0x18121110, 0x271b1d19, 0x39262a25, 0x4f363b33, 0x6042483f,
+    0x3f2a2a1f, 0x36272314, 0x3a2c2615, 0x3a2e2717, 0x382e2617, 0x3c322b1c,
+    0x362e271b, 0x29221c12, 0x28231e17, 0x1815120f, 0x0d0b0909, 0x0b0a0808,
+    0x0c0c090b, 0x100f0c0d, 0x11100d0e, 0x100f0c0d, 0x03020001, 0x02010000,
+    0x03020000, 0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x05040504, 0x03020302, 0x00000000, 0x0a090909, 0x0a090909, 0x08070707,
+    0x0c0b0c0b, 0x09080908, 0x09080908, 0x0a090909, 0x1b191a1a, 0x211e1f20,
+    0x14111214, 0x2c292a2b, 0x19171619, 0x1e1c1c1e, 0x1d1b1b1d, 0x14131213,
+    0x0d0c0c0c, 0x13121212, 0x13121212, 0x0b0a0b0a, 0x00000000, 0x00000000,
+    0x00000000, 0x04030403, 0x17151516, 0x1a191919, 0x2d2b2c2c, 0x04030303,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x03020302, 0x100e0f0f, 0x1c191b1b, 0x0f0e0f0e, 0x03020202,
+    0x00000000, 0x07050404, 0x09060507, 0x0a080606, 0x05050202, 0x09060607,
+    0x32272a2f, 0x5e43535c, 0x8f617882, 0xd18b9f91, 0xffacbb99, 0xffafb687,
+    0xffb3b37a, 0xffb6b071, 0xffb8ae69, 0xffb8ab61, 0xffbaaa5c, 0xffbca955,
+    0xffbea854, 0xffbfa958, 0xf9bba553, 0xefb29e4c, 0xe7ae9d56, 0xb88e7f49,
+    0xa27d7046, 0x7c5d5436, 0x4c3c3629, 0x1f1c1a1a, 0x12120f12, 0x08060404,
+    0x03010000, 0x03020000, 0x03020000, 0x03020000, 0x01000000, 0x00000000,
+    0x00000000, 0x02010201, 0x06050605, 0x02010201, 0x07060706, 0x0a090a09,
+    0x0b0a0a0a, 0x17141616, 0x0a090a09, 0x08070807, 0x05040504, 0x0e0d0d0d,
+    0x11101010, 0x0d0b0b0d, 0x4b49494a, 0x4f4c4e4e, 0x100e0f0f, 0x0f0e0e0e,
+    0x08070707, 0x0b0a0a0a, 0x0a090a09, 0x0d0c0d0c, 0x07060706, 0x00000000,
+    0x00000000, 0x00000000, 0x03020302, 0x0e0d0e0d, 0x1a181819, 0x0e0d0d0d,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x02010201, 0x01000000, 0x12111111, 0x14131313, 0x13121212,
+    0x03020102, 0x02010000, 0x02010000, 0x0e0c090b, 0x03030000, 0x0d0a090a,
+    0x4330393e, 0x9269808b, 0xd193b0b5, 0xf7a9c1ab, 0xffa8bea4, 0xffa5bda7,
+    0xffa9b998, 0xffafb27d, 0xffb6ae6c, 0xffb6ac65, 0xffb8aa5c, 0xffbda650,
+    0xffbda54d, 0xffbea54c, 0xffbfa54c, 0xffbea54c, 0xffbfa44b, 0xffbfa64c,
+    0xffbfa54c, 0xffbca34b, 0xffb09a46, 0xffa48f40, 0xeb988541, 0xb67d7040,
+    0x59463f2d, 0x07070506, 0x03030002, 0x04030002, 0x03020000, 0x03020000,
+    0x02010000, 0x01000000, 0x06050605, 0x08070707, 0x01000100, 0x06050605,
+    0x0a090a09, 0x07060706, 0x0e0c0d0d, 0x120f1111, 0x06050605, 0x0b0a0b0a,
+    0x05040404, 0x02020102, 0x12111111, 0x5b595a5a, 0x48464747, 0x06050505,
+    0x03020202, 0x02010201, 0x01000101, 0x00000000, 0x00000000, 0x01000100,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05040504, 0x04030403,
+    0x0c0a0a0b, 0x06050505, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x100f0f0f, 0x22201f21,
+    0x14131112, 0x08080305, 0x02010000, 0x02010000, 0x00000000, 0x06040404,
+    0x62455259, 0xbf86a4b0, 0xf4abcccb, 0xfdadbd9b, 0xffadb891, 0xffabbb9b,
+    0xffacb686, 0xffb6ab66, 0xffbaa958, 0xffb9a85c, 0xffb6ac67, 0xffbaa95c,
+    0xffbba752, 0xffbda64e, 0xffc0a54d, 0xffc0a44c, 0xffbea64d, 0xffbfa64c,
+    0xffbea64c, 0xffbfa64c, 0xfebfa54a, 0xffbea54b, 0xffbba249, 0xffb39b45,
+    0xff9b8739, 0xff8f7b32, 0xf8907e37, 0xac756b43, 0x1c1a1711, 0x02020001,
+    0x02000000, 0x02010000, 0x03020000, 0x05040303, 0x07060606, 0x01000100,
+    0x07060706, 0x09080908, 0x07060706, 0x0d0c0d0c, 0x0b0a0a0a, 0x0f0c0d0e,
+    0x07060706, 0x04030403, 0x00000000, 0x0a090909, 0x33323232, 0x211f2021,
+    0x02020101, 0x00000000, 0x00000000, 0x00000000, 0x01000100, 0x03010202,
+    0x05040404, 0x03010202, 0x05030403, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02010101, 0x03020001,
+    0x08070506, 0x12100e10, 0x0a080606, 0x06040203, 0x0b070707, 0x241b1c1f,
+    0x7752656c, 0xe9a1c9d6, 0xffb7ddea, 0xfcb7cbb7, 0xf9abb890, 0xfeb1b98a,
+    0xfeb4b175, 0xffb8ad69, 0xffb7ab65, 0xffb2af70, 0xffafb484, 0xffb1b380,
+    0xffb8aa5c, 0xffbea54e, 0xffbfa64b, 0xffc0a64d, 0xffc0a64b, 0xffbfa64b,
+    0xffc0a54d, 0xffbfa54a, 0xffbca34a, 0xffbba149, 0xffbba149, 0xffbaa04a,
+    0xffb59c44, 0xffb09845, 0xffab9543, 0xfe9d883a, 0xfe8d7931, 0xff88772f,
+    0xde837744, 0x4c3b372d, 0x06050303, 0x03020001, 0x03020000, 0x05040203,
+    0x03020202, 0x01000100, 0x07060706, 0x06050605, 0x0e0d0e0d, 0x0d0c0d0c,
+    0x04030403, 0x08070807, 0x03020202, 0x00000000, 0x00000000, 0x08070707,
+    0x06060505, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x06050505, 0x05040404, 0x04030302, 0x0a09080a, 0x03020302,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x02010201, 0x04030303,
+    0x03020101, 0x02010000, 0x03020000, 0x04030002, 0x1c141617, 0x452d383c,
+    0x8858707b, 0xe89fc8d4, 0xffb6dadf, 0xffbbd3c8, 0xfebac5a4, 0xffbab885,
+    0xffb9ba89, 0xf7b0b68a, 0xfeb1b88a, 0xffacb484, 0xffaeb484, 0xffafb382,
+    0xffb7ab62, 0xffbfa547, 0xffc0a44b, 0xffbea64b, 0xffbca248, 0xffb9a049,
+    0xffb8a04a, 0xffb69f4d, 0xffb39c49, 0xffad9644, 0xffa89242, 0xffa58f3f,
+    0xffa18b3b, 0xffa08b39, 0xffa5903e, 0xffa38c3b, 0xff958035, 0xff907c34,
+    0xfe887531, 0xfe7e6c29, 0xff7c6a29, 0xe6837540, 0x5a4b473d, 0x08070506,
+    0x03020001, 0x04030102, 0x0a090909, 0x09080908, 0x04030403, 0x0e0d0e0d,
+    0x0e0d0e0d, 0x04030403, 0x04030403, 0x04030303, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x03010201, 0x01000100, 0x01000100,
+    0x05030403, 0x02010101, 0x01000100, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03020302,
+    0x08070707, 0x06050304, 0x05040202, 0x02010000, 0x02010000, 0x5d3f4d51,
+    0xc37da2af, 0xeb8bbed2, 0xffacd1d2, 0xffb6d2cc, 0xffb9d5d0, 0xfeb7cab6,
+    0xffbac39f, 0xffb9c4a1, 0xfeb6c19a, 0xffb5b785, 0xffb5b279, 0xfeb1af76,
+    0xffb1b179, 0xffbaa859, 0xffbea64d, 0xffc0a74e, 0xffb9a248, 0xffa48d3a,
+    0xffab9752, 0xffb1a268, 0xffbeb282, 0xffcdc4a0, 0xffd2caa8, 0xffbfb79a,
+    0xffb9b197, 0xff938b6e, 0xffcbc3a7, 0xff9b9171, 0xff998b60, 0xff897737,
+    0xff83702a, 0xff82702b, 0xff7e6c2b, 0xff7a6827, 0xff766525, 0xff7a6828,
+    0xc9887c57, 0x17161211, 0x06050304, 0x05040203, 0x05040404, 0x00000000,
+    0x0b0a0b0a, 0x0a090a09, 0x07060706, 0x07060706, 0x02010101, 0x00000000,
+    0x00000000, 0x00000000, 0x01000100, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x03020202, 0x09080808, 0x01000100, 0x00000000, 0x00000000, 0x00000000,
+    0x02010201, 0x03020302, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x05050404, 0x0d0c0c0c, 0x08070507, 0x06050204, 0x07060305, 0x03030000,
+    0x38263032, 0xd482acb7, 0xff96c5c8, 0xff9ac1bf, 0xff9acbd5, 0xfe9cd2e5,
+    0xffb1d5d8, 0xffaec7b4, 0xffb1ba90, 0xffb6af72, 0xffb9aa5c, 0xffb7ac64,
+    0xffb1b07c, 0xffaeb27d, 0xffb0b178, 0xffa8b68e, 0xffa5c0aa, 0xffb29e4b,
+    0xffa48f3f, 0xffdfd7b7, 0xfff9f7f1, 0xfffaf8f4, 0xffe5e5e2, 0xffcacac8,
+    0xffd2d2d1, 0xffebebea, 0xffd8d8d7, 0xffb0b0ae, 0xfff2f2f1, 0xffc6c6c6,
+    0xffc3c2c1, 0xffe7e3da, 0xffada78c, 0xff8f7f45, 0xff786424, 0xff7a682c,
+    0xfe8b7c48, 0xff978a57, 0xff887a42, 0x805d5b4a, 0x13120f13, 0x0b0a0808,
+    0x09090607, 0x0d0c0c0c, 0x0a090a09, 0x02010201, 0x05040504, 0x01000100,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x01000100, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x03020202, 0x08070707, 0x05050405, 0x01000100, 0x00000000,
+    0x00000000, 0x00000000, 0x05040504, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x03020202, 0x0a090909, 0x05040202, 0x07070202, 0x07060302,
+    0x0e090a09, 0x89567077, 0xff94c4cc, 0xff8bbfc3, 0xfe92c7d5, 0xff91cfeb,
+    0xff9dd4ec, 0xffa0cfd8, 0xff9bbeb4, 0xffa9b487, 0xffb3ad68, 0xffafb074,
+    0xffadb486, 0xffa7b894, 0xffabb68f, 0xffa8b99b, 0xffa3bca9, 0xffa4b189,
+    0xffaba15b, 0xffb5a460, 0xffe5dfc8, 0xfffefefe, 0xfffdfdfe, 0xfffdfdfd,
+    0xffd2d2d3, 0xffeeeeee, 0xfff2f2f2, 0xffcecece, 0xffc9c9c9, 0xffaaaaaa,
+    0xfff7f7f7, 0xffe4e4e4, 0xffc5c5c4, 0xffe2e1e3, 0xffc3c2c5, 0xffdad5cc,
+    0xffa89d71, 0xffeceada, 0xfffffffe, 0xfffafafd, 0xfff3f2e7, 0x8978766e,
+    0x100f0c0f, 0x0c0b0909, 0x13121011, 0x0e0d0d0d, 0x00000000, 0x04030403,
+    0x03020302, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x01000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x04040303, 0x09090809, 0x09080808, 0x0f0e0d0f, 0x03030202, 0x02010101,
+    0x07050606, 0x00000000, 0x02010201, 0x08070807, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x02010101, 0x07060505, 0x04030102, 0x04040000,
+    0x02020000, 0x35242a2f, 0xc06b99ac, 0xff7bc1d9, 0xff79c0d5, 0xfe7bc3e1,
+    0xff8bc6d3, 0xffa8c5aa, 0xffb1bc85, 0xffafbb85, 0xffacbe95, 0xffb1b884,
+    0xffadbb94, 0xffa9bc9e, 0xffa6b99a, 0xffa2b99f, 0xff9db497, 0xff9ca57b,
+    0xffa09552, 0xffaf9b55, 0xffd4c8a2, 0xfff8f5ee, 0xffffffff, 0xfffefefc,
+    0xfffefefe, 0xfff1f1f1, 0xffe2e2e2, 0xff737373, 0xffdadada, 0xffe7e7e7,
+    0xffc2c2c2, 0xffc8c8c8, 0xffcfcfcf, 0xffececec, 0xffcececd, 0xffb2b2b2,
+    0xfff6f6f6, 0xffc1c2c4, 0xffe5e6e6, 0xfffcfbfc, 0xff8c8b8d, 0xfec5c5c3,
+    0xffffffff, 0xc8c7c7c7, 0x11110e0f, 0x0c0b080a, 0x0d0d090a, 0x0a090909,
+    0x04030403, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x01000100, 0x05040504, 0x01000100, 0x00000000, 0x00000000, 0x00000000,
+    0x06050505, 0x0c0b0b0c, 0x0a0a0909, 0x07070607, 0x02010101, 0x01000000,
+    0x03020202, 0x06050605, 0x08060707, 0x06050605, 0x04030403, 0x00000000,
+    0x00000000, 0x00000000, 0x03020101, 0x09080508, 0x0c0c0808, 0x05040203,
+    0x02020000, 0x06050303, 0x6745555a, 0xde6fabc2, 0xff6bc0e0, 0xff6cbee2,
+    0xfe5fbae1, 0xff7bbcb7, 0xffccca5e, 0xffedce35, 0xffeace3e, 0xffe7d146,
+    0xffebd13f, 0xffeece35, 0xffeccc3c, 0xffdccf56, 0xffcdd077, 0xffd6d373,
+    0xffdbcb60, 0xffdac24e, 0xffdfc451, 0xfff1ebcb, 0xffffffff, 0xffffffff,
+    0xffffffff, 0xffffffff, 0xffffffff, 0xfffcfcfc, 0xffdadada, 0xffb8b8b8,
+    0xffd9d9d9, 0xffd9d9d9, 0xffe5e5e5, 0xffe3e3e3, 0xffd3d3d3, 0xffdedfde,
+    0xffe3e3e3, 0xffd3d3d4, 0xffefefef, 0xffd8d8d7, 0xfff4f4f4, 0xffacabab,
+    0xff868686, 0xffffffff, 0xfefcfcfa, 0xe3a09f9f, 0x2d262325, 0x04040102,
+    0x05040102, 0x05040303, 0x01000101, 0x00000000, 0x02010201, 0x00000000,
+    0x01000000, 0x00000000, 0x06050505, 0x0d0c0c0c, 0x00000000, 0x00000000,
+    0x02010201, 0x19181718, 0x11100f11, 0x08080707, 0x04040303, 0x00000000,
+    0x00000000, 0x00000000, 0x05040504, 0x02010101, 0x07060706, 0x04030303,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08070506, 0x11100c0f,
+    0x06040305, 0x00000000, 0x2b1e2223, 0xce89acb6, 0xf872bddb, 0xff5eb9e2,
+    0xff64bce3, 0xfe55b5e6, 0xff5eb6d3, 0xffc3ce6a, 0xffffda27, 0xfffeda25,
+    0xfffdda2e, 0xffffd928, 0xffffd926, 0xffffd925, 0xffffda25, 0xfffdd92e,
+    0xfffade3f, 0xfffeda33, 0xfffed933, 0xffffdc36, 0xffe2cd57, 0xffb6a878,
+    0xffb1afa7, 0xffb1b0b2, 0xffacacac, 0xffababab, 0xffefefef, 0xffffffff,
+    0xfffafafa, 0xfff7f7f7, 0xfff8f8f8, 0xfffbfbfb, 0xffe8e8e8, 0xffd6d6d6,
+    0xffececec, 0xfff5f5f5, 0xffededed, 0xfffcfcfc, 0xfffbfbfb, 0xfffdfdfd,
+    0xfffefefe, 0xffe7e7e7, 0xfff7f7f7, 0xffffffff, 0xfeb4b3b4, 0xff504c4d,
+    0x9a404242, 0x00000000, 0x02010000, 0x02010000, 0x00000000, 0x00000000,
+    0x00000000, 0x01000100, 0x01000100, 0x0a090909, 0x0c0b0b0b, 0x312f3030,
+    0x0d0c0c0c, 0x0e0d0d0d, 0x0c0b0b0b, 0x04010302, 0x03010201, 0x04040303,
+    0x04030303, 0x00000000, 0x00000000, 0x01000100, 0x06050605, 0x0d0c0d0c,
+    0x03020302, 0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x05040404,
+    0x09080607, 0x09080605, 0x07060405, 0x29212022, 0xca85a8b2, 0xff79c1de,
+    0xfe4baad5, 0xff55b3db, 0xff57b6e0, 0xff62b8cd, 0xffbacb74, 0xffffda26,
+    0xfffed924, 0xfffed82a, 0xfffed92d, 0xfffed828, 0xfffed926, 0xffffd829,
+    0xfffcdb30, 0xfffdda34, 0xfffed92f, 0xfffdd92e, 0xfffddc2f, 0xfffdd829,
+    0xfffad734, 0xfff1d565, 0xffedece7, 0xfff5f5f6, 0xfffefefe, 0xfffdfdfd,
+    0xffb9b9b9, 0xffbebebe, 0xfff3f3f3, 0xfff8f8f8, 0xfffbfbfb, 0xfffdfdfd,
+    0xfff7f7f7, 0xffeaeaea, 0xffe6e6e6, 0xfff6f6f6, 0xfff7f7f7, 0xffc7c7c7,
+    0xfff8f8f8, 0xfffbfbfb, 0xfffefefe, 0xffffffff, 0xfef9f9f9, 0xfeaca9ab,
+    0xff3d393d, 0xff4d484c, 0xe9424242, 0x01010101, 0x04030101, 0x02010000,
+    0x00000000, 0x03020202, 0x0a090909, 0x00000000, 0x07060706, 0x0d0c0c0c,
+    0x28262727, 0x47454547, 0x08070707, 0x0e0d0d0d, 0x0f0f0d0e, 0x08070707,
+    0x07060606, 0x05040405, 0x03020203, 0x02010102, 0x02010201, 0x0a090a09,
+    0x09080908, 0x01000100, 0x00000000, 0x00000000, 0x00000000, 0x04030304,
+    0x0c0a0b0b, 0x0b0a0909, 0x0b0a0708, 0x09080608, 0x1d17171a, 0xaf6e8f97,
+    0xff79c2dd, 0xff49a8d3, 0xff4eaed8, 0xff55b6e2, 0xff6ebbc1, 0xffc9ce64,
+    0xffffda26, 0xfffdd927, 0xfffed926, 0xfffcd929, 0xfffddc40, 0xfffdda2f,
+    0xfffed926, 0xfffdda2b, 0xfffedc33, 0xfffdda2f, 0xfffdd92b, 0xffffd827,
+    0xfffdd827, 0xffffda27, 0xffe7d16d, 0xff959590, 0xff6f6b6e, 0xff8f8d8e,
+    0xffb0afaf, 0xffd2d1d1, 0xffdfdfdf, 0xffededed, 0xffc4c4c4, 0xffc8c8c8,
+    0xffd6d6d6, 0xffdbdbdb, 0xffd8d8d8, 0xffd4d4d4, 0xff9d9d9d, 0xff8e8d8e,
+    0xffb1b0b1, 0xfff7f7f7, 0xffe0e0e0, 0xfffcfdfd, 0xfffdfdfd, 0xffddddde,
+    0xfb9f9d9e, 0xfc2d292c, 0xff2e282c, 0xfe5a565b, 0xf63c383b, 0x54333333,
+    0x08080708, 0x07060304, 0x02010101, 0x02010201, 0x08070807, 0x06050505,
+    0x0d0c0c0c, 0x201e1f1f, 0x34313333, 0x18171617, 0x0e0e0d0e, 0x17171617,
+    0x1d1c1b1d, 0x02010101, 0x00000000, 0x02000001, 0x01000001, 0x03010103,
+    0x07060706, 0x09080908, 0x04030403, 0x00000000, 0x00000000, 0x00000000,
+    0x03020203, 0x09050607, 0x0b090909, 0x13111012, 0x09070607, 0x110e0d0f,
+    0xbc7899a6, 0xff77c1dd, 0xff4ba8d4, 0xfe4dadd6, 0xff56b7e1, 0xff78bcbb,
+    0xffd8d152, 0xffffda26, 0xffffd827, 0xfffcdd43, 0xfffcdc3f, 0xfffbdf5e,
+    0xfff9dd4e, 0xfffddc3f, 0xfffddb38, 0xfffed927, 0xfffdd928, 0xfffdd92d,
+    0xfffdd829, 0xfffed829, 0xfffed928, 0xfff5d430, 0xffa39036, 0xff534d49,
+    0xffaba8aa, 0xfffdfdfd, 0xffdadada, 0xffd8d7d7, 0xffc4c4c4, 0xffbfbfbf,
+    0xffc7c7c7, 0xffcecece, 0xffc3c3c3, 0xffbfbfbf, 0xffb8b8b8, 0xffb1b1b1,
+    0xffb8b8b8, 0xffdedede, 0xffb6b6b6, 0xfff1f1f1, 0xffffffff, 0xffc2c1c1,
+    0xff757274, 0xfe4b474b, 0xff2b252a, 0xff2e292d, 0xfe332e32, 0xff514c50,
+    0xfe514d50, 0xab606262, 0x1a1a1a1a, 0x0b0b0809, 0x04030203, 0x03020302,
+    0x0a090a09, 0x0e0d0d0d, 0x13121112, 0x29262729, 0x19171818, 0x06050605,
+    0x0d0c0c0d, 0x1b1a1a1a, 0x1a171819, 0x03010103, 0x01000000, 0x01000001,
+    0x02000002, 0x02000002, 0x00000000, 0x03020302, 0x06050605, 0x01000000,
+    0x00000000, 0x01000000, 0x04000002, 0x06000001, 0x0f07080a, 0x0d0a070a,
+    0x03030101, 0xbd789ba2, 0xff75c1de, 0xff4eacd5, 0xfe4bacd2, 0xff56b4e1,
+    0xff69bacf, 0xffbecb6f, 0xfffed928, 0xffffd822, 0xfffbdc3c, 0xfffbe068,
+    0xfff9e179, 0xfff8e37d, 0xfffcdf65, 0xfffcdd4d, 0xfffbdb37, 0xfffed928,
+    0xfffddb31, 0xfffdd932, 0xfffed82a, 0xfffeda29, 0xffffda2b, 0xfff5d333,
+    0xff82722d, 0xff2d2925, 0xff959298, 0xffffffff, 0xffffffff, 0xffffffff,
+    0xffffffff, 0xfff6f6f6, 0xfff0f0f0, 0xffe6e6e6, 0xffe2e2e2, 0xffe5e5e5,
+    0xffededed, 0xfff5f5f5, 0xfff7f7f7, 0xffb9b9b9, 0xffe4e4e3, 0xffe9e8e9,
+    0xff5c5a5d, 0xff342f33, 0xff2e292d, 0xff2d282c, 0xff2d282c, 0xff2e292d,
+    0xff322d31, 0xff464044, 0xff4a464a, 0xea8f8e8f, 0x5c524f52, 0x0c0c080a,
+    0x04030102, 0x07060706, 0x0e0d0e0d, 0x11101010, 0x16151515, 0x14131213,
+    0x05040404, 0x00000000, 0x22212121, 0x0e0d0c0e, 0x04020204, 0x01000001,
+    0x02000002, 0x01000001, 0x01000001, 0x03000002, 0x04030403, 0x02010101,
+    0x00000000, 0x03020302, 0x02000101, 0x05000001, 0x05000001, 0x08010203,
+    0x0f060407, 0x0c050407, 0xa069838b, 0xff89c6df, 0xfe59b3d7, 0xff4ba8d3,
+    0xff57b5e1, 0xff5ebad5, 0xff9fc28d, 0xfffad930, 0xffffd824, 0xfffdd830,
+    0xfffbdf57, 0xfff8e272, 0xfff6e589, 0xfff7e283, 0xfff6e382, 0xfff8df64,
+    0xfffddc4a, 0xfffdda2c, 0xfffdd82b, 0xfffacf26, 0xfffbd527, 0xfffed827,
+    0xfffed825, 0xfffdd225, 0xff917a39, 0xff352d33, 0xff302e30, 0xff3b373a,
+    0xff5b585b, 0xff7e7b7e, 0xffaeaeae, 0xffeaeaea, 0xfff4f3f4, 0xfff6f6f6,
+    0xfff5f5f5, 0xfff5f5f5, 0xfff6f6f6, 0xffd8d8d8, 0xffa7a7a7, 0xffefefef,
+    0xffe5e4e5, 0xff524d51, 0xff2b262b, 0xff2f2a2e, 0xff2f2a2e, 0xff2f2a2e,
+    0xff2e292d, 0xff2e292d, 0xff302b2f, 0xff433d41, 0xff484246, 0xff939192,
+    0x8c6c6b6d, 0x10100d0e, 0x07060405, 0x0d0c0c0c, 0x0e0d0e0d, 0x12111111,
+    0x11101010, 0x09080808, 0x07060706, 0x08070707, 0x08060608, 0x01000000,
+    0x01000001, 0x02000002, 0x01000001, 0x01000001, 0x08050608, 0x06050605,
+    0x05040404, 0x00000000, 0x03020202, 0x04020202, 0x05000001, 0x06000001,
+    0x0a020304, 0x0c040305, 0x0a030003, 0x764e5e64, 0xff97ccdb, 0xff80c0d6,
+    0xff5dafd0, 0xff52b3dd, 0xff53b3df, 0xff6ebac3, 0xffcbd06b, 0xffedd53c,
+    0xfffed824, 0xfffcdb3a, 0xfffae36a, 0xfff8e173, 0xfff8e387, 0xfff6e593,
+    0xfff7e27b, 0xfff9e170, 0xfffbdf57, 0xfffed92c, 0xfffdd528, 0xffdab123,
+    0xffc2a528, 0xfffcd82a, 0xffe1b824, 0xffb89326, 0xff40392e, 0xff726e71,
+    0xffbcbbbb, 0xffdad9da, 0xffdbdada, 0xffebeaea, 0xffc9c8c9, 0xffa5a4a4,
+    0xffa9a8a8, 0xffacabab, 0xffadabac, 0xffaeacad, 0xffbbbbbb, 0xffdadada,
+    0xffffffff, 0xffffffff, 0xff989798, 0xff2f2a2e, 0xff2e292d, 0xff2e292d,
+    0xff2f2a2e, 0xff2e292d, 0xff2f2a2e, 0xff2e292d, 0xff312c30, 0xff423d41,
+    0xfe474246, 0xff8b898b, 0x71434344, 0x12110e0f, 0x0c0b080a, 0x110f0f10,
+    0x0f0e0f0e, 0x13111312, 0x09080908, 0x03020302, 0x06050505, 0x100f0f0f,
+    0x01000001, 0x01000001, 0x01000001, 0x02000001, 0x03000103, 0x0d0a0b0d,
+    0x13101113, 0x03020202, 0x05040504, 0x02010101, 0x04010101, 0x06000001,
+    0x07000002, 0x08000103, 0x0e050406, 0x06000000, 0x50364144, 0xf8a7ccd2,
+    0xf599c5d0, 0xfd93c4d4, 0xff57b3d6, 0xff41a0cc, 0xff5ab6dc, 0xff82c4d1,
+    0xffafca90, 0xfff5d732, 0xffffd925, 0xfffedb33, 0xfffcdb3f, 0xfff9e170,
+    0xfff7e48e, 0xfff8e27c, 0xfff8e16d, 0xfff9df62, 0xfffbde52, 0xfffedb2b,
+    0xfffdc825, 0xff9c8129, 0xff74652a, 0xffb79b2e, 0xff7a6026, 0xff4d4533,
+    0xff97959a, 0xfffbfdfa, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+    0xffffffff, 0xffffffff, 0xffffffff, 0xfffefefe, 0xfffbfbfb, 0xfffefffe,
+    0xffffffff, 0xffffffff, 0xfffefefe, 0xfff6f6f6, 0xff656365, 0xff2c272b,
+    0xff2e282c, 0xff2d282c, 0xff2e292d, 0xff2d282c, 0xff2f2a2e, 0xff2f2a2e,
+    0xff302b2f, 0xff423d41, 0xff3d383c, 0xff807e81, 0xa7676969, 0x13100d0e,
+    0x04030102, 0x0b0a090b, 0x0f0e0f0e, 0x09080908, 0x04030303, 0x0a090a09,
+    0x0f0e0e0e, 0x24222223, 0x01000001, 0x02000002, 0x01000001, 0x00000000,
+    0x04030303, 0x02010201, 0x02000002, 0x00000000, 0x05040504, 0x04030303,
+    0x04000001, 0x07000002, 0x07000002, 0x0c040404, 0x08020000, 0x01000000,
+    0x583b4549, 0xf7a1c8d2, 0xd38cabb5, 0xfc6ebbd8, 0xff3191be, 0xff50b1d8,
+    0xff63bde5, 0xff88c3b5, 0xffe4d449, 0xffffda29, 0xffffd826, 0xffffd829,
+    0xfffddc3a, 0xfff9e06d, 0xfff8e277, 0xfffbde4f, 0xfffcdb43, 0xfffddd49,
+    0xfff5d447, 0xffeaca44, 0xffc19930, 0xff4e4429, 0xff51472d, 0xff433828,
+    0xff302c2c, 0xff726d70, 0xfff8f8f8, 0xfffffefe, 0xfffdfdfd, 0xfffefdfe,
+    0xfffdfdfd, 0xfffefefe, 0xfffefefe, 0xfffdfdfd, 0xfffefefe, 0xfffefefe,
+    0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffdfdfd, 0xfffefefe, 0xffe3e2e2,
+    0xff524d50, 0xfe2c272b, 0xff2b282b, 0xfe2d282c, 0xff2e282c, 0xff2e292d,
+    0xff2e292d, 0xff2f2a2e, 0xff2e292d, 0xff3f3a3e, 0xff353034, 0xff767477,
+    0xbb757878, 0x110a0809, 0x05000000, 0x07030103, 0x05030403, 0x01000100,
+    0x0d0c0d0c, 0x0d0c0c0c, 0x201e1e1f, 0x25222325, 0x01000001, 0x02000002,
+    0x08050607, 0x0f0c0d0f, 0x02000002, 0x02000001, 0x01000000, 0x04000000,
+    0x01000000, 0x04030303, 0x04010201, 0x05000001, 0x07000002, 0x09040103,
+    0x04010100, 0x0e080709, 0xbf7c9aa0, 0x9b647c82, 0xc46597a8, 0xff3996bd,
+    0xff42a3cd, 0xff56b4e0, 0xff6ab9ca, 0xffcdd162, 0xffefd846, 0xfffcd829,
+    0xfffed929, 0xfffed925, 0xfffcda3b, 0xfffae273, 0xfffbdc40, 0xffffd929,
+    0xfffed927, 0xffffdb33, 0xffe5b32d, 0xffad8e3e, 0xff63583b, 0xff2f2a29,
+    0xff383129, 0xff2f292e, 0xff2c2a2b, 0xff817d81, 0xffffffff, 0xfffefefe,
+    0xfffefefe, 0xfffdfefd, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe,
+    0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe,
+    0xfffefefe, 0xffd4d3d3, 0xff413f41, 0xff2f292d, 0xf1464748, 0xff2d292d,
+    0xff2c292e, 0xff302b2e, 0xff2d282c, 0xff2e292d, 0xff2e292d, 0xff3a373a,
+    0xff332f33, 0xff787376, 0xb9727373, 0x12080508, 0x0a030003, 0x0c030204,
+    0x0b060608, 0x1c181a1b, 0x19161718, 0x16161515, 0x19181818, 0x12111111,
+    0x04020204, 0x0f0c0d0f, 0x0b08090b, 0x01000001, 0x02000001, 0x04000001,
+    0x07000002, 0x07000002, 0x06000002, 0x05000001, 0x03000000, 0x04010102,
+    0x05020102, 0x06040203, 0x0e0b0709, 0xae758d92, 0xa96d868c, 0x76445b64,
+    0xfa4fa0c4, 0xff399ac6, 0xff4bacd3, 0xff4eadd4, 0xff8bc2a5, 0xffc0cc75,
+    0xffe7d440, 0xffffda2b, 0xfffeda28, 0xfffdd927, 0xfffcdf53, 0xfffcdc45,
+    0xfffed825, 0xffffd825, 0xfffed629, 0xfffed731, 0xffd8a428, 0xff715b2c,
+    0xff372f2b, 0xff2e2a2b, 0xff322b2c, 0xff2f292e, 0xff2d292d, 0xff777576,
+    0xfffdfdfd, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe,
+    0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffdfdfd,
+    0xfffefefe, 0xfffefefe, 0xfffefefe, 0xffc9c8c8, 0xfe363236, 0xff322f32,
+    0x583d3a3c, 0xe23d3d3e, 0xff2b272a, 0xfe2c272b, 0xff2d282c, 0xff2e292d,
+    0xff2f2a2e, 0xff342f33, 0xfe332f33, 0xff757174, 0xb36c6d6d, 0x12060507,
+    0x0b030003, 0x0b020204, 0x07010103, 0x15121314, 0x221f2022, 0x211e1e20,
+    0x0f0b0b0d, 0x0e0b0c0d, 0x1a17181a, 0x0c090a0b, 0x03000001, 0x05000001,
+    0x06000002, 0x07000002, 0x07000002, 0x07000002, 0x06000001, 0x07000002,
+    0x05000001, 0x03010101, 0x04010000, 0x04000000, 0x835a686c, 0xb97d9698,
+    0x3822292d, 0xeb62a5c0, 0xff3797c1, 0xfe40a1ca, 0xff48a7d2, 0xff63b9d1,
+    0xff98c498, 0xffe7d445, 0xffffda27, 0xfffdd926, 0xffffd826, 0xfffcda38,
+    0xfffddd45, 0xfffdda25, 0xfffed826, 0xfffeda2b, 0xfffbc521, 0xffffd12e,
+    0xffcf9822, 0xff584a33, 0xff302c2a, 0xff2f2b2c, 0xff2d292d, 0xff2d292c,
+    0xff2e282c, 0xff747172, 0xfffbfbfb, 0xfffefefe, 0xfffefefe, 0xfffefefe,
+    0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe,
+    0xfffefefe, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffc3c3c4,
+    0xff322e32, 0xff383738, 0x332a2929, 0x7d282829, 0xff312d30, 0xff2d282d,
+    0xff2d282c, 0xff2e292d, 0xff2f2a2e, 0xff312c30, 0xfe373135, 0xff6e686b,
+    0x8b545354, 0x0d030205, 0x0a030003, 0x0c060508, 0x110d0e10, 0x2a27282a,
+    0x1b18181a, 0x08030205, 0x05000001, 0x05000002, 0x0a060608, 0x05000001,
+    0x06000001, 0x07000002, 0x07000002, 0x06000001, 0x07000002, 0x06000001,
+    0x07000002, 0x06000001, 0x0a020304, 0x08020002, 0x09020002, 0x0a010002,
+    0x36222528, 0x150a0a0e, 0xc36994a4, 0xff3896be, 0xff3596c0, 0xfe41a3cd,
+    0xff51afd7, 0xff6db9c2, 0xffd5d156, 0xfffbd429, 0xfffed525, 0xfffdd926,
+    0xfffed627, 0xfffbca24, 0xffffd82c, 0xfffed925, 0xffffd928, 0xffffd729,
+    0xfff9bb1d, 0xfff8c628, 0xffb48320, 0xff594f3e, 0xff2e2929, 0xff2e292d,
+    0xff2d282d, 0xff2d292c, 0xff2d282c, 0xff6a686a, 0xfff6f6f6, 0xfffefefe,
+    0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe, 0xfffefefe,
+    0xfffefefe, 0xfffdfdfd, 0xfffefefe, 0xffebebec, 0xff999798, 0xff6e6d6d,
+    0xffc1c0c0, 0xffb6b4b6, 0xff312c30, 0xff484748, 0x07070707, 0x38171717,
+    0xe5333034, 0xff2d292a, 0xff2d282d, 0xff302b2f, 0xff302b2f, 0xff302b2f,
+    0xff363034, 0xff605d5f, 0x5c333334, 0x07010001, 0x06030102, 0x08070707,
+    0x0c0b0c0b, 0x0b08090a, 0x07000103, 0x06000001, 0x07000002, 0x06000002,
+    0x06000001, 0x07000002, 0x06000001, 0x07000002, 0x07000002, 0x07000002,
+    0x07000002, 0x07000002, 0x07000002, 0x09010203, 0x0b030204, 0x0a020002,
+    0x0a010002, 0x0a020003, 0x05000000, 0x7142575f, 0xff4ba2c8, 0xfe2a8bb9,
+    0xff409fca, 0xff49a6d2, 0xff4ba6c2, 0xffb6cb7b, 0xffe1d048, 0xfff3cc2c,
+    0xfffddb25, 0xffffd92a, 0xfffbc822, 0xfffcd026, 0xfffed927, 0xffffd827,
+    0xfffed929, 0xfffed328, 0xfff9b81a, 0xfff4bd23, 0xff956f25, 0xff4a4337,
+    0xff2d282c, 0xff2d292c, 0xff2d282d, 0xff2e292c, 0xff2d282c, 0xff474446,
+    0xffd3d2d3, 0xfffefefe, 0xfffdfdfd, 0xfffefefe, 0xfffefefe, 0xfffefefe,
+    0xfffefefe, 0xfffefefe, 0xfffdfdfd, 0xfffefefe, 0xfff4f3f4, 0xff908e91,
+    0xff716c71, 0xff575256, 0xff464145, 0xff5c585c, 0xff2e292d, 0xff454547,
+    0x24181616, 0x120e0e0d, 0xb73f3e40, 0xff322d31, 0xfe2c272b, 0xff302b2f,
+    0xff312c30, 0xff312c30, 0xff342f33, 0xe8434144, 0x3c1f1d1f, 0x09080508,
+    0x09090607, 0x05040404, 0x02000000, 0x06000001, 0x07000002, 0x07000002,
+    0x06000001, 0x05000002, 0x07000002, 0x06000001, 0x07000002, 0x07000002,
+    0x07000002, 0x07000002, 0x07000002, 0x06000001, 0x09010203, 0x10060608,
+    0x0a020002, 0x09010002, 0x09020002, 0x09030001, 0x52323e42, 0xfa5facca,
+    0xfe2789b4, 0xfe3a99c3, 0xff41a2cd, 0xff3e9dc0, 0xff90c3a3, 0xffb6c976,
+    0xffd2c551, 0xfffdd629, 0xfffedb2e, 0xfffcd42a, 0xfffdcb26, 0xfffed72a,
+    0xfffdd926, 0xfffed828, 0xfffeda29, 0xfffed52b, 0xfff8b91c, 0xffd9a621,
+    0xff5f4723, 0xff302a2b, 0xff2d292d, 0xff2e292c, 0xff2e282d, 0xff2d292c,
+    0xff2e292d, 0xff292428, 0xff575457, 0xffdcdbdc, 0xffffffff, 0xfffdfdfd,
+    0xfffdfdfd, 0xfffefefe, 0xfffefefe, 0xfffdfdfd, 0xfffdfdfd, 0xffffffff,
+    0xffbebdbf, 0xff757074, 0xff4e494d, 0xff2e292d, 0xff2d282c, 0xff322e32,
+    0xfe2d292d, 0xff2b282c, 0xe4464546, 0x52232222, 0x241e1d1d, 0xad373839,
+    0xff342f33, 0xff2e292d, 0xff302b2f, 0xff312c30, 0xff302c30, 0xce48484a,
+    0x231e1c1d, 0x08080506, 0x07050306, 0x08030406, 0x06000001, 0x06000002,
+    0x06000002, 0x07000002, 0x05000001, 0x05040403, 0x07000002, 0x07000002,
+    0x07000002, 0x07000002, 0x07000002, 0x07000002, 0x07000002, 0x05000001,
+    0x0f060608, 0x0b020003, 0x0a020003, 0x0a020002, 0x08000000, 0x3620262b,
+    0xde5b97ad, 0xff348fb7, 0xfe2c8bb7, 0xff3799c3, 0xff3b9ac3, 0xff6eb8c2,
+    0xff87bfad, 0xff9abb8e, 0xffe8d23d, 0xffffda31, 0xfffcd72b, 0xfffccc25,
+    0xfffdd227, 0xfffed829, 0xfffed927, 0xfffdd829, 0xfffed929, 0xfffed52a,
+    0xfff5b71c, 0xffb88b24, 0xff564425, 0xff2f2b2b, 0xff2e292e, 0xff2e292d,
+    0xff2e282d, 0xff2d292c, 0xff2e292d, 0xff2e282c, 0xff282327, 0xff534f53,
+    0xffdddcde, 0xffffffff, 0xfffdfdfd, 0xfffdfdfd, 0xfffefefe, 0xfffdfdfd,
+    0xffffffff, 0xffd5d4d6, 0xff767276, 0xff544e53, 0xff322c30, 0xff2e292d,
+    0xff2d292d, 0xff2d292c, 0xff2f2a2e, 0xfe2d282c, 0xff312c30, 0xf83a383a,
+    0x702f2f2f, 0x16161616, 0xff413f41, 0xff2c272b, 0xff2e292d, 0xfe2d282c,
+    0xff322f33, 0xb8545656, 0x0f0e0c0d, 0x05030002, 0x110a090b, 0x06000001,
+    0x06000001, 0x07000002, 0x06000001, 0x06000002, 0x03010101, 0x07060706,
+    0x07000002, 0x07000002, 0x07000002, 0x07000002, 0x07000002, 0x07000002,
+    0x06000001, 0x0e050608, 0x0d040305, 0x0a030002, 0x0b010003, 0x08010001,
+    0x170f0e13, 0xc1588798, 0xff338db5, 0xff3090ba, 0xff2b8db8, 0xff3091bc,
+    0xff50acce, 0xff6abac6, 0xff83b9ab, 0xffc7ca60, 0xfffdd32a, 0xfffcd329,
+    0xfffccb27, 0xfffbc620, 0xfffdd428, 0xfffcda28, 0xffffd82b, 0xfffed928,
+    0xfffdd928, 0xffffd72b, 0xfff4b81d, 0xffb98c1f, 0xff664d26, 0xff312c2a,
+    0xff2e2a2b, 0xff2d292b, 0xff2d282d, 0xff2e292c, 0xff2e292d, 0xff2e292d,
+    0xff2d282c, 0xff2e292d, 0xff4b484c, 0xffd6d6d6, 0xffffffff, 0xfffdfdfd,
+    0xfffdfdfd, 0xffffffff, 0xffefefef, 0xff736f73, 0xff443f43, 0xff363034,
+    0xff2d282c, 0xff2d282c, 0xff2d282c, 0xff2e292d, 0xff2e292d, 0xff2e292d,
+    0xfe2f2a2e, 0xff2f2a2e, 0xfa383637, 0x784d4e4f, 0xff3b393c, 0xff2d272b,
+    0xff2e292d, 0xfe2f292d, 0xf239373a, 0x34252124, 0x05020002, 0x09010002,
+    0x1209080a, 0x06000001, 0x06000001, 0x06000001, 0x07000002, 0x07000002,
+    0x05000001, 0x03020202, 0x07000002, 0x07000002, 0x07000002, 0x07000002,
+    0x06000001, 0x06000001, 0x09010203, 0x0f060507, 0x09010002, 0x0a020003,
+    0x08000002, 0x0e090505, 0xad608391, 0xff338ab2, 0xfe2b8cb5, 0xff2787b3,
+    0xff2d8eb8, 0xff3e9dc8, 0xff5fb8d8, 0xff6bb8c9, 0xffa6c286, 0xffe7c63c,
+    0xfff9ca24, 0xfffdca24, 0xfff9bd1c, 0xfffdd52a, 0xfffdd62a, 0xffffd62a,
+    0xfffad023, 0xffffd929, 0xfffdd829, 0xffffd92c, 0xfff7b81c, 0xffd39f1e,
+    0xff8a6a24, 0xff3c3429, 0xff2f2a2d, 0xff2d292e, 0xff2e282d, 0xff2e282c,
+    0xff2d292d, 0xff2e292d, 0xff2e292d, 0xff2d282c, 0xff2e292d, 0xff4c484c,
+    0xffd1d0d1, 0xfffefefe, 0xfffefefe, 0xffffffff, 0xff9a9899, 0xff4e494d,
+    0xff353034, 0xff2d282c, 0xff2d292c, 0xff2e282d, 0xff2e292d, 0xff2d282c,
+    0xff2d282c, 0xff2f2a2e, 0xff2f2a2e, 0xfe322e32, 0xff2c2529, 0xff545657,
+    0xfe3f3d40, 0xfe2b262a, 0xfe2d282c, 0xff302d2f, 0x99414342, 0x00000000,
+    0x09010002, 0x0a020003, 0x0f060708, 0x06000001, 0x07000002, 0x06000001,
+    0x06000001, 0x07000002, 0x06000002, 0x06020204, 0x07000002, 0x07000002,
+    0x07000002, 0x06000001, 0x06000001, 0x0a020304, 0x0c020205, 0x0a020002,
+    0x0a020002, 0x09010002, 0x06030001, 0x894f6772, 0xff4293b5, 0xfe2181ab,
+    0xfe2282ae, 0xff2b88b4, 0xff3695c1, 0xff54b3da, 0xff61b7d7, 0xff98be96,
+    0xffd2c251, 0xffefc32d, 0xfffcc41d, 0xfffabe20, 0xffffd428, 0xfffcd128,
+    0xfffcd62d, 0xfffbc622, 0xfffdd628, 0xfffed929, 0xfffdda2a, 0xfffdd42a,
+    0xfff9ba1b, 0xfffcc023, 0xffdca524, 0xff664f24, 0xff322b28, 0xff2d292c,
+    0xff2d292c, 0xff2e292c, 0xff2d292d, 0xff2e292d, 0xff2e292d, 0xff2d292d,
+    0xff2d282c, 0xff2a2529, 0xff484547, 0xffc1bfc1, 0xffffffff, 0xffe9e8e9,
+    0xff5f5c5e, 0xff312c30, 0xff2e292d, 0xff2d292c, 0xff2d292d, 0xff2e282d,
+    0xff2d282c, 0xff2d282c, 0xff2e292d, 0xff2f2a2e, 0xff302b2f, 0xff342f33,
+    0xfe2f2b2f, 0xff322d32, 0xfe363437, 0xfe2b262a, 0xff332f32, 0xdf494c4c,
+    0x1f161314, 0x06000000, 0x0a020003, 0x10070709, 0x06000001, 0x06000001,
+    0x06000001, 0x07000002, 0x07000002, 0x06000002, 0x05000002, 0x05000001,
+    0x07000002, 0x06000001, 0x06000001, 0x07000002, 0x0d040506, 0x0d040306,
+    0x0b030003, 0x0b020004, 0x09000000, 0x04000000, 0x5f36464b, 0xf64794b4,
+    0xff2282ab, 0xfe2383ab, 0xff2b88ae, 0xff3894be, 0xff4ba7d1, 0xff57b3d9,
+    0xff80bab0, 0xffbebd67, 0xffedc32e, 0xfffdc115, 0xfffbc01e, 0xfffed22a,
+    0xfffcd132, 0xfffccf2a, 0xfffbc525, 0xfffdd027, 0xfffdd829, 0xfffed82b,
+    0xfffeda30, 0xfffcc621, 0xfffdcb23, 0xfffcc624, 0xfffebf23, 0xffd3981c,
+    0xff7c6026, 0xff433728, 0xff2c292a, 0xff2d292c, 0xff2e292d, 0xff2d292d,
+    0xff2d292d, 0xff2e292d, 0xff2d282c, 0xff2d282c, 0xff2b252a, 0xff3d383c,
+    0xff959394, 0xffa5a4a6, 0xff373337, 0xff2d282c, 0xff2d282c, 0xff2d282c,
+    0xff2e282d, 0xff2d282c, 0xff2d282c, 0xff2d282c, 0xff2d282c, 0xff2e292d,
+    0xff2c272b, 0xff302b2f, 0xff312c30, 0xff3c363a, 0xfe2e2a2e, 0xff312c2f,
+    0xc7414343, 0x351c1a1d, 0x05000000, 0x09010002, 0x0d040305, 0x09010103,
+    0x05000001, 0x03000000, 0x05000001, 0x06000001, 0x05000001, 0x06000002,
+    0x06000002, 0x07000002, 0x06000001, 0x07000002, 0x09010203, 0x0f060507,
+    0x08010001, 0x06000000, 0x05000000, 0x08000002, 0x08020001, 0x3720262b,
+    0xdc4d8ba5, 0xff2a89b2, 0xfe2684af, 0xff3089aa, 0xff469ab2, 0xff49a6ca,
+    0xff53b1d8, 0xff73b6c4, 0xffa3b787, 0xffd9c34a, 0xffdeb836, 0xfffdc01b,
+    0xfffdd326, 0xfffbc933, 0xfffcd33a, 0xfffcc923, 0xfffac222, 0xfffdd528,
+    0xfffed829, 0xfffdd931, 0xfffdd02f, 0xfffbc922, 0xfffed92a, 0xfffdd132,
+    0xfffcc223, 0xfffebb21, 0xffcb951d, 0xff705725, 0xff322d2a, 0xff2d282c,
+    0xff2e292d, 0xff2e292d, 0xff2d282c, 0xff2d282c, 0xff2e292d, 0xff2e292d,
+    0xff2d282c, 0xff2d282c, 0xff332e31, 0xff373337, 0xff2f292d, 0xff2e282c,
+    0xff2f2a2e, 0xff2f2a2e, 0xff2d282c, 0xff2e292d, 0xff2e292d, 0xff353034,
+    0xff423d41, 0xff3d383c, 0xff423d41, 0xff343134, 0xff3d393d, 0xff3c393c,
+    0xff302c30, 0xde3d3d3e, 0x351b1b1d, 0x09010002, 0x0a020002, 0x0a020002,
+    0x0a030204, 0x04010102, 0x00000000, 0x01000000, 0x03000001, 0x04000001,
+    0x05000001, 0x05000001, 0x05000001, 0x05000001, 0x0d040406, 0x0d050406,
+    0x10060407, 0x1f0c0a0d, 0x411c1d21, 0x6134393b, 0x7f4c5356, 0x59343b3f,
+    0x3621282d, 0xdb6c9dad, 0xff358fb7, 0xfe2480aa, 0xff3b8faa, 0xff75a588,
+    0xff68a9a7, 0xff55aed3, 0xff6eb5c5, 0xff96b798, 0xffaec17c, 0xffc7b24b,
+    0xfffbbb16, 0xfffdd025, 0xfffbcc26, 0xfffbcc2f, 0xfffdcc25, 0xfffac31f,
+    0xfffbcb23, 0xfffdd727, 0xfffdd82b, 0xfffdd42e, 0xfff8c120, 0xfffcd629,
+    0xfffed92a, 0xfffdd62b, 0xfffdce2d, 0xfffac222, 0xfff7b61d, 0xff9f7a25,
+    0xff463b29, 0xff2d282c, 0xff2d292d, 0xff2d292d, 0xff2e292d, 0xff2e292d,
+    0xff2e292d, 0xff2d282c, 0xff2e292d, 0xff2f2a2e, 0xff2e292d, 0xff2c292c,
+    0xff2d292c, 0xff2e282d, 0xfe2c272b, 0xff2f2a2d, 0xff302b2f, 0xff383337,
+    0xff555054, 0xff777377, 0xff8a888b, 0xff767477, 0xfb555356, 0xf7555656,
+    0xfb636464, 0xff3b3a3b, 0xf4373638, 0x5d2f2f30, 0x02000000, 0x0a000002,
+    0x09010002, 0x08020103, 0x06030304, 0x02010101, 0x01000000, 0x01000000,
+    0x01000000, 0x01000000, 0x02000000, 0x03000000, 0x03000000, 0x02000000,
+    0x09030003, 0x3818191d, 0x972f3439, 0xec465358, 0xff4b6471, 0xff527686,
+    0xff548ba4, 0xff6daac3, 0xf961a3bf, 0xff529ebd, 0xfe2682ae, 0xfe2484b0,
+    0xff80ad8c, 0xff9db06d, 0xff66adbb, 0xff70b3bf, 0xffbab46a, 0xffa0b887,
+    0xffbdb964, 0xfff5bf22, 0xfffccb23, 0xfffcd227, 0xfffbc827, 0xfffbcc27,
+    0xfffdca24, 0xfffcc822, 0xfffcd026, 0xfffcd426, 0xfffdd529, 0xfffac021,
+    0xfffbcc29, 0xfffdd82b, 0xfffed727, 0xfffed92a, 0xfffdda32, 0xfffdd22c,
+    0xfff9c220, 0xffc59826, 0xff584828, 0xff2e292d, 0xff2e292c, 0xff2d292d,
+    0xff2d282d, 0xff2d282c, 0xff2e292d, 0xff2e292d, 0xff2d282c, 0xff2e292d,
+    0xff2f2a2e, 0xff2e292d, 0xff2d282c, 0xff2e292c, 0xff2f2a2e, 0xf2363335,
+    0xd9302e30, 0xdd363437, 0xd7373537, 0xc42c2a2b, 0xc2313031, 0xae3b3c3c,
+    0x82343435, 0x7d4d5050, 0xe0626767, 0xff444346, 0x83444445, 0x00000000,
+    0x09000002, 0x09020002, 0x08020103, 0x08050606, 0x05040504, 0x01000100,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x01000000, 0x00000000, 0x552c2b2c, 0xe23d454b, 0xff3c6577, 0xff6aa0bb,
+    0xff8ec4d8, 0xfe92c9e2, 0xfe70b7d4, 0xff7ebad4, 0xff8bbed6, 0xfe7ab7ce,
+    0xff1d7eaa, 0xff2b8dbb, 0xff99af78, 0xffa3b077, 0xff89b19d, 0xffc5b45c,
+    0xffecb72f, 0xffbaba65, 0xffecbf2e, 0xfffcca21, 0xfffbce23, 0xfffccc27,
+    0xfffbc723, 0xfffcce29, 0xfffac21f, 0xfffdcd25, 0xfffac61a, 0xfffcd125,
+    0xfffabc1e, 0xfffabf26, 0xfffcd333, 0xfffbca22, 0xfffdd426, 0xffffd82a,
+    0xfffdda2e, 0xfffdd62b, 0xfff5bc20, 0xffa58524, 0xff70572a, 0xff352d2a,
+    0xff2d2a2c, 0xff2e282e, 0xff2d292d, 0xff2e292c, 0xff2e292d, 0xff2e292d,
+    0xff2e292d, 0xff2d282c, 0xff2d282c, 0xff2e292d, 0xff2d282c, 0xff2d292c,
+    0xff312d31, 0xb63c3c3e, 0x26100e11, 0x301b191b, 0x2d202020, 0x1b171616,
+    0x13131112, 0x00000000, 0x00000000, 0x5d313031, 0xff616765, 0x6b2e2e32,
+    0x06020003, 0x09000001, 0x09010002, 0x07020001, 0x0b08090a, 0x06040505,
+    0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xf144484c, 0xff457b94,
+    0xff5bb2d8, 0xfe8acae6, 0xff91cde8, 0xff79bfdc, 0xff4e9dc2, 0xff3d92b4,
+    0xff9cc3d8, 0xff97b8c5, 0xfe3881a3, 0xff3399c5, 0xfea2b68b, 0xffd3af45,
+    0xffecb12c, 0xfff8b821, 0xffd1bb4d, 0xffe5bb36, 0xfffdc722, 0xfff9c21d,
+    0xfffdd128, 0xfffbc624, 0xfffcce28, 0xfffabd1c, 0xfffecd25, 0xfffcca1e,
+    0xfffcca21, 0xfffabc1e, 0xfffbaf17, 0xfffdce2c, 0xfffabd1d, 0xfffdc722,
+    0xfffed82b, 0xfffdd72a, 0xffffd82c, 0xfff9c31e, 0xfffdca25, 0xffdaa421,
+    0xff5d4922, 0xff53422a, 0xff2d282c, 0xff2d292b, 0xff2d282d, 0xff2e282c,
+    0xff2d282d, 0xff2d282c, 0xff2d282c, 0xff2e292d, 0xff2d282c, 0xff2e292d,
+    0xff2e292d, 0xff2c292c, 0xff322b2f, 0xba373739, 0x110c0a0d, 0x0f0c0b0d,
+    0x1a18191a, 0x08070807, 0x05040304, 0x02010000, 0x0a060505, 0x94535755,
+    0x733c3d3d, 0x0f050306, 0x09010002, 0x09010002, 0x0a040205, 0x07060505,
+    0x03000001, 0x02000000, 0x01000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0xff4f7484, 0xfe5bb8e0, 0xff5db6dc, 0xff7fc8e6, 0xff68b6da, 0xff5fadca,
+    0xff348fb6, 0xff267da2, 0xfe96bccc, 0xfcb2887d, 0xff3b6577, 0xfe8aada6,
+    0xffd7af45, 0xfff8ad16, 0xfffcb516, 0xffe9b931, 0xffe8b72e, 0xfffebc1a,
+    0xfff9ba18, 0xfffdcd25, 0xfffbc520, 0xfffdca26, 0xfff9bd1e, 0xfffdc21e,
+    0xfff8b70f, 0xfffbc71c, 0xfffbc221, 0xfff9ae15, 0xfffcc522, 0xfffbc223,
+    0xfffbbc1b, 0xfffbca21, 0xfffccc24, 0xfffdd333, 0xfffbca24, 0xfffcc220,
+    0xfff7cf29, 0xfff8b921, 0xffa17520, 0xff463727, 0xff443b2a, 0xff302b2b,
+    0xff2e2a2d, 0xff2d292d, 0xff2e2a2c, 0xff2f2a2e, 0xff2e292d, 0xff2d282c,
+    0xff2d282c, 0xff2e292d, 0xff2f2a2e, 0xff2f2a2e, 0xff2f2a2d, 0xc6322f31,
+    0x1d111013, 0x110e0d10, 0x13131212, 0x0b0a0a0a, 0x01000101, 0x02010000,
+    0x07050303, 0x22171717, 0x02000000, 0x08020002, 0x0a020001, 0x0a040404,
+    0x05020302, 0x04000001, 0x03000001, 0x02000000, 0x01000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0xff5db1d6, 0xff50add4, 0xff65b7da, 0xff6abcde,
+    0xff6db2cf, 0xff469abf, 0xff1d7aa3, 0xff4a97b9, 0xffa37e73, 0xff9d5d35,
+    0xfe417280, 0xffdd9c26, 0xfef1a01e, 0xfffcb017, 0xfffaaf16, 0xfff9ae15,
+    0xfffbb114, 0xfff9b218, 0xfffcc11e, 0xfffbc622, 0xfffdc724, 0xfff9bd1d,
+    0xfffbb91d, 0xfffab313, 0xfffabe17, 0xfffdc61f, 0xfffcb418, 0xfffbbe1e,
+    0xfffdc422, 0xfffbbd1f, 0xfffcbe20, 0xfffabd1c, 0xfffabb22, 0xfffcce2b,
+    0xfffbc11e, 0xfffcc01c, 0xffeabc25, 0xffb98a1e, 0xffe4a424, 0xff6c5223,
+    0xff3f3327, 0xff3c332b, 0xff2e2a2a, 0xff2d282e, 0xff2e292d, 0xff2d282c,
+    0xff2d282c, 0xff2e292d, 0xff2e292d, 0xff2d282c, 0xff2e292d, 0xff2f2a2c,
+    0xff2e292c, 0xda373638, 0x331b1d1e, 0x09050607, 0x09080908, 0x00000000,
+    0x00000000, 0x05030203, 0x07030103, 0x06030102, 0x04010001, 0x08030304,
+    0x09040406, 0x0a060709, 0x06000102, 0x06000002, 0x05000001, 0x02000000,
+    0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xff5fb6dd, 0xff419bc2,
+    0xff5ca8ca, 0xff51a3c6, 0xff3e92b9, 0xff2581a9, 0xff1c7ba4, 0xff428bad,
+    0xff7c401d, 0xffbc782c, 0xff61624e, 0xffbe6314, 0xfff4a525, 0xfffaac15,
+    0xfffaac1a, 0xfffba911, 0xfffab31d, 0xfffcba1a, 0xfffbc321, 0xfffcc122,
+    0xfffbb81c, 0xfffbb41a, 0xfffab518, 0xfffcbd1e, 0xfffaba19, 0xfffcbf1d,
+    0xfffbbb1e, 0xfffbbf1e, 0xfffcc023, 0xfffbc020, 0xfffbbb1d, 0xfffab51a,
+    0xfffcc722, 0xfffbc21e, 0xfffab61b, 0xfffbbb1d, 0xfff9b11a, 0xffbf8b1e,
+    0xffbd881f, 0xffd39520, 0xff684f22, 0xff403628, 0xff3b332a, 0xff2c292d,
+    0xff2d292d, 0xff2e282c, 0xff2e282d, 0xff2d282d, 0xff2d282c, 0xff2e282d,
+    0xff2e292d, 0xff2f2a2e, 0xff2c292d, 0xdc373333, 0x32191818, 0x07020204,
+    0x00000000, 0x00000000, 0x00000000, 0x07010203, 0x08010103, 0x0a030305,
+    0x02000000, 0x03020202, 0x04010203, 0x03000000, 0x05000001, 0x05000001,
+    0x05000001, 0x04000001, 0x02000000, 0x01000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0xff5bafd2, 0xff4496b8, 0xff4397bb, 0xff2a85b1, 0xff2083aa, 0xff1d79a1,
+    0xff2583ac, 0xff3b6e85, 0xff77331a, 0xff994a26, 0xff52443b, 0xffd98218,
+    0xfffcad17, 0xfffbab1f, 0xfffaac1c, 0xfffcb223, 0xfffcb215, 0xfffbb719,
+    0xfffbb61a, 0xfffaaf18, 0xfffbb116, 0xfffbb419, 0xfffcbb1d, 0xfffaad17,
+    0xfffab41e, 0xfffcb917, 0xfffcba1d, 0xfffbbf1d, 0xfffbc123, 0xfffab91c,
+    0xfffab51b, 0xfffcc01d, 0xfffed329, 0xfffbb81c, 0xfffcb51c, 0xfffab117,
+    0xfffbac19, 0xfff9ac17, 0xffad7b19, 0xffbb861e, 0xffdd9c1f, 0xff6e5220,
+    0xff564a2d, 0xff3a3027, 0xff282528, 0xff2c292e, 0xff2d2a2b, 0xff2e292c,
+    0xff2e292d, 0xff2d2a2c, 0xff2d282c, 0xff322c30, 0xff312c2a, 0xe54f412f,
+    0x43332b1f, 0x0e050707, 0x0a080709, 0x03000201, 0x04000000, 0x06000001,
+    0x05000001, 0x04000001, 0x02000000, 0x01000000, 0x02000000, 0x02000000,
+    0x03000000, 0x04000001, 0x05000001, 0x05000001, 0x03000000, 0x01000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x01000000, 0xff2c8ab1, 0xff3f94b8, 0xff2b86ad, 0xff2686ae,
+    0xff1e77a1, 0xff207ba3, 0xff3387ab, 0xff3a5363, 0xff903616, 0xff933920,
+    0xff64402e, 0xffdf8e19, 0xffde7f0e, 0xffd67a10, 0xfffab12a, 0xfffba919,
+    0xfffbab12, 0xfffbaf16, 0xfff9ac16, 0xfffaab14, 0xfffdb318, 0xfffbba1d,
+    0xfffaad16, 0xfffcae17, 0xfffab013, 0xfffcbd1e, 0xfffabb19, 0xfffabd20,
+    0xfffdb51e, 0xfffcb61a, 0xfffcb918, 0xfff8b012, 0xfff9b71a, 0xfff8ae17,
+    0xfffbad16, 0xfffaac16, 0xfffbab15, 0xfff9a816, 0xfffeac1c, 0xffba841c,
+    0xffb37d1a, 0xffdda624, 0xff8c6620, 0xff9a6f1f, 0xffb77f2a, 0xff473424,
+    0xff302a2d, 0xff2f2a30, 0xff2d292c, 0xff2e292e, 0xff2f2b2c, 0xff37322c,
+    0xfe5b4627, 0xffbc8b2a, 0x887c602b, 0x130a0808, 0x1b16171b, 0x02000000,
+    0x06000001, 0x05000001, 0x03000000, 0x02000000, 0x01000000, 0x00000000,
+    0x00000000, 0x00000000, 0x01000000, 0x02000000, 0x04000001, 0x05000001,
+    0x05000001, 0x03000000, 0x02000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x01000000, 0x01000100, 0x03020302, 0xff2f8bb2, 0xff2e89b0,
+    0xff2c89b2, 0xff1a799f, 0xff1f759f, 0xff2782a6, 0xff3b84a4, 0xff393c43,
+    0xff863519, 0xff7a2f18, 0xff6d301f, 0xffb24e1b, 0xffc65a10, 0xffe59528,
+    0xfffdb123, 0xfffba60d, 0xfffbaa12, 0xfffba913, 0xfffaab15, 0xfffcb319,
+    0xfffbb519, 0xfffaab16, 0xfffbac16, 0xfffab417, 0xfffcbc1c, 0xfffcb61a,
+    0xfff5ac1c, 0xfff8b01d, 0xfffbb419, 0xfffab217, 0xfffbb616, 0xfff19d0b,
+    0xfffbaa17, 0xfff9a713, 0xfffaa914, 0xfffbac16, 0xfffaab16, 0xfff6a216,
+    0xfff9a512, 0xffffae15, 0xffe7a71e, 0xffc98d19, 0xffda931e, 0xffd48e1b,
+    0xffdb8f17, 0xffb5791d, 0xff6e5123, 0xff53432d, 0xff433626, 0xff3c3228,
+    0xff564225, 0xff84622c, 0xfe9e7016, 0xffffb424, 0xdab29758, 0x5f3a3c3b,
+    0x09060709, 0x04020201, 0x04000001, 0x04000001, 0x02000000, 0x01000000,
+    0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000000,
+    0x03000000, 0x05000001, 0x06000001, 0x04000001, 0x03000001, 0x01000000,
+    0x00000000, 0x00000000, 0x01000000, 0x03020302, 0x03020202, 0x08070807,
+    0xff348db4, 0xff2a88b0, 0xff257ba2, 0xff1b6e90, 0xff2280a8, 0xff3080a2,
+    0xff327692, 0xff42322e, 0xff612b1e, 0xff5f2a1b, 0xff693120, 0xffa3350f,
+    0xffc55a0d, 0xfff0a023, 0xfffba913, 0xfffca912, 0xfff8a911, 0xfffaaa13,
+    0xfff9aa13, 0xfffbae15, 0xfffba812, 0xfffaac16, 0xfffcb317, 0xfffab518,
+    0xfffcb51b, 0xfff3a419, 0xfff39d18, 0xfffbad17, 0xfff9ac17, 0xfffbb215,
+    0xfff7aa15, 0xfff8a816, 0xfff9a914, 0xfffaa815, 0xfffaab17, 0xfffbad17,
+    0xfff9aa18, 0xfff5a114, 0xfffba815, 0xfff6a714, 0xfffcaf19, 0xfff7a417,
+    0xffec9c19, 0xfff7a813, 0xfff8a516, 0xffe99412, 0xffda981d, 0xffcb8f22,
+    0xffc18d2a, 0xffb98321, 0xffda9719, 0xfffdb222, 0xffffb01a, 0xffe8a828,
+    0xf39c8b63, 0x924a4d4c, 0x05040405, 0x0a080809, 0x01000000, 0x02000000,
+    0x01000000, 0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x01000000, 0x03000000, 0x05000001, 0x06000002, 0x06000001,
+    0x04000001, 0x02000001, 0x07050506, 0x0b0a0a0b, 0x07050606, 0x04030403,
+    0x0a090a09, 0x110f1110, 0xff2885ae, 0xff2586b1, 0xff1c6484, 0xff247393,
+    0xff24799c, 0xff25769a, 0xff2b596f, 0xff432e30, 0xff3d2925, 0xff5c2b1c,
+    0xff642718, 0xffaf410d, 0xffd16d0e, 0xfffdad1e, 0xfff7a20f, 0xfff8a911,
+    0xfffaa913, 0xfffaaa13, 0xfffbaa13, 0xfffca70f, 0xfffcac16, 0xfffcac16,
+    0xfffbb015, 0xfffbae16, 0xfff39e15, 0xfff29116, 0xfff9a617, 0xfffbab16,
+    0xfffbae14, 0xfff9b118, 0xffef9912, 0xfffaa915, 0xfffba915, 0xfff8a512,
+    0xfff6a013, 0xfffaac16, 0xfffaa214, 0xfff39e13, 0xfff7a713, 0xfff9a816,
+    0xfff69f15, 0xffef9714, 0xfff9a817, 0xfff8a613, 0xfff19910, 0xfffca817,
+    0xfffbae17, 0xfffaab15, 0xfffab126, 0xfffaaa14, 0xfffbab16, 0xfffaad13,
+    0xfff8ac16, 0xffaa7f2e, 0xff69695f, 0x9c424244, 0x0b0b0b0a, 0x0a070a09,
+    0x02000000, 0x03000001, 0x01000000, 0x01000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x03000001, 0x05000001,
+    0x07000003, 0x06000002, 0x06000001, 0x0c0a0b0a, 0x1b1a1815, 0x2524211e,
+    0x0d0b0c0b, 0x0d0c0d0c, 0x15131514, 0x0f0e0e0e, 0xff2988b1, 0xff1d7ca5,
+    0xff1e5e79, 0xff216685, 0xff257696, 0xff1b6689, 0xff2c4451, 0xff362f34,
+    0xff342927, 0xff5e2b1f, 0xff602a18, 0xffa73705, 0xffed951d, 0xfff6a311,
+    0xfff9a412, 0xfff9a910, 0xfffaaa14, 0xfffaaa12, 0xfffaa911, 0xfffbab16,
+    0xfff49e15, 0xfffaa30f, 0xfffba813, 0xfff29211, 0xffe57d0b, 0xfff29b11,
+    0xfffcad16, 0xfffaac15, 0xfffba415, 0xffef9314, 0xfff59f12, 0xfff9a917,
+    0xfffbab16, 0xfff6a114, 0xfff6a014, 0xfff8a112, 0xffe37d12, 0xfff9a516,
+    0xfff9a816, 0xfff7a016, 0xffee930e, 0xfff8a216, 0xfff6a212, 0xfff39a12,
+    0xfff7a214, 0xfffbab16, 0xfffcab17, 0xfffba911, 0xfffbab14, 0xfffcab14,
+    0xfffaab13, 0xfffbad1b, 0xffba8726, 0xff2f393c, 0xff213f4c, 0xab394346,
+    0x12121112, 0x1f1c1c1e, 0x0d0a0b0c, 0x04000001, 0x03000000, 0x01000000,
+    0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x03000101,
+    0x04000102, 0x05000001, 0x07000100, 0x0a020507, 0x18151515, 0x211c1710,
+    0x2c21190d, 0x12100b03, 0x17131512, 0x17161616, 0x0c0b0b0b, 0x08070807,
+    0xff2382ac, 0xff19759a, 0xff21617e, 0xff24607c, 0xff176e91, 0xff1c5b79,
+    0xff2b3c47, 0xff302b2e, 0xff432922, 0xff5e2b1d, 0xff672816, 0xffbc5410,
+    0xffcc650b, 0xfff19b17, 0xfff5a011, 0xfffaa813, 0xfff8a714, 0xfff9aa11,
+    0xfffcab16, 0xfff6a119, 0xfff08e0d, 0xfff9a412, 0xfff1920d, 0xffed8b0e,
+    0xfff49813, 0xfffbad16, 0xfffaab15, 0xfffbad15, 0xfff69d11, 0xfff5a014,
+    0xfffaaa16, 0xfffbac15, 0xfff7a216, 0xffea8810, 0xfff39914, 0xffe78010,
+    0xfff29515, 0xfffbab15, 0xfff6a314, 0xffef8f15, 0xfff5a015, 0xfff7a417,
+    0xffe68913, 0xfff6a113, 0xfffaab16, 0xfffaab16, 0xfffbaa15, 0xfff7a411,
+    0xfffbaa14, 0xfffaaa13, 0xfffead15, 0xffbf871e, 0xff383228, 0xff284b5a,
+    0xff1e3a49, 0xfc5d747b, 0x87596c6f, 0x523b4346, 0x09060607, 0x05000001,
+    0x04000001, 0x04000001, 0x03000000, 0x02000000, 0x02000000, 0x02000000,
+    0x04020203, 0x12101111, 0x12101111, 0x0a060607, 0x03000001, 0x0c0a0908,
+    0x5a473d24, 0x6a50472a, 0x241e180e, 0x56433b29, 0x664e452d, 0x1814120e,
+    0x0d0b0b0b, 0x0a09090a, 0xff1f79a0, 0xff1c749c, 0xff22576e, 0xff235b76,
+    0xff106589, 0xff24536a, 0xff2c363d, 0xff31292c, 0xff5f2f22, 0xff58291c,
+    0xff6f2b12, 0xffb44f10, 0xffd97612, 0xffe48a17, 0xfff49a0f, 0xfff6a015,
+    0xfff9a813, 0xfffdaa17, 0xfff7a41a, 0xffef920e, 0xfff69e0f, 0xffef8e0c,
+    0xfff09011, 0xffdf7109, 0xffee8e10, 0xfffcab16, 0xfffbab17, 0xfffba816,
+    0xffee9010, 0xfff69e13, 0xfff19b12, 0xfff79e14, 0xffeb8c10, 0xfff09112,
+    0xffed8d11, 0xfff09916, 0xfffdac17, 0xfff49a12, 0xffe57913, 0xffed8c13,
+    0xfff8a815, 0xffe58513, 0xffe78914, 0xfff5a116, 0xfff7a615, 0xfffbac14,
+    0xfffaa915, 0xfff8a716, 0xfffbac18, 0xfffea814, 0xffcc8f23, 0xff443827,
+    0xff2b2e35, 0xff2c5363, 0xfe213341, 0xff3d5d6b, 0xeb95bac2, 0x60364348,
+    0x00000000, 0x06000002, 0x05000001, 0x05000001, 0x05000001, 0x05000001,
+    0x04000001, 0x07040504, 0x110f100f, 0x1a191717, 0x100e0e0f, 0x05040403,
+    0x1613100b, 0x93726743, 0xf3b5a057, 0xeeada148, 0xa67b7845, 0x82665d43,
+    0xb7897e50, 0x3e302b1e, 0x03030000, 0x4e3b3421, 0xff166c90, 0xff236f90,
+    0xff243b47, 0xff1a536c, 0xff1a6e93, 0xff2b4a5b, 0xff333139, 0xff393433,
+    0xff7b301a, 0xff55271d, 0xff7a321c, 0xffbf5912, 0xffd77510, 0xffda730b,
+    0xfff69d15, 0xfff6a211, 0xfff7a110, 0xfff39813, 0xffeb8d10, 0xfff39613,
+    0xffea7e05, 0xfff49312, 0xffda6706, 0xffd05303, 0xffed8910, 0xfffcaf16,
+    0xfffaa813, 0xffe8820e, 0xffe87e0f, 0xfff79e14, 0xffe47a0c, 0xffef8d13,
+    0xffec860b, 0xfff39a13, 0xfff6a213, 0xfffbab13, 0xfff1910f, 0xffdc6309,
+    0xffe88211, 0xfff8a314, 0xfff29619, 0xffda7714, 0xffda6e11, 0xffe38011,
+    0xfff9a715, 0xfffbaa16, 0xfff29d12, 0xfff2a016, 0xfffaa814, 0xffdf961f,
+    0xff574627, 0xff2b282c, 0xff2e4955, 0xff2a4d5f, 0xff253542, 0xfe2b4f61,
+    0xf68fb8c1, 0x59323f45, 0x00000000, 0x06000001, 0x06000001, 0x06000001,
+    0x06000001, 0x05000001, 0x0c080a0b, 0x14111313, 0x100e0f0f, 0x09080708,
+    0x08040603, 0x28221c14, 0xb0867748, 0xfeb8a84d, 0xe6aaa14e, 0xcc968d41,
+    0x44322e15, 0x2019170d, 0x48383021, 0x1e19140e, 0x73584d34, 0xf4b5a566,
+    0xff207ba1, 0xff275d75, 0xff272e35, 0xff1d4e65, 0xff287599, 0xff30414c,
+    0xff373539, 0xff533835, 0xff8e2e0d, 0xff4d2920, 0xff7d3118, 0xffc5600d,
+    0xffbd4c08, 0xffed9010, 0xfff19711, 0xfff79d12, 0xffec8a0d, 0xffec890f,
+    0xffeb8110, 0xffe57e08, 0xfff69414, 0xffd55f03, 0xffcf5104, 0xffe2740c,
+    0xfff59c10, 0xfff79d14, 0xffef8f11, 0xffe77a0a, 0xfff49d12, 0xffe8850f,
+    0xffea800f, 0xffe27708, 0xfff59e15, 0xfff8a813, 0xfff5a215, 0xffe7870f,
+    0xffd95a07, 0xffdf710b, 0xfff39614, 0xfff49d14, 0xffd86f0a, 0xffdd7b12,
+    0xffd06c0b, 0xffed9114, 0xfff3a114, 0xfff6a514, 0xfff29b14, 0xfff6a214,
+    0xffe19318, 0xff664d26, 0xff2a242b, 0xff253d4c, 0xff2b4251, 0xff234656,
+    0xff253845, 0xff2a4d5b, 0xf79cc3cb, 0x60374548, 0x01000000, 0x07000002,
+    0x07000002, 0x08010103, 0x0b040406, 0x17131211, 0x413c372f, 0x1f1b1713,
+    0x08070302, 0x09070301, 0x362c2317, 0xca978b4c, 0xfdb7a94a, 0xb2857e42,
+    0x34262009, 0x231b170d, 0x1c181009, 0xb78b7e52, 0xe5ab9b61, 0x7055492d,
+    0xe0a8975f, 0x7a605537, 0xff2a81a7, 0xff1e4d63, 0xff282d34, 0xff294c5f,
+    0xff185977, 0xff38373c, 0xff34353a, 0xff7e3623, 0xff7e2b11, 0xff4b2a23,
+    0xff904618, 0xffb34109, 0xffbf5008, 0xfff29313, 0xfff09511, 0xffe9830c,
+    0xffed8811, 0xffe4750d, 0xffe77705, 0xfff19118, 0xffda6807, 0xffcd5105,
+    0xffde6909, 0xffe1720b, 0xffe7840c, 0xffed8910, 0xffec830c, 0xffef8f0d,
+    0xfff19212, 0xffe77f0d, 0xffe77f0e, 0xffed8c11, 0xfff29813, 0xffeb8f10,
+    0xffda740f, 0xffc94f05, 0xffe3720d, 0xffe38110, 0xffe98914, 0xffde790e,
+    0xffe88b13, 0xffe38712, 0xffdd7e12, 0xffdb780d, 0xffed9713, 0xffdf8112,
+    0xffd66f0d, 0xffe5991b, 0xff6f4e23, 0xff272229, 0xff2b333a, 0xff234b5e,
+    0xff29363f, 0xff244556, 0xff263946, 0xff2d4753, 0xf57fabb7, 0x5229373c,
+    0x03000000, 0x09010204, 0x08000103, 0x0b060405, 0x372b251a, 0x67534934,
+    0x5a463b26, 0x2e252018, 0x0b080300, 0x624a4123, 0xe0a5964a, 0xd99e9240,
+    0x77595121, 0x392b2716, 0x27201c15, 0x3b2b2417, 0xc590814f, 0xefb29c5d,
+    0x9a73663a, 0x624b4027, 0x71564c30, 0xd48d834b, 0xff1f7194, 0xff1d4b60,
+    0xff283038, 0xff213f50, 0xff21495d, 0xff383234, 0xff343134, 0xff9a300f,
+    0xff652a19, 0xff563220, 0xff933e16, 0xffa92f04, 0xffce5e0a, 0xffef8d0f,
+    0xffe68411, 0xffea8511, 0xffe27008, 0xffe16505, 0xffe67407, 0xffd76308,
+    0xffcc4e04, 0xffda5e06, 0xffd55a07, 0xffcb5005, 0xffe1750a, 0xffe87a0d,
+    0xffe97d08, 0xffea810b, 0xffe9820f, 0xfff49815, 0xffeb890e, 0xffe87d0e,
+    0xffdf770c, 0xffc95d0e, 0xffbe4909, 0xffe17510, 0xffd67110, 0xffd0640d,
+    0xffe28211, 0xffea8d16, 0xffd77710, 0xffca610b, 0xffc15109, 0xffd57413,
+    0xffc14f0b, 0xffb03604, 0xffd57213, 0xff7f5c28, 0xff2f292b, 0xff2b2b2e,
+    0xff283f4d, 0xff273a46, 0xff2a2e36, 0xff244353, 0xff273a44, 0xff344448,
+    0xfa6b9aa1, 0x91546b70, 0x17100f0f, 0x04010002, 0x1912110d, 0x664d4731,
+    0x80635c41, 0x9e796c47, 0xd39d8c52, 0x98756845, 0x9d746934, 0xf4afa139,
+    0xfeb4a836, 0xaa817a44, 0x56433c26, 0x04030000, 0x5d403b24, 0xe891894a,
+    0xd98e8546, 0x85645734, 0x73564b2d, 0x79574e2e, 0xdb887f40, 0xc67b753f,
+    0xff126488, 0xff1e4c64, 0xff28313b, 0xff253f4c, 0xff2b363c, 0xff333137,
+    0xff412a26, 0xffa0300d, 0xff4f2a20, 0xff633820, 0xff94300e, 0xffa72c03,
+    0xffd86a0d, 0xffec9014, 0xffc25407, 0xffdb690a, 0xffe06911, 0xffe06706,
+    0xffdd680a, 0xffcb5005, 0xffd65a05, 0xffd05206, 0xffc84703, 0xffda6706,
+    0xffec8112, 0xffde6604, 0xffe77c09, 0xffe97f12, 0xffed8814, 0xffe2770a,
+    0xffe5760d, 0xffd66208, 0xffc7570d, 0xffb03705, 0xffcf5f0d, 0xffc95d09,
+    0xffcd6210, 0xffd7750f, 0xffe18213, 0xffba4c07, 0xffc2520b, 0xffac3506,
+    0xffbd4f0b, 0xffc2581c, 0xffa72c06, 0xff9c3b15, 0xff80562a, 0xff44392e,
+    0xff2d292c, 0xff2d2e34, 0xff293740, 0xff2a3033, 0xff292d35, 0xff234657,
+    0xff273d4a, 0xff363f3f, 0xff57888c, 0xea8cb0b4, 0x4d393e3d, 0x7c5e563a,
+    0xbe8f825b, 0x7f625a3f, 0x795e5640, 0xbc918258, 0xffbda75f, 0xfab7a444,
+    0xfdb5a630, 0xffb5a734, 0xecac9d46, 0xecae9d57, 0x5c463f28, 0x835a5639,
+    0xfa938e42, 0xc97c7940, 0x8e615c3e, 0x996b6745, 0x815f5737, 0xe188803e,
+    0x8f4e4818, 0x2714120a, 0xff15658a, 0xff224d63, 0xff26333d, 0xff2e353c,
+    0xff2f2d33, 0xff312f32, 0xff4c2921, 0xff9a2f10, 0xff382826, 0xff682f1c,
+    0xff9e2c08, 0xffa83201, 0xffec8c1a, 0xffcd660f, 0xffcb5309, 0xffdf6b12,
+    0xffe17009, 0xffea8010, 0xffcf5506, 0xffd75804, 0xffd15009, 0xffc54704,
+    0xffd96206, 0xfff08b11, 0xffdd6507, 0xffe06d07, 0xffe77b0c, 0xffe46e0b,
+    0xffdb6704, 0xffe7770d, 0xffcf5707, 0xffbd4506, 0xffae3203, 0xffb74207,
+    0xffc35009, 0xffcc5f0e, 0xffca600c, 0xffd46f0d, 0xffb43f04, 0xffb33c09,
+    0xffa62c01, 0xffac3406, 0xffb84714, 0xffae3d16, 0xffa62d05, 0xff623324,
+    0xff363134, 0xff302c2d, 0xff2e2a2d, 0xff2e2b2f, 0xff2b2b2f, 0xff2c2c30,
+    0xff292e35, 0xff1e4d62, 0xff26495c, 0xff36414a, 0xff508a95, 0xea7d988b,
+    0xb4817d5e, 0xbf8e8053, 0x5a483e28, 0x44312917, 0x221b150e, 0x382e2618,
+    0xf4b8a563, 0xffb8a83d, 0xfbb2a63a, 0x9a756732, 0x78584d25, 0xffafa354,
+    0xffa19a4f, 0xfe969145, 0xba787245, 0x8f5e5b36, 0xcc827f49, 0xa76f6b42,
+    0xf8948d45, 0x914f4819, 0x1a0b0900, 0x83565744, 0xff1c6c90, 0xff1e4254,
+    0xff27333c, 0xff2d2d31, 0xff2f2b2e, 0xff2f2a2e, 0xff5b2b1e, 0xff812d13,
+    0xff332727, 0xff6b2c1a, 0xff9f2906, 0xffc45a0f, 0xffe78c1d, 0xffbe4403,
+    0xffde6909, 0xffee8711, 0xfff18b13, 0xffd35d06, 0xffd65605, 0xffce4f06,
+    0xffc94f02, 0xffdd6307, 0xffed8510, 0xffe57407, 0xffde6a05, 0xffef880b,
+    0xffe16908, 0xffdd6707, 0xffe5720e, 0xffce5305, 0xffbb3e06, 0xffad3208,
+    0xffaa3206, 0xffbe4507, 0xffba4309, 0xffb13b03, 0xffd1670e, 0xffba4909,
+    0xffa82c04, 0xffa72b02, 0xffa82e06, 0xffae3608, 0xffb4431c, 0xffaa2f07,
+    0xff9e2f0b, 0xff3c2826, 0xff2e2a2e, 0xff2c2a2d, 0xff2f292e, 0xff2e292d,
+    0xff2c292e, 0xff2c2d31, 0xff293038, 0xff195973, 0xff235e79, 0xff314a55,
+    0xff48859f, 0xf981a193, 0xb07f7a58, 0x664f4732, 0x4836301f, 0x17140e0b,
+    0x45342e1d, 0xc897864d, 0xffbba84f, 0xebad9e45, 0xa1797339, 0xa8776f3b,
+    0xffafa356, 0xffaba352, 0xdd8c8644, 0x9a66623d, 0xa96b693a, 0xff9b9045,
+    0xff9a8f40, 0xfa938a3d, 0x82474117, 0x1b0d0a03, 0x86504f3d, 0xff7c7b4d,
+    0xff146388, 0xff213c4b, 0xff29323a, 0xff2f2c30, 0xff302b2e, 0xff2f282d,
+    0xff662c19, 0xff6c2b17, 0xff352728, 0xff712c16, 0xffac3708, 0xffe5851b,
+    0xffcc5609, 0xffdf730e, 0xfff9a116, 0xffe9840d, 0xffdd6806, 0xffdf6707,
+    0xffcf5205, 0xffd35902, 0xffe77008, 0xffe97d0b, 0xffe47408, 0xffe26f06,
+    0xfff7990f, 0xffe97b07, 0xffe36f0a, 0xffe06b09, 0xffcd4e04, 0xffbd4005,
+    0xffb03506, 0xffac3005, 0xffae3103, 0xffbb3d08, 0xffa82d03, 0xffbd4909,
+    0xffc15009, 0xffa92c04, 0xffa82c04, 0xffa72c02, 0xffa82e06, 0xffad360d,
+    0xffad3911, 0xffaa2d07, 0xff9e310c, 0xff342828, 0xff2d292d, 0xff2e292d,
+    0xff2d292c, 0xff2d292c, 0xff2c292d, 0xff2a2e33, 0xff2b3039, 0xff185d7c,
+    0xff206f92, 0xff325a6d, 0xff377e98, 0xf380abac, 0xe6a59f70, 0x83645838,
+    0x16151110, 0x84635a33, 0xecaf9d49, 0xffb7a63c, 0xdfa49a42, 0x96706a34,
+    0xdd9d954b, 0xffaea450, 0xffada352, 0xb9807a44, 0x8c65603c, 0xd68b8547,
+    0xff999043, 0xff978e3c, 0xf08d853b, 0x6a3a3613, 0x180b0903, 0x97565641,
+    0xf9747048, 0xff706a39, 0xff115f80, 0xff253642, 0xff292f36, 0xff2f2b2f,
+    0xff2e2a2c, 0xff31292a, 0xff732d16, 0xff552a1d, 0xff41292a, 0xff782d13,
+    0xffca5910, 0xffd15809, 0xffc7560a, 0xfffcac1e, 0xfff8a114, 0xffe57b0a,
+    0xffe8790a, 0xffd35b04, 0xffd96306, 0xfff18708, 0xffe77505, 0xffe16f07,
+    0xffe37106, 0xfffa9c0d, 0xffe87705, 0xffe47409, 0xffdf6908, 0xffce4e05,
+    0xffbd4003, 0xffb53904, 0xffaf3405, 0xffa92f07, 0xffb73907, 0xffb13704,
+    0xffb13904, 0xffbd4907, 0xffa82c05, 0xffa82c04, 0xffa72d05, 0xffa92b03,
+    0xffa92e06, 0xffac360e, 0xffaa3008, 0xffaa2e07, 0xff9e320e, 0xff302728,
+    0xff302b2f, 0xff2d2a2e, 0xff2e292d, 0xff2d282c, 0xff2e282c, 0xff2b2e35,
+    0xff293239, 0xff1d6280, 0xff227196, 0xff2a6a84, 0xff2e7792, 0xff84aba1,
+    0xbb858058, 0x7861573b, 0xbf8b823c, 0xfdb5a736, 0xffb5a734, 0xc28f893f,
+    0x916e6931, 0xf4aca23e, 0xffafa347, 0xffada659, 0xa5757247, 0x976e6a44,
+    0xed9d944b, 0xff9a9142, 0xff978e3b, 0xe988823b, 0x59332d13, 0x14080501,
+    0xb3676951, 0xff726f44, 0xff706a3a, 0xfe716a3a, 0xff145d7b, 0xff25323c,
+    0xff2d2d33, 0xff2f2b2e, 0xff2e282d, 0xff31282a, 0xff7c2d16, 0xff422923,
+    0xff542c21, 0xff8b4016, 0xffd45d0d, 0xffac3303, 0xfff19519, 0xfff8a311,
+    0xffea850c, 0xffec850f, 0xffe47407, 0xffe9810d, 0xfffc9b09, 0xfff18805,
+    0xffdf6906, 0xffe47208, 0xfff8950d, 0xffe17203, 0xffe3720a, 0xffe67409,
+    0xffcc4e05, 0xffbd3f02, 0xffbd3f07, 0xffb63906, 0xffb03507, 0xffab2f03,
+    0xffb33504, 0xffb53b05, 0xffb73f06, 0xffac3406, 0xffad3203, 0xffa92e04,
+    0xffa72c04, 0xffaa2d04, 0xffa92f06, 0xffab310a, 0xffa92e04, 0xffab3006,
+    0xff9b2f0d, 0xff2d2829, 0xff2f292d, 0xff2d292d, 0xff302a2e, 0xff2d282c,
+    0xff2e282c, 0xff2d2e34, 0xff2b353d, 0xff256888, 0xff207293, 0xff287494,
+    0xff2b7790, 0xe275a1a2, 0xab7d7d51, 0xf7b0a53c, 0xffb7a52f, 0xfbb4a637,
+    0xaa7d7635, 0x9d756f2e, 0xffb4a837, 0xffb2a535, 0xffafa654, 0x74534d26,
+    0xb07e794d, 0xffa59b4c, 0xff998f41, 0xff958d3a, 0xe0827b38, 0x4426220e,
+    0x1b0c0a07, 0xba65644a, 0xff6f6a3d, 0xfe6f6a39, 0xfe6e6a3b, 0xff6e6b39,
+    0xff195773, 0xff273138, 0xff2d2c31, 0xff2e292d, 0xff2d292d, 0xff362828,
+    0xff7e2d15, 0xff3a2728, 0xff62311c, 0xff9c501a, 0xffb84709, 0xffc75f1f,
+    0xfff79d13, 0xffed8c0f, 0xffeb850f, 0xffea7f0a, 0xffee870a, 0xffffa10c,
+    0xfff6920b, 0xffe26f05, 0xffeb7e0b, 0xfff08d10, 0xffe57506, 0xffe87605,
+    0xffe46f07, 0xffcd4e04, 0xffc04004, 0xffbf4307, 0xffbc400a, 0xffbf4309,
+    0xffaa3002, 0xffb53808, 0xffb33707, 0xffb94005, 0xffb23905, 0xffb13906,
+    0xffb53c05, 0xffa62c04, 0xffa82d03, 0xffa82e05, 0xffab3007, 0xffaa2e06,
+    0xffa92e06, 0xffac2f03, 0xff923010, 0xff2b282b, 0xff2f292c, 0xff2d292d,
+    0xff2f2a2e, 0xff2d282c, 0xff2d292c, 0xff2b3036, 0xff273641, 0xff256b8c,
+    0xff1d6e93, 0xff227292, 0xff368098, 0xfe88b398, 0xffb4a838, 0xffb3a72f,
+    0xeda99f3a, 0xa2787236, 0xb8867f31, 0xffb5a631, 0xfeb3a52b, 0xffb1a53e,
+    0xffaea453, 0xefa19952, 0xffa19646, 0xff958d3c, 0xfe938b3a, 0xff958d38,
+    0xc66f692d, 0x53282617, 0xbe5d5c41, 0xff706b3d, 0xfe7b7639, 0xff77713b,
+    0xff726b39, 0xff857c3c, 0xff1c5069, 0xff28343c, 0xff2d2d32, 0xff2d2a2d,
+    0xff30282d, 0xff3e2825, 0xff762b17, 0xff352925, 0xff6a3321, 0xff984112,
+    0xffb7440f, 0xffd56f18, 0xfff19010, 0xffee8b10, 0xffec850e, 0xfff08f0c,
+    0xfff4950d, 0xfff39110, 0xffeb7f0c, 0xffef8309, 0xffea800f, 0xffe47407,
+    0xffea7b09, 0xffe06805, 0xffd05307, 0xffc04304, 0xffc44604, 0xffc34709,
+    0xffc94f11, 0xffaf3404, 0xffaf3204, 0xffb83c07, 0xffaf3404, 0xffbf4507,
+    0xffb23804, 0xffbc4607, 0xffa82d04, 0xffaa2f04, 0xffaa2e05, 0xffaa2f06,
+    0xffa92e05, 0xffa82d04, 0xffa92f06, 0xffa82d03, 0xff923618, 0xff29272a,
+    0xff2d292c, 0xff2d292d, 0xff2d282c, 0xff2e282c, 0xff2d292b, 0xff2b343d,
+    0xff263945, 0xff1d698a, 0xff1d6e91, 0xff1d6e91, 0xfe408183, 0xff87ac85,
+    0xffb9a43a, 0xfdb7ac49, 0x96726c35, 0xd0958d35, 0xffb4a62e, 0xffb4a729,
+    0xfeb2a530, 0xfeafa346, 0xfea69c4a, 0xff9b9240, 0xff958d3b, 0xfe948b3a,
+    0xff958c3b, 0xff948c3a, 0xfc8c833a, 0xf56e6b3e, 0xff75703c, 0xff88803a,
+    0xff938c3c, 0xff8b843b, 0xff8c833b, 0xff958c3c, 0xff1b495e, 0xff293843,
+    0xff2f2c30, 0xff2e2a2e, 0xff30282c, 0xff4a2a22, 0xff6b2b19, 0xff362629,
+    0xff6f301c, 0xff98310a, 0xffc9540d, 0xffed9014, 0xfff19614, 0xffee8e14,
+    0xfff89a10, 0xffef930f, 0xfff79e16, 0xfff38e12, 0xffef8108, 0xffe57205,
+    0xffe37007, 0xffe87c0c, 0xffdf6706, 0xffd15808, 0xffbf4702, 0xffcd4d08,
+    0xffc44605, 0xffcf550a, 0xffb23504, 0xffb43906, 0xffbe4408, 0xffbc4105,
+    0xffbe4408, 0xffb74006, 0xffbd490a, 0xffab3304, 0xffa92f03, 0xffac3106,
+    0xffab3007, 0xffaa2f06, 0xffa72c03, 0xffa82e05, 0xffa92d04, 0xffad3109,
+    0xff8a3214, 0xff29282b, 0xff32282b, 0xff2e2a2f, 0xff2e292c, 0xff2d282c,
+    0xff2d282c, 0xff2c3741, 0xff233b48, 0xff1b688a, 0xff1d6e8f, 0xff196c8e,
+    0xff528b8b, 0xff8cab82, 0xffb8a632, 0xfdb4a833, 0xeeab9e38, 0xfdb3a632,
+    0xe1a29b40, 0xf3ada13b, 0xffb2a536, 0xfeada34d, 0xffa19949, 0xff968e3d,
+    0xff958d3c, 0xff958d3c, 0xfe978f3e, 0xff988f3d, 0xff958b3d, 0xff89823c,
+    0xff978d43, 0xfe9c913f, 0xff958d3b, 0xff948c3c, 0xff948c3b, 0xff958d3b,
+    0xff204253, 0xff293e4c, 0xff2e2b2f, 0xff2e292e, 0xff2f2a2b, 0xff582b1f,
+    0xff612f22, 0xff392728, 0xff6e2d18, 0xffa63a13, 0xffdc781a, 0xfff7a316,
+    0xfff79e17, 0xfffaa214, 0xfff19911, 0xfff49910, 0xfff59a13, 0xffeb7e0a,
+    0xffe77504, 0xffe57607, 0xffec7e0f, 0xffdc6205, 0xffd56005, 0xffca5001,
+    0xffd75f0a, 0xffc54905, 0xffd0540a, 0xffb53804, 0xffbd3f06, 0xffc74f08,
+    0xffc45006, 0xffc34b09, 0xffb93e02, 0xffcc5b10, 0xffb53f0d, 0xffa93002,
+    0xffb94008, 0xffac3204, 0xffac3105, 0xffa72c03, 0xffa92e05, 0xffa92d05,
+    0xffa82c03, 0xffb0350d, 0xff8d2f10, 0xff2c2729, 0xff3d2c2c, 0xff2f2c2e,
+    0xff332b2e, 0xff2d292c, 0xff2d292c, 0xff293640, 0xff223f4e, 0xff1d6c8e,
+    0xff206f91, 0xff186b8c, 0xff60938a, 0xfe91a96a, 0xffb5a728, 0xffb5a72b,
+    0xf7b0a134, 0xae7e7639, 0x5b43412d, 0xba868342, 0xffb2a538, 0xffb0a449,
+    0xffac9f4e, 0xff9c9443, 0xff968e3d, 0xff9e9544, 0xfeab9f4d, 0xec978d45,
+    0xe6918a43, 0xffac9f50, 0xffaa9e4c, 0xff9a9040, 0xff948b3c, 0xff958d3c,
+    0xff978d3d, 0xff998d3e, 0xff243847, 0xff254250, 0xff2e2b2e, 0xff2f292d,
+    0xff312929, 0xff623025, 0xff553027, 0xff412925, 0xff632b1a, 0xffb44117,
+    0xffdf7b12, 0xffed9012, 0xfff8a21b, 0xfff6a012, 0xffef8e0e, 0xfff09212,
+    0xfff08b10, 0xffe87402, 0xffe97905, 0xffe8790f, 0xffd96002, 0xffe06d05,
+    0xffd45c05, 0xffda6405, 0xffd05506, 0xffd2550b, 0xffbf4005, 0xffca4e08,
+    0xffc74c09, 0xffd66108, 0xffcc580b, 0xffba4004, 0xffce5906, 0xffc2500b,
+    0xffa92e01, 0xffc6530f, 0xffb63d06, 0xffb4390c, 0xffaa2f04, 0xffa82d04,
+    0xffa92e05, 0xffa92d04, 0xffab3006, 0xffad3507, 0xff9a300f, 0xff332728,
+    0xff46302d, 0xff302c2d, 0xff31282b, 0xff2d2a2d, 0xff2c292e, 0xff2a3944,
+    0xff224252, 0xff1e6e91, 0xff227094, 0xff186a8b, 0xfe6d9e89, 0xff9ba958,
+    0xffb6a72b, 0xeca99e3b, 0x8c636134, 0x543e3b2b, 0x8f666238, 0xeba49b4a,
+    0xffafa44a, 0xfeaea34b, 0xfeaea34e, 0xffaba04e, 0xffa69c4a, 0xfaaa9f4f,
+    0xbd7f773a, 0x482c260d, 0x5138341c, 0xf8aba55c, 0xffa59b4a, 0xff978e3e,
+    0xff958d3b, 0xff968c3d, 0xff9e9042, 0xffad9c50, 0xff243642, 0xff214150,
+    0xff2e2a2c, 0xff2d2a2e, 0xff31292a, 0xff56342d, 0xff452c25, 0xff422b28,
+    0xff642e1a, 0xffae3309, 0xffd76a09, 0xffec8e13, 0xfffaa318, 0xffee8d0e,
+    0xffec8a0f, 0xfff39111, 0xffe47208, 0xffe47306, 0xffe36c07, 0xffda5c04,
+    0xffeb7d07, 0xffda6504, 0xffe77606, 0xffe26e05, 0xffcf5a07, 0xffc44908,
+    0xffd35207, 0xffcd4e09, 0xffd05307, 0xffd96609, 0xffc34c08, 0xffcb5306,
+    0xffca5808, 0xffb33b04, 0xffc65009, 0xffca5c14, 0xffaf3507, 0xffb93f0c,
+    0xffa82c03, 0xffa92e05, 0xffa82d03, 0xffa92e04, 0xffb53707, 0xffa92f06,
+    0xff9c2e0a, 0xff352626, 0xff513631, 0xff303c44, 0xff30282a, 0xff2d2b2f,
+    0xff2c2a30, 0xff283e4b, 0xff214657, 0xff196c8e, 0xff1f7092, 0xff1c6c8a,
+    0xff78a892, 0xffa5a94d, 0xcd938a38, 0x5e444027, 0x58413f2d, 0xb7817e48,
+    0xf6a9a04f, 0xffb0a346, 0xfeb0a43d, 0xfeb2a631, 0xffb2a540, 0xffada450,
+    0xeda29851, 0x86595328, 0x29171506, 0x452f2c1e, 0xad757140, 0xfdaea356,
+    0xffaca14f, 0xff9e9443, 0xff99903f, 0xffa9994b, 0xffb9a459, 0xffbca65d,
+    0xff243946, 0xff224456, 0xff2d282b, 0xff2d292d, 0xff362f31, 0xff41312f,
+    0xff3c2b29, 0xff3c2b2a, 0xff732a15, 0xffbc4004, 0xffea880f, 0xfff2991b,
+    0xffec910f, 0xffea850e, 0xffe9820d, 0xffe26d09, 0xffdf690b, 0xffde650d,
+    0xffda610b, 0xffe8750a, 0xffdf6b05, 0xffeb7c09, 0xffed8109, 0xffcc5602,
+    0xffd76713, 0xffda5b05, 0xffd35606, 0xffcf5109, 0xffd55a07, 0xffce5b06,
+    0xffd46009, 0xffc75105, 0xffbc4805, 0xffc44b05, 0xffe0720e, 0xffae3803,
+    0xffc0450d, 0xffaa2e03, 0xffaa2f06, 0xffa92e05, 0xffa82d02, 0xffb13607,
+    0xffb33805, 0xffae3006, 0xff9a2e0c, 0xff332625, 0xff523731, 0xff2b4a5b,
+    0xff31282a, 0xff2b2c33, 0xff2b2c30, 0xff283f4c, 0xff1f495e, 0xff16678b,
+    0xff1a6e93, 0xfe2b7286, 0xfc77a9a2, 0xaf777740, 0x43312d1d, 0x563c3b25,
+    0xd2938c49, 0xfeb0a344, 0xffb3a538, 0xffb2a62f, 0xfeb3a52b, 0xffb7a736,
+    0xffb9a64e, 0xcc8e844b, 0x4e322e15, 0x25161309, 0x7d565436, 0xe29a9452,
+    0xfdada253, 0xffaea351, 0xfeada24a, 0xffb5a351, 0xffbba35b, 0xffbea75e,
+    0xffae9c56, 0xff847b43, 0xff233b48, 0xff21465b, 0xff2c282a, 0xff2e292b,
+    0xff332c31, 0xff332828, 0xff372a29, 0xff362829, 0xff882e11, 0xffce5f0b,
+    0xffe98d15, 0xfff29719, 0xffe8850d, 0xffea810f, 0xffe57511, 0xffde670e,
+    0xffdb620b, 0xffda6c1a, 0xffd8600c, 0xffe26c08, 0xffe97d08, 0xffed8a0d,
+    0xffd96702, 0xffe78612, 0xffe8790a, 0xffdc6208, 0xffd1570c, 0xffd45406,
+    0xffc95106, 0xffd9690c, 0xffca5406, 0xffc04a05, 0xffc74f04, 0xffdc6809,
+    0xffc85809, 0xffb13505, 0xffbf410a, 0xffa82c04, 0xffaa3006, 0xffa82c03,
+    0xffac3205, 0xffb63a05, 0xffb63906, 0xffae3103, 0xff952e0f, 0xff312727,
+    0xff4e3834, 0xff294556, 0xff302b2b, 0xff2a3138, 0xff2a2a30, 0xff284351,
+    0xff1c4d64, 0xff13678c, 0xff156d94, 0xff407e7d, 0xec6da6af, 0x291c1b12,
+    0x6c4c482e, 0xeea39d58, 0xffafa444, 0xfeb3a62d, 0xfeb4a62c, 0xffb8a637,
+    0xfebaa549, 0xf3b39f59, 0xa1756b44, 0x2c1c170c, 0x3a262212, 0xb0797546,
+    0xfca8a056, 0xff988f4b, 0xfe867e42, 0xffaa9e40, 0xffb5a730, 0xffb7a63c,
+    0xffb3a04b, 0xff938846, 0xff736e3d, 0xff706b3c, 0xff263844, 0xff1e475c,
+    0xff2d282c, 0xff2e292c, 0xff312a2e, 0xff30292b, 0xff382a2a, 0xff332728,
+    0xffa14017, 0xffe07713, 0xffe78d17, 0xffea890f, 0xffec8711, 0xffe0700a,
+    0xffe17015, 0xffd65d09, 0xffdc6b20, 0xffd1590e, 0xffde6307, 0xffe67809,
+    0xfff0900e, 0xffe57707, 0xffef8d10, 0xffef8b0a, 0xffe06a05, 0xffe1730e,
+    0xffd35d0e, 0xffce5204, 0xffe27b1a, 0xffce5d09, 0xffc24c03, 0xffcf5806,
+    0xffd55d05, 0xffdd740a, 0xffb43e06, 0xffbe4009, 0xffae3204, 0xffac3206,
+    0xffa92f04, 0xffaf3305, 0xffb23905, 0xffbc3e07, 0xffb93c06, 0xffac2f04,
+    0xff8e2e10, 0xff312627, 0xff513a37, 0xff293f4f, 0xff322b2e, 0xff2b2b2f,
+    0xff2a2b2f, 0xff24495a, 0xff1d4e68, 0xff136688, 0xff15678a, 0xff4f8b87,
+    0xeb7aa7a3, 0x956d6641, 0xf3a79d55, 0xffb0a454, 0xfeb4a450, 0xffb9a644,
+    0xffbca64c, 0xffbea75a, 0xf5b39f5c, 0x7b595136, 0x25141109, 0x683f3c1f,
+    0xd8908b4c, 0xffa0984f, 0xff867f42, 0xfe6f6b39, 0xff797137, 0xffa2972f,
+    0xffb7a92c, 0xffa3982e, 0xff7a7336, 0xff6d6937, 0xff7b743d, 0xff928a47,
+    0xff26323d, 0xff20465a, 0xff2d292c, 0xff2d2a2d, 0xff30292b, 0xff30292a,
+    0xff392928, 0xff3a2825, 0xffc05a17, 0xffde7b11, 0xffe07710, 0xffe98310,
+    0xffe27408, 0xffee8b19, 0xffd95f09, 0xffd15e1b, 0xffd05711, 0xffd95a08,
+    0xffe37106, 0xfff18e0d, 0xffe87b08, 0xffe67d0b, 0xfff49814, 0xffe47705,
+    0xffe57409, 0xffe97d07, 0xffd35b04, 0xffeb7c0e, 0xffdc7115, 0xffc24b02,
+    0xffd05d05, 0xffd35705, 0xffe67e0d, 0xffc95b08, 0xffb33805, 0xffb83c05,
+    0xffaf3404, 0xffb23707, 0xffa82c04, 0xffb94206, 0xffb63b05, 0xffc14409,
+    0xffb63b05, 0xffaa2f04, 0xff8d3214, 0xff362725, 0xff523d3b, 0xff283d49,
+    0xff302e32, 0xff2c292d, 0xff2b2d32, 0xff24495d, 0xff1e4b5d, 0xff185e80,
+    0xff185873, 0xff5e9799, 0xfa95a784, 0xfbbba658, 0xffb3a356, 0xff9d904e,
+    0xffb59f58, 0xffbfa75b, 0xffbca55c, 0xffad9b4e, 0xf89c9148, 0xa96d693f,
+    0xaf6a6635, 0xf38f8741, 0xff8b8344, 0xff78723d, 0xfe6f683a, 0xff877f36,
+    0xffa69a30, 0xffb5a42e, 0xffb6a82b, 0xffa39937, 0xff7c7437, 0xff938a35,
+    0xffab9e33, 0xffb0a54d, 0xff283038, 0xff234658, 0xff2d292b, 0xff2c2a2d,
+    0xff31292b, 0xff33282b, 0xff3b2827, 0xff442822, 0xffd46b15, 0xffd2670b,
+    0xffe0710c, 0xffde6b06, 0xfff59d1b, 0xffe2710f, 0xffcb520e, 0xffcf5513,
+    0xffd35406, 0xffe16c08, 0xffed8008, 0xffe67b08, 0xffe77708, 0xffef8910,
+    0xffe77f0a, 0xffe6780a, 0xffeb8310, 0xffe77707, 0xffe5730c, 0xffe57c12,
+    0xffc74f03, 0xffd05d05, 0xffd35804, 0xffe4770a, 0xffda7409, 0xffbf490a,
+    0xffb83a06, 0xffb23504, 0xffbb3f08, 0xffad3004, 0xffac3105, 0xffb23904,
+    0xffc84a07, 0xffbe4206, 0xffb43a08, 0xffab2c05, 0xff933818, 0xff372523,
+    0xff503f3f, 0xff283c47, 0xff2d3036, 0xff2d292c, 0xff2a2e34, 0xff24485b,
+    0xff1d495c, 0xff1d546d, 0xff21566d, 0xfe65a1a9, 0xffada971, 0xffb39d57,
+    0xfe877b44, 0xfe706b3a, 0xff8c7e46, 0xffc1a95f, 0xffb39f52, 0xfe998f3f,
+    0xfe958b3c, 0xfd958d3f, 0xfe8c833e, 0xff78713a, 0xff706b3b, 0xfe7a713f,
+    0xffa29353, 0xffb5a449, 0xffb6a72f, 0xffb3a72f, 0xffb2a43c, 0xffb2a537,
+    0xffafa32f, 0xffb4a72a, 0xffb4a739, 0xffa79c4c
+};
diff --git a/demos/parrot.jpg b/demos/parrot.jpg
new file mode 100644 (file)
index 0000000..e7727f3
Binary files /dev/null and b/demos/parrot.jpg differ
diff --git a/demos/quad2quad.c b/demos/quad2quad.c
new file mode 100644 (file)
index 0000000..66b838f
--- /dev/null
@@ -0,0 +1,2183 @@
+#include <math.h>
+#include <stdio.h>
+#include <pixman.h>
+
+/* This code is basically the output of Maxima translated into C.
+ *
+ * See http://maxima.sourceforge.net/
+ */
+static void
+quad_to_quad (double x0, double y0,
+             double x1, double y1,
+             double x2, double y2,
+             double x3, double y3,
+
+             double px0, double py0,
+             double px1, double py1,
+             double px2, double py2,
+             double px3, double py3,
+
+             struct pixman_f_transform *trans)
+{
+    double
+       t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18,
+       t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34,
+       t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49, t50,
+       t51, t52, t53, t54, t55, t56, t57, t58, t59, t60, t61, t62, t63, t64, t65, t66,
+       t67, t68, t69, t70, t71, t72, t73, t74, t75, t76, t77, t78, t79, t80, t81, t82,
+       t83, t84, t85, t86, t87, t88, t89, t90, t91, t92, t93, t94, t95, t96, t97, t98,
+       t99, t100, t101, t102, t103, t104, t105, t106, t107, t108, t109, t110, t111,
+       t112, t113, t114, t115, t116, t117, t118, t119, t120, t121, t122, t123,
+       t124, t125, t126, t127, t128, t129, t130, t131, t132, t133, t134, t135,
+       t136, t137, t138, t139, t140, t141, t142, t143, t144, t145, t146, t147,
+       t148, t149, t150, t151, t152, t153, t154, t155, t156, t157, t158, t159,
+       t160, t161, t162, t163, t164, t165, t166, t167, t168, t169, t170, t171,
+       t172, t173, t174, t175, t176, t177, t178, t179, t180, t181, t182, t183,
+       t184, t185, t186, t187, t188, t189, t190, t191, t192, t193, t194, t195,
+       t196, t197, t198, t199, t200, t201, t202, t203, t204, t205, t206, t207,
+       t208, t209, t210, t211, t212, t213, t214, t215, t216, t217, t218, t219,
+       t220, t221, t222, t223, t224, t225, t226, t227, t228, t229, t230, t231,
+       t232, t233, t234, t235, t236, t237, t238, t239, t240, t241, t242, t243,
+       t244, t245, t246, t247, t248, t249, t250, t251, t252, t253, t254, t255,
+       t256, t257, t258, t259, t260, t261, t262, t263, t264, t265, t266, t267,
+       t268, t269, t270, t271, t272, t273, t274, t275, t276, t277, t278, t279,
+       t280, t281, t282, t283, t284, t285, t286, t287, t288, t289, t290, t291,
+       t292, t293, t294, t295, t296, t297, t298, t299, t300, t301, t302, t303,
+       t304, t305, t306, t307, t308, t309, t310, t311, t312, t313, t314, t315,
+       t316, t317, t318, t319, t320, t321, t322, t323, t324, t325, t326, t327,
+       t328, t329, t330, t331, t332, t333, t334, t335, t336, t337, t338, t339,
+       t340, t341, t342, t343, t344, t345, t346, t347, t348, t349, t350, t351,
+       t352, t353, t354, t355, t356, t357, t358, t359, t360, t361, t362, t363,
+       t364, t365, t366, t367, t368, t369, t370, t371, t372, t373, t374, t375,
+       t376, t377, t378, t379, t380, t381, t382, t383, t384, t385, t386, t387,
+       t388, t389, t390, t391, t392, t393, t394, t395, t396, t397, t398, t399,
+       t400, t401, t402, t403, t404, t405, t406, t407, t408, t409, t410, t411,
+       t412, t413, t414, t415, t416, t417, t418, t419, t420, t421, t422, t423,
+       t424, t425, t426, t427, t428, t429, t430, t431, t432, t433, t434, t435,
+       t436, t437, t438, t439, t440, t441, t442, t443, t444, t445, t446, t447,
+       t448, t449, t450, t451, t452, t453, t454, t455, t456, t457, t458, t459,
+       t460, t461, t462, t463, t464, t465, t466, t467, t468, t469, t470, t471,
+       t472, t473, t474, t475, t476, t477, t478, t479, t480, t481, t482, t483,
+       t484, t485, t486, t487, t488, t489, t490, t491, t492, t493, t494, t495,
+       t496, t497, t498, t499, t500, t501, t502, t503, t504, t505, t506, t507,
+       t508, t509, t510, t511, t512, t513, t514, t515, t516, t517, t518, t519,
+       t520, t521, t522, t523, t524, t525, t526, t527, t528, t529, t530, t531,
+       t532, t533, t534, t535, t536, t537, t538, t539, t540, t541, t542, t543,
+       t544, t545, t546, t547, t548, t549, t550, t551, t552, t553, t554, t555,
+       t556, t557, t558, t559, t560, t561, t562, t563, t564, t565, t566, t567,
+       t568, t569, t570, t571, t572, t573, t574, t575, t576, t577, t578, t579,
+       t580, t581, t582, t583, t584, t585, t586, t587, t588, t589, t590, t591,
+       t592, t593, t594, t595, t596, t597, t598, t599, t600, t601, t602, t603,
+       t604, t605, t606, t607, t608, t609, t610, t611, t612, t613, t614, t615,
+       t616, t617, t618, t619, t620, t621, t622, t623, t624, t625, t626, t627,
+       t628, t629, t630, t631, t632, t633, t634, t635, t636, t637, t638, t639,
+       t640, t641, t642, t643, t644, t645, t646, t647, t648, t649, t650, t651,
+       t652, t653, t654, t655, t656, t657, t658, t659, t660, t661, t662, t663,
+       t664, t665, t666, t667, t668, t669, t670, t671, t672, t673, t674, t675,
+       t676, t677, t678, t679, t680, t681, t682, t683, t684, t685, t686, t687,
+       t688, t689, t690, t691, t692, t693, t694, t695, t696, t697, t698, t699,
+       t700, t701, t702, t703, t704, t705, t706, t707, t708, t709, t710, t711,
+       t712, t713, t714, t715, t716, t717, t718, t719, t720, t721, t722, t723,
+       t724, t725, t726, t727, t728, t729, t730, t731, t732, t733, t734, t735,
+       t736, t737, t738, t739, t740, t741, t742, t743, t744, t745, t746, t747,
+       t748, t749, t750, t751, t752, t753, t754, t755, t756, t757, t758, t759,
+       t760, t761, t762, t763, t764, t765, t766, t767, t768, t769, t770, t771,
+       t772, t773, t774, t775, t776, t777, t778, t779, t780, t781, t782, t783,
+       t784, t785, t786, t787, t788, t789, t790, t791, t792, t793, t794, t795,
+       t796, t797, t798, t799, t800, t801, t802, t803, t804, t805, t806, t807,
+       t808, t809, t810, t811, t812, t813, t814, t815, t816, t817, t818, t819,
+       t820, t821, t822, t823, t824, t825, t826, t827, t828, t829, t830, t831,
+       t832, t833, t834, t835, t836, t837, t838, t839, t840, t841, t842, t843,
+       t844, t845, t846, t847, t848, t849, t850, t851, t852, t853, t854, t855,
+       t856, t857, t858, t859, t860, t861, t862, t863, t864, t865, t866, t867,
+       t868, t869, t870, t871, t872, t873, t874, t875, t876, t877, t878, t879,
+       t880, t881, t882, t883, t884, t885, t886, t887, t888, t889, t890, t891,
+       t892, t893, t894, t895, t896, t897, t898, t899, t900, t901, t902, t903,
+       t904, t905, t906, t907, t908, t909, t910, t911, t912, t913, t914, t915,
+       t916, t917, t918, t919, t920, t921, t922, t923, t924, t925, t926, t927,
+       t928, t929, t930, t931, t932, t933, t934, t935, t936, t937, t938, t939,
+       t940, t941, t942, t943, t944, t945, t946, t947, t948, t949, t950, t951,
+       t952, t953, t954, t955, t956, t957, t958, t959, t960, t961, t962, t963,
+       t964, t965, t966, t967, t968, t969, t970, t971, t972, t973, t974, t975,
+       t976, t977, t978, t979, t980, t981, t982, t983, t984, t985, t986, t987,
+       t988, t989, t990, t991, t992, t993, t994, t995, t996, t997, t998, t999,
+       t1000, t1001, t1002, t1003, t1004, t1005, t1006, t1007, t1008, t1009,
+       t1010, t1011, t1012, t1013, t1014, t1015, t1016, t1017, t1018, t1019,
+       t1020, t1021, t1022, t1023, t1024, t1025, t1026, t1027, t1028, t1029,
+       t1030, t1031, t1032, t1033, t1034, t1035, t1036, t1037, t1038, t1039,
+       t1040, t1041, t1042, t1043, t1044, t1045, t1046, t1047, t1048, t1049,
+       t1050, t1051, t1052, t1053, t1054, t1055, t1056, t1057, t1058, t1059,
+       t1060, t1061, t1062, t1063, t1064, t1065, t1066, t1067, t1068, t1069,
+       t1070, t1071, t1072, t1073;
+
+    t1 = y1 * y1;
+    t2 = x3 * x3;
+    t3 = px2 * px3 * t2;
+    t4 = (t3 - px2 * px3 * x2 * x3) * y2;
+    t5 = x2 * x2;
+    t6 = px2 * px3 * t5 * y3;
+
+    t7 = - px2 * px3 * x2 * x3 * y3;
+    t8 = py1 * (t7 + t6 + t4);
+    t9 = px3 * py2 * x2 * x3;
+
+    t10 = - px3 * py2 * t2;
+    t11 = (t10 + t9) * y2;
+    t12 = - px2 * py3 * t5 * y3;
+
+    t13 = px2 * py3 * x2 * x3 * y3;
+    t14 = y0 * y0;
+    t15 = - px3 * py2;
+    t16 = px2 * py3;
+
+    t17 = t16 + t15;
+    t18 = t17 * x2;
+    t19 = px3 * py2 * x3;
+    t20 = - px2 * py3 * x3;
+
+    t21 = t20 + t19 + t18;
+    t22 = px2 * px3 * t5;
+    t23 = - 2 * px2 * px3 * x2 * x3;
+
+    t24 = py1 * (t3 + t23 + t22);
+    t25 = - px2 * py3 * t5;
+    t26 = px2 * py3 * x3;
+
+    t27 = x2 * (t26 + t19);
+    t28 = t10 + t27 + t25;
+    t29 = x1 * x1;
+    t30 = px3 * py2;
+
+    t31 = - px2 * py3;
+    t32 = t31 + t30;
+    t33 = t32 * y2;
+    t34 = - px3 * py2 * y3;
+
+    t35 = px2 * py3 * y3;
+    t36 = t35 + t34 + t33;
+    t37 = - px2 * px3 * t2;
+
+    t38 = (t37 + px2 * px3 * x2 * x3) * y2;
+    t39 = - px2 * px3 * t5 * y3;
+
+    t40 = px2 * px3 * x2 * x3 * y3;
+    t41 = py1 * (t40 + t39 + t38);
+    t42 = - px2 * py3 * x2 * x3;
+
+    t43 = px3 * py2 * t2;
+    t44 = (t43 + t42) * y2;
+    t45 = px2 * py3 * t5 * y3;
+
+    t46 = - px3 * py2 * x2 * x3 * y3;
+    t47 = (px2 * px3 * x3 - px2 * px3 * x2) * y2;
+
+    t48 = px2 * px3 * x2 * y3;
+    t49 = - px2 * px3 * x3 * y3;
+    t50 = py1 * (t49 + t48 + t47);
+
+    t51 = px2 * py3 * x2;
+    t52 = - 2 * px3 * py2 * x3;
+    t53 = (t26 + t52 + t51) * y2;
+
+    t54 = px3 * py2 * x3 * y3;
+    t55 = px3 * py2 * y3;
+    t56 = - 2 * px2 * py3 * y3;
+    t57 = t56 + t55;
+
+    t58 = x2 * t57;
+    t59 = - px2 * px3 * t5;
+    t60 = 2 * px2 * px3 * x2 * x3;
+    t61 = - px2;
+
+    t62 = px3 + t61;
+    t63 = t62 * x2;
+    t64 = px2 * x3;
+    t65 = - px3 * x3;
+    t66 = t65 + t64 + t63;
+
+    t67 = px2 * t5;
+    t68 = - px2 * x3;
+    t69 = x2 * (t65 + t68);
+    t70 = px3 * t2;
+
+    t71 = t70 + t69 + t67;
+    t72 = - px3;
+    t73 = t72 + px2;
+    t74 = - px2 * y3;
+    t75 = px3 * y3;
+
+    t76 = t75 + t74 + t73 * y2;
+    t77 = px2 * x2 * x3;
+    t78 = - px3 * t2;
+    t79 = - px2 * t5 * y3;
+
+    t80 = px3 * x2 * x3 * y3;
+    t81 = t80 + t79 + (t78 + t77) * y2;
+
+    t82 = (px2 * px3 * x2 - px2 * px3 * x3) * y2;
+    t83 = - px2 * px3 * x2 * y3;
+
+    t84 = px2 * px3 * x3 * y3;
+    t85 = - px2 * x2;
+    t86 = 2 * px3 * x3;
+    t87 = - px3 * x3 * y3;
+
+    t88 = 2 * px2 * y3;
+    t89 = - px3 * y3;
+    t90 = t89 + t88;
+    t91 = x2 * t90;
+
+    t92 = t91 + t87 + (t86 + t68 + t85) * y2;
+    t93 = px2 * py3 * t5;
+    t94 = - px3 * py2 * x3;
+
+    t95 = x2 * (t20 + t94);
+    t96 = t32 * x2;
+    t97 = t73 * x2;
+    t98 = px3 * x3;
+
+    t99 = t98 + t68 + t97;
+    t100 = py1 * t99;
+    t101 = - px2 * t5;
+    t102 = x2 * (t98 + t64);
+
+    t103 = t78 + t102 + t101;
+    t104 = py1 * t103;
+    t105 = - py2;
+    t106 = py3 + t105;
+
+    t107 = py2 * y3;
+    t108 = - py3 * y3;
+    t109 = t108 + t107 + t106 * y2;
+    t110 = - px3 * x2 * x3;
+
+    t111 = px2 * t5 * y3;
+    t112 = - px2 * x2 * x3 * y3;
+    t113 = t112 + t111 + (t70 + t110) * y2;
+
+    t114 = - py2 * x3;
+    t115 = py3 * x3;
+    t116 = t115 + t114;
+    t117 = py2 * x3 * y3;
+
+    t118 = - py3 * x3 * y3;
+    t119 = t118 + t117;
+    t120 = x2 * t119;
+
+    t121 = px1 * (t120 + x2 * t116 * y2);
+    t122 = - px3 * py2 * x2;
+    t123 = (t19 + t122) * y2;
+
+    t124 = px2 * py3 * x2 * y3;
+    t125 = - px2 * py3 * x3 * y3;
+    t126 = px3 * x2;
+
+    t127 = - px2 * x2 * y3;
+    t128 = px2 * x3 * y3;
+    t129 = t128 + t127 + (t65 + t126) * y2;
+
+    t130 = - py3;
+    t131 = t130 + py2;
+    t132 = t131 * x2;
+    t133 = py2 * x3;
+    t134 = - py3 * x3;
+
+    t135 = - py2 * x3 * y3;
+    t136 = py3 * x3 * y3;
+    t137 = - py2 * y3;
+    t138 = py3 * y3;
+
+    t139 = t138 + t137;
+    t140 = x2 * t139;
+
+    t141 = px1 * (t140 + t136 + t135 + (t134 + t133 + t132) * y2);
+    t142 = y2 * y2;
+
+    t143 = - px3 * py2 * x3 * y3;
+    t144 = px2 * py3 * x3 * y3;
+    t145 = t144 + t143;
+
+    t146 = t142 * t145;
+    t147 = y3 * y3;
+    t148 = px3 * py2 * t147;
+    t149 = - px2 * py3 * t147;
+
+    t150 = t149 + t148;
+    t151 = x2 * y2 * t150;
+    t152 = t151 + t146;
+    t153 = - px2 * py3 * y3;
+
+    t154 = t153 + t55;
+    t155 = t142 * t154;
+    t156 = - px3 * py2 * t147;
+
+    t157 = px2 * py3 * t147;
+    t158 = t157 + t156;
+    t159 = y2 * t158;
+    t160 = t159 + t155;
+
+    t161 = x0 * x0;
+    t162 = py1 * t76;
+    t163 = px1 * t109;
+    t164 = px2 * y3;
+    t165 = t89 + t164;
+
+    t166 = - px2 * t147;
+    t167 = px3 * t147;
+    t168 = t167 + t166;
+
+    t169 = y2 * t168 + t142 * t165;
+    t170 = py1 * t169;
+    t171 = py2 * t147;
+
+    t172 = - py3 * t147;
+    t173 = t172 + t171;
+    t174 = y2 * t173 + t142 * t139;
+
+    t175 = px1 * t174;
+    t176 = t17 * t142;
+    t177 = px2 * t147;
+    t178 = - px3 * t147;
+
+    t179 = t178 + t177 + t62 * t142;
+    t180 = - py2 * t147;
+    t181 = py3 * t147;
+
+    t182 = t181 + t180 + t131 * t142;
+
+    t183 = y1 * (px1 * t182 + py1 * t179 + t149 + t148 + t176)
+       + t175 + t170 + t159 + t1 * (t163 + t162 + t35 + t34 + t33) + t155;
+
+    t184 = - px2 * px3 * t2 * t142;
+    t185 = 2 * px2 * px3 * x2 * x3 * y2 * y3;
+
+    t186 = - px2 * px3 * t5 * t147;
+    t187 = py1 * (t186 + t185 + t184);
+
+    t188 = px3 * py2 * t2 * t142;
+    t189 = x2 * y2 * (t125 + t143);
+    t190 = px2 * py3 * t5 * t147;
+
+    t191 = t190 + t189 + t188;
+    t192 = px2 * px3 * x3 * t142;
+    t193 = y2 * (t49 + t83);
+
+    t194 = px2 * px3 * x2 * t147;
+    t195 = py1 * (t194 + t193 + t192);
+
+    t196 = - px3 * py2 * x3 * t142;
+    t197 = 2 * px3 * py2 * x3 * y3;
+    t198 = 2 * px2 * py3 * y3;
+
+    t199 = t198 + t34;
+    t200 = x2 * t199;
+    t201 = y2 * (t200 + t125 + t197);
+
+    t202 = - px2 * py3 * x2 * t147;
+    t203 = - px2 * x3 * y3;
+    t204 = px3 * x3 * y3;
+
+    t205 = t204 + t203;
+    t206 = t142 * t205;
+    t207 = t178 + t177;
+    t208 = x2 * y2 * t207;
+
+    t209 = t208 + t206;
+    t210 = px2 * px3 * t2 * t142;
+    t211 = - 2 * px2 * px3 * x2 * x3 * y2 * y3;
+
+    t212 = px2 * px3 * t5 * t147;
+    t213 = - px3 * t2 * t142;
+    t214 = x2 * y2 * (t204 + t128);
+
+    t215 = - px2 * t5 * t147;
+    t216 = t215 + t214 + t213;
+    t217 = - px2 * px3 * x3 * t142;
+
+    t218 = y2 * (t84 + t48);
+    t219 = - px2 * px3 * x2 * t147;
+    t220 = px3 * x3 * t142;
+
+    t221 = - 2 * px3 * x3 * y3;
+    t222 = - 2 * px2 * y3;
+    t223 = t75 + t222;
+    t224 = x2 * t223;
+
+    t225 = y2 * (t224 + t221 + t128);
+    t226 = px2 * x2 * t147;
+    t227 = t226 + t225 + t220;
+
+    t228 = t125 + t54;
+    t229 = t142 * t228;
+    t230 = x2 * y2 * t158;
+    t231 = t87 + t128;
+
+    t232 = t142 * t231;
+    t233 = x2 * y2 * t168;
+    t234 = t233 + t232;
+    t235 = py1 * t234;
+
+    t236 = - px3 * py2 * t2 * t142;
+    t237 = x2 * y2 * (t144 + t54);
+
+    t238 = - px2 * py3 * t5 * t147;
+    t239 = px3 * t2 * t142;
+    t240 = x2 * y2 * (t87 + t203);
+
+    t241 = px2 * t5 * t147;
+    t242 = t241 + t240 + t239;
+    t243 = py1 * t242;
+
+    t244 = px2 * py3 * x3 * t142;
+    t245 = - px2 * py3 * x2 * y3;
+    t246 = y2 * (t143 + t245);
+
+    t247 = px3 * py2 * x2 * t147;
+    t248 = - px2 * x3 * t142;
+    t249 = px2 * x2 * y3;
+
+    t250 = y2 * (t204 + t249);
+    t251 = - px3 * x2 * t147;
+    t252 = t251 + t250 + t248;
+
+    t253 = t134 + t133;
+    t254 = t253 * t142;
+    t255 = t108 + t107;
+    t256 = x2 * t255;
+
+    t257 = t256 + t136 + t135;
+    t258 = y2 * t257;
+    t259 = t181 + t180;
+    t260 = x2 * t259;
+
+    t261 = px1 * (t260 + t258 + t254);
+    t262 = py1 * (t37 + t60 + t59);
+
+    t263 = t43 + t95 + t93;
+    t264 = px1 * t263;
+    t265 = t26 + t94;
+    t266 = x2 * t265 * y2;
+
+    t267 = x2 * t228;
+    t268 = t267 + t266;
+    t269 = py1 * (t84 + t83 + t82);
+
+    t270 = - 2 * px2 * py3;
+    t271 = (t26 + (t270 + t30) * x2) * y2;
+    t272 = px3 * py2 * x2 * y3;
+
+    t273 = - 2 * px3 * py2 * x3 * y3;
+    t274 = t149 + t148 + t176;
+
+    t275 = py1 * (t212 + t211 + t210);
+    t276 = t238 + t237 + t236;
+    t277 = px1 * t276;
+
+    t278 = py1 * (t219 + t218 + t217);
+    t279 = 2 * px3 * py2 * x3;
+    t280 = t20 + t279;
+
+    t281 = t280 * t142;
+    t282 = - px3 * py2 * x2 * y3;
+    t283 = y2 * (t125 + t282);
+
+    t284 = 2 * px2 * py3 * t147;
+    t285 = x2 * (t284 + t156);
+    t286 = px1 * t103;
+
+    t287 = t98 + t68;
+    t288 = x2 * t287 * y2;
+    t289 = x2 * t231;
+    t290 = t289 + t288;
+
+    t291 = 2 * px2;
+    t292 = - px3 * x2 * y3;
+    t293 = 2 * px3 * x3 * y3;
+
+    t294 = t293 + t203 + t292 + (t68 + (t72 + t291) * x2) * y2;
+    t295 = px1 * t242;
+
+    t296 = - 2 * px3 * x3;
+    t297 = t296 + t64;
+    t298 = px3 * x2 * y3;
+    t299 = y2 * (t128 + t298);
+
+    t300 = - 2 * px2 * t147;
+    t301 = x2 * (t167 + t300) + t299 + t297 * t142;
+    t302 = py1 * t71;
+
+    t303 = py1 * t290;
+    t304 = 2 * py2 * x3;
+    t305 = - 2 * py3 * x3;
+    t306 = - 2 * py2 * x3 * y3;
+
+    t307 = 2 * py3 * x3 * y3;
+    t308 = t307 + t306;
+    t309 = - 2 * px2 * py3 * x3;
+
+    t310 = (t309 + t19 + t51) * y2;
+    t311 = - 2 * px3 * py2 * y3;
+    t312 = t35 + t311;
+
+    t313 = x2 * t312;
+    t314 = 2 * px2 * x3;
+    t315 = 2 * px3 * y3;
+    t316 = t315 + t74;
+
+    t317 = x2 * t316;
+    t318 = t317 + t87 + (t65 + t314 + t85) * y2;
+    t319 = t106 * x2;
+
+    t320 = px1 * (t256 + t118 + t117 + (t115 + t114 + t319) * y2);
+    t321 = py1 * t216;
+
+    t322 = 2 * px2 * py3 * x3 * y3;
+    t323 = 2 * px3 * py2 * y3;
+    t324 = t153 + t323;
+
+    t325 = x2 * t324;
+    t326 = y2 * (t325 + t322 + t143);
+    t327 = - 2 * px2 * x3 * y3;
+
+    t328 = - 2 * px3 * y3;
+    t329 = t328 + t164;
+    t330 = x2 * t329;
+
+    t331 = y2 * (t330 + t204 + t327);
+    t332 = t226 + t331 + t220;
+    t333 = t116 * t142;
+
+    t334 = t140 + t118 + t117;
+    t335 = y2 * t334;
+    t336 = x2 * t173;
+
+    t337 = px1 * (t336 + t335 + t333);
+    t338 = t26 + t94 + t96;
+    t339 = t17 * y2;
+
+    t340 = t153 + t55 + t339;
+    t341 = px2 * px3 * t142;
+    t342 = - 2 * px2 * px3 * y2 * y3;
+
+    t343 = px2 * px3 * t147;
+    t344 = py1 * (t343 + t342 + t341);
+    t345 = - px2 * py3 * t142;
+
+    t346 = y2 * (t35 + t55);
+    t347 = t156 + t346 + t345;
+    t348 = px1 * t347 + t344;
+
+    t349 = t89 + t164 + t62 * y2;
+    t350 = - px2 * px3 * t142;
+    t351 = 2 * px2 * px3 * y2 * y3;
+
+    t352 = - px2 * px3 * t147;
+    t353 = px2 * t142;
+    t354 = y2 * (t89 + t74);
+
+    t355 = t167 + t354 + t353;
+    t356 = px1 * t355 + t352 + t351 + t350;
+    t357 = py1 * t66;
+
+    t358 = py1 * t349;
+    t359 = 2 * py2;
+    t360 = - 2 * py3;
+    t361 = - 2 * py2 * y3;
+
+    t362 = 2 * py3 * y3;
+    t363 = px3 * py2 * t142;
+    t364 = y2 * (t153 + t34);
+
+    t365 = - px3 * t142;
+    t366 = y2 * (t75 + t164);
+    t367 = t166 + t366 + t365;
+
+    t368 = py1 * t367;
+    t369 = px1 * (t172 + t171 + t106 * t142);
+    t370 = t35 + t34;
+
+    t371 = t142 * t370;
+    t372 = y2 * t150;
+    t373 = t372 + t371;
+    t374 = t230 + t229;
+
+    t375 = py1 * (t352 + t351 + t350);
+    t376 = t157 + t364 + t363;
+    t377 = px1 * t376 + t375;
+
+    t378 = t75 + t74;
+    t379 = y2 * t207 + t142 * t378;
+    t380 = px1 * t367 + t343 + t342 + t341;
+
+    t381 = py1 * t209;
+    t382 = py1 * t355;
+    t383 = py1 * t379;
+    t384 = 2 * py2 * y3;
+
+    t385 = - 2 * py3 * y3;
+    t386 = t385 + t384;
+    t387 = - 2 * py2 * t147;
+    t388 = 2 * py3 * t147;
+
+    t389 = px2 * py3 * t2;
+    t390 = t389 + t10;
+    t391 = x2 * t390 * y2;
+    t392 = t5 * t228;
+
+    t393 = - px2 * t2;
+    t394 = t70 + t393;
+    t395 = x2 * t394 * y2;
+    t396 = t5 * t231;
+
+    t397 = t396 + t395;
+    t398 = py1 * t397;
+    t399 = py2 * t2;
+    t400 = - py3 * t2;
+
+    t401 = t400 + t399;
+    t402 = x2 * t401 * y2;
+    t403 = t136 + t135;
+    t404 = t5 * t403;
+
+    t405 = t404 + t402;
+    t406 = px1 * t405;
+    t407 = t1 * (t406 + t398 + t392 + t391);
+
+    t408 = t65 + t64;
+    t409 = t5 * t408;
+    t410 = x2 * t394;
+    t411 = t410 + t409;
+
+    t412 = py1 * t411;
+    t413 = t5 * t116;
+    t414 = x2 * t401;
+    t415 = t414 + t413;
+
+    t416 = px1 * t415;
+    t417 = py2 * t5;
+    t418 = x2 * (t134 + t114);
+    t419 = py3 * t2;
+
+    t420 = t419 + t418 + t417;
+    t421 = px1 * t420;
+    t422 = t265 * y2;
+    t423 = x2 * t154;
+
+    t424 = px2 * x2;
+    t425 = (t68 + t424) * y2;
+    t426 = - py2 * x2;
+    t427 = (t133 + t426) * y2;
+
+    t428 = py3 * x2 * y3;
+    t429 = t20 + t19;
+    t430 = x2 * t429;
+    t431 = - px2 * py3 * t2;
+
+    t432 = (t431 + t43 + t430) * y2;
+    t433 = t5 * t370;
+    t434 = x2 * t145;
+
+    t435 = - px2 * x2 * x3;
+    t436 = px2 * t2;
+    t437 = (t436 + t435) * y2;
+    t438 = px3 * t5 * y3;
+
+    t439 = - px3 * x2 * x3 * y3;
+    t440 = py2 * x2 * x3;
+    t441 = - py2 * t2;
+
+    t442 = (t441 + t440) * y2;
+    t443 = - py3 * t5 * y3;
+    t444 = py3 * x2 * x3 * y3;
+
+    t445 = t5 * t287;
+    t446 = t78 + t436;
+    t447 = x2 * t446;
+    t448 = - t2;
+
+    t449 = t448 + 2 * x2 * x3 - t5;
+    t450 = px1 * t449;
+    t451 = (t98 + t85) * y2;
+    t452 = - x2 * y3;
+
+    t453 = x3 * y3;
+    t454 = t453 + t452 + (x2 - x3) * y2;
+    t455 = px1 * t454;
+    t456 = t65 + t314;
+
+    t457 = x2 * t456;
+    t458 = (t78 + t457) * y2;
+    t459 = x2 * (t293 + t203);
+
+    t460 = - x2 * x3 * y3 + t5 * y3 + (t2 - x2 * x3) * y2;
+    t461 = px1 * t460;
+    t462 = t5 * t253;
+
+    t463 = t419 + t441;
+    t464 = x2 * t463;
+    t465 = - py2 * t5;
+    t466 = x2 * (t115 + t133);
+
+    t467 = t2 - 2 * x2 * x3 + t5;
+    t468 = py1 * t467;
+    t469 = py2 * x2;
+    t470 = (t134 + t469) * y2;
+
+    t471 = - py2 * x2 * y3;
+    t472 = x2 * y3;
+    t473 = - x3 * y3;
+    t474 = t473 + t472 + (x3 - x2) * y2;
+
+    t475 = py1 * t474;
+    t476 = - 2 * py2 * x3;
+    t477 = t115 + t476;
+    t478 = x2 * t477;
+
+    t479 = (t419 + t478) * y2;
+    t480 = py2 * t5 * y3;
+    t481 = - 2 * py3 * x3 * y3;
+
+    t482 = x2 * (t481 + t117);
+    t483 = x2 * x3 * y3 - t5 * y3 + (t448 + x2 * x3) * y2;
+
+    t484 = py1 * t483;
+    t485 = t431 + t43;
+    t486 = t485 * t142;
+    t487 = t5 * t158;
+
+    t488 = t446 * t142;
+    t489 = t5 * t168;
+    t490 = t489 + t488;
+    t491 = py1 * t490;
+
+    t492 = t463 * t142;
+    t493 = t5 * t173;
+    t494 = t493 + t492;
+    t495 = px1 * t494;
+
+    t496 = x1 * y1 * (t495 + t491 + t487 + t486);
+    t497 = t142 * t119;
+    t498 = x2 * y2 * t259;
+
+    t499 = t498 + t497;
+    t500 = px1 * t499;
+    t501 = t29 * (t500 + t381 + t151 + t146);
+
+    t502 = t429 * t142;
+    t503 = x2 * t370;
+    t504 = y2 * (t503 + t125 + t54);
+    t505 = x2 * t158;
+
+    t506 = - px3 * x3 * t142;
+    t507 = - px2 * x2 * t147;
+    t508 = py3 * x3 * t142;
+
+    t509 = y2 * (t118 + t471);
+    t510 = py2 * x2 * t147;
+    t511 = - py2 * t142;
+
+    t512 = y2 * (t138 + t107);
+    t513 = t172 + t512 + t511;
+    t514 = px1 * t513;
+
+    t515 = y2 * t259 + t142 * t255;
+    t516 = px1 * t515;
+    t517 = py1 * t454;
+
+    t518 = - py2 * x3 * t142;
+    t519 = t108 + t384;
+    t520 = x2 * t519;
+
+    t521 = y2 * (t520 + t307 + t135);
+    t522 = - py3 * x2 * t147;
+    t523 = py2 * t142;
+
+    t524 = y2 * (t108 + t137);
+    t525 = - t147 + 2 * y2 * y3 - t142;
+    t526 = py1 * t525;
+
+    t527 = x2 * t147 + y2 * (t473 + t452) + x3 * t142;
+    t528 = py1 * t527;
+    t529 = px1 * t474;
+
+    t530 = px2 * x3 * t142;
+    t531 = px3 * x2 * t147;
+
+    t532 = - x2 * t147 + y2 * (t453 + t472) - x3 * t142;
+    t533 = px1 * t532;
+
+    t534 = - px2 * t142;
+    t535 = t147 - 2 * y2 * y3 + t142;
+    t536 = px1 * t535;
+
+    t537 = t447 + t445;
+    t538 = py1 * t537;
+    t539 = t464 + t462;
+    t540 = px1 * t539;
+
+    t541 = 2 * px3 * py2 * t2;
+    t542 = - 2 * px2 * py3 * t2;
+    t543 = x2 * t446 * y2;
+
+    t544 = t5 * t205;
+    t545 = t544 + t543;
+    t546 = py1 * t545;
+    t547 = x2 * t463 * y2;
+
+    t548 = t5 * t119;
+    t549 = t548 + t547;
+    t550 = px1 * t549;
+    t551 = x2 * t265;
+
+    t552 = (t389 + t10 + t551) * y2;
+    t553 = t5 * t154;
+    t554 = 2 * px3 * t2;
+
+    t555 = (t554 + t393 + t110) * y2;
+    t556 = t5 * t90;
+    t557 = py3 * x2 * x3;
+
+    t558 = - 2 * py3 * t2;
+    t559 = (t558 + t399 + t557) * y2;
+    t560 = py2 * x2 * x3 * y3;
+
+    t561 = t138 + t361;
+    t562 = t5 * t561;
+    t563 = t390 * t142;
+    t564 = t5 * t150;
+
+    t565 = - px2 * t2 * t142;
+    t566 = - px3 * t5 * t147;
+    t567 = t566 + t214 + t565;
+
+    t568 = py1 * t567;
+    t569 = py2 * t2 * t142;
+    t570 = x2 * y2 * (t118 + t135);
+
+    t571 = py3 * t5 * t147;
+    t572 = t571 + t570 + t569;
+    t573 = px1 * t572;
+    t574 = t86 + t68;
+
+    t575 = x2 * t574;
+    t576 = (t78 + t575) * y2;
+    t577 = 2 * px2 * x3 * y3;
+
+    t578 = x2 * (t87 + t577);
+    t579 = px1 * t527;
+
+    t580 = - t5 * t147 + 2 * x2 * x3 * y2 * y3 - t2 * t142;
+    t581 = px1 * t580;
+    t582 = t305 + t133;
+
+    t583 = x2 * t582;
+    t584 = (t419 + t583) * y2;
+    t585 = x2 * (t136 + t306);
+
+    t586 = py1 * t532;
+    t587 = - py3 * t2 * t142;
+    t588 = x2 * y2 * (t136 + t117);
+
+    t589 = - py2 * t5 * t147;
+    t590 = t5 * t147 - 2 * x2 * x3 * y2 * y3 + t2 * t142;
+
+    t591 = py1 * t590;
+    t592 = t400 + t466 + t465;
+    t593 = px1 * t592;
+    t594 = t309 + t279;
+
+    t595 = t198 + t311;
+    t596 = x2 * t378;
+    t597 = t596 + t408 * y2;
+    t598 = py1 * t597;
+
+    t599 = t256 + t116 * y2;
+    t600 = px1 * t599;
+    t601 = t178 + t366 + t534;
+
+    t602 = py1 * t601;
+    t603 = t181 + t524 + t523;
+    t604 = px1 * t603;
+    t605 = t265 * t142;
+
+    t606 = t423 + t144 + t143;
+    t607 = y2 * t606;
+    t608 = x2 * t150;
+    t609 = 2 * py2 * x3 * y3;
+
+    t610 = t362 + t137;
+    t611 = x2 * t610;
+    t612 = y2 * (t611 + t118 + t609);
+
+    t613 = py1 * t449;
+    t614 = t419 + t613 + t418 + t417;
+    t615 = py1 * t460;
+
+    t616 = py1 * t535;
+    t617 = t616 + t172 + t512 + t511;
+    t618 = t134 + t304;
+
+    t619 = t618 * t142;
+    t620 = - py3 * x2 * y3;
+    t621 = y2 * (t135 + t620);
+
+    t622 = x2 * (t388 + t180);
+    t623 = px1 * t467;
+    t624 = t623 + t78 + t102 + t101;
+
+    t625 = px1 * t483;
+    t626 = px1 * t525;
+    t627 = t167 + t626 + t354 + t353;
+
+    t628 = - 2 * px2 * x3;
+    t629 = t98 + t628;
+    t630 = t629 * t142;
+    t631 = - 2 * px3 * t147;
+
+    t632 = x2 * (t631 + t177);
+    t633 = - 2 * px2 * py3 * x3 * y3;
+    t634 = t633 + t197;
+
+    t635 = - 2 * px3 * py2 * t147;
+    t636 = t142 * t403;
+    t637 = x2 * y2 * t173;
+
+    t638 = t637 + t636;
+    t639 = px1 * t638;
+    t640 = t589 + t588 + t587;
+    t641 = px1 * t640;
+
+    t642 = px1 * t590;
+    t643 = py1 * t580;
+
+    t644 = (x0 * (px0 * (y1 * (x1 * (t528 + t522 + t612 + t518)
+                              + t643 + t571 + t570 + t569)
+                        + t29 * t515 + x1 * t638 + t1 * (t615 + t444 + t443 + t442))
+                 + py0 * (y1 * (x1 * (t533 + t531 + t331 + t530)
+                                + t642 + t566 + t214 + t565)
+                          + x1 * t234 + t29 * t379 + t1 * (t625 + t439 + t438 + t437))
+                 + y1 * (x1 * (px1 * (t622 + t621 + t619) + py1 * (t632 + t299 + t630)
+                               + t608 + t607 + t605)
+                         + t641 + t243 + t564 + t563)
+                 + x1 * (t639 + t235 + x2 * y2 * (t284 + t635) + t142 * t634)
+                 + t29 * (t175 + t170)
+                 + t1 * (px1 * (t482 + t480 + t479) + py1 * (t459 + t79 + t458) + t434
+                         + t433 + t432))
+           + y0 * (x0 * (py0 * (x1 * (t579 + t632 + t299 + t630)
+                                + t489 + t29 * t627
+                                + y1 * (x1 * t597 + t625 + t556 + t112 + t555) + t488
+                                + t624 * t1)
+                         + px0 * (x1 * (t586 + t622 + t621 + t619)
+                                  + t29 * t617 + t493
+                                  + y1 * (x1 * t599 + t615 + t562 + t560 + t559) + t492
+                                  + t614 * t1)
+                         + x1 * (px1 * (t522 + t612 + t518) + py1 * (t531 + t331 + t530)
+                                 + t608 + t607 + t605)
+                         + t29 * (t604 + t602) + t487
+                         + y1 * (x1 * (t600 + t598 + x2 * t595 + t594 * y2)
+                                 + px1 * (t585 + t480 + t584) + py1 * (t578 + t79 + t576) + t267
+                                 + t553 + t552) + t486 + (t593 + t302) * t1)
+                   + px0 * (x1 * (t591 + t589 + t588 + t587)
+                            + t29 * (t586 + t510 + t509 + t508)
+                            + y1 * (x1 * (t484 + t585 + t480 + t584) + t548 + t547) + t415 * t1)
+                   + py0 * (x1 * (t581 + t241 + t240 + t239)
+                            + t29 * (t579 + t507 + t250 + t506)
+                            + y1 * (x1 * (t461 + t578 + t79 + t576) + t544 + t543) + t411 * t1)
+                   + x1 * (t573 + t568 + t564 + t563)
+                   + t29 * (px1 * (t522 + t521 + t518) + py1 * (t531 + t225 + t530) + t505
+                            + t504 + t502)
+                   + y1 * (x1 * (px1 * (t562 + t560 + t559) + py1 * (t556 + t112 + t555)
+                                 + t267 + t553 + t552)
+                           + t550 + t546 + t5 * (t322 + t273) + x2 * (t542 + t541) * y2)
+                   + (t540 + t538) * t1)
+           + t161 * (py0 * (y1 * (x1 * (t536 + t178 + t366 + t534)
+                                  + t533 + t531 + t225 + t530)
+                            + x1 * t169 + t208 + t1 * (t529 + t204 + t292 + t425) + t206)
+                     + px0 * (y1 * (t528 + x1 * (t181 + t526 + t524 + t523) + t522 + t521
+                                    + t518)
+                              + x1 * t174 + t498 + t1 * (t517 + t118 + t428 + t427) + t497)
+                     + x1 * (t516 + t383)
+                     + y1 * (x1 * (t514 + t382) + px1 * (t510 + t509 + t508)
+                             + py1 * (t507 + t250 + t506) + t505 + t504
+                             + t502) + t151
+                     + t1 * (px1 * (t136 + t471 + t470) + py1 * (t87 + t249 + t451) + t423
+                             + t422) + t146) + t501 + t496
+           + t14 * (px0 * (x1 * (t484 + t482 + t480 + t479)
+                           + t29 * (t475 + t136 + t471 + t470) + t404 + t402
+                           + (x1 * (t468 + t400 + t466 + t465) + t464 + t462) * y1)
+                    + py0 * (x1 * (t461 + t459 + t79 + t458)
+                             + t29 * (t455 + t87 + t249 + t451) + t396 + t395
+                             + (x1 * (t70 + t450 + t69 + t67) + t447 + t445) * y1)
+                    + x1 * (px1 * (t444 + t443 + t442) + py1 * (t439 + t438 + t437) + t434
+                            + t433 + t432)
+                    + t29 * (px1 * (t118 + t428 + t427) + py1 * (t204 + t292 + t425) + t423
+                             + t422) + t392 + t391
+                    + (x1 * (t421 + t104) + t416 + t412) * y1) + t407);
+    t645 = t5 * t265;
+
+    t646 = t115 + t114 + t132;
+    t647 = px1 * t646;
+    t648 = x2 * t485;
+    t649 = t32 * t5;
+
+    t650 = t70 + t393 + t73 * t5;
+    t651 = t400 + t399 + t106 * t5;
+
+    t652 = t540 + x1 * (px1 * t651 + py1 * t650 + t389 + t10 + t649) + t538 + t648
+       + t29 * (t647 + t357 + t20 + t19 + t18) + t645;
+    t653 = t648 + t645;
+
+    t654 = t392 + t391;
+    t655 = px1 * t654;
+    t656 = t309 + t19;
+    t657 = x2 * t656;
+
+    t658 = (t389 + t657) * y2;
+    t659 = px3 * py2 * t5 * y3;
+    t660 = x2 * (t144 + t273);
+
+    t661 = - px3 * py2 * t5;
+    t662 = t431 + t27 + t661;
+    t663 = px1 * t662 + t24;
+
+    t664 = t5 * t429;
+    t665 = x2 * t390;
+    t666 = t665 + t664;
+    t667 = px3 * py2 * x2;
+
+    t668 = (t20 + t667) * y2;
+    t669 = x2 * t485 * y2;
+    t670 = t5 * t145;
+    t671 = t670 + t669;
+
+    t672 = px1 * t671;
+    t673 = t26 + t52;
+    t674 = x2 * t673;
+    t675 = (t389 + t674) * y2;
+
+    t676 = x2 * (t633 + t54);
+    t677 = px3 * t5;
+    t678 = t436 + t69 + t677;
+
+    t679 = px1 * t678 + t37 + t60 + t59;
+    t680 = - px3 * x2;
+
+    t681 = t203 + t298 + (t64 + t680) * y2;
+    t682 = px1 * t545;
+    t683 = - px3 * t5 * y3;
+
+    t684 = t578 + t683 + (t393 + t575) * y2;
+    t685 = 2 * py3 * x3;
+    t686 = t685 + t476;
+
+    t687 = 2 * py2 * t2;
+    t688 = px1 * (t419 + t441 + t131 * t5);
+    t689 = - px2 * py3 * x2;
+
+    t690 = 2 * px2 * py3 * x3;
+    t691 = (t690 + t94 + t689) * y2;
+
+    t692 = t330 + t204 + (t98 + t628 + t424) * y2;
+    t693 = t134 + t133 + t319;
+
+    t694 = px1 * (t140 + t118 + t117 + t693 * y2);
+    t695 = (t542 + t43 + t9) * y2;
+
+    t696 = t5 * t312;
+    t697 = 2 * px2 * t2;
+    t698 = t5 * t316 + t112 + (t78 + t697 + t110) * y2;
+
+    t699 = x2 * t253;
+    t700 = t5 * t255;
+    t701 = x2 * t403;
+
+    t702 = px1 * (t701 + t700 + (t419 + t441 + t699) * y2);
+    t703 = px2 * py3 * x2 * x3;
+
+    t704 = (t10 + t703) * y2;
+    t705 = px3 * py2 * x2 * x3 * y3;
+    t706 = (t20 + t279 + t689) * y2;
+
+    t707 = t439 + t111 + (t70 + t435) * y2;
+    t708 = t224 + t204 + (t296 + t64 + t424) * y2;
+
+    t709 = - 2 * py2;
+    t710 = 2 * py3;
+    t711 = py1 * t678;
+
+    t712 = t459 + t683 + (t393 + t457) * y2;
+    t713 = x2 * t116;
+    t714 = t5 * t139;
+
+    t715 = px1 * (t120 + t714 + (t400 + t399 + t713) * y2);
+    t716 = 2 * px2 * py3;
+
+    t717 = (t94 + (t716 + t15) * x2) * y2;
+    t718 = - 2 * px2;
+
+    t719 = t221 + t128 + t249 + (t98 + (px3 + t718) * x2) * y2;
+
+    t720 = px1 * (t256 + t136 + t135 + t646 * y2);
+    t721 = - px2 * py3 * t2 * t142;
+
+    t722 = - px3 * py2 * t5 * t147;
+    t723 = t722 + t237 + t721;
+    t724 = - px2 * py3 * x3 * t142;
+
+    t725 = y2 * (t54 + t124);
+    t726 = px1 * y2 * t257;
+    t727 = - px3 * py2 * x2 * t147;
+
+    t728 = y2 * (t87 + t127);
+    t729 = t531 + t728 + t530;
+    t730 = px2 * py3 * t2 * t142;
+
+    t731 = px3 * py2 * t5 * t147;
+    t732 = px1 * t397;
+    t733 = t251 + t299 + t248;
+
+    t734 = px2 * t2 * t142;
+    t735 = px3 * t5 * t147;
+    t736 = t735 + t240 + t734;
+
+    t737 = t389 + t10 + t649;
+    t738 = t731 + t189 + t730;
+    t739 = px1 * t738;
+
+    t740 = x2 * t165;
+    t741 = t740 + t204 + t203;
+    t742 = py1 * y2 * t741;
+    t743 = py1 * t736;
+
+    t744 = px2 * py3 * t142;
+    t745 = px1 * t567;
+    t746 = t148 + t364 + t744;
+
+    t747 = px3 * py2 * t5;
+    t748 = t389 + t95 + t747;
+    t749 = (t26 + t122) * y2;
+
+    t750 = x2 * t280;
+    t751 = (t431 + t750) * y2;
+    t752 = - px3 * py2 * t5 * y3;
+
+    t753 = x2 * (t322 + t143);
+    t754 = - px3 * t5;
+    t755 = t393 + t102 + t754;
+
+    t756 = t128 + t292 + (t68 + t126) * y2;
+    t757 = x2 * t297;
+    t758 = x2 * (t204 + t327);
+
+    t759 = t758 + t438 + (t436 + t757) * y2;
+    t760 = (t94 + t667) * y2;
+
+    t761 = t203 + t249 + (t98 + t680) * y2;
+    t762 = px1 * (t140 + t253 * y2);
+
+    t763 = - px3 * py2 * x2 * x3;
+    t764 = (t43 + t763) * y2;
+    t765 = - px2 * py3 * x2 * x3 * y3;
+
+    t766 = px3 * x2 * x3;
+    t767 = px2 * x2 * x3 * y3;
+    t768 = t767 + t79 + (t78 + t766) * y2;
+
+    t769 = px1 * (t120 + t700 + (t419 + t441 + t713) * y2);
+    t770 = t501 + t496 + t407;
+
+    t771 = px3 * py2 * x3 * t142;
+    t772 = y2 * (t313 + t633 + t54);
+
+    t773 = px2 * py3 * x2 * t147;
+    t774 = - px3 * py2 * t142;
+    t775 = t149 + t346 + t774;
+
+    t776 = y2 * (t317 + t87 + t577);
+    t777 = t507 + t776 + t506;
+    t778 = px3 * t142;
+
+    t779 = t177 + t354 + t778;
+    t780 = y2 * (t144 + t272);
+    t781 = y2 * (t203 + t292);
+
+    t782 = t531 + t781 + t530;
+    t783 = px1 * (t336 + t258 + t333);
+    t784 = t690 + t94;
+
+    t785 = x2 * t784;
+    t786 = (t431 + t785) * y2;
+    t787 = x2 * (t125 + t197);
+
+    t788 = x2 * t629;
+    t789 = x2 * (t221 + t128);
+    t790 = t789 + t438 + (t436 + t788) * y2;
+
+    t791 = - 2 * py2 * t2;
+    t792 = 2 * py3 * t2;
+    t793 = 2 * px2 * py3 * t2;
+
+    t794 = (t793 + t10 + t42) * y2;
+    t795 = t5 * t324;
+    t796 = - 2 * px2 * t2;
+
+    t797 = t5 * t329 + t80 + (t70 + t796 + t77) * y2;
+
+    t798 = px1 * (t701 + t714 + (t400 + t399 + t699) * y2);
+
+    t799 = px1 * (t5 * t259 + t401 * t142);
+    t800 = t429 * y2;
+    t801 = t503 + t800;
+
+    t802 = t487 + t486;
+    t803 = t673 * t142;
+    t804 = - 2 * px2 * py3 * t147;
+
+    t805 = x2 * (t804 + t148);
+    t806 = 2 * px2 * t147;
+
+    t807 = x2 * (t178 + t806) + t728 + t574 * t142;
+    t808 = py1 * t755;
+    t809 = py1 * t779;
+
+    t810 = y2 * (t58 + t144 + t273);
+    t811 = y2 * (t91 + t293 + t203);
+
+    t812 = t507 + t811 + t506;
+    t813 = px1 * (t260 + t335 + t254);
+    t814 = 2 * py2 * t147;
+
+    t815 = - 2 * py3 * t147;
+    t816 = (t389 + t42) * y2;
+    t817 = - py2 * py3 * t2;
+
+    t818 = (t817 + py2 * py3 * x2 * x3) * y2;
+    t819 = - py2 * py3 * t5 * y3;
+
+    t820 = py2 * py3 * x2 * x3 * y3;
+    t821 = px1 * (t820 + t819 + t818);
+    t822 = - py2 * py3 * t5;
+
+    t823 = 2 * py2 * py3 * x2 * x3;
+    t824 = px1 * (t817 + t823 + t822);
+    t825 = (t431 + t9) * y2;
+
+    t826 = py2 * py3 * t2;
+    t827 = (t826 - py2 * py3 * x2 * x3) * y2;
+    t828 = py2 * py3 * t5 * y3;
+
+    t829 = - py2 * py3 * x2 * x3 * y3;
+    t830 = px1 * (t829 + t828 + t827);
+
+    t831 = (py2 * py3 * x2 - py2 * py3 * x3) * y2;
+    t832 = - py2 * py3 * x2 * y3;
+
+    t833 = py2 * py3 * x3 * y3;
+    t834 = px1 * (t833 + t832 + t831);
+
+    t835 = (t690 + t94 + t122) * y2;
+    t836 = px1 * t693;
+    t837 = - py2 * t5 * y3;
+
+    t838 = t560 + t837 + (t400 + t557) * y2;
+    t839 = x2 * t205;
+
+    t840 = py1 * (t839 + x2 * t408 * y2);
+    t841 = (t20 + t51) * y2;
+    t842 = - py3 * x2;
+
+    t843 = py2 * x2 * y3;
+    t844 = t135 + t843 + (t115 + t842) * y2;
+
+    t845 = py1 * (t740 + t87 + t128 + (t98 + t68 + t63) * y2);
+    t846 = py2 * py3 * t5;
+
+    t847 = - 2 * py2 * py3 * x2 * x3;
+    t848 = - py2 * x2 * x3;
+    t849 = - py3 * x2 * x3 * y3;
+
+    t850 = t849 + t480 + (t419 + t848) * y2;
+    t851 = (py2 * py3 * x3 - py2 * py3 * x2) * y2;
+
+    t852 = py2 * py3 * x2 * y3;
+    t853 = - py2 * py3 * x3 * y3;
+    t854 = x2 * t561;
+
+    t855 = t854 + t136 + (t305 + t133 + t469) * y2;
+    t856 = py2 * py3 * t2 * t142;
+
+    t857 = - 2 * py2 * py3 * x2 * x3 * y2 * y3;
+    t858 = py2 * py3 * t5 * t147;
+
+    t859 = px1 * (t858 + t857 + t856);
+    t860 = - py2 * py3 * x3 * t142;
+
+    t861 = y2 * (t833 + t852);
+    t862 = - py2 * py3 * x2 * t147;
+
+    t863 = px1 * (t862 + t861 + t860);
+    t864 = - py2 * py3 * t2 * t142;
+
+    t865 = 2 * py2 * py3 * x2 * x3 * y2 * y3;
+    t866 = - py2 * py3 * t5 * t147;
+
+    t867 = py3 * t2 * t142;
+    t868 = py2 * t5 * t147;
+    t869 = t868 + t570 + t867;
+
+    t870 = py2 * py3 * x3 * t142;
+    t871 = y2 * (t853 + t832);
+    t872 = py2 * py3 * x2 * t147;
+
+    t873 = - py3 * x3 * t142;
+    t874 = - py2 * x2 * t147;
+    t875 = t874 + t521 + t873;
+
+    t876 = py2 * x3 * t142;
+    t877 = py3 * x2 * t147;
+    t878 = t877 + t509 + t876;
+
+    t879 = t287 * t142;
+    t880 = t596 + t87 + t128;
+    t881 = y2 * t880;
+    t882 = x2 * t207;
+
+    t883 = py1 * (t882 + t881 + t879);
+    t884 = py1 * t662;
+
+    t885 = px1 * (t826 + t847 + t846);
+    t886 = 2 * px3 * py2;
+
+    t887 = (t94 + (t31 + t886) * x2) * y2;
+    t888 = px1 * (t853 + t852 + t851);
+
+    t889 = py1 * t738;
+    t890 = px1 * (t866 + t865 + t864);
+
+    t891 = px1 * (t872 + t871 + t870);
+    t892 = t656 * t142;
+    t893 = x2 * (t157 + t635);
+
+    t894 = t221 + t577;
+    t895 = x2 * t253 * y2;
+    t896 = t701 + t895;
+    t897 = px1 * t896;
+
+    t898 = (t20 + t279 + t122) * y2;
+
+    t899 = py1 * (t596 + t204 + t203 + (t65 + t64 + t97) * y2);
+    t900 = t385 + t107;
+
+    t901 = x2 * t900;
+    t902 = t901 + t136 + (t115 + t476 + t469) * y2;
+    t903 = px1 * t869;
+
+    t904 = t874 + t612 + t873;
+    t905 = t408 * t142;
+    t906 = y2 * t741;
+    t907 = x2 * t168;
+
+    t908 = py1 * (t907 + t906 + t905);
+    t909 = - py2 * py3 * t142;
+
+    t910 = 2 * py2 * py3 * y2 * y3;
+    t911 = - py2 * py3 * t147;
+
+    t912 = px1 * (t911 + t910 + t909);
+    t913 = t912 + py1 * t376;
+
+    t914 = t481 + t117 + t428 + (t133 + (py3 + t709) * x2) * y2;
+    t915 = 2 * px3;
+
+    t916 = t138 + t137 + t131 * y2;
+    t917 = px1 * t916;
+
+    t918 = py1 * (t167 + t166 + t73 * t142);
+    t919 = py3 * t142;
+    t920 = t171 + t524 + t919;
+
+    t921 = px1 * t920;
+    t922 = py2 * py3 * t142;
+    t923 = - 2 * py2 * py3 * y2 * y3;
+
+    t924 = py2 * py3 * t147;
+    t925 = py1 * t513 + t924 + t923 + t922;
+    t926 = py1 * t420;
+
+    t927 = py1 * t640;
+    t928 = t685 + t114;
+    t929 = x2 * (t172 + t814) + t621 + t928 * t142;
+
+    t930 = px1 * (t924 + t923 + t922);
+    t931 = t930 + py1 * t347;
+
+    t932 = py1 * t920 + t911 + t910 + t909;
+    t933 = t315 + t222;
+    t934 = py1 * t654;
+
+    t935 = (t10 + t750) * y2;
+    t936 = t824 + py1 * t263;
+    t937 = py1 * t671;
+
+    t938 = (t19 + t689) * y2;
+    t939 = (t10 + t785) * y2;
+    t940 = t296 + t314;
+
+    t941 = py1 * (t78 + t436 + t62 * t5);
+    t942 = (t26 + t52 + t667) * y2;
+
+    t943 = py1 * (t740 + t204 + t203 + t99 * y2);
+
+    t944 = t611 + t118 + (t134 + t304 + t426) * y2;
+    t945 = (t431 + t541 + t42) * y2;
+
+    t946 = t5 * t199;
+    t947 = t5 * t900 + t560 + (t419 + t791 + t557) * y2;
+    t948 = x2 * t287;
+
+    t949 = t5 * t378;
+    t950 = py1 * (t289 + t949 + (t78 + t436 + t948) * y2);
+
+    t951 = - py3 * t5;
+    t952 = t441 + t466 + t951;
+    t953 = py1 * t952 + t826 + t847 + t846;
+
+    t954 = py3 * x2;
+    t955 = t117 + t620 + (t114 + t954) * y2;
+    t956 = py1 * t549;
+
+    t957 = py3 * t5 * y3;
+    t958 = t585 + t957 + (t399 + t583) * y2;
+    t959 = (t389 + t763) * y2;
+
+    t960 = (t309 + t19 + t667) * y2;
+    t961 = - 2 * px3;
+    t962 = px1 * t952;
+    t963 = x2 * t408;
+
+    t964 = t5 * t165;
+    t965 = py1 * (t839 + t964 + (t70 + t393 + t963) * y2);
+
+    t966 = t482 + t957 + (t399 + t478) * y2;
+    t967 = - 2 * px3 * py2;
+
+    t968 = (t26 + (t16 + t967) * x2) * y2;
+
+    t969 = t307 + t135 + t471 + (t134 + (t130 + t359) * x2) * y2;
+
+    t970 = py1 * (t596 + t87 + t128 + t66 * y2);
+    t971 = t444 + t837 + (t400 + t440) * y2;
+
+    t972 = t520 + t118 + (t685 + t114 + t426) * y2;
+    t973 = py1 * t405;
+
+    t974 = t877 + t621 + t876;
+    t975 = - py2 * t2 * t142;
+    t976 = - py3 * t5 * t147;
+
+    t977 = t976 + t588 + t975;
+    t978 = py1 * y2 * t880;
+    t979 = y2 * (t136 + t843);
+
+    t980 = t522 + t979 + t518;
+    t981 = py1 * t276;
+    t982 = py1 * t572;
+    t983 = px1 * y2 * t334;
+
+    t984 = px1 * t977;
+    t985 = (t94 + t51) * y2;
+    t986 = (t43 + t657) * y2;
+
+    t987 = (t26 + t689) * y2;
+    t988 = t117 + t471 + (t134 + t954) * y2;
+
+    t989 = py1 * (t740 + t287 * y2);
+    t990 = (t431 + t703) * y2;
+    t991 = - py3 * x2 * x3;
+
+    t992 = - py2 * x2 * x3 * y3;
+    t993 = t992 + t480 + (t419 + t991) * y2;
+
+    t994 = py1 * (t839 + t949 + (t78 + t436 + t963) * y2);
+    t995 = py3 * t5;
+
+    t996 = t399 + t418 + t995;
+    t997 = t135 + t428 + (t133 + t842) * y2;
+    t998 = x2 * t928;
+
+    t999 = x2 * (t118 + t609);
+    t1000 = t999 + t443 + (t441 + t998) * y2;
+
+    t1001 = y2 * (t901 + t136 + t306);
+    t1002 = t510 + t1001 + t508;
+    t1003 = - py3 * t142;
+
+    t1004 = t180 + t512 + t1003;
+    t1005 = y2 * (t117 + t428);
+    t1006 = t522 + t1005 + t518;
+
+    t1007 = py1 * (t907 + t881 + t905);
+    t1008 = y2 * (t854 + t481 + t117);
+
+    t1009 = t510 + t1008 + t508;
+    t1010 = 2 * px3 * t147;
+
+    t1011 = py1 * (t5 * t207 + t394 * t142);
+    t1012 = t784 * t142;
+
+    t1013 = 2 * px3 * py2 * t147;
+    t1014 = x2 * (t149 + t1013);
+
+    t1015 = py1 * (t882 + t906 + t879);
+    t1016 = x2 * (t181 + t387) + t979 + t582 * t142;
+
+    t1017 = (t43 + t674) * y2;
+    t1018 = x2 * t618;
+    t1019 = x2 * (t307 + t135);
+
+    t1020 = t1019 + t443 + (t441 + t1018) * y2;
+    t1021 = - 2 * px3 * t2;
+
+    t1022 = - 2 * px3 * py2 * t2;
+    t1023 = (t389 + t1022 + t9) * y2;
+    t1024 = t5 * t57;
+
+    t1025 = t5 * t610 + t849 + (t400 + t687 + t848) * y2;
+
+    t1026 = py1 * (t289 + t964 + (t70 + t393 + t948) * y2);
+    t1027 = px1 * t996;
+
+    t1028 = px1 * t1004;
+    t1029 = x2 * t429 * y2;
+    t1030 = (t436 + t110) * y2;
+
+    t1031 = (t441 + t557) * y2;
+    t1032 = (t393 + t77) * y2;
+    t1033 = (t399 + t848) * y2;
+
+    t1034 = (t26 + t94 + t18) * y2;
+    t1035 = (t64 + t85) * y2;
+    t1036 = (t114 + t469) * y2;
+
+    t1037 = (t98 + t628 + t126) * y2;
+    t1038 = (t134 + t304 + t842) * y2;
+
+    t1039 = (t20 + t19 + t96) * y2;
+    t1040 = (t296 + t64 + t126) * y2;
+
+    t1041 = (t685 + t114 + t842) * y2;
+    t1042 = (t98 + (t961 + px2) * x2) * y2;
+
+    t1043 = t456 * t142;
+    t1044 = x2 * (t1010 + t166);
+
+    t1045 = (t134 + (t710 + t105) * x2) * y2;
+    t1046 = t477 * t142;
+
+    t1047 = x2 * (t815 + t171);
+    t1048 = t32 * t142;
+    t1049 = t171 + t526 + t524 + t919;
+
+    t1050 = t536 + t166 + t366 + t365;
+    t1051 = (t389 + t10 + t430) * y2;
+
+    t1052 = (t393 + t766) * y2;
+    t1053 = (t399 + t991) * y2;
+    t1054 = t17 * t5;
+
+    t1055 = (t431 + t43 + t551) * y2;
+    t1056 = (t1021 + t436 + t77) * y2;
+    t1057 = t5 * t223;
+
+    t1058 = (t792 + t441 + t848) * y2;
+    t1059 = t5 * t519;
+    t1060 = t338 * y2;
+
+    t1061 = (t86 + t68 + t680) * y2;
+    t1062 = (t305 + t133 + t954) * y2;
+
+    t1063 = (t115 + t426) * y2;
+    t1064 = (t400 + t1018) * y2;
+    t1065 = (t65 + t424) * y2;
+
+    t1066 = (t70 + t788) * y2;
+    t1067 = (t70 + t757) * y2;
+    t1068 = (t400 + t998) * y2;
+
+    t1069 = t21 * y2;
+    t1070 = (t68 + (t915 + t61) * x2) * y2;
+
+    t1071 = (t133 + (t360 + py2) * x2) * y2;
+    t1072 = (t115 + t476 + t954) * y2;
+
+    t1073 = (t65 + t314 + t680) * y2;
+
+    trans->m[0][0]
+       = (x0 * (px0 * (x1 * (px1 * (y2 * (t388 + t387) + t142 * t386)
+                             + t383 + t372 + t371)
+                       + y1 * (x1 * (t369 + t382 + t156 + t346 + t345)
+                               + t337 + py1 * t301 + t285 + t283 + t281) + t381 + t151
+                       + t1 * (t141 + py1 * t92 + t58 + t54 + t53) + t146)
+                + py0 * (y1 * (x1 * t380 + px1 * t332 + t219 + t218 + t217)
+                         + px1 * t234 + px1 * x1 * t379 + t1 * (px1 * t129 + t49 + t48 + t47))
+                + y1 * (x1 * t377 + px1 * (t202 + t326 + t196) + t195) + px1 * t374
+                + px1 * x1 * t373 + t1 * (px1 * (t125 + t124 + t123) + t269))
+          + y0 * (x0 * (px0 * (t261 + x1 * (t369 + t368 + t157 + t364 + t363) + py1 * t227
+                               + t202
+                               + y1
+                               * (x1
+                                  * (px1 * (t362 + t361 + (t360 + t359) * y2)
+                                     + t358 + t153 + t55 + t339)
+                                  + t320 + py1 * t294 + t144 + t273 + t272 + t271)
+                               + t201 + t196 + (t357 + t20 + t19 + t18) * t1)
+                        + py0 * (x1 * t356 + px1 * t252 + t194
+                                 + y1 * (px1 * t318 + px1 * x1 * t349 + t84 + t83 + t82)
+                                 + t193 + t192 + px1 * t99 * t1) + x1 * t348
+                        + px1 * (t247 + t246 + t244) + t278
+                        + y1 * (px1 * (t313 + t54 + t310) + t50 + px1 * x1 * t340)
+                        + px1 * t338 * t1)
+                  + px0 * (x1 * (t337 + py1 * t332 + t202 + t326 + t196)
+                           + t321 + px1 * t29 * t182 + t190
+                           + y1 * (x1 * (t320 + py1 * t318 + t313 + t54 + t310)
+                                   + px1 * (x2 * t308 + x2 * (t305 + t304) * y2) + t303 + t267
+                                   + t266) + t189 + t188 + (t302 + t10 + t27 + t25) * t1)
+                  + py0 * (x1 * (px1 * t301 + t194 + t193 + t192)
+                           + t295 + px1 * t29 * t179 + t186
+                           + y1 * (x1 * (px1 * t294 + t49 + t48 + t47) + px1 * t290) + t185 + t184
+                           + (t286 + t3 + t23 + t22) * t1)
+                  + x1 * (px1 * (t285 + t283 + t281) + t278) + t277 + t275 + px1 * t29 * t274
+                  + y1 * (x1 * (px1 * (t144 + t273 + t272 + t271) + t269) + px1 * t268)
+                  + (t264 + t262) * t1)
+          + px0 * (y1 * (x1 * (t261 + py1 * t252 + t247 + t246 + t244)
+                         + t243 + t238 + t237 + t236)
+                   + x1 * (t235 + t230 + t229) + px1 * t29 * t174
+                   + t1 * (t121 + py1 * t81 + t46 + t45 + t44))
+          + py0 * (y1 * (x1 * (px1 * t227 + t219 + t218 + t217)
+                         + px1 * t216 + t212 + t211 + t210)
+                   + px1 * t29 * t169 + px1 * x1 * t209 + t1 * (px1 * t113 + t40 + t39 + t38))
+          + y1 * (x1 * (px1 * (t202 + t201 + t196) + t195) + px1 * t191 + t187)
+          + px0 * t161 * t183 + px1 * t29 * t160 + px1 * x1 * t152
+          + t14 * (px0 * (x1 * (t141 + py1 * t129 + t125 + t124 + t123)
+                          + t121 + py1 * t113 + px1 * t29 * t109 + t13 + t12 + t11
+                          + (t104 + t43 + x1 * (t100 + t26 + t94 + t96) + t95 + t93) * y1)
+                   + py0 * (x1 * (px1 * t92 + t84 + t83 + t82)
+                            + px1 * t81 + px1 * t29 * t76 + t7 + t6 + t4
+                            + (px1 * t71 + t37 + px1 * x1 * t66 + t60 + t59) * y1)
+                   + x1 * (px1 * (t58 + t54 + t53) + t50) + px1 * (t46 + t45 + t44) + t41
+                   + px1 * t29 * t36 + (px1 * t28 + t24 + px1 * x1 * t21) * y1)
+          + t1 * (px1 * (t13 + t12 + t11) + t8));
+
+    trans->m[0][1] =
+       (t161 * (px0 * (x1 * (t382 + t156 + t346 + t345)
+                       + py1 * t733 + t247
+                       + y1 * (t694 + x1 * (t358 + t153 + t55 + t339) + py1 * t681
+                               + t144 + t282 + t668) + t726 + t283 + t244
+                       + px1 * t646 * t1)
+                + py0 * (x1 * (px1 * t601 + t343 + t342 + t341)
+                         + px1 * t729 + t219
+                         + y1 * (px1 * t692 + px1 * x1 * t76 + t49 + t48 + t47) + t218
+                         + t217 + px1 * t66 * t1) + x1 * (px1 * t746 + t375)
+                + px1 * (t727 + t725 + t724) + t195
+                + y1 * (px1 * (t325 + t143 + t691) + t269 + px1 * x1 * t36)
+                + px1 * t21 * t1)
+        + x0 * (py0 * (t29 * t356 + t745 + t212
+                       + y1
+                       * (x1 * (px1 * t719 + t84 + t83 + t82)
+                          + px1 * t698 + t40 + t39 + t38) + px1 * x1 * y2 * t741
+                       + t211 + t210 + px1 * t650 * t1)
+                + px0 * (t29 * (t602 + t148 + t364 + t744)
+                         + t743 + t722
+                         + y1 * (x1 * (t720 + py1 * t708 + t200 + t143 + t706)
+                                 + t702 + py1 * t684 + t676 + t659 + t675)
+                         + x1 * (t607 + px1 * y2 * (x2 * (t362 + t361) + t481 + t609) + t742)
+                         + t237 + t721 + px1 * t651 * t1) + t29 * t348 + t739 + t187
+                + y1 * (x1 * (px1 * (t125 + t197 + t245 + t717) + t50)
+                        + px1 * (t696 + t13 + t695) + t8) + px1 * x1 * y2 * t606
+                + px1 * t737 * t1)
+        + py0 * (x1 * (px1 * t736 + t186 + t185 + t184)
+                 + t29 * (px1 * t733 + t194 + t193 + t192)
+                 + y1 * (x1 * (px1 * t712 + t7 + t6 + t4) + t732) + px1 * t537 * t1)
+        + px0 * (x1 * (t568 + t731 + t189 + t730)
+                 + t29 * (py1 * t729 + t727 + t726 + t725 + t724)
+                 + y1 * (x1 * (t715 + py1 * t707 + t705 + t12 + t704) + t546 + t670 + t669)
+                 + px1 * t539 * t1) + x1 * (px1 * t723 + t275)
+        + t29 * (px1 * (t247 + t283 + t244) + t278)
+        + y0 * (x0 * (px0 * (x1 * (t720 + py1 * t719 + t125 + t197 + t245 + t717)
+                             + t715 + py1 * t712 + t29 * (t162 + t35 + t34 + t33) + t660
+                             + t659 + t658
+                             + (t688 + t711 + t431
+                                + x1
+                                * (px1 * (t305 + t304 + (t710 + t709) * x2)
+                                   + t100 + t26 + t94 + t96) + t27 + t661)
+                             * y1)
+                      + py0 * (x1 * (px1 * t708 + t49 + t48 + t47)
+                               + px1 * t707 + px1 * t29 * t349 + t40 + t39 + t38
+                               + (t286 + t3 + px1 * x1 * t99 + t23 + t22) * y1)
+                      + x1 * (px1 * (t200 + t143 + t706) + t269) + px1 * (t705 + t12 + t704)
+                      + t8 + px1 * t29 * t340 + (t264 + t262 + px1 * x1 * t338) * y1)
+                + px0 * (x1 * (t702 + py1 * t698 + t696 + t13 + t695)
+                         + t29 * (t694 + py1 * t692 + t325 + t143 + t691) + t398 + t392 + t391
+                         + (x1 * (t688 + t104 + t43 + t95 + t93)
+                            + px1 * (x2 * (t558 + t687) + t5 * t686) + t412 + t665 + t664)
+                         * y1)
+                + py0 * (x1 * (px1 * t684 + t7 + t6 + t4) + t682
+                         + t29 * (px1 * t681 + t84 + t83 + t82)
+                         + (px1 * t411 + x1 * t679) * y1)
+                + x1 * (px1 * (t676 + t659 + t675) + t41) + t672
+                + t29 * (px1 * (t144 + t282 + t668) + t50) + (px1 * t666 + x1 * t663) * y1)
+        + y1 * (x1 * (px1 * (t660 + t659 + t658) + t41) + t655) + px1 * t653 * t1
+        + px0 * t652 * t14)
+       ;
+
+    trans->m[0][2] =
+       (x0 * (px0 * (y1 * (x1 * (t813 + py1 * t807 + t805 + t725 + t803)
+                           + t799 + t568 + t731 + t189 + t730)
+                     + x1 * (px1 * (x2 * y2 * (t815 + t814) + t142 * t308)
+                             + t235 + t230 + t229) + t29 * (t170 + t159 + t155)
+                     + t1 * (t769 + py1 * t759 + t753 + t752 + t751))
+              + py0 * (y1 * (x1 * (px1 * t812 + t194 + t193 + t192)
+                             + t295 + t186 + t185 + t184)
+                       + px1 * x1 * t234 + px1 * t29 * t379
+                       + t1 * (px1 * t768 + t7 + t6 + t4))
+              + y1 * (x1 * (px1 * (t773 + t810 + t771) + t278) + t277 + t275)
+              + px1 * x1 * t374 + px1 * t29 * t373
+              + t1 * (px1 * (t765 + t45 + t764) + t41))
+        + y0 * (x0 * (px0 * (x1 * (t813 + py1 * t812 + t773 + t810 + t771)
+                             + t495 + t29 * (t809 + t149 + t346 + t774)
+                             + y1
+                             * (x1
+                                * (px1 * (x2 * t386 + t686 * y2)
+                                   + t598 + t503 + t800)
+                                + t798 + py1 * t790 + t787 + t752 + t786)
+                             + (t808 + t389 + t95 + t747) * t1)
+                      + py0 * (x1 * (px1 * t807 + t219 + t218 + t217)
+                               + px1 * t490 + t29 * t380
+                               + y1 * (px1 * x1 * t597 + px1 * t797 + t7 + t6 + t4)
+                               + t679 * t1)
+                      + x1 * (px1 * (t805 + t725 + t803) + t195) + px1 * t802
+                      + t29 * t377
+                      + y1 * (px1 * x1 * t801 + px1 * (t795 + t46 + t794) + t41)
+                      + t663 * t1)
+                + px0 * (x1 * (t799 + t243 + t238 + t237 + t236)
+                         + t29 * (t783 + py1 * t777 + t773 + t772 + t771)
+                         + y1 * (x1 * (t798 + py1 * t797 + t795 + t46 + t794)
+                                 + px1 * (t5 * (t481 + t609) + x2 * (t792 + t791) * y2)
+                                 + t546 + t670 + t669) + (t538 + t648 + t645) * t1)
+                + py0 * (x1 * (t745 + t212 + t211 + t210)
+                         + t29 * (px1 * t782 + t219 + t218 + t217)
+                         + y1 * (x1 * (px1 * t790 + t40 + t39 + t38) + t682)
+                         + px1 * t411 * t1) + x1 * (t739 + t187)
+                + t29 * (px1 * (t727 + t780 + t724) + t195)
+                + y1 * (x1 * (px1 * (t787 + t752 + t786) + t8) + t672)
+                + px1 * t666 * t1)
+        + t161 * (px0 * (y1
+                         * (t783 + x1 * (t368 + t157 + t364 + t363) + py1 * t782
+                            + t727 + t780 + t724)
+                         + x1 * (t383 + t372 + t371) + t500
+                         + t1 * (t762 + py1 * t756 + t125 + t272 + t749))
+                  + py0 * (y1
+                           * (x1 * (px1 * t779 + t352 + t351 + t350)
+                              + px1 * t777 + t194 + t193 + t192)
+                           + px1 * x1 * t169 + px1 * t209
+                           + t1 * (px1 * t761 + t84 + t83 + t82))
+                  + y1 * (x1 * (px1 * t775 + t344) + px1 * (t773 + t772 + t771)
+                          + t278) + px1 * x1 * t160
+                  + px1 * t152 + t1 * (px1 * (t144 + t245 + t760) + t50))
+        + px0 * t770
+        + t14 * (px0 * (x1 * (t769 + py1 * t768 + t765 + t45 + t764)
+                        + t29 * (t762 + py1 * t761 + t144 + t245 + t760) + t406
+                        + (t412 + x1 * (t711 + t431 + t27 + t661) + t665 + t664)
+                        * y1)
+                 + py0 * (x1 * (px1 * t759 + t40 + t39 + t38)
+                          + t732 + t29 * (px1 * t756 + t49 + t48 + t47)
+                          + (px1 * t537 + x1 * (px1 * t755 + t3 + t23 + t22)) * y1)
+                 + x1 * (px1 * (t753 + t752 + t751) + t8) + t655
+                 + t29 * (px1 * (t125 + t272 + t749) + t269)
+                 + (x1 * (px1 * t748 + t262) + px1 * t653) * y1));
+
+    trans->m[1][0] = (x0 * (py0 * (x1 * (t516 + py1 * (y2 * (t631 + t806) + t142 * t933) + t372
+                                        + t371)
+                                  + y1 * (px1 * t929 + x1 * (t514 + t918 + t157 + t364 + t363) + t908
+                                          + t893 + t725 + t892) + t500 + t151
+                                  + t1 * (px1 * t855 + t845 + t325 + t125 + t835) + t146)
+                           + px0 * (y1 * (x1 * t932 + py1 * t904 + t872 + t871 + t870)
+                                    + py1 * x1 * t515 + py1 * t638
+                                    + t1 * (py1 * t844 + t833 + t832 + t831))
+                           + y1 * (x1 * t931 + t863 + py1 * (t247 + t810 + t244)) + py1 * t374
+                           + py1 * x1 * t373 + t1 * (t888 + py1 * (t54 + t282 + t841)))
+                     + y0 * (px0 * (x1 * (py1 * t929 + t862 + t861 + t860)
+                                    + t927 + py1 * t29 * t182 + t858
+                                    + y1 * (py1 * t896 + x1 * (py1 * t914 + t833 + t832 + t831)) + t857
+                                    + t856 + (t926 + t817 + t823 + t822) * t1)
+                             + x0 * (px0 * (x1 * t925 + py1 * t878 + t862
+                                            + y1
+                                            * (py1 * t902 + py1 * x1 * t916 + t853 + t852
+                                               + t851) + t861 + t860
+                                            + py1 * t693 * t1)
+                                     + py0 * (x1 * (t921 + t918 + t156 + t346 + t345)
+                                              + t883 + px1 * t875 + t247
+                                              + y1 * (x1 * (t917 + py1 * (t328 + t88 + (t915 + t718) * y2)
+                                                            + t153 + t55 + t339)
+                                                      + t899 + px1 * t914 + t322 + t143 + t245 + t887) + t772
+                                              + t244 + (t647 + t20 + t19 + t18) * t1) + x1 * t913 + t891
+                                     + py1 * (t202 + t780 + t196)
+                                     + y1 * (py1 * (t200 + t125 + t898) + t834 + py1 * x1 * t340)
+                                     + py1 * t338 * t1)
+                             + py0 * (x1 * (t908 + px1 * t904 + t247 + t810 + t244)
+                                      + t903 + py1 * t29 * t179 + t722
+                                      + y1 * (x1 * (px1 * t902 + t899 + t200 + t125 + t898)
+                                              + t897 + py1 * (x2 * t894 + x2 * (t86 + t628) * y2) + t267
+                                              + t266) + t237 + t721 + (t593 + t389 + t95 + t747) * t1)
+                             + x1 * (py1 * (t893 + t725 + t892) + t891) + t890 + t889 + py1 * t29 * t274
+                             + y1 * (x1 * (t888 + py1 * (t322 + t143 + t245 + t887)) + py1 * t268)
+                             + (t885 + t884) * t1)
+                     + py0 * (y1 * (x1 * (t883 + px1 * t878 + t202 + t780 + t196)
+                                    + t641 + t731 + t189 + t730)
+                              + x1 * (t639 + t230 + t229) + py1 * t29 * t169
+                              + t1 * (t840 + px1 * t850 + t13 + t752 + t825))
+                     + px0 * (y1 * (x1 * (py1 * t875 + t872 + t871 + t870)
+                                    + py1 * t869 + t866 + t865 + t864)
+                              + py1 * x1 * t499 + py1 * t29 * t174
+                              + t1 * (py1 * t838 + t829 + t828 + t827))
+                     + y1 * (x1 * (t863 + py1 * (t247 + t772 + t244)) + t859 + py1 * t723)
+                     + py0 * t161 * t183 + py1 * t29 * t160 + py1 * x1 * t152
+                     + t14 * (px0 * (x1 * (py1 * t855 + t853 + t852 + t851)
+                                     + py1 * t850 + py1 * t29 * t109 + t820 + t819 + t818
+                                     + (py1 * t592 + t826 + py1 * x1 * t646 + t847 + t846) * y1)
+                              + py0 * (x1 * (t845 + px1 * t844 + t54 + t282 + t841)
+                                       + t840 + px1 * t838 + py1 * t29 * t76 + t46 + t659 + t816
+                                       + (t421 + t431 + x1 * (t836 + t26 + t94 + t96) + t27 + t661) * y1)
+                              + x1 * (py1 * (t325 + t125 + t835) + t834) + t830
+                              + py1 * (t13 + t752 + t825) + py1 * t29 * t36
+                              + (t824 + py1 * t748 + py1 * x1 * t21) * y1)
+                     + t1 * (t821 + py1 * (t46 + t659 + t816)))
+       ;
+
+    trans->m[1][1] = (t161 * (px0 * (x1 * (py1 * t603 + t911 + t910 + t909)
+                                    + py1 * t980 + t872
+                                    + y1 * (py1 * t944 + py1 * x1 * t109 + t833 + t832 + t831) + t871
+                                    + t870 + py1 * t646 * t1)
+                             + py0 * (x1 * (t514 + t157 + t364 + t363)
+                                      + px1 * t974 + t202
+                                      + y1 * (x1 * (t917 + t153 + t55 + t339)
+                                              + t943 + px1 * t955 + t143 + t124 + t938) + t978 + t725
+                                      + t196 + py1 * t66 * t1) + x1 * (t930 + py1 * t775) + t863
+                             + py1 * (t773 + t283 + t771)
+                             + y1 * (py1 * (t58 + t144 + t942) + t888 + py1 * x1 * t36)
+                             + py1 * t21 * t1)
+                     + x0 * (py0 * (t29 * (t604 + t149 + t346 + t774)
+                                    + t984 + t190
+                                    + y1 * (x1 * (px1 * t972 + t970 + t313 + t144 + t960)
+                                            + px1 * t958 + t950 + t787 + t12 + t939)
+                                    + x1 * (t607 + t983 + py1 * y2 * (x2 * (t328 + t88) + t293 + t327))
+                                    + t189 + t188 + py1 * t650 * t1)
+                             + px0 * (t29 * t925 + t982 + t866
+                                      + y1
+                                      * (x1 * (py1 * t969 + t853 + t852 + t851)
+                                         + py1 * t947 + t829 + t828 + t827)
+                                      + py1 * x1 * y2 * t334 + t865 + t864 + py1 * t651 * t1)
+                             + t29 * t913 + t859 + t981
+                             + y1 * (x1 * (t834 + py1 * (t633 + t54 + t272 + t968))
+                                     + py1 * (t946 + t46 + t945) + t821) + py1 * x1 * y2 * t606
+                             + py1 * t737 * t1)
+                     + py0 * (x1 * (t573 + t238 + t237 + t236)
+                              + t29 * (px1 * t980 + t773 + t978 + t283 + t771)
+                              + y1 * (x1 * (t965 + px1 * t971 + t765 + t659 + t959) + t550 + t670 + t669)
+                              + py1 * t537 * t1)
+                     + px0 * (x1 * (py1 * t977 + t858 + t857 + t856)
+                              + t29 * (py1 * t974 + t862 + t861 + t860)
+                              + y1 * (x1 * (py1 * t966 + t820 + t819 + t818) + t973) + py1 * t539 * t1)
+                     + x1 * (t890 + py1 * t191) + t29 * (t891 + py1 * (t202 + t725 + t196))
+                     + y0 * (x0 * (px0 * (x1 * (py1 * t972 + t833 + t832 + t831)
+                                          + py1 * t971 + py1 * t29 * t916 + t829 + t828 + t827
+                                          + (t926 + t817 + py1 * x1 * t693 + t823 + t822) * y1)
+                                   + py0 * (x1 * (t970 + px1 * t969 + t633 + t54 + t272 + t968)
+                                            + px1 * t966 + t965 + t29 * (t163 + t35 + t34 + t33) + t753 + t12
+                                            + t935
+                                            + (t962 + t941 + t43
+                                               + x1
+                                               * (t836 + py1 * (t86 + t628 + (t961 + t291) * x2)
+                                                  + t26 + t94 + t96) + t95 + t93)
+                                            * y1) + x1 * (py1 * (t313 + t144 + t960) + t888) + t821
+                                   + py1 * (t765 + t659 + t959) + py1 * t29 * t340
+                                   + (t885 + t884 + py1 * x1 * t338) * y1)
+                             + px0 * (x1 * (py1 * t958 + t820 + t819 + t818)
+                                      + t956 + t29 * (py1 * t955 + t853 + t852 + t851)
+                                      + (py1 * t415 + x1 * t953) * y1)
+                             + py0 * (x1 * (t950 + px1 * t947 + t946 + t46 + t945)
+                                      + t29 * (px1 * t944 + t943 + t58 + t144 + t942) + t406 + t392 + t391
+                                      + (x1 * (t421 + t941 + t431 + t27 + t661)
+                                         + t416 + py1 * (x2 * (t554 + t796) + t5 * t940) + t665 + t664)
+                                      * y1) + x1 * (py1 * (t787 + t12 + t939) + t830)
+                             + t29 * (t834 + py1 * (t143 + t124 + t938)) + t937
+                             + (x1 * t936 + py1 * t666) * y1)
+                     + y1 * (x1 * (py1 * (t753 + t12 + t935) + t830) + t934) + py1 * t653 * t1
+                     + py0 * t652 * t14)
+       ;
+
+    trans->m[1][2] = (y0 * (x0 * (px0 * (x1 * (py1 * t1016 + t872 + t871 + t870)
+                                        + py1 * t494 + t29 * t932
+                                        + y1
+                                        * (py1 * t1025 + py1 * x1 * t599 + t820 + t819
+                                           + t818) + t953 * t1)
+                                 + py0 * (x1 * (t1015 + px1 * t1009 + t727 + t326 + t724)
+                                          + t29 * (t1028 + t148 + t364 + t744) + t491
+                                          + y1
+                                          * (x1
+                                             * (t600 + py1 * (x2 * t933 + t940 * y2) + t503
+                                                + t800)
+                                             + px1 * t1020 + t1026 + t676 + t45 + t1017)
+                                          + (t1027 + t10 + t27 + t25) * t1)
+                                 + x1 * (py1 * (t1014 + t283 + t1012) + t863) + t29 * t931
+                                 + py1 * t802
+                                 + y1 * (py1 * x1 * t801 + py1 * (t1024 + t13 + t1023) + t830)
+                                 + t936 * t1)
+                           + py0 * (t29 * (t1007 + px1 * t1002 + t727 + t201 + t724)
+                                    + x1 * (t1011 + t641 + t731 + t189 + t730)
+                                    + y1 * (x1 * (t1026 + px1 * t1025 + t1024 + t13 + t1023)
+                                            + t550
+                                            + py1
+                                            * (t5 * (t293 + t327) + x2 * (t1021 + t697) * y2)
+                                            + t670 + t669) + (t540 + t648 + t645) * t1)
+                           + px0 * (x1 * (t982 + t866 + t865 + t864)
+                                    + t29 * (py1 * t1006 + t872 + t871 + t870)
+                                    + y1 * (x1 * (py1 * t1020 + t829 + t828 + t827) + t956)
+                                    + py1 * t415 * t1) + x1 * (t859 + t981)
+                           + t29 * (t863 + py1 * (t773 + t246 + t771))
+                           + y1 * (x1 * (py1 * (t676 + t45 + t1017) + t821) + t937)
+                           + py1 * t666 * t1)
+                     + x0 * (py0 * (y1 * (x1 * (px1 * t1016 + t1015 + t1014 + t283 + t1012)
+                                          + t1011 + t573 + t238 + t237 + t236)
+                                    + x1 * (t639
+                                            + py1 * (x2 * y2 * (t1010 + t300) + t142 * t894)
+                                            + t230 + t229) + t29 * (t175 + t159 + t155)
+                                    + t1 * (px1 * t1000 + t994 + t660 + t45 + t986))
+                             + px0 * (y1 * (x1 * (py1 * t1009 + t862 + t861 + t860)
+                                            + t927 + t858 + t857 + t856)
+                                      + py1 * t29 * t515 + py1 * x1 * t638
+                                      + t1 * (py1 * t993 + t820 + t819 + t818))
+                             + y1 * (x1 * (t891 + py1 * (t727 + t326 + t724)) + t890 + t889)
+                             + py1 * x1 * t374 + py1 * t29 * t373
+                             + t1 * (t830 + py1 * (t705 + t752 + t990)))
+                     + t161 * (py0 * (x1 * (t516 + t372 + t371)
+                                      + y1
+                                      * (x1 * (t921 + t156 + t346 + t345)
+                                         + t1007 + px1 * t1006 + t773 + t246 + t771) + t381
+                                      + t1 * (t989 + px1 * t997 + t54 + t245 + t985))
+                               + px0 * (y1
+                                        * (x1 * (py1 * t1004 + t924 + t923 + t922)
+                                           + py1 * t1002 + t862 + t861 + t860)
+                                        + py1 * t499 + py1 * x1 * t174
+                                        + t1 * (py1 * t988 + t853 + t852 + t851))
+                               + y1 * (x1 * (t912 + py1 * t746) + t891
+                                       + py1 * (t727 + t201 + t724))
+                               + py1 * x1 * t160 + py1 * t152
+                               + t1 * (t834 + py1 * (t143 + t272 + t987))) + py0 * t770
+                     + t14 * (px0 * (x1 * (py1 * t1000 + t829 + t828 + t827)
+                                     + t973 + t29 * (py1 * t997 + t833 + t832 + t831)
+                                     + (py1 * t539 + x1 * (py1 * t996 + t817 + t823 + t822))
+                                     * y1)
+                              + py0 * (x1 * (t994 + px1 * t993 + t705 + t752 + t990)
+                                       + t29 * (t989 + px1 * t988 + t143 + t272 + t987) + t398
+                                       + (t416 + x1 * (t962 + t43 + t95 + t93) + t665 + t664)
+                                       * y1) + x1 * (py1 * (t660 + t45 + t986) + t821)
+                              + t29 * (t888 + py1 * (t54 + t245 + t985)) + t934
+                              + (x1 * (t885 + py1 * t28) + py1 * t653) * y1));
+
+    trans->m[2][0] = (x0 * (px0 * (y1 * (x1 * t617 + t586 + t877 + t1008 + t876)
+                                  + x1 * t515 + t637 + t1 * (t475 + t136 + t620 + t1036) + t636)
+                           + py0 * (y1 * (t579 + x1 * t627 + t251 + t811 + t248)
+                                    + x1 * t379 + t233 + t1 * (t455 + t87 + t298 + t1035) + t232)
+                           + x1 * (t516 + t383 + y2 * (t804 + t1013) + t142 * t595)
+                           + y1 * (px1 * (t1047 + t979 + t1046)
+                                   + x1 * (t921 + t368 + t157 + t156 + t1048)
+                                   + py1 * (t1044 + t728 + t1043) + t505 + t607 + t502) + t500 + t381
+                           + t1 * (px1 * (t611 + t135 + t1038) + py1 * (t330 + t128 + t1037) + t423
+                                   + t125 + t54 + t1034))
+                     + y0 * (x0 * (py0 * (x1 * t1050 + t533 + t226
+                                          + y1 * (t529 + t224 + x1 * t349 + t128 + t1040)
+                                          + t781 + t220 + t99 * t1)
+                                   + px0 * (t528 + x1 * t1049 + t874
+                                            + y1 * (t517 + x1 * t916 + t520 + t135 + t1041) + t1005
+                                            + t873 + t693 * t1)
+                                   + x1 * (t514 + t382 + t157 + t156 + t1048)
+                                   + px1 * (t877 + t1001 + t876) + py1 * (t251 + t776 + t248) + t608
+                                   + y1 * (x1 * (t917 + t358 + t56 + t323 + (t716 + t967) * y2)
+                                           + px1 * (t118 + t609 + t471 + t1045)
+                                           + py1 * (t204 + t327 + t249 + t1042) + t503 + t144 + t143
+                                           + t1039) + t504 + t605 + (t647 + t357) * t1)
+                             + px0 * (x1 * (t528 + t1047 + t979 + t1046)
+                                      + t643 + t29 * t182 + t571
+                                      + y1 * (x1 * (t475 + t118 + t609 + t471 + t1045) + t701 + t895)
+                                      + t570 + t569 + (t468 + t441 + t466 + t951) * t1)
+                             + py0 * (x1 * (t533 + t1044 + t728 + t1043)
+                                      + t642 + t29 * t179 + t566
+                                      + y1 * (x1 * (t455 + t204 + t327 + t249 + t1042) + t289 + t288)
+                                      + t214 + t565 + (t436 + t450 + t69 + t677) * t1)
+                             + x1 * (px1 * (t877 + t1008 + t876) + py1 * (t251 + t811 + t248) + t505
+                                     + t607 + t502) + t984 + t743
+                             + t29 * t274
+                             + y1 * (x1 * (px1 * (t520 + t135 + t1041) + py1 * (t224 + t128 + t1040)
+                                           + t503 + t144 + t143 + t1039)
+                                     + t897 + t303 + x2 * t634 + x2 * (t690 + t52) * y2)
+                             + (t1027 + t808) * t1)
+                     + py0 * (y1 * (x1 * (t579 + t251 + t776 + t248) + t581 + t735 + t240 + t734)
+                              + t29 * t169 + x1 * t209 + t1 * (t461 + t80 + t683 + t1032))
+                     + px0 * (y1 * (x1 * (t586 + t877 + t1001 + t876) + t591 + t976 + t588 + t975)
+                              + x1 * t499 + t29 * t174 + t1 * (t484 + t849 + t957 + t1033))
+                     + y1 * (x1 * (px1 * (t874 + t1005 + t873) + py1 * (t226 + t781 + t220) + t608
+                                   + t504 + t605)
+                             + t573 + t568) + t161 * t183 + x1 * (t639 + t235) + t29 * t160
+                     + t14 * (px0 * (x1 * (t517 + t611 + t135 + t1038)
+                                     + t615 + t29 * t109 + t560 + t443 + t1031
+                                     + (t399 + t613 + x1 * t646 + t418 + t995) * y1)
+                              + py0 * (x1 * (t529 + t330 + t128 + t1037)
+                                       + t625 + t29 * t76 + t112 + t438 + t1030
+                                       + (t623 + t393 + t102 + x1 * t66 + t754) * y1)
+                              + x1 * (px1 * (t136 + t620 + t1036) + py1 * (t87 + t298 + t1035) + t423
+                                      + t125 + t54 + t1034)
+                              + px1 * (t849 + t957 + t1033) + py1 * (t80 + t683 + t1032) + t434
+                              + t29 * t36 + t1029 + (t962 + t711 + x1 * (t836 + t100)) * y1)
+                     + t1 * (px1 * (t560 + t443 + t1031) + py1 * (t112 + t438 + t1030) + t434
+                             + t1029))
+       ;
+
+    trans->m[2][1] = (t161 * (px0 * (x1 * (t616 + t180 + t512 + t1003)
+                                    + t586 + t510 + y1 * (t475 + t854 + x1 * t109 + t117 + t1062)
+                                    + t621 + t508 + t646 * t1)
+                             + py0 * (t579 + x1 * (t177 + t626 + t354 + t778) + t507
+                                      + y1 * (t455 + x1 * t76 + t91 + t203 + t1061) + t299
+                                      + t506 + t66 * t1) + x1 * (t921 + t368)
+                             + px1 * (t874 + t979 + t873) + py1 * (t226 + t728 + t220)
+                             + y1 * (x1 * (t917 + t358) + px1 * (t118 + t843 + t1063)
+                                     + py1 * (t204 + t127 + t1065) + t423 + t144
+                                     + t143 + t1060) + t504 + t21 * t1)
+                     + x0 * (py0 * (t29 * t1050 + t581 + t241
+                                    + y1
+                                    * (x1 * (t529 + t87 + t577 + t292 + t1070)
+                                       + t461 + t1057 + t80 + t1056) + x1 * y2 * t741 + t240
+                                    + t239 + t650 * t1)
+                             + px0 * (t591 + t29 * t1049 + t589
+                                      + y1 * (x1 * (t517 + t136 + t306 + t428 + t1071)
+                                              + t484 + t1059 + t849 + t1058) + x1 * y2 * t334 + t588
+                                      + t587 + t651 * t1) + t29 * (t1028 + t809) + t903 + t321
+                             + y1 * (x1 * (px1 * (t901 + t117 + t1072) + py1 * (t317 + t203 + t1073)
+                                           + t503 + t125 + t54 + t1069)
+                                     + px1 * (t1019 + t837 + t1064) + py1 * (t789 + t111 + t1066) + t267
+                                     + t433 + t1055)
+                             + x1 * (y2 * (x2 * (t56 + t323) + t322 + t273) + t983 + t742) + t737 * t1)
+                     + py0 * (x1 * (t642 + t215 + t214 + t213) + t29 * (t533 + t226 + t728 + t220)
+                              + y1
+                              * (x1 * (t625 + t758 + t111 + t1067)
+                                 + t396 + t395) + t537 * t1)
+                     + px0 * (x1 * (t643 + t868 + t570 + t867) + t29 * (t528 + t874 + t979 + t873)
+                              + y1
+                              * (x1 * (t615 + t999 + t837 + t1068)
+                                 + t404 + t402) + t539 * t1)
+                     + x1 * (t641 + t243)
+                     + t29 * (px1 * (t510 + t621 + t508) + py1 * (t507 + t299 + t506) + t504)
+                     + y0 * (x0 * (py0 * (x1 * (t455 + t317 + t203 + t1073)
+                                          + t461 + t29 * t349 + t767 + t683 + t1052
+                                          + (t436 + t450 + x1 * t99 + t69 + t677) * y1)
+                                   + px0 * (x1 * (t475 + t901 + t117 + t1072)
+                                            + t484 + t29 * t916 + t992 + t957 + t1053
+                                            + (t468 + t441 + t466 + x1 * t693 + t951) * y1)
+                                   + x1 * (px1 * (t136 + t306 + t428 + t1071)
+                                           + py1 * (t87 + t577 + t292 + t1070) + t503 + t125 + t54 + t1069)
+                                   + px1 * (t999 + t837 + t1068) + py1 * (t758 + t111 + t1067)
+                                   + t29 * (t163 + t162) + t434 + t553 + t1051
+                                   + (t421 + t104 + t431 + t43
+                                      + x1 * (t836 + t100 + t690 + t52 + (t270 + t886) * x2)
+                                      + t1054)
+                                   * y1)
+                             + py0 * (x1 * (t625 + t789 + t111 + t1066)
+                                      + t29 * (t529 + t204 + t127 + t1065) + t544 + t543
+                                      + (x1 * t624 + t410 + t409) * y1)
+                             + px0 * (x1 * (t615 + t1019 + t837 + t1064)
+                                      + t29 * (t517 + t118 + t843 + t1063) + t548 + t547
+                                      + (x1 * t614 + t414 + t413) * y1)
+                             + t29 * (px1 * (t854 + t117 + t1062) + py1 * (t91 + t203 + t1061) + t423
+                                      + t144 + t143 + t1060)
+                             + x1 * (px1 * (t1059 + t849 + t1058) + py1 * (t1057 + t80 + t1056) + t267
+                                     + t433 + t1055) + t406 + t398
+                             + (t416 + x1 * (t962 + t711 + t431 + t43 + t1054) + t412
+                                + x2 * (t793 + t1022) + t5 * t594)
+                             * y1)
+                     + y1 * (x1 * (px1 * (t992 + t957 + t1053) + py1 * (t767 + t683 + t1052) + t434
+                                   + t553 + t1051)
+                             + t550 + t546) + t653 * t1 + t652 * t14)
+       ;
+    trans->m[2][2] = t644;
+}
+
+static void
+print_trans (const char *header, struct pixman_f_transform *trans)
+{
+    int i, j;
+    double max;
+
+    max = 0;
+
+    printf ("%s\n", header);
+
+    for (i = 0; i < 3; ++i)
+    {
+       for (j = 0; j < 3; ++j)
+       {
+           double a = fabs (trans->m[i][j]);
+
+           if (a > max)
+               max = a;
+       }
+    }
+
+    if (max == 0.0)
+       max = 1.0;
+
+    for (i = 0; i < 3; ++i)
+    {
+       printf ("{ ");
+       for (j = 0; j < 3; ++j)
+       {
+           printf ("D2F (%.5f)%s", 16384 * (trans->m[i][j] / max), j == 2 ? "" : ", ");
+       }
+
+       printf ("},\n");
+    }
+}
+
+int
+main ()
+{
+    struct pixman_f_transform t;
+
+#if 0
+    quad_to_quad (75, 200,
+                 325, 200,
+                 450, 335,
+                 -50, 335,
+
+                 0, 0,
+                 400, 0,
+                 400, 400,
+                 0, 400,
+
+                 &t);
+#endif
+    quad_to_quad (
+       1, 0,
+       1, 2,
+       2, 2,
+       2, 0,
+
+       1, 0,
+       1, 112,
+       2, 2,
+       2, 0,
+
+       &t);
+
+    print_trans ("0->0", &t);
+
+    return 0;
+}
index af940b0..870608a 100644 (file)
@@ -1,7 +1,9 @@
+#sbs-git:slp/pkgs/p/pixman pixman 0.26.0 67eba3516f06fef40915917d7396b68108ee6316
+
 Name:       pixman
 Summary:    Pixel manipulation library
-Version:    0.23.7
-Release:    1
+Version:    0.26.0
+Release:    3
 Group:      System/Libraries
 License:    MIT
 URL:        http://www.x.org/
@@ -26,7 +28,7 @@ Pixel manipulation library
 
 %build
 
-%reconfigure
+%reconfigure --disable-arm-iwmmxt
 make %{?jobs:-j%jobs}
 
 %install
index 286b7cf..b320a58 100644 (file)
@@ -102,5 +102,33 @@ libpixman_1_la_LIBADD += libpixman-iwmmxt.la
 ASM_CFLAGS_IWMMXT=$(IWMMXT_CFLAGS)
 endif
 
+# mips dspr2 code
+if USE_MIPS_DSPR2
+noinst_LTLIBRARIES += libpixman-mips-dspr2.la
+libpixman_mips_dspr2_la_SOURCES = \
+        pixman-mips-dspr2.c \
+        pixman-mips-dspr2.h \
+        pixman-mips-dspr2-asm.S \
+        pixman-mips-dspr2-asm.h \
+        pixman-mips-memcpy-asm.S
+libpixman_mips_dspr2_la_CFLAGS = $(DEP_CFLAGS)
+libpixman_mips_dspr2_la_LIBADD = $(DEP_LIBS)
+libpixman_1_la_LIBADD += libpixman-mips-dspr2.la
+
+ASM_CFLAGS_mips_dspr2=
+endif
+
+# loongson code
+if USE_LOONGSON_MMI
+noinst_LTLIBRARIES += libpixman-loongson-mmi.la
+libpixman_loongson_mmi_la_SOURCES = pixman-mmx.c loongson-mmintrin.h
+libpixman_loongson_mmi_la_CFLAGS = $(DEP_CFLAGS) $(LS_CFLAGS)
+libpixman_loongson_mmi_la_LIBADD = $(DEP_LIBS)
+libpixman_1_la_LDFLAGS += $(LS_LDFLAGS)
+libpixman_1_la_LIBADD += libpixman-loongson-mmi.la
+
+ASM_CFLAGS_ls=$(LS_CFLAGS)
+endif
+
 .c.s : $(libpixmaninclude_HEADERS) $(BUILT_SOURCES)
        $(CC) $(CFLAGS) $(ASM_CFLAGS_$(@:pixman-%.s=%)) $(ASM_CFLAGS_$(@:pixman-arm-%.s=arm_%)) -DHAVE_CONFIG_H -I$(srcdir) -I$(builddir) -I$(top_builddir) -S -o $@ $<
diff --git a/pixman/loongson-mmintrin.h b/pixman/loongson-mmintrin.h
new file mode 100644 (file)
index 0000000..8295ba0
--- /dev/null
@@ -0,0 +1,273 @@
+/* The gcc-provided loongson intrinsic functions are way too fucking broken
+ * to be of any use, otherwise I'd use them.
+ *
+ * - The hardware instructions are very similar to MMX or iwMMXt. Certainly
+ *   close enough that they could have implemented the _mm_*-style intrinsic
+ *   interface and had a ton of optimized code available to them. Instead they
+ *   implemented something much, much worse.
+ *
+ * - pshuf takes a dead first argument, causing extra instructions to be
+ *   generated.
+ *
+ * - There are no 64-bit shift or logical intrinsics, which means you have
+ *   to implement them with inline assembly, but this is a nightmare because
+ *   gcc doesn't understand that the integer vector datatypes are actually in
+ *   floating-point registers, so you end up with braindead code like
+ *
+ *     punpcklwd       $f9,$f9,$f5
+ *         dmtc1       v0,$f8
+ *     punpcklwd       $f19,$f19,$f5
+ *         dmfc1       t9,$f9
+ *         dmtc1       v0,$f9
+ *         dmtc1       t9,$f20
+ *         dmfc1       s0,$f19
+ *     punpcklbh       $f20,$f20,$f2
+ *
+ *   where crap just gets copied back and forth between integer and floating-
+ *   point registers ad nauseum.
+ *
+ * Instead of trying to workaround the problems from these crap intrinsics, I
+ * just implement the _mm_* intrinsics needed for pixman-mmx.c using inline
+ * assembly.
+ */
+
+#include <stdint.h>
+
+/* vectors are stored in 64-bit floating-point registers */
+typedef double __m64;
+/* having a 32-bit datatype allows us to use 32-bit loads in places like load8888 */
+typedef float  __m32;
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_setzero_si64 (void)
+{
+       return 0.0;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_adds_pu16 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("paddush %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_adds_pu8 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("paddusb %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_and_si64 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("and %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_empty (void)
+{
+
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_madd_pi16 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("pmaddhw %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mulhi_pu16 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("pmulhuh %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mullo_pi16 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("pmullh %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_or_si64 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("or %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_packs_pu16 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("packushb %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_shuffle_pi16 (__m64 __m, int64_t __n)
+{
+       __m64 ret;
+       asm("pshufh %0, %1, %2\n\t"
+           : "=f" (ret)
+           : "f" (__m), "f" (*(__m64 *)&__n)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_slli_si64 (__m64 __m, int64_t __count)
+{
+       __m64 ret;
+       asm("dsll  %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m), "f" (*(__m64 *)&__count)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_srli_pi16 (__m64 __m, int64_t __count)
+{
+       __m64 ret;
+       asm("psrlh %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m), "f" (*(__m64 *)&__count)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_srli_si64 (__m64 __m, int64_t __count)
+{
+       __m64 ret;
+       asm("dsrl  %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m), "f" (*(__m64 *)&__count)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_unpackhi_pi8 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("punpckhbh %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_unpackhi_pi16 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("punpckhhw %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_unpacklo_pi8 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("punpcklbh %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+/* Since punpcklbh doesn't care about the high 32-bits, we use the __m32 datatype which
+ * allows load8888 to use 32-bit loads */
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_unpacklo_pi8_f (__m32 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("punpcklbh %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_unpacklo_pi16 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("punpcklhw %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_xor_si64 (__m64 __m1, __m64 __m2)
+{
+       __m64 ret;
+       asm("xor %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+loongson_extract_pi16 (__m64 __m, int64_t __pos)
+{
+       __m64 ret;
+       asm("pextrh %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m), "f" (*(__m64 *)&__pos)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+loongson_insert_pi16 (__m64 __m1, __m64 __m2, int64_t __pos)
+{
+       __m64 ret;
+       asm("pinsrh_%3 %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m1), "f" (__m2), "i" (__pos)
+       );
+       return ret;
+}
index 189b191..6743887 100644 (file)
      (((s) >> 6) & 0x03e0) |                                            \
      (((s) >> 9) & 0x7c00))
 
-#define RGB15_TO_ENTRY(mif,rgb15)                                      \
-    ((mif)->ent[rgb15])
-
-#define RGB24_TO_ENTRY(mif,rgb24)                                      \
-    RGB15_TO_ENTRY (mif,CONVERT_RGB24_TO_RGB15 (rgb24))
-
-#define RGB24_TO_ENTRY_Y(mif,rgb24)                                    \
-    ((mif)->ent[CONVERT_RGB24_TO_Y15 (rgb24)])
-
 /* Fetch macros */
 
 #ifdef WORDS_BIGENDIAN
index 90c8ea7..8e0b036 100644 (file)
@@ -1,21 +1,10 @@
 #ifdef PIXMAN_FB_ACCESSORS
 
-#define ACCESS(sym) sym##_accessors
-
 #define READ(img, ptr)                                                 \
     (((bits_image_t *)(img))->read_func ((ptr), sizeof(*(ptr))))
 #define WRITE(img, ptr,val)                                            \
     (((bits_image_t *)(img))->write_func ((ptr), (val), sizeof (*(ptr))))
 
-#define MEMCPY_WRAPPED(img, dst, src, size)                            \
-    do {                                                               \
-       size_t _i;                                                      \
-       uint8_t *_dst = (uint8_t*)(dst), *_src = (uint8_t*)(src);       \
-       for(_i = 0; _i < size; _i++) {                                  \
-           WRITE((img), _dst +_i, READ((img), _src + _i));             \
-       }                                                               \
-    } while (0)
-
 #define MEMSET_WRAPPED(img, dst, val, size)                            \
     do {                                                               \
        size_t _i;                                                      \
 
 #else
 
-#define ACCESS(sym) sym
-
 #define READ(img, ptr)         (*(ptr))
 #define WRITE(img, ptr, val)   (*(ptr) = (val))
-#define MEMCPY_WRAPPED(img, dst, src, size)                            \
-    memcpy(dst, src, size)
 #define MEMSET_WRAPPED(img, dst, val, size)                            \
     memset(dst, val, size)
 
index 87aae1d..12421c1 100644 (file)
@@ -3634,3 +3634,9 @@ generate_bilinear_scanline_func \
 generate_bilinear_scanline_func \
     pixman_scaled_bilinear_scanline_0565_0565_SRC_asm_neon, 0565, 0565, \
     1, 1, 28, BILINEAR_FLAG_UNROLL_4
+
+pixman_asm_function _pixman_arm_check_neon
+    vqadd.u8 d0, d1, d0
+    bx lr
+.endfunc
+
index 8fe1b50..0f919af 100644 (file)
@@ -437,3 +437,9 @@ generate_nearest_scanline_func \
 
 generate_nearest_scanline_func \
     pixman_scaled_nearest_scanline_8888_8888_SRC_asm_armv6, 2,  , 48, 32
+
+pixman_asm_function _pixman_arm_check_v6
+    uqadd8 r1, r1, r2
+    bx lr
+.endfunc
+
index 99c0dfe..1f6897c 100644 (file)
@@ -381,11 +381,11 @@ bits_image_fetch_pixel_convolution (bits_image_t   *image,
     int y_off = (params[1] - pixman_fixed_1) >> 1;
     int32_t cwidth = pixman_fixed_to_int (params[0]);
     int32_t cheight = pixman_fixed_to_int (params[1]);
-    int32_t srtot, sgtot, sbtot, satot;
     int32_t i, j, x1, x2, y1, y2;
     pixman_repeat_t repeat_mode = image->common.repeat;
     int width = image->width;
     int height = image->height;
+    int srtot, sgtot, sbtot, satot;
 
     params += 2;
 
@@ -421,10 +421,10 @@ bits_image_fetch_pixel_convolution (bits_image_t   *image,
                    pixel = get_pixel (image, rx, ry, TRUE);
                }
 
-               srtot += RED_8 (pixel) * f;
-               sgtot += GREEN_8 (pixel) * f;
-               sbtot += BLUE_8 (pixel) * f;
-               satot += ALPHA_8 (pixel) * f;
+               srtot += (int)RED_8 (pixel) * f;
+               sgtot += (int)GREEN_8 (pixel) * f;
+               sbtot += (int)BLUE_8 (pixel) * f;
+               satot += (int)ALPHA_8 (pixel) * f;
            }
 
            params++;
@@ -970,28 +970,6 @@ replicate_pixel_64 (bits_image_t *   bits,
 }
 
 static void
-bits_image_fetch_solid_32 (pixman_image_t * image,
-                           int              x,
-                           int              y,
-                           int              width,
-                           uint32_t *       buffer,
-                           const uint32_t * mask)
-{
-    replicate_pixel_32 (&image->bits, 0, 0, width, buffer);
-}
-
-static void
-bits_image_fetch_solid_64 (pixman_image_t * image,
-                           int              x,
-                           int              y,
-                           int              width,
-                           uint32_t *       b,
-                           const uint32_t * unused)
-{
-    replicate_pixel_64 (&image->bits, 0, 0, width, b);
-}
-
-static void
 bits_image_fetch_untransformed_repeat_none (bits_image_t *image,
                                             pixman_bool_t wide,
                                             int           x,
@@ -1131,12 +1109,6 @@ typedef struct
 
 static const fetcher_info_t fetcher_info[] =
 {
-    { PIXMAN_solid,
-      FAST_PATH_NO_ALPHA_MAP,
-      bits_image_fetch_solid_32,
-      bits_image_fetch_solid_64
-    },
-
     { PIXMAN_any,
       (FAST_PATH_NO_ALPHA_MAP                  |
        FAST_PATH_ID_TRANSFORM                  |
@@ -1294,12 +1266,27 @@ dest_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
     image->bits.fetch_scanline_32 (image, x, y, width, buffer, mask);
     if (image->common.alpha_map)
     {
-       x -= image->common.alpha_origin_x;
-       y -= image->common.alpha_origin_y;
+       uint32_t *alpha;
+
+       if ((alpha = malloc (width * sizeof (uint32_t))))
+       {
+           int i;
+
+           x -= image->common.alpha_origin_x;
+           y -= image->common.alpha_origin_y;
+
+           image->common.alpha_map->fetch_scanline_32 (
+               (pixman_image_t *)image->common.alpha_map,
+               x, y, width, alpha, mask);
 
-       image->common.alpha_map->fetch_scanline_32 (
-           (pixman_image_t *)image->common.alpha_map,
-           x, y, width, buffer, mask);
+           for (i = 0; i < width; ++i)
+           {
+               buffer[i] &= ~0xff000000;
+               buffer[i] |= (alpha[i] & 0xff000000);
+           }
+
+           free (alpha);
+       }
     }
 
     return iter->buffer;
@@ -1312,17 +1299,33 @@ dest_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
     int             x      = iter->x;
     int             y      = iter->y;
     int             width  = iter->width;
-    uint32_t *     buffer = iter->buffer;
+    uint64_t *     buffer = (uint64_t *)iter->buffer;
 
     image->fetch_scanline_64 (
-       (pixman_image_t *)image, x, y, width, buffer, mask);
+       (pixman_image_t *)image, x, y, width, (uint32_t *)buffer, mask);
     if (image->common.alpha_map)
     {
-       x -= image->common.alpha_origin_x;
-       y -= image->common.alpha_origin_y;
+       uint64_t *alpha;
 
-       image->common.alpha_map->fetch_scanline_64 (
-           (pixman_image_t *)image->common.alpha_map, x, y, width, buffer, mask);
+       if ((alpha = malloc (width * sizeof (uint64_t))))
+       {
+           int i;
+
+           x -= image->common.alpha_origin_x;
+           y -= image->common.alpha_origin_y;
+
+           image->common.alpha_map->fetch_scanline_64 (
+               (pixman_image_t *)image->common.alpha_map,
+               x, y, width, (uint32_t *)alpha, mask);
+
+           for (i = 0; i < width; ++i)
+           {
+               buffer[i] &= ~0xffff000000000000ULL;
+               buffer[i] |= (alpha[i] & 0xffff000000000000ULL);
+           }
+
+           free (alpha);
+       }
     }
 
     return iter->buffer;
index c17bcea..cd008d9 100644 (file)
@@ -522,7 +522,7 @@ combine_multiply_ca (pixman_implementation_t *imp,
            UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (result, isa, s, ida);      \
                                                                        \
            *(dest + i) = result +                                      \
-               (DIV_ONE_UNc (sa * da) << A_SHIFT) +                    \
+               (DIV_ONE_UNc (sa * (comp4_t)da) << A_SHIFT) +           \
                (blend_ ## name (RED_c (d), da, RED_c (s), sa) << R_SHIFT) + \
                (blend_ ## name (GREEN_c (d), da, GREEN_c (s), sa) << G_SHIFT) + \
                (blend_ ## name (BLUE_c (d), da, BLUE_c (s), sa));      \
@@ -552,7 +552,7 @@ combine_multiply_ca (pixman_implementation_t *imp,
            UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (result, ~m, s, ida);     \
                                                                        \
            result +=                                                   \
-               (DIV_ONE_UNc (ALPHA_c (m) * da) << A_SHIFT) +           \
+               (DIV_ONE_UNc (ALPHA_c (m) * (comp4_t)da) << A_SHIFT) +  \
                (blend_ ## name (RED_c (d), da, RED_c (s), RED_c (m)) << R_SHIFT) + \
                (blend_ ## name (GREEN_c (d), da, GREEN_c (s), GREEN_c (m)) << G_SHIFT) + \
                (blend_ ## name (BLUE_c (d), da, BLUE_c (s), BLUE_c (m))); \
@@ -926,7 +926,7 @@ PDF_SEPARABLE_BLEND_MODE (exclusion)
            blend_ ## name (c, dc, da, sc, sa);                         \
                                                                        \
            *(dest + i) = result +                                      \
-               (DIV_ONE_UNc (sa * da) << A_SHIFT) +                    \
+               (DIV_ONE_UNc (sa * (comp4_t)da) << A_SHIFT) +           \
                (DIV_ONE_UNc (c[0]) << R_SHIFT) +                       \
                (DIV_ONE_UNc (c[1]) << G_SHIFT) +                       \
                (DIV_ONE_UNc (c[2]));                                   \
index 67ed309..20f784b 100644 (file)
  */
 
 #define MUL_UNc(a, b, t)                                               \
-    ((t) = (a) * (b) + ONE_HALF, ((((t) >> G_SHIFT ) + (t) ) >> G_SHIFT ))
+    ((t) = (a) * (comp2_t)(b) + ONE_HALF, ((((t) >> G_SHIFT ) + (t) ) >> G_SHIFT ))
 
 #define DIV_UNc(a, b)                                                  \
-    (((comp2_t) (a) * MASK) / (b))
+    (((comp2_t) (a) * MASK + ((b) / 2)) / (b))
 
 #define ADD_UNc(x, y, t)                                    \
     ((t) = (x) + (y),                                       \
index fe2a613..ffd5172 100644 (file)
 # define UINT32_MAX             (4294967295U)
 #endif
 
+#ifndef INT64_MIN
+# define INT64_MIN              (-9223372036854775807-1)
+#endif
+
+#ifndef INT64_MAX
+# define INT64_MAX              (9223372036854775807)
+#endif
+
+
 #ifndef M_PI
 # define M_PI                  3.14159265358979323846
 #endif
 #   define PIXMAN_GET_THREAD_LOCAL(name)                               \
     (&name)
 
-#elif defined(TOOLCHAIN_SUPPORTS__THREAD)
+#elif defined(TLS)
 
 #   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)                      \
-    static __thread type name
+    static TLS type name
 #   define PIXMAN_GET_THREAD_LOCAL(name)                               \
     (&name)
 
index dff27d1..52ee536 100644 (file)
 #endif
 
 #include <string.h>
+#include <stdlib.h>
 
 #if defined(USE_ARM_SIMD) && defined(_MSC_VER)
 /* Needed for EXCEPTION_ILLEGAL_INSTRUCTION */
 #include <windows.h>
 #endif
 
+#if defined(__APPLE__)
+#include "TargetConditionals.h"
+#endif
+
 #include "pixman-private.h"
 
 #ifdef USE_VMX
@@ -244,6 +249,84 @@ pixman_have_arm_neon (void)
 
 #endif /* USE_ARM_NEON */
 
+#elif (defined (__APPLE__) && defined(TARGET_OS_IPHONE)) /* iOS (iPhone/iPad/iPod touch) */
+
+/* Detection of ARM NEON on iOS is fairly simple because iOS binaries
+ * contain separate executable images for each processor architecture.
+ * So all we have to do is detect the armv7 architecture build. The
+ * operating system automatically runs the armv7 binary for armv7 devices
+ * and the armv6 binary for armv6 devices.
+ */
+
+pixman_bool_t
+pixman_have_arm_simd (void)
+{
+#if defined(USE_ARM_SIMD)
+    return TRUE;
+#else
+    return FALSE;
+#endif
+}
+
+pixman_bool_t
+pixman_have_arm_neon (void)
+{
+#if defined(USE_ARM_NEON) && defined(__ARM_NEON__)
+    /* This is an armv7 cpu build */
+    return TRUE;
+#else
+    /* This is an armv6 cpu build */
+    return FALSE;
+#endif
+}
+
+pixman_bool_t
+pixman_have_arm_iwmmxt (void)
+{
+#if defined(USE_ARM_IWMMXT)
+    return FALSE;
+#else
+    return FALSE;
+#endif
+}
+
+#elif defined (__linux__) || defined(__ANDROID__) || defined(ANDROID) /* linux ELF or ANDROID */
+
+static pixman_bool_t arm_has_v7 = FALSE;
+static pixman_bool_t arm_has_v6 = FALSE;
+static pixman_bool_t arm_has_vfp = FALSE;
+static pixman_bool_t arm_has_neon = FALSE;
+static pixman_bool_t arm_has_iwmmxt = FALSE;
+static pixman_bool_t arm_tests_initialized = FALSE;
+
+#if defined(__ANDROID__) || defined(ANDROID) /* Android device support */
+
+#include <cpu-features.h>
+
+static void
+pixman_arm_read_auxv_or_cpu_features ()
+{
+    AndroidCpuFamily cpu_family;
+    uint64_t cpu_features;
+
+    cpu_family = android_getCpuFamily();
+    cpu_features = android_getCpuFeatures();
+
+    if (cpu_family == ANDROID_CPU_FAMILY_ARM)
+    {
+       if (cpu_features & ANDROID_CPU_ARM_FEATURE_ARMv7)
+           arm_has_v7 = TRUE;
+       
+       if (cpu_features & ANDROID_CPU_ARM_FEATURE_VFPv3)
+           arm_has_vfp = TRUE;
+       
+       if (cpu_features & ANDROID_CPU_ARM_FEATURE_NEON)
+           arm_has_neon = TRUE;
+    }
+
+    arm_tests_initialized = TRUE;
+}
+
 #elif defined (__linux__) /* linux ELF */
 
 #include <stdlib.h>
@@ -254,16 +337,51 @@ pixman_have_arm_neon (void)
 #include <fcntl.h>
 #include <string.h>
 #include <elf.h>
+#include <signal.h>
+#include <setjmp.h>
 
-static pixman_bool_t arm_has_v7 = FALSE;
-static pixman_bool_t arm_has_v6 = FALSE;
-static pixman_bool_t arm_has_vfp = FALSE;
-static pixman_bool_t arm_has_neon = FALSE;
-static pixman_bool_t arm_has_iwmmxt = FALSE;
-static pixman_bool_t arm_tests_initialized = FALSE;
+static sigjmp_buf cpu_jmpbuf;
+
+static void
+pixman_catch_sigill(int sig)
+{
+    siglongjmp(cpu_jmpbuf, 1);
+}
+
+static void
+pixman_arm_check_neon (void)
+{
+    struct sigaction sa, old_sa;
+
+    /* setup the sigaction */
+    sa.sa_handler = pixman_catch_sigill;
+    sa.sa_flags = SA_RESTART;
+    sigemptyset(&sa.sa_mask);
+    sigaction(SIGILL, &sa, &old_sa);
+
+#if defined(USE_ARM_NEON)
+    if (!sigsetjmp(cpu_jmpbuf, 1))
+    {
+        _pixman_arm_check_neon();
+        arm_has_neon = TRUE;
+    }
+#endif
+
+#if defined(USE_ARM_SIMD)
+    if (!sigsetjmp(cpu_jmpbuf, 1))
+    {
+        _pixman_arm_check_v6();
+        arm_has_v6 = TRUE;
+    }
+#endif
+
+    sigaction(SIGILL, &old_sa, NULL);
+
+    arm_tests_initialized = TRUE;
+}
 
 static void
-pixman_arm_read_auxv ()
+pixman_arm_read_auxv_or_cpu_features ()
 {
     int fd;
     Elf32_auxv_t aux;
@@ -304,12 +422,14 @@ pixman_arm_read_auxv ()
     arm_tests_initialized = TRUE;
 }
 
+#endif /* Linux elf */
+
 #if defined(USE_ARM_SIMD)
 pixman_bool_t
 pixman_have_arm_simd (void)
 {
     if (!arm_tests_initialized)
-       pixman_arm_read_auxv ();
+       pixman_arm_check_neon ();
 
     return arm_has_v6;
 }
@@ -321,7 +441,7 @@ pixman_bool_t
 pixman_have_arm_neon (void)
 {
     if (!arm_tests_initialized)
-       pixman_arm_read_auxv ();
+       pixman_arm_check_neon ();
 
     return arm_has_neon;
 }
@@ -333,14 +453,14 @@ pixman_bool_t
 pixman_have_arm_iwmmxt (void)
 {
     if (!arm_tests_initialized)
-       pixman_arm_read_auxv ();
+       pixman_arm_read_auxv_or_cpu_features ();
 
     return arm_has_iwmmxt;
 }
 
 #endif /* USE_ARM_IWMMXT */
 
-#else /* linux ELF */
+#else /* !_MSC_VER && !Linux elf && !Android */
 
 #define pixman_have_arm_simd() FALSE
 #define pixman_have_arm_neon() FALSE
@@ -350,6 +470,70 @@ pixman_have_arm_iwmmxt (void)
 
 #endif /* USE_ARM_SIMD || USE_ARM_NEON || USE_ARM_IWMMXT */
 
+#if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
+
+#if defined (__linux__) /* linux ELF */
+
+static pixman_bool_t
+pixman_have_mips_feature (const char *search_string)
+{
+    const char *file_name = "/proc/cpuinfo";
+    /* Simple detection of MIPS features at runtime for Linux.
+     * It is based on /proc/cpuinfo, which reveals hardware configuration
+     * to user-space applications.  According to MIPS (early 2010), no similar
+     * facility is universally available on the MIPS architectures, so it's up
+     * to individual OSes to provide such.
+     */
+
+    char cpuinfo_line[256];
+
+    FILE *f = NULL;
+
+    if ((f = fopen (file_name, "r")) == NULL)
+        return FALSE;
+
+    while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL)
+    {
+        if (strstr (cpuinfo_line, search_string) != NULL)
+        {
+            fclose (f);
+            return TRUE;
+        }
+    }
+
+    fclose (f);
+
+    /* Did not find string in the proc file. */
+    return FALSE;
+}
+
+#if defined(USE_MIPS_DSPR2)
+pixman_bool_t
+pixman_have_mips_dspr2 (void)
+{
+     /* Only currently available MIPS core that supports DSPr2 is 74K. */
+    return pixman_have_mips_feature ("MIPS 74K");
+}
+#endif
+
+#if defined(USE_LOONGSON_MMI)
+pixman_bool_t
+pixman_have_loongson_mmi (void)
+{
+    /* I really don't know if some Loongson CPUs don't have MMI. */
+    return pixman_have_mips_feature ("Loongson");
+}
+#endif
+
+#else /* linux ELF */
+
+#define pixman_have_mips_dspr2() FALSE
+#define pixman_have_loongson_mmi() FALSE
+
+#endif /* linux ELF */
+
+#endif /* USE_MIPS_DSPR2 || USE_LOONGSON_MMI */
+
 #if defined(USE_X86_MMX) || defined(USE_SSE2)
 /* The CPU detection code needs to be in a file not compiled with
  * "-mmmx -msse", as gcc would generate CMOV instructions otherwise
@@ -541,6 +725,7 @@ detect_cpu_features (void)
     return features;
 }
 
+#ifdef USE_X86_MMX
 static pixman_bool_t
 pixman_have_mmx (void)
 {
@@ -556,6 +741,7 @@ pixman_have_mmx (void)
 
     return mmx_present;
 }
+#endif
 
 #ifdef USE_SSE2
 static pixman_bool_t
@@ -586,46 +772,87 @@ pixman_have_sse2 (void)
 #endif /* __amd64__ */
 #endif
 
+static pixman_bool_t
+disabled (const char *name)
+{
+    const char *env;
+
+    if ((env = getenv ("PIXMAN_DISABLE")))
+    {
+       do
+       {
+           const char *end;
+           int len;
+
+           if ((end = strchr (env, ' ')))
+               len = end - env;
+           else
+               len = strlen (env);
+
+           if (strlen (name) == len && strncmp (name, env, len) == 0)
+           {
+               printf ("pixman: Disabled %s implementation\n", name);
+               return TRUE;
+           }
+
+           env += len;
+       }
+       while (*env++);
+    }
+
+    return FALSE;
+}
+
 pixman_implementation_t *
 _pixman_choose_implementation (void)
 {
     pixman_implementation_t *imp;
 
     imp = _pixman_implementation_create_general();
-    imp = _pixman_implementation_create_fast_path (imp);
-    
+
+    if (!disabled ("fast"))
+       imp = _pixman_implementation_create_fast_path (imp);
+
 #ifdef USE_X86_MMX
-    if (pixman_have_mmx ())
+    if (!disabled ("mmx") && pixman_have_mmx ())
        imp = _pixman_implementation_create_mmx (imp);
 #endif
 
 #ifdef USE_SSE2
-    if (pixman_have_sse2 ())
+    if (!disabled ("sse2") && pixman_have_sse2 ())
        imp = _pixman_implementation_create_sse2 (imp);
 #endif
 
 #ifdef USE_ARM_SIMD
-    if (pixman_have_arm_simd ())
+    if (!disabled ("arm-simd") && pixman_have_arm_simd ())
        imp = _pixman_implementation_create_arm_simd (imp);
 #endif
 
 #ifdef USE_ARM_IWMMXT
-    if (pixman_have_arm_iwmmxt ())
+    if (!disabled ("arm-iwmmxt") && pixman_have_arm_iwmmxt ())
+       imp = _pixman_implementation_create_mmx (imp);
+#endif
+#ifdef USE_LOONGSON_MMI
+    if (!disabled ("loongson-mmi") && pixman_have_loongson_mmi ())
        imp = _pixman_implementation_create_mmx (imp);
 #endif
-
 #ifdef USE_ARM_NEON
-    if (pixman_have_arm_neon ())
+    if (!disabled ("arm-neon") && pixman_have_arm_neon ())
        imp = _pixman_implementation_create_arm_neon (imp);
 #endif
 
+#ifdef USE_MIPS_DSPR2
+    if (!disabled ("mips-dspr2") && pixman_have_mips_dspr2 ())
+       imp = _pixman_implementation_create_mips_dspr2 (imp);
+#endif
+
 #ifdef USE_VMX
-    if (pixman_have_vmx ())
+    if (!disabled ("vmx") && pixman_have_vmx ())
        imp = _pixman_implementation_create_vmx (imp);
 #endif
 
     imp = _pixman_implementation_create_noop (imp);
-    
+
     return imp;
 }
 
index 038dcf7..0a134ed 100644 (file)
@@ -906,8 +906,8 @@ fast_composite_add_n_8_8 (pixman_implementation_t *imp,
     do { *((p) + ((n) >> 5)) |= CREATE_BITMASK ((n) & 31); } while (0);
 
 static void
-fast_composite_add_1000_1000 (pixman_implementation_t *imp,
-                              pixman_composite_info_t *info)
+fast_composite_add_1_1 (pixman_implementation_t *imp,
+                       pixman_composite_info_t *info)
 {
     PIXMAN_COMPOSITE_ARGS (info);
     uint32_t     *dst_line, *dst;
@@ -1839,7 +1839,7 @@ static const pixman_fast_path_t c_fast_paths[] =
     PIXMAN_STD_FAST_PATH (ADD, a8r8g8b8, null, a8r8g8b8, fast_composite_add_8888_8888),
     PIXMAN_STD_FAST_PATH (ADD, a8b8g8r8, null, a8b8g8r8, fast_composite_add_8888_8888),
     PIXMAN_STD_FAST_PATH (ADD, a8, null, a8, fast_composite_add_8_8),
-    PIXMAN_STD_FAST_PATH (ADD, a1, null, a1, fast_composite_add_1000_1000),
+    PIXMAN_STD_FAST_PATH (ADD, a1, null, a1, fast_composite_add_1_1),
     PIXMAN_STD_FAST_PATH_CA (ADD, solid, a8r8g8b8, a8r8g8b8, fast_composite_add_n_8888_8888_ca),
     PIXMAN_STD_FAST_PATH (ADD, solid, a8, a8, fast_composite_add_n_8_8),
     PIXMAN_STD_FAST_PATH (SRC, solid, null, a8r8g8b8, fast_composite_solid_fill),
@@ -1969,9 +1969,9 @@ static const pixman_fast_path_t c_fast_paths[] =
 };
 
 #ifdef WORDS_BIGENDIAN
-#define A1_FILL_MASK(n, offs) (((1 << (n)) - 1) << (32 - (offs) - (n)))
+#define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (32 - (offs) - (n)))
 #else
-#define A1_FILL_MASK(n, offs) (((1 << (n)) - 1) << (offs))
+#define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (offs))
 #endif
 
 static force_inline void
index 2ccdfcd..27fa3ab 100644 (file)
@@ -171,20 +171,8 @@ general_composite_rect  (pixman_implementation_t *imp,
        imp->toplevel, &dest_iter, dest_image, dest_x, dest_y, width, height,
        dest_buffer, narrow | op_flags[op].dst);
 
-    if (narrow)
-    {
-       if (component_alpha)
-           compose = _pixman_implementation_combine_32_ca;
-       else
-           compose = _pixman_implementation_combine_32;
-    }
-    else
-    {
-       if (component_alpha)
-           compose = (pixman_combine_32_func_t)_pixman_implementation_combine_64_ca;
-       else
-           compose = (pixman_combine_32_func_t)_pixman_implementation_combine_64;
-    }
+    compose = _pixman_implementation_lookup_combiner (
+       imp->toplevel, op, component_alpha, narrow);
 
     if (!compose)
        return;
index dd666b4..e7e724f 100644 (file)
@@ -31,7 +31,7 @@
 void
 _pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
                               gradient_t *              gradient,
-                              unsigned int              spread)
+                              pixman_repeat_t          repeat)
 {
     walker->num_stops = gradient->n_stops;
     walker->stops     = gradient->stops;
@@ -42,112 +42,54 @@ _pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
     walker->left_rb   = 0;
     walker->right_ag  = 0;
     walker->right_rb  = 0;
-    walker->spread    = spread;
+    walker->repeat    = repeat;
 
     walker->need_reset = TRUE;
 }
 
-void
-_pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
-                               pixman_fixed_32_32_t      pos)
+static void
+gradient_walker_reset (pixman_gradient_walker_t *walker,
+                      pixman_fixed_48_16_t      pos)
 {
     int32_t x, left_x, right_x;
-    pixman_color_t          *left_c, *right_c;
+    pixman_color_t *left_c, *right_c;
     int n, count = walker->num_stops;
-    pixman_gradient_stop_t *      stops = walker->stops;
-
-    static const pixman_color_t transparent_black = { 0, 0, 0, 0 };
+    pixman_gradient_stop_t *stops = walker->stops;
 
-    switch (walker->spread)
+    if (walker->repeat == PIXMAN_REPEAT_NORMAL)
     {
-    case PIXMAN_REPEAT_NORMAL:
-       x = (int32_t)pos & 0xFFFF;
-       for (n = 0; n < count; n++)
-           if (x < stops[n].x)
-               break;
-       if (n == 0)
-       {
-           left_x =  stops[count - 1].x - 0x10000;
-           left_c = &stops[count - 1].color;
-       }
-       else
-       {
-           left_x =  stops[n - 1].x;
-           left_c = &stops[n - 1].color;
-       }
-
-       if (n == count)
-       {
-           right_x =  stops[0].x + 0x10000;
-           right_c = &stops[0].color;
-       }
-       else
-       {
-           right_x =  stops[n].x;
-           right_c = &stops[n].color;
-       }
-       left_x  += (pos - x);
-       right_x += (pos - x);
-       break;
-
-    case PIXMAN_REPEAT_PAD:
-       for (n = 0; n < count; n++)
-           if (pos < stops[n].x)
-               break;
-
-       if (n == 0)
-       {
-           left_x =  INT32_MIN;
-           left_c = &stops[0].color;
-       }
-       else
-       {
-           left_x =  stops[n - 1].x;
-           left_c = &stops[n - 1].color;
-       }
-
-       if (n == count)
-       {
-           right_x =  INT32_MAX;
-           right_c = &stops[n - 1].color;
-       }
-       else
-       {
-           right_x =  stops[n].x;
-           right_c = &stops[n].color;
-       }
-       break;
-
-    case PIXMAN_REPEAT_REFLECT:
-       x = (int32_t)pos & 0xFFFF;
+       x = (int32_t)pos & 0xffff;
+    }
+    else if (walker->repeat == PIXMAN_REPEAT_REFLECT)
+    {
+       x = (int32_t)pos & 0xffff;
        if ((int32_t)pos & 0x10000)
            x = 0x10000 - x;
-       for (n = 0; n < count; n++)
-           if (x < stops[n].x)
-               break;
-
-       if (n == 0)
-       {
-           left_x =  -stops[0].x;
-           left_c = &stops[0].color;
-       }
-       else
-       {
-           left_x =  stops[n - 1].x;
-           left_c = &stops[n - 1].color;
-       }
-
-       if (n == count)
-       {
-           right_x = 0x20000 - stops[n - 1].x;
-           right_c = &stops[n - 1].color;
-       }
-       else
-       {
-           right_x =  stops[n].x;
-           right_c = &stops[n].color;
-       }
-
+    }
+    else
+    {
+       x = pos;
+    }
+    
+    for (n = 0; n < count; n++)
+    {
+       if (x < stops[n].x)
+           break;
+    }
+    
+    left_x =  stops[n - 1].x;
+    left_c = &stops[n - 1].color;
+    
+    right_x =  stops[n].x;
+    right_c = &stops[n].color;
+
+    if (walker->repeat == PIXMAN_REPEAT_NORMAL)
+    {
+       left_x  += (pos - x);
+       right_x += (pos - x);
+    }
+    else if (walker->repeat == PIXMAN_REPEAT_REFLECT)
+    {
        if ((int32_t)pos & 0x10000)
        {
            pixman_color_t  *tmp_c;
@@ -165,32 +107,13 @@ _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
        }
        left_x  += (pos - x);
        right_x += (pos - x);
-       break;
-
-    default:  /* REPEAT_NONE */
-       for (n = 0; n < count; n++)
-           if (pos < stops[n].x)
-               break;
-
+    }
+    else if (walker->repeat == PIXMAN_REPEAT_NONE)
+    {
        if (n == 0)
-       {
-           left_x  =  INT32_MIN;
-           right_x =  stops[0].x;
-           left_c  = right_c = (pixman_color_t*) &transparent_black;
-       }
+           right_c = left_c;
        else if (n == count)
-       {
-           left_x  = stops[n - 1].x;
-           right_x = INT32_MAX;
-           left_c  = right_c = (pixman_color_t*) &transparent_black;
-       }
-       else
-       {
-           left_x  =  stops[n - 1].x;
-           right_x =  stops[n].x;
-           left_c  = &stops[n - 1].color;
-           right_c = &stops[n].color;
-       }
+           left_c = right_c;
     }
 
     walker->left_x   = left_x;
@@ -201,8 +124,8 @@ _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
     walker->right_rb = ((right_c->red & 0xff00) << 8) | (right_c->blue >> 8);
 
     if (walker->left_x == walker->right_x                ||
-        ( walker->left_ag == walker->right_ag &&
-          walker->left_rb == walker->right_rb )   )
+        (walker->left_ag == walker->right_ag &&
+        walker->left_rb == walker->right_rb))
     {
        walker->stepper = 0;
     }
@@ -215,20 +138,15 @@ _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
     walker->need_reset = FALSE;
 }
 
-#define  PIXMAN_GRADIENT_WALKER_NEED_RESET(w, x)                         \
-    ( (w)->need_reset || (x) < (w)->left_x || (x) >= (w)->right_x)
-
-
-/* the following assumes that PIXMAN_GRADIENT_WALKER_NEED_RESET(w,x) is FALSE */
 uint32_t
 _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker,
-                               pixman_fixed_32_32_t      x)
+                               pixman_fixed_48_16_t      x)
 {
     int dist, idist;
     uint32_t t1, t2, a, color;
 
-    if (PIXMAN_GRADIENT_WALKER_NEED_RESET (walker, x))
-       _pixman_gradient_walker_reset (walker, x);
+    if (walker->need_reset || x < walker->left_x || x >= walker->right_x)
+       gradient_walker_reset (walker, x);
 
     dist  = ((int)(x - walker->left_x) * walker->stepper) >> 16;
     idist = 256 - dist;
index afe587f..8599a1e 100644 (file)
 
 #include "pixman-private.h"
 
+static const pixman_color_t transparent_black = { 0, 0, 0, 0 };
+
+static void
+gradient_property_changed (pixman_image_t *image)
+{
+    gradient_t *gradient = &image->gradient;
+    int n = gradient->n_stops;
+    pixman_gradient_stop_t *stops = gradient->stops;
+    pixman_gradient_stop_t *begin = &(gradient->stops[-1]);
+    pixman_gradient_stop_t *end = &(gradient->stops[n]);
+
+    switch (gradient->common.repeat)
+    {
+    default:
+    case PIXMAN_REPEAT_NONE:
+       begin->x = INT32_MIN;
+       begin->color = transparent_black;
+       end->x = INT32_MAX;
+       end->color = transparent_black;
+       break;
+
+    case PIXMAN_REPEAT_NORMAL:
+       begin->x = stops[n - 1].x - pixman_fixed_1;
+       begin->color = stops[n - 1].color;
+       end->x = stops[0].x + pixman_fixed_1;
+       end->color = stops[0].color;
+       break;
+
+    case PIXMAN_REPEAT_REFLECT:
+       begin->x = - stops[0].x;
+       begin->color = stops[0].color;
+       end->x = pixman_int_to_fixed (2) - stops[n - 1].x;
+       end->color = stops[n - 1].color;
+       break;
+
+    case PIXMAN_REPEAT_PAD:
+       begin->x = INT32_MIN;
+       begin->color = stops[0].color;
+       end->x = INT32_MAX;
+       end->color = stops[n - 1].color;
+       break;
+    }
+}
+
 pixman_bool_t
 _pixman_init_gradient (gradient_t *                  gradient,
                        const pixman_gradient_stop_t *stops,
@@ -38,14 +82,27 @@ _pixman_init_gradient (gradient_t *                  gradient,
 {
     return_val_if_fail (n_stops > 0, FALSE);
 
-    gradient->stops = pixman_malloc_ab (n_stops, sizeof (pixman_gradient_stop_t));
+    /* We allocate two extra stops, one before the beginning of the stop list,
+     * and one after the end. These stops are initialized to whatever color
+     * would be used for positions outside the range of the stop list.
+     *
+     * This saves a bit of computation in the gradient walker.
+     *
+     * The pointer we store in the gradient_t struct still points to the
+     * first user-supplied struct, so when freeing, we will have to
+     * subtract one.
+     */
+    gradient->stops =
+       pixman_malloc_ab (n_stops + 2, sizeof (pixman_gradient_stop_t));
     if (!gradient->stops)
        return FALSE;
 
+    gradient->stops += 1;
     memcpy (gradient->stops, stops, n_stops * sizeof (pixman_gradient_stop_t));
-
     gradient->n_stops = n_stops;
 
+    gradient->common.property_changed = gradient_property_changed;
+
     return TRUE;
 }
 
@@ -88,11 +145,8 @@ _pixman_image_fini (pixman_image_t *image)
 
        pixman_region32_fini (&common->clip_region);
 
-       if (common->transform)
-           free (common->transform);
-
-       if (common->filter_params)
-           free (common->filter_params);
+       free (common->transform);
+       free (common->filter_params);
 
        if (common->alpha_map)
            pixman_image_unref ((pixman_image_t *)common->alpha_map);
@@ -102,7 +156,17 @@ _pixman_image_fini (pixman_image_t *image)
            image->type == CONICAL)
        {
            if (image->gradient.stops)
-               free (image->gradient.stops);
+           {
+               /* See _pixman_init_gradient() for an explanation of the - 1 */
+               free (image->gradient.stops - 1);
+           }
+
+           /* This will trigger if someone adds a property_changed
+            * method to the linear/radial/conical gradient overwriting
+            * the general one.
+            */
+           assert (
+               image->common.property_changed == gradient_property_changed);
        }
 
        if (image->type == BITS && image->bits.free_me)
@@ -235,13 +299,12 @@ compute_image_info (pixman_image_t *image)
                     image->common.transform->matrix[1][1] == 0)
            {
                pixman_fixed_t m01 = image->common.transform->matrix[0][1];
-               if (m01 == -image->common.transform->matrix[1][0])
-               {
-                       if (m01 == -pixman_fixed_1)
-                           flags |= FAST_PATH_ROTATE_90_TRANSFORM;
-                       else if (m01 == pixman_fixed_1)
-                           flags |= FAST_PATH_ROTATE_270_TRANSFORM;
-               }
+               pixman_fixed_t m10 = image->common.transform->matrix[1][0];
+
+               if (m01 == -1 && m10 == 1)
+                   flags |= FAST_PATH_ROTATE_90_TRANSFORM;
+               else if (m01 == 1 && m10 == -1)
+                   flags |= FAST_PATH_ROTATE_270_TRANSFORM;
            }
        }
 
@@ -567,7 +630,7 @@ pixman_image_set_transform (pixman_image_t *          image,
     }
 
     if (common->transform &&
-       memcmp (common->transform, transform, sizeof (pixman_transform_t) == 0))
+       memcmp (common->transform, transform, sizeof (pixman_transform_t)) == 0)
     {
        return TRUE;
     }
index 2b7b19d..b0a2959 100644 (file)
 #include <stdlib.h>
 #include "pixman-private.h"
 
-static void
-delegate_combine_32 (pixman_implementation_t * imp,
-                     pixman_op_t               op,
-                     uint32_t *                dest,
-                     const uint32_t *          src,
-                     const uint32_t *          mask,
-                     int                       width)
-{
-    _pixman_implementation_combine_32 (imp->delegate,
-                                       op, dest, src, mask, width);
-}
-
-static void
-delegate_combine_64 (pixman_implementation_t * imp,
-                     pixman_op_t               op,
-                     uint64_t *                dest,
-                     const uint64_t *          src,
-                     const uint64_t *          mask,
-                     int                       width)
-{
-    _pixman_implementation_combine_64 (imp->delegate,
-                                       op, dest, src, mask, width);
-}
-
-static void
-delegate_combine_32_ca (pixman_implementation_t * imp,
-                        pixman_op_t               op,
-                        uint32_t *                dest,
-                        const uint32_t *          src,
-                        const uint32_t *          mask,
-                        int                       width)
-{
-    _pixman_implementation_combine_32_ca (imp->delegate,
-                                          op, dest, src, mask, width);
-}
-
-static void
-delegate_combine_64_ca (pixman_implementation_t * imp,
-                        pixman_op_t               op,
-                        uint64_t *                dest,
-                        const uint64_t *          src,
-                        const uint64_t *          mask,
-                        int                       width)
-{
-    _pixman_implementation_combine_64_ca (imp->delegate,
-                                          op, dest, src, mask, width);
-}
-
 static pixman_bool_t
 delegate_blt (pixman_implementation_t * imp,
               uint32_t *                src_bits,
@@ -150,61 +102,44 @@ _pixman_implementation_create (pixman_implementation_t *delegate,
     imp->src_iter_init = delegate_src_iter_init;
     imp->dest_iter_init = delegate_dest_iter_init;
 
+    imp->fast_paths = fast_paths;
+
     for (i = 0; i < PIXMAN_N_OPERATORS; ++i)
     {
-       imp->combine_32[i] = delegate_combine_32;
-       imp->combine_64[i] = delegate_combine_64;
-       imp->combine_32_ca[i] = delegate_combine_32_ca;
-       imp->combine_64_ca[i] = delegate_combine_64_ca;
+       imp->combine_32[i] = NULL;
+       imp->combine_64[i] = NULL;
+       imp->combine_32_ca[i] = NULL;
+       imp->combine_64_ca[i] = NULL;
     }
 
-    imp->fast_paths = fast_paths;
-
     return imp;
 }
 
-void
-_pixman_implementation_combine_32 (pixman_implementation_t * imp,
-                                   pixman_op_t               op,
-                                   uint32_t *                dest,
-                                   const uint32_t *          src,
-                                   const uint32_t *          mask,
-                                   int                       width)
+pixman_combine_32_func_t
+_pixman_implementation_lookup_combiner (pixman_implementation_t *imp,
+                                       pixman_op_t              op,
+                                       pixman_bool_t            component_alpha,
+                                       pixman_bool_t            narrow)
 {
-    (*imp->combine_32[op]) (imp, op, dest, src, mask, width);
-}
+    pixman_combine_32_func_t f;
 
-void
-_pixman_implementation_combine_64 (pixman_implementation_t * imp,
-                                   pixman_op_t               op,
-                                   uint64_t *                dest,
-                                   const uint64_t *          src,
-                                   const uint64_t *          mask,
-                                   int                       width)
-{
-    (*imp->combine_64[op]) (imp, op, dest, src, mask, width);
-}
+    do
+    {
+       pixman_combine_32_func_t (*combiners[]) =
+       {
+           (pixman_combine_32_func_t *)imp->combine_64,
+           (pixman_combine_32_func_t *)imp->combine_64_ca,
+           imp->combine_32,
+           imp->combine_32_ca,
+       };
 
-void
-_pixman_implementation_combine_32_ca (pixman_implementation_t * imp,
-                                      pixman_op_t               op,
-                                      uint32_t *                dest,
-                                      const uint32_t *          src,
-                                      const uint32_t *          mask,
-                                      int                       width)
-{
-    (*imp->combine_32_ca[op]) (imp, op, dest, src, mask, width);
-}
+       f = combiners[component_alpha | (narrow << 1)][op];
 
-void
-_pixman_implementation_combine_64_ca (pixman_implementation_t * imp,
-                                      pixman_op_t               op,
-                                      uint64_t *                dest,
-                                      const uint64_t *          src,
-                                      const uint64_t *          mask,
-                                      int                       width)
-{
-    (*imp->combine_64_ca[op]) (imp, op, dest, src, mask, width);
+       imp = imp->delegate;
+    }
+    while (!f);
+
+    return f;
 }
 
 pixman_bool_t
diff --git a/pixman/pixman-mips-dspr2-asm.S b/pixman/pixman-mips-dspr2-asm.S
new file mode 100644 (file)
index 0000000..87558f0
--- /dev/null
@@ -0,0 +1,812 @@
+/*
+ * Copyright (c) 2012
+ *      MIPS Technologies, Inc., California.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Author:  Nemanja Lukic (nlukic@mips.com)
+ */
+
+#include "pixman-mips-dspr2-asm.h"
+
+LEAF_MIPS_DSPR2(pixman_fill_buff16_mips)
+/*
+ * a0 - *dest
+ * a1 - count (bytes)
+ * a2 - value to fill buffer with
+ */
+
+    beqz     a1, 3f
+     andi    t1, a0, 0x0002
+    beqz     t1, 0f          /* check if address is 4-byte aligned */
+     nop
+    sh       a2, 0(a0)
+    addiu    a0, a0, 2
+    addiu    a1, a1, -2
+0:
+    srl      t1, a1, 5       /* t1 how many multiples of 32 bytes */
+    replv.ph a2, a2          /* replicate fill value (16bit) in a2 */
+    beqz     t1, 2f
+     nop
+1:
+    addiu    t1, t1, -1
+    beqz     t1, 11f
+     addiu   a1, a1, -32
+    pref     30, 32(a0)
+    sw       a2, 0(a0)
+    sw       a2, 4(a0)
+    sw       a2, 8(a0)
+    sw       a2, 12(a0)
+    sw       a2, 16(a0)
+    sw       a2, 20(a0)
+    sw       a2, 24(a0)
+    sw       a2, 28(a0)
+    b        1b
+     addiu   a0, a0, 32
+11:
+    sw       a2, 0(a0)
+    sw       a2, 4(a0)
+    sw       a2, 8(a0)
+    sw       a2, 12(a0)
+    sw       a2, 16(a0)
+    sw       a2, 20(a0)
+    sw       a2, 24(a0)
+    sw       a2, 28(a0)
+    addiu    a0, a0, 32
+2:
+    blez     a1, 3f
+     addiu   a1, a1, -2
+    sh       a2, 0(a0)
+    b        2b
+     addiu   a0, a0, 2
+3:
+    jr       ra
+     nop
+
+END(pixman_fill_buff16_mips)
+
+LEAF_MIPS32R2(pixman_fill_buff32_mips)
+/*
+ * a0 - *dest
+ * a1 - count (bytes)
+ * a2 - value to fill buffer with
+ */
+
+    beqz     a1, 3f
+     nop
+    srl      t1, a1, 5 /* t1 how many multiples of 32 bytes */
+    beqz     t1, 2f
+     nop
+1:
+    addiu    t1, t1, -1
+    beqz     t1, 11f
+     addiu   a1, a1, -32
+    pref     30, 32(a0)
+    sw       a2, 0(a0)
+    sw       a2, 4(a0)
+    sw       a2, 8(a0)
+    sw       a2, 12(a0)
+    sw       a2, 16(a0)
+    sw       a2, 20(a0)
+    sw       a2, 24(a0)
+    sw       a2, 28(a0)
+    b        1b
+     addiu   a0, a0, 32
+11:
+    sw       a2, 0(a0)
+    sw       a2, 4(a0)
+    sw       a2, 8(a0)
+    sw       a2, 12(a0)
+    sw       a2, 16(a0)
+    sw       a2, 20(a0)
+    sw       a2, 24(a0)
+    sw       a2, 28(a0)
+    addiu    a0, a0, 32
+2:
+    blez     a1, 3f
+     addiu   a1, a1, -4
+    sw       a2, 0(a0)
+    b        2b
+     addiu   a0, a0, 4
+3:
+    jr       ra
+     nop
+
+END(pixman_fill_buff32_mips)
+
+LEAF_MIPS_DSPR2(pixman_composite_src_8888_0565_asm_mips)
+/*
+ * a0 - dst (r5g6b5)
+ * a1 - src (a8r8g8b8)
+ * a2 - w
+ */
+
+    beqz     a2, 3f
+     nop
+    addiu    t1, a2, -1
+    beqz     t1, 2f
+     nop
+    li       t4, 0xf800f800
+    li       t5, 0x07e007e0
+    li       t6, 0x001f001f
+1:
+    lw       t0, 0(a1)
+    lw       t1, 4(a1)
+    addiu    a1, a1, 8
+    addiu    a2, a2, -2
+
+    CONVERT_2x8888_TO_2x0565 t0, t1, t2, t3, t4, t5, t6, t7, t8
+
+    sh       t2, 0(a0)
+    sh       t3, 2(a0)
+
+    addiu    t2, a2, -1
+    bgtz     t2, 1b
+     addiu   a0, a0, 4
+2:
+    beqz     a2, 3f
+     nop
+    lw       t0, 0(a1)
+
+    CONVERT_1x8888_TO_1x0565 t0, t1, t2, t3
+
+    sh       t1, 0(a0)
+3:
+    j        ra
+     nop
+
+END(pixman_composite_src_8888_0565_asm_mips)
+
+LEAF_MIPS_DSPR2(pixman_composite_src_0565_8888_asm_mips)
+/*
+ * a0 - dst (a8r8g8b8)
+ * a1 - src (r5g6b5)
+ * a2 - w
+ */
+
+    beqz     a2, 3f
+     nop
+    addiu    t1, a2, -1
+    beqz     t1, 2f
+     nop
+    li       t4, 0x07e007e0
+    li       t5, 0x001F001F
+1:
+    lhu      t0, 0(a1)
+    lhu      t1, 2(a1)
+    addiu    a1, a1, 4
+    addiu    a2, a2, -2
+
+    CONVERT_2x0565_TO_2x8888 t0, t1, t2, t3, t4, t5, t6, t7, t8, t9
+
+    sw       t2, 0(a0)
+    sw       t3, 4(a0)
+
+    addiu    t2, a2, -1
+    bgtz     t2, 1b
+     addiu   a0, a0, 8
+2:
+    beqz     a2, 3f
+     nop
+    lhu      t0, 0(a1)
+
+    CONVERT_1x0565_TO_1x8888 t0, t1, t2, t3
+
+    sw       t1, 0(a0)
+3:
+    j        ra
+     nop
+
+END(pixman_composite_src_0565_8888_asm_mips)
+
+LEAF_MIPS_DSPR2(pixman_composite_src_x888_8888_asm_mips)
+/*
+ * a0 - dst (a8r8g8b8)
+ * a1 - src (x8r8g8b8)
+ * a2 - w
+ */
+
+    beqz     a2, 4f
+     nop
+    li       t9, 0xff000000
+    srl      t8, a2, 3    /* t1 = how many multiples of 8 src pixels */
+    beqz     t8, 3f       /* branch if less than 8 src pixels */
+     nop
+1:
+    addiu    t8, t8, -1
+    beqz     t8, 2f
+     addiu   a2, a2, -8
+    pref     0, 32(a1)
+    lw       t0, 0(a1)
+    lw       t1, 4(a1)
+    lw       t2, 8(a1)
+    lw       t3, 12(a1)
+    lw       t4, 16(a1)
+    lw       t5, 20(a1)
+    lw       t6, 24(a1)
+    lw       t7, 28(a1)
+    addiu    a1, a1, 32
+    or       t0, t0, t9
+    or       t1, t1, t9
+    or       t2, t2, t9
+    or       t3, t3, t9
+    or       t4, t4, t9
+    or       t5, t5, t9
+    or       t6, t6, t9
+    or       t7, t7, t9
+    pref     30, 32(a0)
+    sw       t0, 0(a0)
+    sw       t1, 4(a0)
+    sw       t2, 8(a0)
+    sw       t3, 12(a0)
+    sw       t4, 16(a0)
+    sw       t5, 20(a0)
+    sw       t6, 24(a0)
+    sw       t7, 28(a0)
+    b        1b
+     addiu   a0, a0, 32
+2:
+    lw       t0, 0(a1)
+    lw       t1, 4(a1)
+    lw       t2, 8(a1)
+    lw       t3, 12(a1)
+    lw       t4, 16(a1)
+    lw       t5, 20(a1)
+    lw       t6, 24(a1)
+    lw       t7, 28(a1)
+    addiu    a1, a1, 32
+    or       t0, t0, t9
+    or       t1, t1, t9
+    or       t2, t2, t9
+    or       t3, t3, t9
+    or       t4, t4, t9
+    or       t5, t5, t9
+    or       t6, t6, t9
+    or       t7, t7, t9
+    sw       t0, 0(a0)
+    sw       t1, 4(a0)
+    sw       t2, 8(a0)
+    sw       t3, 12(a0)
+    sw       t4, 16(a0)
+    sw       t5, 20(a0)
+    sw       t6, 24(a0)
+    sw       t7, 28(a0)
+    beqz     a2, 4f
+     addiu   a0, a0, 32
+3:
+    lw       t0, 0(a1)
+    addiu    a1, a1, 4
+    addiu    a2, a2, -1
+    or       t1, t0, t9
+    sw       t1, 0(a0)
+    bnez     a2, 3b
+     addiu   a0, a0, 4
+4:
+    jr       ra
+     nop
+
+END(pixman_composite_src_x888_8888_asm_mips)
+
+LEAF_MIPS_DSPR2(pixman_composite_over_n_8888_8888_ca_asm_mips)
+/*
+ * a0 - dst  (a8r8g8b8)
+ * a1 - src  (32bit constant)
+ * a2 - mask (a8r8g8b8)
+ * a3 - w
+ */
+
+    SAVE_REGS_ON_STACK 8, s0, s1, s2, s3, s4, s5
+    beqz         a3, 4f
+     nop
+    li           t6, 0xff
+    addiu        t7, zero, -1 /* t7 = 0xffffffff */
+    srl          t8, a1, 24   /* t8 = srca */
+    li           t9, 0x00ff00ff
+    addiu        t1, a3, -1
+    beqz         t1, 3f       /* last pixel */
+     nop
+    beq          t8, t6, 2f   /* if (srca == 0xff) */
+     nop
+1:
+                              /* a1 = src */
+    lw           t0, 0(a2)    /* t0 = mask */
+    lw           t1, 4(a2)    /* t1 = mask */
+    or           t2, t0, t1
+    beqz         t2, 12f      /* if (t0 == 0) && (t1 == 0) */
+     addiu       a2, a2, 8
+    and          t3, t0, t1
+    move         t4, a1       /* t4 = src */
+    move         t5, a1       /* t5 = src */
+    lw           t2, 0(a0)    /* t2 = dst */
+    beq          t3, t7, 11f  /* if (t0 == 0xffffffff) && (t1 == 0xffffffff) */
+     lw          t3, 4(a0)    /* t3 = dst */
+    MIPS_2xUN8x4_MUL_2xUN8x4 a1, a1, t0, t1, t4, t5, t9, s0, s1, s2, s3, s4, s5
+    MIPS_2xUN8x4_MUL_2xUN8   t0, t1, t8, t8, t0, t1, t9, s0, s1, s2, s3, s4, s5
+11:
+    not          t0, t0
+    not          t1, t1
+    MIPS_2xUN8x4_MUL_2xUN8x4 t2, t3, t0, t1, t2, t3, t9, s0, s1, s2, s3, s4, s5
+    addu_s.qb    t2, t4, t2
+    addu_s.qb    t3, t5, t3
+    sw           t2, 0(a0)
+    sw           t3, 4(a0)
+12:
+    addiu        a3, a3, -2
+    addiu        t1, a3, -1
+    bgtz         t1, 1b
+     addiu       a0, a0, 8
+    b            3f
+     nop
+2:
+                              /* a1 = src */
+    lw           t0, 0(a2)    /* t0 = mask */
+    lw           t1, 4(a2)    /* t1 = mask */
+    or           t2, t0, t1
+    beqz         t2, 22f      /* if (t0 == 0) & (t1 == 0) */
+     addiu       a2, a2, 8
+    and          t2, t0, t1
+    move         t4, a1
+    beq          t2, t7, 21f  /* if (t0 == 0xffffffff) && (t1 == 0xffffffff) */
+     move        t5, a1
+    lw           t2, 0(a0)    /* t2 = dst */
+    lw           t3, 4(a0)    /* t3 = dst */
+    MIPS_2xUN8x4_MUL_2xUN8x4 a1, a1, t0, t1, t4, t5, t9, s0, s1, s2, s3, s4, s5
+    not          t0, t0
+    not          t1, t1
+    MIPS_2xUN8x4_MUL_2xUN8x4 t2, t3, t0, t1, t2, t3, t9, s0, s1, s2, s3, s4, s5
+    addu_s.qb    t4, t4, t2
+    addu_s.qb    t5, t5, t3
+21:
+    sw           t4, 0(a0)
+    sw           t5, 4(a0)
+22:
+    addiu        a3, a3, -2
+    addiu        t1, a3, -1
+    bgtz         t1, 2b
+     addiu       a0, a0, 8
+3:
+    blez         a3, 4f
+     nop
+                              /* a1 = src */
+    lw           t1, 0(a2)    /* t1 = mask */
+    beqz         t1, 4f
+     nop
+    move         t2, a1       /* t2 = src */
+    beq          t1, t7, 31f
+     lw          t0, 0(a0)    /* t0 = dst */
+
+    MIPS_UN8x4_MUL_UN8x4  a1, t1, t2, t9, t3, t4, t5, t6
+    MIPS_UN8x4_MUL_UN8    t1, t8, t1, t9, t3, t4, t5
+31:
+    not          t1, t1
+    MIPS_UN8x4_MUL_UN8x4  t0, t1, t0, t9, t3, t4, t5, t6
+    addu_s.qb    t0, t2, t0
+    sw           t0, 0(a0)
+4:
+    RESTORE_REGS_FROM_STACK 8, s0, s1, s2, s3, s4, s5
+    j            ra
+     nop
+
+END(pixman_composite_over_n_8888_8888_ca_asm_mips)
+
+LEAF_MIPS_DSPR2(pixman_composite_over_n_8888_0565_ca_asm_mips)
+/*
+ * a0 - dst  (r5g6b5)
+ * a1 - src  (32bit constant)
+ * a2 - mask (a8r8g8b8)
+ * a3 - w
+ */
+
+    SAVE_REGS_ON_STACK 20, s0, s1, s2, s3, s4, s5, s6, s7, s8
+    beqz         a3, 4f
+     nop
+    li           t5, 0xf800f800
+    li           t6, 0x07e007e0
+    li           t7, 0x001F001F
+    li           t9, 0x00ff00ff
+
+    srl          t8, a1, 24   /* t8 = srca */
+    addiu        t1, a3, -1
+    beqz         t1, 3f       /* last pixel */
+     nop
+    li           s0, 0xff     /* s0 = 0xff */
+    addiu        s1, zero, -1 /* s1 = 0xffffffff */
+
+    beq          t8, s0, 2f   /* if (srca == 0xff) */
+     nop
+1:
+                              /* a1 = src */
+    lw           t0, 0(a2)    /* t0 = mask */
+    lw           t1, 4(a2)    /* t1 = mask */
+    or           t2, t0, t1
+    beqz         t2, 12f      /* if (t0 == 0) && (t1 == 0) */
+     addiu       a2, a2, 8
+    and          t3, t0, t1
+    move         s2, a1       /* s2 = src */
+    move         s3, a1       /* s3 = src */
+    lhu          t2, 0(a0)    /* t2 = dst */
+    beq          t3, s1, 11f  /* if (t0 == 0xffffffff) && (t1 == 0xffffffff) */
+     lhu         t3, 2(a0)    /* t3 = dst */
+    MIPS_2xUN8x4_MUL_2xUN8x4 a1, a1, t0, t1, s2, s3, t9, t4, s4, s5, s6, s7, s8
+    MIPS_2xUN8x4_MUL_2xUN8   t0, t1, t8, t8, t0, t1, t9, t4, s4, s5, s6, s7, s8
+11:
+    not          t0, t0
+    not          t1, t1
+    CONVERT_2x0565_TO_2x8888 t2, t3, s4, s5, t6, t7, t4, s6, s7, s8
+    MIPS_2xUN8x4_MUL_2xUN8x4 s4, s5, t0, t1, s4, s5, t9, t4, s6, s7, s8, t0, t1
+    addu_s.qb    s2, s2, s4
+    addu_s.qb    s3, s3, s5
+    CONVERT_2x8888_TO_2x0565 s2, s3, t2, t3, t5, t6, t7, s4, s5
+    sh           t2, 0(a0)
+    sh           t3, 2(a0)
+12:
+    addiu        a3, a3, -2
+    addiu        t1, a3, -1
+    bgtz         t1, 1b
+     addiu       a0, a0, 4
+    b            3f
+     nop
+2:
+                              /* a1 = src */
+    lw           t0, 0(a2)    /* t0 = mask */
+    lw           t1, 4(a2)    /* t1 = mask */
+    or           t2, t0, t1
+    beqz         t2, 22f      /* if (t0 == 0) & (t1 == 0) */
+     addiu       a2, a2, 8
+    and          t3, t0, t1
+    move         t2, a1
+    beq          t3, s1, 21f  /* if (t0 == 0xffffffff) && (t1 == 0xffffffff) */
+     move        t3, a1
+    lhu          t2, 0(a0)    /* t2 = dst */
+    lhu          t3, 2(a0)    /* t3 = dst */
+    MIPS_2xUN8x4_MUL_2xUN8x4 a1, a1, t0, t1, s2, s3, t9, t4, s4, s5, s6, s7, s8
+    not          t0, t0
+    not          t1, t1
+    CONVERT_2x0565_TO_2x8888 t2, t3, s4, s5, t6, t7, t4, s6, s7, s8
+    MIPS_2xUN8x4_MUL_2xUN8x4 s4, s5, t0, t1, s4, s5, t9, t4, s6, s7, s8, t2, t3
+    addu_s.qb    t2, s2, s4
+    addu_s.qb    t3, s3, s5
+21:
+    CONVERT_2x8888_TO_2x0565 t2, t3, t0, t1, t5, t6, t7, s2, s3
+    sh           t0, 0(a0)
+    sh           t1, 2(a0)
+22:
+    addiu        a3, a3, -2
+    addiu        t1, a3, -1
+    bgtz         t1, 2b
+     addiu       a0, a0, 4
+3:
+    blez         a3, 4f
+     nop
+                              /* a1 = src */
+    lw           t1, 0(a2)    /* t1 = mask */
+    beqz         t1, 4f
+     nop
+    move         t2, a1       /* t2 = src */
+    beq          t1, t7, 31f
+     lhu         t0, 0(a0)    /* t0 = dst */
+
+    MIPS_UN8x4_MUL_UN8x4     a1, t1, t2, t9, t3, t4, t5, t6
+    MIPS_UN8x4_MUL_UN8       t1, t8, t1, t9, t3, t4, t5
+31:
+    not          t1, t1
+    CONVERT_1x0565_TO_1x8888 t0, s1, s2, s3
+    MIPS_UN8x4_MUL_UN8x4     s1, t1, t3, t9, t4, t5, t6, t7
+    addu_s.qb    t0, t2, t3
+    CONVERT_1x8888_TO_1x0565 t0, s1, s2, s3
+    sh           s1, 0(a0)
+4:
+    RESTORE_REGS_FROM_STACK  20, s0, s1, s2, s3, s4, s5, s6, s7, s8
+    j            ra
+     nop
+
+END(pixman_composite_over_n_8888_0565_ca_asm_mips)
+
+LEAF_MIPS_DSPR2(pixman_composite_over_n_8_8888_asm_mips)
+/*
+ * a0 - dst  (a8r8g8b8)
+ * a1 - src  (32bit constant)
+ * a2 - mask (a8)
+ * a3 - w
+ */
+
+    SAVE_REGS_ON_STACK 4, s0, s1, s2, s3, s4
+    beqz      a3, 4f
+     nop
+    li        t4, 0x00ff00ff
+    li        t5, 0xff
+    addiu     t0, a3, -1
+    beqz      t0, 3f         /* last pixel */
+     srl      t6, a1, 24     /* t6 = srca */
+    not       s4, a1
+    beq       t5, t6, 2f     /* if (srca == 0xff) */
+     srl      s4, s4, 24
+1:
+                             /* a1 = src */
+    lbu       t0, 0(a2)      /* t0 = mask */
+    lbu       t1, 1(a2)      /* t1 = mask */
+    or        t2, t0, t1
+    beqz      t2, 111f       /* if (t0 == 0) && (t1 == 0) */
+     addiu    a2, a2, 2
+    and       t3, t0, t1
+
+    lw        t2, 0(a0)      /* t2 = dst */
+    beq       t3, t5, 11f    /* if (t0 == 0xff) && (t1 == 0xff) */
+     lw       t3, 4(a0)      /* t3 = dst */
+
+    MIPS_2xUN8x4_MUL_2xUN8 a1, a1, t0, t1, s0, s1, t4, t6, t7, t8, t9, s2, s3
+    not       s2, s0
+    not       s3, s1
+    srl       s2, s2, 24
+    srl       s3, s3, 24
+    MIPS_2xUN8x4_MUL_2xUN8 t2, t3, s2, s3, t2, t3, t4, t0, t1, t6, t7, t8, t9
+    addu_s.qb s2, t2, s0
+    addu_s.qb s3, t3, s1
+    sw        s2, 0(a0)
+    b         111f
+     sw       s3, 4(a0)
+11:
+    MIPS_2xUN8x4_MUL_2xUN8 t2, t3, s4, s4, t2, t3, t4, t0, t1, t6, t7, t8, t9
+    addu_s.qb s2, t2, a1
+    addu_s.qb s3, t3, a1
+    sw        s2, 0(a0)
+    sw        s3, 4(a0)
+
+111:
+    addiu     a3, a3, -2
+    addiu     t0, a3, -1
+    bgtz      t0, 1b
+     addiu    a0, a0, 8
+    b         3f
+     nop
+2:
+                             /* a1 = src */
+    lbu       t0, 0(a2)      /* t0 = mask */
+    lbu       t1, 1(a2)      /* t1 = mask */
+    or        t2, t0, t1
+    beqz      t2, 222f       /* if (t0 == 0) && (t1 == 0) */
+     addiu    a2, a2, 2
+    and       t3, t0, t1
+    beq       t3, t5, 22f    /* if (t0 == 0xff) && (t1 == 0xff) */
+     nop
+    lw        t2, 0(a0)      /* t2 = dst */
+    lw        t3, 4(a0)      /* t3 = dst */
+
+    OVER_2x8888_2x8_2x8888 a1, a1, t0, t1, t2, t3, \
+                           t6, t7, t4, t8, t9, s0, s1, s2, s3
+    sw        t6, 0(a0)
+    b         222f
+     sw        t7, 4(a0)
+22:
+    sw        a1, 0(a0)
+    sw        a1, 4(a0)
+222:
+    addiu     a3, a3, -2
+    addiu     t0, a3, -1
+    bgtz      t0, 2b
+     addiu    a0, a0, 8
+3:
+    blez      a3, 4f
+     nop
+                             /* a1 = src */
+    lbu       t0, 0(a2)      /* t0 = mask */
+    beqz      t0, 4f         /* if (t0 == 0) */
+     addiu    a2, a2, 1
+    move      t3, a1
+    beq       t0, t5, 31f    /* if (t0 == 0xff) */
+     lw       t1, 0(a0)      /* t1 = dst */
+
+    MIPS_UN8x4_MUL_UN8 a1, t0, t3, t4, t6, t7, t8
+31:
+    not       t2, t3
+    srl       t2, t2, 24
+    MIPS_UN8x4_MUL_UN8 t1, t2, t1, t4, t6, t7, t8
+    addu_s.qb t2, t1, t3
+    sw        t2, 0(a0)
+4:
+    RESTORE_REGS_FROM_STACK 4, s0, s1, s2, s3, s4
+    j         ra
+     nop
+
+END(pixman_composite_over_n_8_8888_asm_mips)
+
+LEAF_MIPS_DSPR2(pixman_composite_over_n_8_0565_asm_mips)
+/*
+ * a0 - dst  (r5g6b5)
+ * a1 - src  (32bit constant)
+ * a2 - mask (a8)
+ * a3 - w
+ */
+    SAVE_REGS_ON_STACK 24, v0, s0, s1, s2, s3, s4, s5, s6, s7, s8
+    beqz     a3, 4f
+     nop
+    li       t4, 0x00ff00ff
+    li       t5, 0xff
+    li       t6, 0xf800f800
+    li       t7, 0x07e007e0
+    li       t8, 0x001F001F
+    addiu    t1, a3, -1
+    beqz     t1, 3f         /* last pixel */
+     srl     t0, a1, 24     /* t0 = srca */
+    not      v0, a1
+    beq      t0, t5, 2f     /* if (srca == 0xff) */
+     srl     v0, v0, 24
+1:
+                            /* a1 = src */
+    lbu      t0, 0(a2)      /* t0 = mask */
+    lbu      t1, 1(a2)      /* t1 = mask */
+    or       t2, t0, t1
+    beqz     t2, 111f       /* if (t0 == 0) && (t1 == 0) */
+     addiu   a2, a2, 2
+    lhu      t2, 0(a0)      /* t2 = dst */
+    lhu      t3, 2(a0)      /* t3 = dst */
+    CONVERT_2x0565_TO_2x8888 t2, t3, s0, s1, t7, t8, t9, s2, s3, s4
+    and      t9, t0, t1
+    beq      t9, t5, 11f    /* if (t0 == 0xff) && (t1 == 0xff) */
+     nop
+
+    MIPS_2xUN8x4_MUL_2xUN8   a1, a1, t0, t1, s2, s3, t4, t9, s4, s5, s6, s7, s8
+    not      s4, s2
+    not      s5, s3
+    srl      s4, s4, 24
+    srl      s5, s5, 24
+    MIPS_2xUN8x4_MUL_2xUN8   s0, s1, s4, s5, s0, s1, t4, t9, t0, t1, s6, s7, s8
+    addu_s.qb                s4, s2, s0
+    addu_s.qb                s5, s3, s1
+    CONVERT_2x8888_TO_2x0565 s4, s5, t2, t3, t6, t7, t8, s0, s1
+    sh       t2, 0(a0)
+    b        111f
+     sh      t3, 2(a0)
+11:
+    MIPS_2xUN8x4_MUL_2xUN8   s0, s1, v0, v0, s0, s1, t4, t9, t0, t1, s6, s7, s8
+    addu_s.qb                s4, a1, s0
+    addu_s.qb                s5, a1, s1
+    CONVERT_2x8888_TO_2x0565 s4, s5, t2, t3, t6, t7, t8, s0, s1
+    sh       t2, 0(a0)
+    sh       t3, 2(a0)
+111:
+    addiu    a3, a3, -2
+    addiu    t0, a3, -1
+    bgtz     t0, 1b
+     addiu   a0, a0, 4
+    b        3f
+     nop
+2:
+    CONVERT_1x8888_TO_1x0565 a1, s0, s1, s2
+21:
+                            /* a1 = src */
+    lbu      t0, 0(a2)      /* t0 = mask */
+    lbu      t1, 1(a2)      /* t1 = mask */
+    or       t2, t0, t1
+    beqz     t2, 222f       /* if (t0 == 0) && (t1 == 0) */
+     addiu   a2, a2, 2
+    and      t9, t0, t1
+    move     s2, s0
+    beq      t9, t5, 22f    /* if (t0 == 0xff) && (t2 == 0xff) */
+     move    s3, s0
+    lhu      t2, 0(a0)      /* t2 = dst */
+    lhu      t3, 2(a0)      /* t3 = dst */
+
+    CONVERT_2x0565_TO_2x8888 t2, t3, s2, s3, t7, t8, s4, s5, s6, s7
+    OVER_2x8888_2x8_2x8888   a1, a1, t0, t1, s2, s3, \
+                             t2, t3, t4, t9, s4, s5, s6, s7, s8
+    CONVERT_2x8888_TO_2x0565 t2, t3, s2, s3, t6, t7, t8, s4, s5
+22:
+    sh       s2, 0(a0)
+    sh       s3, 2(a0)
+222:
+    addiu    a3, a3, -2
+    addiu    t0, a3, -1
+    bgtz     t0, 21b
+     addiu   a0, a0, 4
+3:
+    blez      a3, 4f
+     nop
+                            /* a1 = src */
+    lbu      t0, 0(a2)      /* t0 = mask */
+    beqz     t0, 4f         /* if (t0 == 0) */
+     nop
+    lhu      t1, 0(a0)      /* t1 = dst */
+    CONVERT_1x0565_TO_1x8888 t1, t2, t3, t7
+    beq      t0, t5, 31f    /* if (t0 == 0xff) */
+     move    t3, a1
+
+    MIPS_UN8x4_MUL_UN8       a1, t0, t3, t4, t7, t8, t9
+31:
+    not      t6, t3
+    srl      t6, t6, 24
+    MIPS_UN8x4_MUL_UN8       t2, t6, t2, t4, t7, t8, t9
+    addu_s.qb                t1, t2, t3
+    CONVERT_1x8888_TO_1x0565 t1, t2, t3, t7
+    sh       t2, 0(a0)
+4:
+    RESTORE_REGS_FROM_STACK  24, v0, s0, s1, s2, s3, s4, s5, s6, s7, s8
+    j        ra
+     nop
+
+END(pixman_composite_over_n_8_0565_asm_mips)
+
+LEAF_MIPS_DSPR2(pixman_scaled_bilinear_scanline_8888_8_8888_OVER_asm_mips)
+/*
+ * a0     - dst        (a8r8g8b8)
+ * a1     - mask       (a8)
+ * a2     - src_top    (a8r8g8b8)
+ * a3     - src_bottom (a8r8g8b8)
+ * 16(sp) - wt
+ * 20(sp) - wb
+ * 24(sp) - vx
+ * 28(sp) - unit_x
+ * 32(sp) - w
+ */
+
+    SAVE_REGS_ON_STACK 28, v0, v1, s0, s1, s2, s3, s4, s5, s6, s7, s8
+
+    lw       v1, 60(sp)        /* v1 = w(sp + 32 + 28 save regs stack offset)*/
+    beqz     v1, 1f
+     nop
+
+    lw       s0, 44(sp)        /* s0 = wt */
+    lw       s1, 48(sp)        /* s1 = wb */
+    lw       s2, 52(sp)        /* s2 = vx */
+    lw       s3, 56(sp)        /* s3 = unit_x */
+    li       v0, 256
+    li       s8, 0x00ff00ff
+0:
+    andi     t4, s2, 0xffff    /* t4 = (short)vx */
+    srl      t4, t4, 8         /* t4 = vx >> 8 */
+    subu     t5, v0, t4        /* t5 = ( 256 - (vx>>8)) */
+
+    mul      s4, s0, t5        /* s4 = wt*(256-(vx>>8)) */
+    mul      s5, s0, t4        /* s5 = wt*(vx>>8) */
+    mul      s6, s1, t5        /* s6 = wb*(256-(vx>>8)) */
+    mul      s7, s1, t4        /* s7 = wb*(vx>>8) */
+
+    sra      t9, s2, 16
+    sll      t9, t9, 2
+    addiu    t8, t9, 4
+    lwx      t0, t9(a2)        /* t0 = tl */
+    lwx      t1, t8(a2)        /* t1 = tr */
+    addiu    v1, v1, -1
+    lwx      t2, t9(a3)        /* t2 = bl */
+    lwx      t3, t8(a3)        /* t3 = br */
+
+    BILINEAR_INTERPOLATE_SINGLE_PIXEL t0, t1, t2, t3, \
+                                      t4, t5, t6, t7, t8, t9, s4, s5, s6, s7
+    lbu      t1, 0(a1)         /* t1 = mask */
+    lw       t2, 0(a0)         /* t2 = dst */
+    addiu    a1, a1, 1
+    OVER_8888_8_8888 t0, t1, t2, t0, s8, t3, t4, t5, t6
+
+    addu     s2, s2, s3        /* vx += unit_x; */
+    sw       t0, 0(a0)
+    bnez     v1, 0b
+     addiu   a0, a0, 4
+
+1:
+    RESTORE_REGS_FROM_STACK 28, v0, v1, s0, s1, s2, s3, s4, s5, s6, s7, s8
+    j        ra
+     nop
+
+END(pixman_scaled_bilinear_scanline_8888_8_8888_OVER_asm_mips)
diff --git a/pixman/pixman-mips-dspr2-asm.h b/pixman/pixman-mips-dspr2-asm.h
new file mode 100644 (file)
index 0000000..7cf3281
--- /dev/null
@@ -0,0 +1,625 @@
+/*
+ * Copyright (c) 2012
+ *      MIPS Technologies, Inc., California.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Author:  Nemanja Lukic (nlukic@mips.com)
+ */
+
+#ifndef PIXMAN_MIPS_DSPR2_ASM_H
+#define PIXMAN_MIPS_DSPR2_ASM_H
+
+#define zero $0
+#define AT   $1
+#define v0   $2
+#define v1   $3
+#define a0   $4
+#define a1   $5
+#define a2   $6
+#define a3   $7
+#define t0   $8
+#define t1   $9
+#define t2   $10
+#define t3   $11
+#define t4   $12
+#define t5   $13
+#define t6   $14
+#define t7   $15
+#define s0   $16
+#define s1   $17
+#define s2   $18
+#define s3   $19
+#define s4   $20
+#define s5   $21
+#define s6   $22
+#define s7   $23
+#define t8   $24
+#define t9   $25
+#define k0   $26
+#define k1   $27
+#define gp   $28
+#define sp   $29
+#define fp   $30
+#define s8   $30
+#define ra   $31
+
+/*
+ * LEAF_MIPS32R2 - declare leaf routine for MIPS32r2
+ */
+#define LEAF_MIPS32R2(symbol)                           \
+                .globl  symbol;                         \
+                .align  2;                              \
+                .type   symbol, @function;              \
+                .ent    symbol, 0;                      \
+symbol:         .frame  sp, 0, ra;                      \
+                .set    push;                           \
+                .set    arch=mips32r2;                  \
+                .set    noreorder;                      \
+                .set    noat;
+
+/*
+ * LEAF_MIPS32R2 - declare leaf routine for MIPS DSPr2
+ */
+#define LEAF_MIPS_DSPR2(symbol)                         \
+LEAF_MIPS32R2(symbol)                                   \
+                .set    dspr2;
+
+/*
+ * END - mark end of function
+ */
+#define END(function)                                   \
+                .set    pop;                            \
+                .end    function;                       \
+                .size   function,.-function
+
+/*
+ * Checks if stack offset is big enough for storing/restoring regs_num
+ * number of register to/from stack. Stack offset must be greater than
+ * or equal to the number of bytes needed for storing registers (regs_num*4).
+ * Since MIPS ABI allows usage of first 16 bytes of stack frame (this is
+ * preserved for input arguments of the functions, already stored in a0-a3),
+ * stack size can be further optimized by utilizing this space.
+ */
+.macro CHECK_STACK_OFFSET regs_num, stack_offset
+.if \stack_offset < \regs_num * 4 - 16
+.error "Stack offset too small."
+.endif
+.endm
+
+/*
+ * Saves set of registers on stack. Maximum number of registers that
+ * can be saved on stack is limitted to 14 (a0-a3, v0-v1 and s0-s7).
+ * Stack offset is number of bytes that are added to stack pointer (sp)
+ * before registers are pushed in order to provide enough space on stack
+ * (offset must be multiple of 4, and must be big enough, as described by
+ * CHECK_STACK_OFFSET macro). This macro is intended to be used in
+ * combination with RESTORE_REGS_FROM_STACK macro. Example:
+ *  SAVE_REGS_ON_STACK      4, v0, v1, s0, s1
+ *  RESTORE_REGS_FROM_STACK 4, v0, v1, s0, s1
+ */
+.macro SAVE_REGS_ON_STACK stack_offset = 0, r1, \
+                          r2  = 0, r3  = 0, r4  = 0, \
+                          r5  = 0, r6  = 0, r7  = 0, \
+                          r8  = 0, r9  = 0, r10 = 0, \
+                          r11 = 0, r12 = 0, r13 = 0, \
+                          r14 = 0
+    .if (\stack_offset < 0) || (\stack_offset - (\stack_offset / 4) * 4)
+    .error "Stack offset must be pozitive and multiple of 4."
+    .endif
+    .if \stack_offset != 0
+    addiu           sp, sp, -\stack_offset
+    .endif
+    sw              \r1, 0(sp)
+    .if \r2 != 0
+    sw              \r2, 4(sp)
+    .endif
+    .if \r3 != 0
+    sw              \r3, 8(sp)
+    .endif
+    .if \r4 != 0
+    sw              \r4, 12(sp)
+    .endif
+    .if \r5 != 0
+    CHECK_STACK_OFFSET 5, \stack_offset
+    sw              \r5, 16(sp)
+    .endif
+    .if \r6 != 0
+    CHECK_STACK_OFFSET 6, \stack_offset
+    sw              \r6, 20(sp)
+    .endif
+    .if \r7 != 0
+    CHECK_STACK_OFFSET 7, \stack_offset
+    sw              \r7, 24(sp)
+    .endif
+    .if \r8 != 0
+    CHECK_STACK_OFFSET 8, \stack_offset
+    sw              \r8, 28(sp)
+    .endif
+    .if \r9 != 0
+    CHECK_STACK_OFFSET 9, \stack_offset
+    sw              \r9, 32(sp)
+    .endif
+    .if \r10 != 0
+    CHECK_STACK_OFFSET 10, \stack_offset
+    sw              \r10, 36(sp)
+    .endif
+    .if \r11 != 0
+    CHECK_STACK_OFFSET 11, \stack_offset
+    sw              \r11, 40(sp)
+    .endif
+    .if \r12 != 0
+    CHECK_STACK_OFFSET 12, \stack_offset
+    sw              \r12, 44(sp)
+    .endif
+    .if \r13 != 0
+    CHECK_STACK_OFFSET 13, \stack_offset
+    sw              \r13, 48(sp)
+    .endif
+    .if \r14 != 0
+    CHECK_STACK_OFFSET 14, \stack_offset
+    sw              \r14, 52(sp)
+    .endif
+.endm
+
+/*
+ * Restores set of registers from stack. Maximum number of registers that
+ * can be restored from stack is limitted to 14 (a0-a3, v0-v1 and s0-s7).
+ * Stack offset is number of bytes that are added to stack pointer (sp)
+ * after registers are restored (offset must be multiple of 4, and must
+ * be big enough, as described by CHECK_STACK_OFFSET macro). This macro is
+ * intended to be used in combination with RESTORE_REGS_FROM_STACK macro.
+ * Example:
+ *  SAVE_REGS_ON_STACK      4, v0, v1, s0, s1
+ *  RESTORE_REGS_FROM_STACK 4, v0, v1, s0, s1
+ */
+.macro RESTORE_REGS_FROM_STACK stack_offset = 0, r1, \
+                               r2  = 0, r3  = 0, r4  = 0, \
+                               r5  = 0, r6  = 0, r7  = 0, \
+                               r8  = 0, r9  = 0, r10 = 0, \
+                               r11 = 0, r12 = 0, r13 = 0, \
+                               r14 = 0
+    .if (\stack_offset < 0) || (\stack_offset - (\stack_offset/4)*4)
+    .error "Stack offset must be pozitive and multiple of 4."
+    .endif
+    lw              \r1, 0(sp)
+    .if \r2 != 0
+    lw              \r2, 4(sp)
+    .endif
+    .if \r3 != 0
+    lw              \r3, 8(sp)
+    .endif
+    .if \r4 != 0
+    lw              \r4, 12(sp)
+    .endif
+    .if \r5 != 0
+    CHECK_STACK_OFFSET 5, \stack_offset
+    lw              \r5, 16(sp)
+    .endif
+    .if \r6 != 0
+    CHECK_STACK_OFFSET 6, \stack_offset
+    lw              \r6, 20(sp)
+    .endif
+    .if \r7 != 0
+    CHECK_STACK_OFFSET 7, \stack_offset
+    lw              \r7, 24(sp)
+    .endif
+    .if \r8 != 0
+    CHECK_STACK_OFFSET 8, \stack_offset
+    lw              \r8, 28(sp)
+    .endif
+    .if \r9 != 0
+    CHECK_STACK_OFFSET 9, \stack_offset
+    lw              \r9, 32(sp)
+    .endif
+    .if \r10 != 0
+    CHECK_STACK_OFFSET 10, \stack_offset
+    lw              \r10, 36(sp)
+    .endif
+    .if \r11 != 0
+    CHECK_STACK_OFFSET 11, \stack_offset
+    lw              \r11, 40(sp)
+    .endif
+    .if \r12 != 0
+    CHECK_STACK_OFFSET 12, \stack_offset
+    lw              \r12, 44(sp)
+    .endif
+    .if \r13 != 0
+    CHECK_STACK_OFFSET 13, \stack_offset
+    lw              \r13, 48(sp)
+    .endif
+    .if \r14 != 0
+    CHECK_STACK_OFFSET 14, \stack_offset
+    lw              \r14, 52(sp)
+    .endif
+    .if \stack_offset != 0
+    addiu           sp, sp, \stack_offset
+    .endif
+.endm
+
+/*
+ * Conversion of single r5g6b5 pixel (in_565) to single a8r8g8b8 pixel
+ * returned in (out_8888) register. Requires two temporary registers
+ * (scratch1 and scratch2).
+ */
+.macro CONVERT_1x0565_TO_1x8888 in_565,   \
+                                out_8888, \
+                                scratch1, scratch2
+    lui     \out_8888, 0xff00
+    sll     \scratch1, \in_565,   0x3
+    andi    \scratch2, \scratch1, 0xff
+    ext     \scratch1, \in_565,   0x2, 0x3
+    or      \scratch1, \scratch2, \scratch1
+    or      \out_8888, \out_8888, \scratch1
+
+    sll     \scratch1, \in_565,   0x5
+    andi    \scratch1, \scratch1, 0xfc00
+    srl     \scratch2, \in_565,   0x1
+    andi    \scratch2, \scratch2, 0x300
+    or      \scratch2, \scratch1, \scratch2
+    or      \out_8888, \out_8888, \scratch2
+
+    andi    \scratch1, \in_565,   0xf800
+    srl     \scratch2, \scratch1, 0x5
+    andi    \scratch2, \scratch2, 0xff00
+    or      \scratch1, \scratch1, \scratch2
+    sll     \scratch1, \scratch1, 0x8
+    or      \out_8888, \out_8888, \scratch1
+.endm
+
+/*
+ * Conversion of two r5g6b5 pixels (in1_565 and in2_565) to two a8r8g8b8 pixels
+ * returned in (out1_8888 and out2_8888) registers. Requires four scratch
+ * registers (scratch1 ... scratch4). It also requires maskG and maskB for
+ * color component extractions. These masks must have following values:
+ *   li       maskG, 0x07e007e0
+ *   li       maskB, 0x001F001F
+ */
+.macro CONVERT_2x0565_TO_2x8888 in1_565, in2_565,     \
+                                out1_8888, out2_8888, \
+                                maskG, maskB,         \
+                                scratch1, scratch2, scratch3, scratch4
+    sll               \scratch1,  \in1_565,   16
+    or                \scratch1,  \scratch1,  \in2_565
+    lui               \out2_8888, 0xff00
+    ori               \out2_8888, \out2_8888, 0xff00
+    shrl.ph           \scratch2,  \scratch1,  11
+    and               \scratch3,  \scratch1,  \maskG
+    shra.ph           \scratch4,  \scratch2,  2
+    shll.ph           \scratch2,  \scratch2,  3
+    shll.ph           \scratch3,  \scratch3,  5
+    or                \scratch2,  \scratch2,  \scratch4
+    shrl.qb           \scratch4,  \scratch3,  6
+    or                \out2_8888, \out2_8888, \scratch2
+    or                \scratch3,  \scratch3,  \scratch4
+    and               \scratch1,  \scratch1,  \maskB
+    shll.ph           \scratch2,  \scratch1,  3
+    shra.ph           \scratch4,  \scratch1,  2
+    or                \scratch2,  \scratch2,  \scratch4
+    or                \scratch3,  \scratch2,  \scratch3
+    precrq.ph.w       \out1_8888, \out2_8888, \scratch3
+    precr_sra.ph.w    \out2_8888, \scratch3,  0
+.endm
+
+/*
+ * Conversion of single a8r8g8b8 pixel (in_8888) to single r5g6b5 pixel
+ * returned in (out_565) register. Requires two temporary registers
+ * (scratch1 and scratch2).
+ */
+.macro CONVERT_1x8888_TO_1x0565 in_8888, \
+                                out_565, \
+                                scratch1, scratch2
+    ext     \out_565,  \in_8888,  0x3, 0x5
+    srl     \scratch1, \in_8888,  0x5
+    andi    \scratch1, \scratch1, 0x07e0
+    srl     \scratch2, \in_8888,  0x8
+    andi    \scratch2, \scratch2, 0xf800
+    or      \out_565,  \out_565,  \scratch1
+    or      \out_565,  \out_565,  \scratch2
+.endm
+
+/*
+ * Conversion of two a8r8g8b8 pixels (in1_8888 and in2_8888) to two r5g6b5
+ * pixels returned in (out1_565 and out2_565) registers. Requires two temporary
+ * registers (scratch1 and scratch2). It also requires maskR, maskG and maskB
+ * for color component extractions. These masks must have following values:
+ *   li       maskR, 0xf800f800
+ *   li       maskG, 0x07e007e0
+ *   li       maskB, 0x001F001F
+ * Value of input register in2_8888 is lost.
+ */
+.macro CONVERT_2x8888_TO_2x0565 in1_8888, in2_8888,  \
+                                out1_565, out2_565,  \
+                                maskR, maskG, maskB, \
+                                scratch1, scratch2
+    precrq.ph.w       \scratch1, \in2_8888, \in1_8888
+    precr_sra.ph.w    \in2_8888, \in1_8888, 0
+    shll.ph           \scratch1, \scratch1, 8
+    srl               \in2_8888, \in2_8888, 3
+    and               \scratch2, \in2_8888, \maskB
+    and               \scratch1, \scratch1, \maskR
+    srl               \in2_8888, \in2_8888, 2
+    and               \out2_565, \in2_8888, \maskG
+    or                \out2_565, \out2_565, \scratch2
+    or                \out1_565, \out2_565, \scratch1
+    srl               \out2_565, \out1_565, 16
+.endm
+
+/*
+ * Multiply pixel (a8) with single pixel (a8r8g8b8). It requires maskLSR needed
+ * for rounding process. maskLSR must have following value:
+ *   li       maskLSR, 0x00ff00ff
+ */
+.macro MIPS_UN8x4_MUL_UN8 s_8888,  \
+                          m_8,     \
+                          d_8888,  \
+                          maskLSR, \
+                          scratch1, scratch2, scratch3
+    replv.ph          \m_8,      \m_8                 /*   0 | M | 0 | M */
+    muleu_s.ph.qbl    \scratch1, \s_8888,   \m_8      /*    A*M  |  R*M */
+    muleu_s.ph.qbr    \scratch2, \s_8888,   \m_8      /*    G*M  |  B*M */
+    shra_r.ph         \scratch3, \scratch1, 8
+    shra_r.ph         \d_8888,   \scratch2, 8
+    and               \scratch3, \scratch3, \maskLSR  /*   0 |A*M| 0 |R*M */
+    and               \d_8888,   \d_8888,   \maskLSR  /*   0 |G*M| 0 |B*M */
+    addq.ph           \scratch1, \scratch1, \scratch3 /* A*M+A*M | R*M+R*M */
+    addq.ph           \scratch2, \scratch2, \d_8888   /* G*M+G*M | B*M+B*M */
+    shra_r.ph         \scratch1, \scratch1, 8
+    shra_r.ph         \scratch2, \scratch2, 8
+    precr.qb.ph       \d_8888,   \scratch1, \scratch2
+.endm
+
+/*
+ * Multiply two pixels (a8) with two pixels (a8r8g8b8). It requires maskLSR
+ * needed for rounding process. maskLSR must have following value:
+ *   li       maskLSR, 0x00ff00ff
+ */
+.macro MIPS_2xUN8x4_MUL_2xUN8 s1_8888, \
+                              s2_8888, \
+                              m1_8,    \
+                              m2_8,    \
+                              d1_8888, \
+                              d2_8888, \
+                              maskLSR, \
+                              scratch1, scratch2, scratch3, \
+                              scratch4, scratch5, scratch6
+    replv.ph          \m1_8,     \m1_8                /*  0 | M1 | 0 | M1 */
+    replv.ph          \m2_8,     \m2_8                /*  0 | M2 | 0 | M2 */
+    muleu_s.ph.qbl    \scratch1, \s1_8888,  \m1_8     /*  A1*M1  |  R1*M1 */
+    muleu_s.ph.qbr    \scratch2, \s1_8888,  \m1_8     /*  G1*M1  |  B1*M1 */
+    muleu_s.ph.qbl    \scratch3, \s2_8888,  \m2_8     /*  A2*M2  |  R2*M2 */
+    muleu_s.ph.qbr    \scratch4, \s2_8888,  \m2_8     /*  G2*M2  |  B2*M2 */
+    shra_r.ph         \scratch5, \scratch1, 8
+    shra_r.ph         \d1_8888,  \scratch2, 8
+    shra_r.ph         \scratch6, \scratch3, 8
+    shra_r.ph         \d2_8888,  \scratch4, 8
+    and               \scratch5, \scratch5, \maskLSR  /* 0 |A1*M1| 0 |R1*M1 */
+    and               \d1_8888,  \d1_8888,  \maskLSR  /* 0 |G1*M1| 0 |B1*M1 */
+    and               \scratch6, \scratch6, \maskLSR  /* 0 |A2*M2| 0 |R2*M2 */
+    and               \d2_8888,  \d2_8888,  \maskLSR  /* 0 |G2*M2| 0 |B2*M2 */
+    addq.ph           \scratch1, \scratch1, \scratch5
+    addq.ph           \scratch2, \scratch2, \d1_8888
+    addq.ph           \scratch3, \scratch3, \scratch6
+    addq.ph           \scratch4, \scratch4, \d2_8888
+    shra_r.ph         \scratch1, \scratch1, 8
+    shra_r.ph         \scratch2, \scratch2, 8
+    shra_r.ph         \scratch3, \scratch3, 8
+    shra_r.ph         \scratch4, \scratch4, 8
+    precr.qb.ph       \d1_8888,  \scratch1, \scratch2
+    precr.qb.ph       \d2_8888,  \scratch3, \scratch4
+.endm
+
+/*
+ * Multiply pixel (a8r8g8b8) with single pixel (a8r8g8b8). It requires maskLSR
+ * needed for rounding process. maskLSR must have following value:
+ *   li       maskLSR, 0x00ff00ff
+ */
+.macro MIPS_UN8x4_MUL_UN8x4 s_8888,  \
+                            m_8888,  \
+                            d_8888,  \
+                            maskLSR, \
+                            scratch1, scratch2, scratch3, scratch4
+    preceu.ph.qbl     \scratch1, \m_8888              /*   0 | A | 0 | R */
+    preceu.ph.qbr     \scratch2, \m_8888              /*   0 | G | 0 | B */
+    muleu_s.ph.qbl    \scratch3, \s_8888,   \scratch1 /*    A*A  |  R*R */
+    muleu_s.ph.qbr    \scratch4, \s_8888,   \scratch2 /*    G*G  |  B*B */
+    shra_r.ph         \scratch1, \scratch3, 8
+    shra_r.ph         \scratch2, \scratch4, 8
+    and               \scratch1, \scratch1, \maskLSR  /*   0 |A*A| 0 |R*R */
+    and               \scratch2, \scratch2, \maskLSR  /*   0 |G*G| 0 |B*B */
+    addq.ph           \scratch1, \scratch1, \scratch3
+    addq.ph           \scratch2, \scratch2, \scratch4
+    shra_r.ph         \scratch1, \scratch1, 8
+    shra_r.ph         \scratch2, \scratch2, 8
+    precr.qb.ph       \d_8888,   \scratch1, \scratch2
+.endm
+
+/*
+ * Multiply two pixels (a8r8g8b8) with two pixels (a8r8g8b8). It requires
+ * maskLSR needed for rounding process. maskLSR must have following value:
+ *   li       maskLSR, 0x00ff00ff
+ */
+
+.macro MIPS_2xUN8x4_MUL_2xUN8x4 s1_8888,  \
+                                s2_8888,  \
+                                m1_8888,  \
+                                m2_8888,  \
+                                d1_8888,  \
+                                d2_8888,  \
+                                maskLSR,  \
+                                scratch1, scratch2, scratch3, \
+                                scratch4, scratch5, scratch6
+    preceu.ph.qbl     \scratch1, \m1_8888             /*   0 | A | 0 | R */
+    preceu.ph.qbr     \scratch2, \m1_8888             /*   0 | G | 0 | B */
+    preceu.ph.qbl     \scratch3, \m2_8888             /*   0 | A | 0 | R */
+    preceu.ph.qbr     \scratch4, \m2_8888             /*   0 | G | 0 | B */
+    muleu_s.ph.qbl    \scratch5, \s1_8888,  \scratch1 /*    A*A  |  R*R */
+    muleu_s.ph.qbr    \scratch6, \s1_8888,  \scratch2 /*    G*G  |  B*B */
+    muleu_s.ph.qbl    \scratch1, \s2_8888,  \scratch3 /*    A*A  |  R*R */
+    muleu_s.ph.qbr    \scratch2, \s2_8888,  \scratch4 /*    G*G  |  B*B */
+    shra_r.ph         \scratch3, \scratch5, 8
+    shra_r.ph         \scratch4, \scratch6, 8
+    shra_r.ph         \d1_8888,  \scratch1, 8
+    shra_r.ph         \d2_8888,  \scratch2, 8
+    and               \scratch3, \scratch3, \maskLSR  /*   0 |A*A| 0 |R*R */
+    and               \scratch4, \scratch4, \maskLSR  /*   0 |G*G| 0 |B*B */
+    and               \d1_8888,  \d1_8888,  \maskLSR  /*   0 |A*A| 0 |R*R */
+    and               \d2_8888,  \d2_8888,  \maskLSR  /*   0 |G*G| 0 |B*B */
+    addq.ph           \scratch3, \scratch3, \scratch5
+    addq.ph           \scratch4, \scratch4, \scratch6
+    addq.ph           \d1_8888,  \d1_8888,  \scratch1
+    addq.ph           \d2_8888,  \d2_8888,  \scratch2
+    shra_r.ph         \scratch3, \scratch3, 8
+    shra_r.ph         \scratch4, \scratch4, 8
+    shra_r.ph         \scratch5, \d1_8888,  8
+    shra_r.ph         \scratch6, \d2_8888,  8
+    precr.qb.ph       \d1_8888,  \scratch3, \scratch4
+    precr.qb.ph       \d2_8888,  \scratch5, \scratch6
+.endm
+
+/*
+ * OVER operation on single a8r8g8b8 source pixel (s_8888) and single a8r8g8b8
+ * destination pixel (d_8888) using a8 mask (m_8). It also requires maskLSR
+ * needed for rounding process. maskLSR must have following value:
+ *   li       maskLSR, 0x00ff00ff
+ */
+.macro OVER_8888_8_8888 s_8888,   \
+                        m_8,      \
+                        d_8888,   \
+                        out_8888, \
+                        maskLSR,  \
+                        scratch1, scratch2, scratch3, scratch4
+    MIPS_UN8x4_MUL_UN8 \s_8888,   \m_8, \
+                       \scratch1, \maskLSR, \
+                       \scratch2, \scratch3, \scratch4
+
+    not                \scratch2, \scratch1
+    srl                \scratch2, \scratch2, 24
+
+    MIPS_UN8x4_MUL_UN8 \d_8888,   \scratch2, \
+                       \d_8888,   \maskLSR,  \
+                       \scratch3, \scratch4, \out_8888
+
+    addu_s.qb          \out_8888, \d_8888,   \scratch1
+.endm
+
+/*
+ * OVER operation on two a8r8g8b8 source pixels (s1_8888 and s2_8888) and two
+ * a8r8g8b8 destination pixels (d1_8888 and d2_8888) using a8 masks (m1_8 and
+ * m2_8). It also requires maskLSR needed for rounding process. maskLSR must
+ * have following value:
+ *   li       maskLSR, 0x00ff00ff
+ */
+.macro OVER_2x8888_2x8_2x8888 s1_8888,   \
+                              s2_8888,   \
+                              m1_8,      \
+                              m2_8,      \
+                              d1_8888,   \
+                              d2_8888,   \
+                              out1_8888, \
+                              out2_8888, \
+                              maskLSR,   \
+                              scratch1, scratch2, scratch3, \
+                              scratch4, scratch5, scratch6
+    MIPS_2xUN8x4_MUL_2xUN8 \s1_8888,   \s2_8888, \
+                           \m1_8,      \m2_8, \
+                           \scratch1,  \scratch2, \
+                           \maskLSR, \
+                           \scratch3,  \scratch4, \out1_8888, \
+                           \out2_8888, \scratch5, \scratch6
+
+    not                    \scratch3,  \scratch1
+    srl                    \scratch3,  \scratch3, 24
+    not                    \scratch4,  \scratch2
+    srl                    \scratch4,  \scratch4, 24
+
+    MIPS_2xUN8x4_MUL_2xUN8 \d1_8888,   \d2_8888, \
+                           \scratch3,  \scratch4, \
+                           \d1_8888,   \d2_8888, \
+                           \maskLSR, \
+                           \scratch5,  \scratch6, \out1_8888, \
+                           \out2_8888, \scratch3, \scratch4
+
+    addu_s.qb              \out1_8888, \d1_8888,  \scratch1
+    addu_s.qb              \out2_8888, \d2_8888,  \scratch2
+.endm
+
+.macro BILINEAR_INTERPOLATE_SINGLE_PIXEL tl, tr, bl, br,         \
+                                         scratch1, scratch2,     \
+                                         alpha, red, green, blue \
+                                         wt1, wt2, wb1, wb2
+    andi            \scratch1, \tl,  0xff
+    andi            \scratch2, \tr,  0xff
+    andi            \alpha,    \bl,  0xff
+    andi            \red,      \br,  0xff
+
+    multu           $ac0,      \wt1, \scratch1
+    maddu           $ac0,      \wt2, \scratch2
+    maddu           $ac0,      \wb1, \alpha
+    maddu           $ac0,      \wb2, \red
+
+    ext             \scratch1, \tl,  8, 8
+    ext             \scratch2, \tr,  8, 8
+    ext             \alpha,    \bl,  8, 8
+    ext             \red,      \br,  8, 8
+
+    multu           $ac1,      \wt1, \scratch1
+    maddu           $ac1,      \wt2, \scratch2
+    maddu           $ac1,      \wb1, \alpha
+    maddu           $ac1,      \wb2, \red
+
+    ext             \scratch1, \tl,  16, 8
+    ext             \scratch2, \tr,  16, 8
+    ext             \alpha,    \bl,  16, 8
+    ext             \red,      \br,  16, 8
+
+    mflo            \blue,     $ac0
+
+    multu           $ac2,      \wt1, \scratch1
+    maddu           $ac2,      \wt2, \scratch2
+    maddu           $ac2,      \wb1, \alpha
+    maddu           $ac2,      \wb2, \red
+
+    ext             \scratch1, \tl,  24, 8
+    ext             \scratch2, \tr,  24, 8
+    ext             \alpha,    \bl,  24, 8
+    ext             \red,      \br,  24, 8
+
+    mflo            \green,    $ac1
+
+    multu           $ac3,      \wt1, \scratch1
+    maddu           $ac3,      \wt2, \scratch2
+    maddu           $ac3,      \wb1, \alpha
+    maddu           $ac3,      \wb2, \red
+
+    mflo            \red,      $ac2
+    mflo            \alpha,    $ac3
+
+    precr.qb.ph     \alpha,    \alpha, \red
+    precr.qb.ph     \scratch1, \green, \blue
+    precrq.qb.ph    \tl,       \alpha, \scratch1
+.endm
+
+#endif //PIXMAN_MIPS_DSPR2_ASM_H
diff --git a/pixman/pixman-mips-dspr2.c b/pixman/pixman-mips-dspr2.c
new file mode 100644 (file)
index 0000000..06d4335
--- /dev/null
@@ -0,0 +1,275 @@
+/*
+ * Copyright (c) 2012
+ *      MIPS Technologies, Inc., California.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Author:  Nemanja Lukic (nlukic@mips.com)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "pixman-private.h"
+#include "pixman-mips-dspr2.h"
+
+PIXMAN_MIPS_BIND_FAST_PATH_SRC_DST (0, src_x888_8888,
+                                    uint32_t, 1, uint32_t, 1)
+PIXMAN_MIPS_BIND_FAST_PATH_SRC_DST (0, src_8888_0565,
+                                    uint32_t, 1, uint16_t, 1)
+PIXMAN_MIPS_BIND_FAST_PATH_SRC_DST (0, src_0565_8888,
+                                    uint16_t, 1, uint32_t, 1)
+PIXMAN_MIPS_BIND_FAST_PATH_SRC_DST (DO_FAST_MEMCPY, src_0565_0565,
+                                    uint16_t, 1, uint16_t, 1)
+PIXMAN_MIPS_BIND_FAST_PATH_SRC_DST (DO_FAST_MEMCPY, src_8888_8888,
+                                    uint32_t, 1, uint32_t, 1)
+PIXMAN_MIPS_BIND_FAST_PATH_SRC_DST (DO_FAST_MEMCPY, src_0888_0888,
+                                    uint8_t, 3, uint8_t, 3)
+
+PIXMAN_MIPS_BIND_FAST_PATH_N_MASK_DST (SKIP_ZERO_SRC, over_n_8888_8888_ca,
+                                       uint32_t, 1, uint32_t, 1)
+PIXMAN_MIPS_BIND_FAST_PATH_N_MASK_DST (SKIP_ZERO_SRC, over_n_8888_0565_ca,
+                                       uint32_t, 1, uint16_t, 1)
+PIXMAN_MIPS_BIND_FAST_PATH_N_MASK_DST (SKIP_ZERO_SRC, over_n_8_8888,
+                                       uint8_t, 1, uint32_t, 1)
+PIXMAN_MIPS_BIND_FAST_PATH_N_MASK_DST (SKIP_ZERO_SRC, over_n_8_0565,
+                                       uint8_t, 1, uint16_t, 1)
+
+PIXMAN_MIPS_BIND_SCALED_BILINEAR_SRC_A8_DST (SKIP_ZERO_SRC, 8888_8_8888, OVER,
+                                             uint32_t, uint32_t)
+
+static pixman_bool_t
+pixman_fill_mips (uint32_t *bits,
+                  int       stride,
+                  int       bpp,
+                  int       x,
+                  int       y,
+                  int       width,
+                  int       height,
+                  uint32_t  _xor)
+{
+    uint8_t *byte_line;
+    uint32_t byte_width;
+    switch (bpp)
+    {
+    case 16:
+        stride = stride * (int) sizeof (uint32_t) / 2;
+        byte_line = (uint8_t *)(((uint16_t *)bits) + stride * y + x);
+        byte_width = width * 2;
+        stride *= 2;
+
+        while (height--)
+        {
+            uint8_t *dst = byte_line;
+            byte_line += stride;
+            pixman_fill_buff16_mips (dst, byte_width, _xor & 0xffff);
+        }
+        return TRUE;
+    case 32:
+        stride = stride * (int) sizeof (uint32_t) / 4;
+        byte_line = (uint8_t *)(((uint32_t *)bits) + stride * y + x);
+        byte_width = width * 4;
+        stride *= 4;
+
+        while (height--)
+        {
+            uint8_t *dst = byte_line;
+            byte_line += stride;
+            pixman_fill_buff32_mips (dst, byte_width, _xor);
+        }
+        return TRUE;
+    default:
+        return FALSE;
+    }
+}
+
+static pixman_bool_t
+pixman_blt_mips (uint32_t *src_bits,
+                 uint32_t *dst_bits,
+                 int       src_stride,
+                 int       dst_stride,
+                 int       src_bpp,
+                 int       dst_bpp,
+                 int       src_x,
+                 int       src_y,
+                 int       dest_x,
+                 int       dest_y,
+                 int       width,
+                 int       height)
+{
+    if (src_bpp != dst_bpp)
+        return FALSE;
+
+    uint8_t *src_bytes;
+    uint8_t *dst_bytes;
+    uint32_t byte_width;
+
+    switch (src_bpp)
+    {
+    case 16:
+        src_stride = src_stride * (int) sizeof (uint32_t) / 2;
+        dst_stride = dst_stride * (int) sizeof (uint32_t) / 2;
+        src_bytes =(uint8_t *)(((uint16_t *)src_bits)
+                                          + src_stride * (src_y) + (src_x));
+        dst_bytes = (uint8_t *)(((uint16_t *)dst_bits)
+                                           + dst_stride * (dest_y) + (dest_x));
+        byte_width = width * 2;
+        src_stride *= 2;
+        dst_stride *= 2;
+
+        while (height--)
+        {
+            uint8_t *src = src_bytes;
+            uint8_t *dst = dst_bytes;
+            src_bytes += src_stride;
+            dst_bytes += dst_stride;
+            pixman_mips_fast_memcpy (dst, src, byte_width);
+        }
+        return TRUE;
+    case 32:
+        src_stride = src_stride * (int) sizeof (uint32_t) / 4;
+        dst_stride = dst_stride * (int) sizeof (uint32_t) / 4;
+        src_bytes = (uint8_t *)(((uint32_t *)src_bits)
+                                           + src_stride * (src_y) + (src_x));
+        dst_bytes = (uint8_t *)(((uint32_t *)dst_bits)
+                                           + dst_stride * (dest_y) + (dest_x));
+        byte_width = width * 4;
+        src_stride *= 4;
+        dst_stride *= 4;
+
+        while (height--)
+        {
+            uint8_t *src = src_bytes;
+            uint8_t *dst = dst_bytes;
+            src_bytes += src_stride;
+            dst_bytes += dst_stride;
+            pixman_mips_fast_memcpy (dst, src, byte_width);
+        }
+        return TRUE;
+    default:
+        return FALSE;
+    }
+}
+
+static const pixman_fast_path_t mips_dspr2_fast_paths[] =
+{
+    PIXMAN_STD_FAST_PATH (SRC, r5g6b5,   null, r5g6b5,   mips_composite_src_0565_0565),
+    PIXMAN_STD_FAST_PATH (SRC, b5g6r5,   null, b5g6r5,   mips_composite_src_0565_0565),
+    PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, r5g6b5,   mips_composite_src_8888_0565),
+    PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, r5g6b5,   mips_composite_src_8888_0565),
+    PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, b5g6r5,   mips_composite_src_8888_0565),
+    PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, b5g6r5,   mips_composite_src_8888_0565),
+    PIXMAN_STD_FAST_PATH (SRC, r5g6b5,   null, a8r8g8b8, mips_composite_src_0565_8888),
+    PIXMAN_STD_FAST_PATH (SRC, r5g6b5,   null, x8r8g8b8, mips_composite_src_0565_8888),
+    PIXMAN_STD_FAST_PATH (SRC, b5g6r5,   null, a8b8g8r8, mips_composite_src_0565_8888),
+    PIXMAN_STD_FAST_PATH (SRC, b5g6r5,   null, x8b8g8r8, mips_composite_src_0565_8888),
+    PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, x8r8g8b8, mips_composite_src_8888_8888),
+    PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, x8r8g8b8, mips_composite_src_8888_8888),
+    PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, x8b8g8r8, mips_composite_src_8888_8888),
+    PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, x8b8g8r8, mips_composite_src_8888_8888),
+    PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, a8r8g8b8, mips_composite_src_8888_8888),
+    PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, a8b8g8r8, mips_composite_src_8888_8888),
+    PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, a8r8g8b8, mips_composite_src_x888_8888),
+    PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, a8b8g8r8, mips_composite_src_x888_8888),
+    PIXMAN_STD_FAST_PATH (SRC, r8g8b8,   null, r8g8b8,   mips_composite_src_0888_0888),
+
+    PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, a8r8g8b8, mips_composite_over_n_8888_8888_ca),
+    PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, x8r8g8b8, mips_composite_over_n_8888_8888_ca),
+    PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, a8b8g8r8, mips_composite_over_n_8888_8888_ca),
+    PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, x8b8g8r8, mips_composite_over_n_8888_8888_ca),
+    PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, r5g6b5,   mips_composite_over_n_8888_0565_ca),
+    PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, b5g6r5,   mips_composite_over_n_8888_0565_ca),
+    PIXMAN_STD_FAST_PATH (OVER, solid,    a8,       a8r8g8b8, mips_composite_over_n_8_8888),
+    PIXMAN_STD_FAST_PATH (OVER, solid,    a8,       x8r8g8b8, mips_composite_over_n_8_8888),
+    PIXMAN_STD_FAST_PATH (OVER, solid,    a8,       a8b8g8r8, mips_composite_over_n_8_8888),
+    PIXMAN_STD_FAST_PATH (OVER, solid,    a8,       x8b8g8r8, mips_composite_over_n_8_8888),
+    PIXMAN_STD_FAST_PATH (OVER, solid,    a8,       r5g6b5,   mips_composite_over_n_8_0565),
+    PIXMAN_STD_FAST_PATH (OVER, solid,    a8,       b5g6r5,   mips_composite_over_n_8_0565),
+
+    SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, mips_8888_8_8888),
+    SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, mips_8888_8_8888),
+
+    { PIXMAN_OP_NONE },
+};
+
+static pixman_bool_t
+mips_dspr2_blt (pixman_implementation_t *imp,
+                uint32_t *               src_bits,
+                uint32_t *               dst_bits,
+                int                      src_stride,
+                int                      dst_stride,
+                int                      src_bpp,
+                int                      dst_bpp,
+                int                      src_x,
+                int                      src_y,
+                int                      dest_x,
+                int                      dest_y,
+                int                      width,
+                int                      height)
+{
+    if (!pixman_blt_mips (
+            src_bits, dst_bits, src_stride, dst_stride, src_bpp, dst_bpp,
+            src_x, src_y, dest_x, dest_y, width, height))
+
+    {
+        return _pixman_implementation_blt (
+            imp->delegate,
+            src_bits, dst_bits, src_stride, dst_stride, src_bpp, dst_bpp,
+            src_x, src_y, dest_x, dest_y, width, height);
+    }
+
+    return TRUE;
+}
+
+static pixman_bool_t
+mips_dspr2_fill (pixman_implementation_t *imp,
+                 uint32_t *               bits,
+                 int                      stride,
+                 int                      bpp,
+                 int                      x,
+                 int                      y,
+                 int                      width,
+                 int                      height,
+                 uint32_t xor)
+{
+    if (pixman_fill_mips (bits, stride, bpp, x, y, width, height, xor))
+        return TRUE;
+
+    return _pixman_implementation_fill (
+        imp->delegate, bits, stride, bpp, x, y, width, height, xor);
+}
+
+pixman_implementation_t *
+_pixman_implementation_create_mips_dspr2 (pixman_implementation_t *fallback)
+{
+    pixman_implementation_t *imp =
+        _pixman_implementation_create (fallback, mips_dspr2_fast_paths);
+
+    imp->blt = mips_dspr2_blt;
+    imp->fill = mips_dspr2_fill;
+
+    return imp;
+}
diff --git a/pixman/pixman-mips-dspr2.h b/pixman/pixman-mips-dspr2.h
new file mode 100644 (file)
index 0000000..5036938
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2012
+ *      MIPS Technologies, Inc., California.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Author:  Nemanja Lukic (nlukic@mips.com)
+ */
+
+#ifndef PIXMAN_MIPS_DSPR2_H
+#define PIXMAN_MIPS_DSPR2_H
+
+#include "pixman-private.h"
+#include "pixman-inlines.h"
+
+#define SKIP_ZERO_SRC  1
+#define SKIP_ZERO_MASK 2
+#define DO_FAST_MEMCPY 3
+
+void
+pixman_mips_fast_memcpy (void *dst, void *src, uint32_t n_bytes);
+void
+pixman_fill_buff16_mips (void *dst, uint32_t n_bytes, uint16_t value);
+void
+pixman_fill_buff32_mips (void *dst, uint32_t n_bytes, uint32_t value);
+
+/****************************************************************/
+
+#define PIXMAN_MIPS_BIND_FAST_PATH_SRC_DST(flags, name,          \
+                                           src_type, src_cnt,    \
+                                           dst_type, dst_cnt)    \
+void                                                             \
+pixman_composite_##name##_asm_mips (dst_type *dst,               \
+                                    src_type *src,               \
+                                    int32_t   w);                \
+                                                                 \
+static void                                                      \
+mips_composite_##name (pixman_implementation_t *imp,             \
+                       pixman_composite_info_t *info)            \
+{                                                                \
+    PIXMAN_COMPOSITE_ARGS (info);                                \
+    dst_type *dst_line, *dst;                                    \
+    src_type *src_line, *src;                                    \
+    int32_t dst_stride, src_stride;                              \
+    int bpp = PIXMAN_FORMAT_BPP (dest_image->bits.format) / 8;   \
+                                                                 \
+    PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type,    \
+                           src_stride, src_line, src_cnt);       \
+    PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \
+                           dst_stride, dst_line, dst_cnt);       \
+                                                                 \
+    while (height--)                                             \
+    {                                                            \
+      dst = dst_line;                                            \
+      dst_line += dst_stride;                                    \
+      src = src_line;                                            \
+      src_line += src_stride;                                    \
+                                                                 \
+      if (flags == DO_FAST_MEMCPY)                               \
+        pixman_mips_fast_memcpy (dst, src, width * bpp);         \
+      else                                                       \
+        pixman_composite_##name##_asm_mips (dst, src, width);    \
+    }                                                            \
+}
+
+/*******************************************************************/
+
+#define PIXMAN_MIPS_BIND_FAST_PATH_N_MASK_DST(flags, name,          \
+                                              mask_type, mask_cnt,  \
+                                              dst_type, dst_cnt)    \
+void                                                                \
+pixman_composite_##name##_asm_mips (dst_type  *dst,                 \
+                                    uint32_t  src,                  \
+                                    mask_type *mask,                \
+                                    int32_t   w);                   \
+                                                                    \
+static void                                                         \
+mips_composite_##name (pixman_implementation_t *imp,                \
+                       pixman_composite_info_t *info)               \
+{                                                                   \
+    PIXMAN_COMPOSITE_ARGS (info);                                   \
+    dst_type  *dst_line, *dst;                                      \
+    mask_type *mask_line, *mask;                                    \
+    int32_t    dst_stride, mask_stride;                             \
+    uint32_t   src;                                                 \
+                                                                    \
+    src = _pixman_image_get_solid (                                 \
+        imp, src_image, dest_image->bits.format);                   \
+                                                                    \
+    if ((flags & SKIP_ZERO_SRC) && src == 0)                        \
+        return;                                                     \
+                                                                    \
+    PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type,    \
+                           dst_stride, dst_line, dst_cnt);          \
+    PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type,   \
+                           mask_stride, mask_line, mask_cnt);       \
+                                                                    \
+    while (height--)                                                \
+    {                                                               \
+        dst = dst_line;                                             \
+        dst_line += dst_stride;                                     \
+        mask = mask_line;                                           \
+        mask_line += mask_stride;                                   \
+        pixman_composite_##name##_asm_mips (dst, src, mask, width); \
+    }                                                               \
+}
+
+/*****************************************************************************/
+
+#define PIXMAN_MIPS_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, name, op,          \
+                                                src_type, dst_type)           \
+void                                                                          \
+pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips (                    \
+                                             dst_type *       dst,            \
+                                             const uint8_t *  mask,           \
+                                             const src_type * top,            \
+                                             const src_type * bottom,         \
+                                             int              wt,             \
+                                             int              wb,             \
+                                             pixman_fixed_t   x,              \
+                                             pixman_fixed_t   ux,             \
+                                             int              width);         \
+                                                                              \
+static force_inline void                                                      \
+scaled_bilinear_scanline_mips_##name##_##op (dst_type *       dst,            \
+                                             const uint8_t *  mask,           \
+                                             const src_type * src_top,        \
+                                             const src_type * src_bottom,     \
+                                             int32_t          w,              \
+                                             int              wt,             \
+                                             int              wb,             \
+                                             pixman_fixed_t   vx,             \
+                                             pixman_fixed_t   unit_x,         \
+                                             pixman_fixed_t   max_vx,         \
+                                             pixman_bool_t    zero_src)       \
+{                                                                             \
+    if ((flags & SKIP_ZERO_SRC) && zero_src)                                  \
+        return;                                                               \
+    pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips (                \
+                      dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \
+}                                                                             \
+                                                                              \
+FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_cover_##op,                      \
+                       scaled_bilinear_scanline_mips_##name##_##op,           \
+                       src_type, uint8_t, dst_type, COVER,                    \
+                       FLAG_HAVE_NON_SOLID_MASK)                              \
+FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_none_##op,                       \
+                       scaled_bilinear_scanline_mips_##name##_##op,           \
+                       src_type, uint8_t, dst_type, NONE,                     \
+                       FLAG_HAVE_NON_SOLID_MASK)                              \
+FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_pad_##op,                        \
+                       scaled_bilinear_scanline_mips_##name##_##op,           \
+                       src_type, uint8_t, dst_type, PAD,                      \
+                       FLAG_HAVE_NON_SOLID_MASK)                              \
+FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_normal_##op,                     \
+                       scaled_bilinear_scanline_mips_##name##_##op,           \
+                       src_type, uint8_t, dst_type, NORMAL,                   \
+                       FLAG_HAVE_NON_SOLID_MASK)
+
+#endif //PIXMAN_MIPS_DSPR2_H
diff --git a/pixman/pixman-mips-memcpy-asm.S b/pixman/pixman-mips-memcpy-asm.S
new file mode 100644 (file)
index 0000000..9ad6da5
--- /dev/null
@@ -0,0 +1,382 @@
+/*
+ * Copyright (c) 2012
+ *      MIPS Technologies, Inc., California.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "pixman-mips-dspr2-asm.h"
+
+/*
+ * This routine could be optimized for MIPS64. The current code only
+ * uses MIPS32 instructions.
+ */
+
+#ifdef EB
+#  define LWHI lwl             /* high part is left in big-endian */
+#  define SWHI swl             /* high part is left in big-endian */
+#  define LWLO lwr             /* low part is right in big-endian */
+#  define SWLO swr             /* low part is right in big-endian */
+#else
+#  define LWHI lwr             /* high part is right in little-endian */
+#  define SWHI swr             /* high part is right in little-endian */
+#  define LWLO lwl             /* low part is left in big-endian */
+#  define SWLO swl             /* low part is left in big-endian */
+#endif
+
+LEAF_MIPS32R2(pixman_mips_fast_memcpy)
+
+       slti    AT, a2, 8
+       bne     AT, zero, $last8
+       move    v0, a0  /* memcpy returns the dst pointer */
+
+/* Test if the src and dst are word-aligned, or can be made word-aligned */
+       xor     t8, a1, a0
+       andi    t8, t8, 0x3             /* t8 is a0/a1 word-displacement */
+
+       bne     t8, zero, $unaligned
+       negu    a3, a0
+
+       andi    a3, a3, 0x3     /* we need to copy a3 bytes to make a0/a1 aligned */
+       beq     a3, zero, $chk16w       /* when a3=0 then the dst (a0) is word-aligned */
+       subu    a2, a2, a3      /* now a2 is the remining bytes count */
+
+       LWHI    t8, 0(a1)
+       addu    a1, a1, a3
+       SWHI    t8, 0(a0)
+       addu    a0, a0, a3
+
+/* Now the dst/src are mutually word-aligned with word-aligned addresses */
+$chk16w:       andi    t8, a2, 0x3f    /* any whole 64-byte chunks? */
+                               /* t8 is the byte count after 64-byte chunks */
+
+       beq     a2, t8, $chk8w  /* if a2==t8, no 64-byte chunks */
+                               /* There will be at most 1 32-byte chunk after it */
+       subu    a3, a2, t8      /* subtract from a2 the reminder */
+                                /* Here a3 counts bytes in 16w chunks */
+       addu    a3, a0, a3      /* Now a3 is the final dst after 64-byte chunks */
+
+       addu    t0, a0, a2      /* t0 is the "past the end" address */
+
+/*
+ * When in the loop we exercise "pref 30, x(a0)", the a0+x should not be past
+ * the "t0-32" address
+ * This means: for x=128 the last "safe" a0 address is "t0-160"
+ * Alternatively, for x=64 the last "safe" a0 address is "t0-96"
+ * In the current version we use "pref 30, 128(a0)", so "t0-160" is the limit
+ */
+       subu    t9, t0, 160     /* t9 is the "last safe pref 30, 128(a0)" address */
+
+       pref    0, 0(a1)                /* bring the first line of src, addr 0 */
+       pref    0, 32(a1)       /* bring the second line of src, addr 32 */
+       pref    0, 64(a1)       /* bring the third line of src, addr 64 */
+       pref    30, 32(a0)      /* safe, as we have at least 64 bytes ahead */
+/* In case the a0 > t9 don't use "pref 30" at all */
+       sgtu    v1, a0, t9
+       bgtz    v1, $loop16w    /* skip "pref 30, 64(a0)" for too short arrays */
+       nop
+/* otherwise, start with using pref30 */
+       pref    30, 64(a0)
+$loop16w:
+       pref    0, 96(a1)
+       lw      t0, 0(a1)
+       bgtz    v1, $skip_pref30_96     /* skip "pref 30, 96(a0)" */
+       lw      t1, 4(a1)
+       pref    30, 96(a0)   /* continue setting up the dest, addr 96 */
+$skip_pref30_96:
+       lw      t2, 8(a1)
+       lw      t3, 12(a1)
+       lw      t4, 16(a1)
+       lw      t5, 20(a1)
+       lw      t6, 24(a1)
+       lw      t7, 28(a1)
+        pref    0, 128(a1)    /* bring the next lines of src, addr 128 */
+
+       sw      t0, 0(a0)
+       sw      t1, 4(a0)
+       sw      t2, 8(a0)
+       sw      t3, 12(a0)
+       sw      t4, 16(a0)
+       sw      t5, 20(a0)
+       sw      t6, 24(a0)
+       sw      t7, 28(a0)
+
+       lw      t0, 32(a1)
+       bgtz    v1, $skip_pref30_128    /* skip "pref 30, 128(a0)" */
+       lw      t1, 36(a1)
+       pref    30, 128(a0)   /* continue setting up the dest, addr 128 */
+$skip_pref30_128:
+       lw      t2, 40(a1)
+       lw      t3, 44(a1)
+       lw      t4, 48(a1)
+       lw      t5, 52(a1)
+       lw      t6, 56(a1)
+       lw      t7, 60(a1)
+        pref    0, 160(a1)    /* bring the next lines of src, addr 160 */
+
+       sw      t0, 32(a0)
+       sw      t1, 36(a0)
+       sw      t2, 40(a0)
+       sw      t3, 44(a0)
+       sw      t4, 48(a0)
+       sw      t5, 52(a0)
+       sw      t6, 56(a0)
+       sw      t7, 60(a0)
+
+       addiu   a0, a0, 64      /* adding 64 to dest */
+       sgtu    v1, a0, t9
+       bne     a0, a3, $loop16w
+       addiu   a1, a1, 64      /* adding 64 to src */
+       move    a2, t8
+
+/* Here we have src and dest word-aligned but less than 64-bytes to go */
+
+$chk8w:
+       pref 0, 0x0(a1)
+       andi    t8, a2, 0x1f    /* is there a 32-byte chunk? */
+                               /* the t8 is the reminder count past 32-bytes */
+       beq     a2, t8, $chk1w  /* when a2=t8, no 32-byte chunk */
+        nop
+
+       lw      t0, 0(a1)
+       lw      t1, 4(a1)
+       lw      t2, 8(a1)
+       lw      t3, 12(a1)
+       lw      t4, 16(a1)
+       lw      t5, 20(a1)
+       lw      t6, 24(a1)
+       lw      t7, 28(a1)
+       addiu   a1, a1, 32
+
+       sw      t0, 0(a0)
+       sw      t1, 4(a0)
+       sw      t2, 8(a0)
+       sw      t3, 12(a0)
+       sw      t4, 16(a0)
+       sw      t5, 20(a0)
+       sw      t6, 24(a0)
+       sw      t7, 28(a0)
+       addiu   a0, a0, 32
+
+$chk1w:
+       andi    a2, t8, 0x3     /* now a2 is the reminder past 1w chunks */
+       beq     a2, t8, $last8
+       subu    a3, t8, a2      /* a3 is count of bytes in 1w chunks */
+       addu    a3, a0, a3      /* now a3 is the dst address past the 1w chunks */
+
+/* copying in words (4-byte chunks) */
+$wordCopy_loop:
+       lw      t3, 0(a1)       /* the first t3 may be equal t0 ... optimize? */
+       addiu   a1, a1, 4
+       addiu   a0, a0, 4
+       bne     a0, a3, $wordCopy_loop
+       sw      t3, -4(a0)
+
+/* For the last (<8) bytes */
+$last8:
+       blez    a2, leave
+       addu    a3, a0, a2      /* a3 is the last dst address */
+$last8loop:
+       lb      v1, 0(a1)
+       addiu   a1, a1, 1
+       addiu   a0, a0, 1
+       bne     a0, a3, $last8loop
+       sb      v1, -1(a0)
+
+leave: j       ra
+       nop
+
+/*
+ * UNALIGNED case
+ */
+
+$unaligned:
+       /* got here with a3="negu a0" */
+       andi    a3, a3, 0x3     /* test if the a0 is word aligned */
+       beqz    a3, $ua_chk16w
+       subu    a2, a2, a3      /* bytes left after initial a3 bytes */
+
+       LWHI    v1, 0(a1)
+       LWLO    v1, 3(a1)
+       addu    a1, a1, a3      /* a3 may be here 1, 2 or 3 */
+       SWHI    v1, 0(a0)
+       addu    a0, a0, a3      /* below the dst will be word aligned (NOTE1) */
+
+$ua_chk16w:    andi    t8, a2, 0x3f    /* any whole 64-byte chunks? */
+                               /* t8 is the byte count after 64-byte chunks */
+       beq     a2, t8, $ua_chk8w       /* if a2==t8, no 64-byte chunks */
+                               /* There will be at most 1 32-byte chunk after it */
+       subu    a3, a2, t8      /* subtract from a2 the reminder */
+                                /* Here a3 counts bytes in 16w chunks */
+       addu    a3, a0, a3      /* Now a3 is the final dst after 64-byte chunks */
+
+       addu    t0, a0, a2      /* t0 is the "past the end" address */
+
+       subu    t9, t0, 160     /* t9 is the "last safe pref 30, 128(a0)" address */
+
+       pref    0, 0(a1)                /* bring the first line of src, addr 0 */
+       pref    0, 32(a1)       /* bring the second line of src, addr 32 */
+       pref    0, 64(a1)       /* bring the third line of src, addr 64 */
+       pref    30, 32(a0)      /* safe, as we have at least 64 bytes ahead */
+/* In case the a0 > t9 don't use "pref 30" at all */
+       sgtu    v1, a0, t9
+       bgtz    v1, $ua_loop16w /* skip "pref 30, 64(a0)" for too short arrays */
+       nop
+/* otherwise,  start with using pref30 */
+       pref    30, 64(a0)
+$ua_loop16w:
+       pref    0, 96(a1)
+       LWHI    t0, 0(a1)
+       LWLO    t0, 3(a1)
+       LWHI    t1, 4(a1)
+       bgtz    v1, $ua_skip_pref30_96
+       LWLO    t1, 7(a1)
+       pref    30, 96(a0)   /* continue setting up the dest, addr 96 */
+$ua_skip_pref30_96:
+       LWHI    t2, 8(a1)
+       LWLO    t2, 11(a1)
+       LWHI    t3, 12(a1)
+       LWLO    t3, 15(a1)
+       LWHI    t4, 16(a1)
+       LWLO    t4, 19(a1)
+       LWHI    t5, 20(a1)
+       LWLO    t5, 23(a1)
+       LWHI    t6, 24(a1)
+       LWLO    t6, 27(a1)
+       LWHI    t7, 28(a1)
+       LWLO    t7, 31(a1)
+        pref    0, 128(a1)    /* bring the next lines of src, addr 128 */
+
+       sw      t0, 0(a0)
+       sw      t1, 4(a0)
+       sw      t2, 8(a0)
+       sw      t3, 12(a0)
+       sw      t4, 16(a0)
+       sw      t5, 20(a0)
+       sw      t6, 24(a0)
+       sw      t7, 28(a0)
+
+       LWHI    t0, 32(a1)
+       LWLO    t0, 35(a1)
+       LWHI    t1, 36(a1)
+       bgtz    v1, $ua_skip_pref30_128
+       LWLO    t1, 39(a1)
+       pref    30, 128(a0)   /* continue setting up the dest, addr 128 */
+$ua_skip_pref30_128:
+       LWHI    t2, 40(a1)
+       LWLO    t2, 43(a1)
+       LWHI    t3, 44(a1)
+       LWLO    t3, 47(a1)
+       LWHI    t4, 48(a1)
+       LWLO    t4, 51(a1)
+       LWHI    t5, 52(a1)
+       LWLO    t5, 55(a1)
+       LWHI    t6, 56(a1)
+       LWLO    t6, 59(a1)
+       LWHI    t7, 60(a1)
+       LWLO    t7, 63(a1)
+        pref    0, 160(a1)    /* bring the next lines of src, addr 160 */
+
+       sw      t0, 32(a0)
+       sw      t1, 36(a0)
+       sw      t2, 40(a0)
+       sw      t3, 44(a0)
+       sw      t4, 48(a0)
+       sw      t5, 52(a0)
+       sw      t6, 56(a0)
+       sw      t7, 60(a0)
+
+       addiu   a0, a0, 64      /* adding 64 to dest */
+       sgtu    v1, a0, t9
+       bne     a0, a3, $ua_loop16w
+       addiu   a1, a1, 64      /* adding 64 to src */
+       move    a2, t8
+
+/* Here we have src and dest word-aligned but less than 64-bytes to go */
+
+$ua_chk8w:
+       pref 0, 0x0(a1)
+       andi    t8, a2, 0x1f    /* is there a 32-byte chunk? */
+                               /* the t8 is the reminder count */
+       beq     a2, t8, $ua_chk1w       /* when a2=t8, no 32-byte chunk */
+
+       LWHI    t0, 0(a1)
+       LWLO    t0, 3(a1)
+       LWHI    t1, 4(a1)
+       LWLO    t1, 7(a1)
+       LWHI    t2, 8(a1)
+       LWLO    t2, 11(a1)
+       LWHI    t3, 12(a1)
+       LWLO    t3, 15(a1)
+       LWHI    t4, 16(a1)
+       LWLO    t4, 19(a1)
+       LWHI    t5, 20(a1)
+       LWLO    t5, 23(a1)
+       LWHI    t6, 24(a1)
+       LWLO    t6, 27(a1)
+       LWHI    t7, 28(a1)
+       LWLO    t7, 31(a1)
+       addiu   a1, a1, 32
+
+       sw      t0, 0(a0)
+       sw      t1, 4(a0)
+       sw      t2, 8(a0)
+       sw      t3, 12(a0)
+       sw      t4, 16(a0)
+       sw      t5, 20(a0)
+       sw      t6, 24(a0)
+       sw      t7, 28(a0)
+       addiu   a0, a0, 32
+
+$ua_chk1w:
+       andi    a2, t8, 0x3     /* now a2 is the reminder past 1w chunks */
+       beq     a2, t8, $ua_smallCopy
+       subu    a3, t8, a2      /* a3 is count of bytes in 1w chunks */
+       addu    a3, a0, a3      /* now a3 is the dst address past the 1w chunks */
+
+/* copying in words (4-byte chunks) */
+$ua_wordCopy_loop:
+       LWHI    v1, 0(a1)
+       LWLO    v1, 3(a1)
+       addiu   a1, a1, 4
+       addiu   a0, a0, 4               /* note: dst=a0 is word aligned here, see NOTE1 */
+       bne     a0, a3, $ua_wordCopy_loop
+       sw      v1, -4(a0)
+
+/* Now less than 4 bytes (value in a2) left to copy */
+$ua_smallCopy:
+       beqz    a2, leave
+       addu    a3, a0, a2      /* a3 is the last dst address */
+$ua_smallCopy_loop:
+       lb      v1, 0(a1)
+       addiu   a1, a1, 1
+       addiu   a0, a0, 1
+       bne     a0, a3, $ua_smallCopy_loop
+       sb      v1, -1(a0)
+
+       j       ra
+       nop
+
+END(pixman_mips_fast_memcpy)
index f848ab4..eb02d1a 100644 (file)
 #include <config.h>
 #endif
 
-#if defined USE_X86_MMX || defined USE_ARM_IWMMXT
+#if defined USE_X86_MMX || defined USE_ARM_IWMMXT || defined USE_LOONGSON_MMI
 
+#ifdef USE_LOONGSON_MMI
+#include <loongson-mmintrin.h>
+#else
 #include <mmintrin.h>
+#endif
 #include "pixman-private.h"
 #include "pixman-combine32.h"
 
@@ -56,6 +60,61 @@ _mm_empty (void)
 }
 #endif
 
+#ifdef USE_X86_MMX
+# if (defined(__SUNPRO_C) || defined(_MSC_VER))
+#  include <xmmintrin.h>
+# else
+/* We have to compile with -msse to use xmmintrin.h, but that causes SSE
+ * instructions to be generated that we don't want. Just duplicate the
+ * functions we want to use.  */
+extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_movemask_pi8 (__m64 __A)
+{
+    int ret;
+
+    asm ("pmovmskb %1, %0\n\t"
+       : "=r" (ret)
+       : "y" (__A)
+    );
+
+    return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mulhi_pu16 (__m64 __A, __m64 __B)
+{
+    asm ("pmulhuw %1, %0\n\t"
+       : "+y" (__A)
+       : "y" (__B)
+    );
+    return __A;
+}
+
+#  ifdef __OPTIMIZE__
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_shuffle_pi16 (__m64 __A, int8_t const __N)
+{
+    __m64 ret;
+
+    asm ("pshufw %2, %1, %0\n\t"
+       : "=y" (ret)
+       : "y" (__A), "K" (__N)
+    );
+
+    return ret;
+}
+#  else
+#   define _mm_shuffle_pi16(A, N) \
+    ((__m64) __builtin_ia32_pshufw ((__v4hi)(__m64)(A), (int)(N)))
+#  endif
+# endif
+#endif
+
+#ifndef _MSC_VER
+#define _MM_SHUFFLE(fp3,fp2,fp1,fp0) \
+ (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | (fp0))
+#endif
+
 /* Notes about writing mmx code
  *
  * give memory operands as the second operand. If you give it as the
@@ -77,17 +136,41 @@ _mm_empty (void)
 
 /* --------------- MMX primitives ------------------------------------- */
 
-#ifdef __GNUC__
+/* If __m64 is defined as a struct or union, then define M64_MEMBER to be
+ * the name of the member used to access the data.
+ * If __m64 requires using mm_cvt* intrinsics functions to convert between
+ * uint64_t and __m64 values, then define USE_CVT_INTRINSICS.
+ * If __m64 and uint64_t values can just be cast to each other directly,
+ * then define USE_M64_CASTS.
+ * If __m64 is a double datatype, then define USE_M64_DOUBLE.
+ */
+#ifdef _MSC_VER
+# define M64_MEMBER m64_u64
+#elif defined(__ICC)
+# define USE_CVT_INTRINSICS
+#elif defined(USE_LOONGSON_MMI)
+# define USE_M64_DOUBLE
+#elif defined(__GNUC__)
+# define USE_M64_CASTS
+#elif defined(__SUNPRO_C)
+# if (__SUNPRO_C >= 0x5120) && !defined(__NOVECTORSIZE__)
+/* Solaris Studio 12.3 (Sun C 5.12) introduces __attribute__(__vector_size__)
+ * support, and defaults to using it to define __m64, unless __NOVECTORSIZE__
+ * is defined.   If it is used, then the mm_cvt* intrinsics must be used.
+ */
+#  define USE_CVT_INTRINSICS
+# else
+/* For Studio 12.2 or older, or when __attribute__(__vector_size__) is
+ * disabled, __m64 is defined as a struct containing "unsigned long long l_".
+ */
+#  define M64_MEMBER l_
+# endif
+#endif
+
+#if defined(USE_M64_CASTS) || defined(USE_CVT_INTRINSICS) || defined(USE_M64_DOUBLE)
 typedef uint64_t mmxdatafield;
 #else
 typedef __m64 mmxdatafield;
-/* If __m64 is defined as a struct or union, define M64_MEMBER to be the
-   name of the member used to access the data */
-# ifdef _MSC_VER
-#  define M64_MEMBER m64_u64
-# elif defined(__SUNPRO_C)
-#  define M64_MEMBER l_
-# endif
 #endif
 
 typedef struct
@@ -96,24 +179,28 @@ typedef struct
     mmxdatafield mmx_4x0080;
     mmxdatafield mmx_565_rgb;
     mmxdatafield mmx_565_unpack_multiplier;
+    mmxdatafield mmx_565_pack_multiplier;
     mmxdatafield mmx_565_r;
     mmxdatafield mmx_565_g;
     mmxdatafield mmx_565_b;
+    mmxdatafield mmx_packed_565_rb;
+    mmxdatafield mmx_packed_565_g;
+#ifndef USE_LOONGSON_MMI
     mmxdatafield mmx_mask_0;
     mmxdatafield mmx_mask_1;
     mmxdatafield mmx_mask_2;
     mmxdatafield mmx_mask_3;
+#endif
     mmxdatafield mmx_full_alpha;
-    mmxdatafield mmx_ffff0000ffff0000;
-    mmxdatafield mmx_0000ffff00000000;
-    mmxdatafield mmx_000000000000ffff;
+    mmxdatafield mmx_4x0101;
+    mmxdatafield mmx_ff000000;
 } mmx_data_t;
 
 #if defined(_MSC_VER)
 # define MMXDATA_INIT(field, val) { val ## UI64 }
 #elif defined(M64_MEMBER)       /* __m64 is a struct, not an integral type */
 # define MMXDATA_INIT(field, val) field =   { val ## ULL }
-#else                           /* __m64 is an integral type */
+#else                           /* mmxdatafield is an integral type */
 # define MMXDATA_INIT(field, val) field =   val ## ULL
 #endif
 
@@ -123,25 +210,29 @@ static const mmx_data_t c =
     MMXDATA_INIT (.mmx_4x0080,                   0x0080008000800080),
     MMXDATA_INIT (.mmx_565_rgb,                  0x000001f0003f001f),
     MMXDATA_INIT (.mmx_565_unpack_multiplier,    0x0000008404100840),
+    MMXDATA_INIT (.mmx_565_pack_multiplier,      0x2000000420000004),
     MMXDATA_INIT (.mmx_565_r,                    0x000000f800000000),
     MMXDATA_INIT (.mmx_565_g,                    0x0000000000fc0000),
     MMXDATA_INIT (.mmx_565_b,                    0x00000000000000f8),
+    MMXDATA_INIT (.mmx_packed_565_rb,            0x00f800f800f800f8),
+    MMXDATA_INIT (.mmx_packed_565_g,             0x0000fc000000fc00),
+#ifndef USE_LOONGSON_MMI
     MMXDATA_INIT (.mmx_mask_0,                   0xffffffffffff0000),
     MMXDATA_INIT (.mmx_mask_1,                   0xffffffff0000ffff),
     MMXDATA_INIT (.mmx_mask_2,                   0xffff0000ffffffff),
     MMXDATA_INIT (.mmx_mask_3,                   0x0000ffffffffffff),
+#endif
     MMXDATA_INIT (.mmx_full_alpha,               0x00ff000000000000),
-    MMXDATA_INIT (.mmx_ffff0000ffff0000,         0xffff0000ffff0000),
-    MMXDATA_INIT (.mmx_0000ffff00000000,         0x0000ffff00000000),
-    MMXDATA_INIT (.mmx_000000000000ffff,         0x000000000000ffff),
+    MMXDATA_INIT (.mmx_4x0101,                   0x0101010101010101),
+    MMXDATA_INIT (.mmx_ff000000,                 0xff000000ff000000),
 };
 
-#ifdef __GNUC__
-#    ifdef __ICC
-#        define MC(x) to_m64 (c.mmx_ ## x)
-#    else
-#        define MC(x) ((__m64)c.mmx_ ## x)
-#    endif
+#ifdef USE_CVT_INTRINSICS
+#    define MC(x) to_m64 (c.mmx_ ## x)
+#elif defined(USE_M64_CASTS)
+#    define MC(x) ((__m64)c.mmx_ ## x)
+#elif defined(USE_M64_DOUBLE)
+#    define MC(x) (*(__m64 *)&c.mmx_ ## x)
 #else
 #    define MC(x) c.mmx_ ## x
 #endif
@@ -149,14 +240,16 @@ static const mmx_data_t c =
 static force_inline __m64
 to_m64 (uint64_t x)
 {
-#ifdef __ICC
+#ifdef USE_CVT_INTRINSICS
     return _mm_cvtsi64_m64 (x);
 #elif defined M64_MEMBER        /* __m64 is a struct, not an integral type */
     __m64 res;
 
     res.M64_MEMBER = x;
     return res;
-#else                           /* __m64 is an integral type */
+#elif defined USE_M64_DOUBLE
+    return *(__m64 *)&x;
+#else /* USE_M64_CASTS */
     return (__m64)x;
 #endif
 }
@@ -164,12 +257,14 @@ to_m64 (uint64_t x)
 static force_inline uint64_t
 to_uint64 (__m64 x)
 {
-#ifdef __ICC
+#ifdef USE_CVT_INTRINSICS
     return _mm_cvtm64_si64 (x);
 #elif defined M64_MEMBER        /* __m64 is a struct, not an integral type */
     uint64_t res = x.M64_MEMBER;
     return res;
-#else                           /* __m64 is an integral type */
+#elif defined USE_M64_DOUBLE
+    return *(uint64_t *)&x;
+#else /* USE_M64_CASTS */
     return (uint64_t)x;
 #endif
 }
@@ -199,8 +294,7 @@ pix_multiply (__m64 a, __m64 b)
 
     res = _mm_mullo_pi16 (a, b);
     res = _mm_adds_pu16 (res, MC (4x0080));
-    res = _mm_adds_pu16 (res, _mm_srli_pi16 (res, 8));
-    res = _mm_srli_pi16 (res, 8);
+    res = _mm_mulhi_pu16 (res, MC (4x0101));
 
     return res;
 }
@@ -214,52 +308,19 @@ pix_add (__m64 a, __m64 b)
 static force_inline __m64
 expand_alpha (__m64 pixel)
 {
-    __m64 t1, t2;
-
-    t1 = shift (pixel, -48);
-    t2 = shift (t1, 16);
-    t1 = _mm_or_si64 (t1, t2);
-    t2 = shift (t1, 32);
-    t1 = _mm_or_si64 (t1, t2);
-
-    return t1;
+    return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE (3, 3, 3, 3));
 }
 
 static force_inline __m64
 expand_alpha_rev (__m64 pixel)
 {
-    __m64 t1, t2;
-
-    /* move alpha to low 16 bits and zero the rest */
-    t1 = shift (pixel,  48);
-    t1 = shift (t1, -48);
-
-    t2 = shift (t1, 16);
-    t1 = _mm_or_si64 (t1, t2);
-    t2 = shift (t1, 32);
-    t1 = _mm_or_si64 (t1, t2);
-
-    return t1;
+    return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE (0, 0, 0, 0));
 }
 
 static force_inline __m64
 invert_colors (__m64 pixel)
 {
-    __m64 x, y, z;
-
-    x = y = z = pixel;
-
-    x = _mm_and_si64 (x, MC (ffff0000ffff0000));
-    y = _mm_and_si64 (y, MC (000000000000ffff));
-    z = _mm_and_si64 (z, MC (0000ffff00000000));
-
-    y = shift (y, 32);
-    z = shift (z, -32);
-
-    x = _mm_or_si64 (x, y);
-    x = _mm_or_si64 (x, z);
-
-    return x;
+    return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE (3, 0, 1, 2));
 }
 
 static force_inline __m64
@@ -285,14 +346,6 @@ in (__m64 src, __m64 mask)
     return pix_multiply (src, mask);
 }
 
-static force_inline __m64
-in_over_full_src_alpha (__m64 src, __m64 mask, __m64 dest)
-{
-    src = _mm_or_si64 (src, MC (full_alpha));
-
-    return over (in (src, mask), mask, dest);
-}
-
 #ifndef _MSC_VER
 static force_inline __m64
 in_over (__m64 src, __m64 srca, __m64 mask, __m64 dest)
@@ -309,26 +362,26 @@ in_over (__m64 src, __m64 srca, __m64 mask, __m64 dest)
 
 /* Elemental unaligned loads */
 
-static __inline__ uint64_t ldq_u(uint64_t *p)
+static force_inline __m64 ldq_u(__m64 *p)
 {
 #ifdef USE_X86_MMX
     /* x86's alignment restrictions are very relaxed. */
-    return *p;
+    return *(__m64 *)p;
 #elif defined USE_ARM_IWMMXT
     int align = (uintptr_t)p & 7;
     __m64 *aligned_p;
     if (align == 0)
        return *p;
     aligned_p = (__m64 *)((uintptr_t)p & ~7);
-    return _mm_align_si64 (aligned_p[0], aligned_p[1], align);
+    return (__m64) _mm_align_si64 (aligned_p[0], aligned_p[1], align);
 #else
-    struct __una_u64 { uint64_t x __attribute__((packed)); };
+    struct __una_u64 { __m64 x __attribute__((packed)); };
     const struct __una_u64 *ptr = (const struct __una_u64 *) p;
-    return ptr->x;
+    return (__m64) ptr->x;
 #endif
 }
 
-static __inline__ uint32_t ldl_u(uint32_t *p)
+static force_inline uint32_t ldl_u(const uint32_t *p)
 {
 #ifdef USE_X86_MMX
     /* x86's alignment restrictions are very relaxed. */
@@ -341,9 +394,35 @@ static __inline__ uint32_t ldl_u(uint32_t *p)
 }
 
 static force_inline __m64
-load8888 (uint32_t v)
+load (const uint32_t *v)
+{
+#ifdef USE_LOONGSON_MMI
+    __m64 ret;
+    asm ("lwc1 %0, %1\n\t"
+       : "=f" (ret)
+       : "m" (*v)
+    );
+    return ret;
+#else
+    return _mm_cvtsi32_si64 (*v);
+#endif
+}
+
+static force_inline __m64
+load8888 (const uint32_t *v)
+{
+#ifdef USE_LOONGSON_MMI
+    return _mm_unpacklo_pi8_f (*(__m32 *)v, _mm_setzero_si64 ());
+#else
+    return _mm_unpacklo_pi8 (load (v), _mm_setzero_si64 ());
+#endif
+}
+
+static force_inline __m64
+load8888u (const uint32_t *v)
 {
-    return _mm_unpacklo_pi8 (_mm_cvtsi32_si64 (v), _mm_setzero_si64 ());
+    uint32_t l = ldl_u (v);
+    return load8888 (&l);
 }
 
 static force_inline __m64
@@ -352,10 +431,53 @@ pack8888 (__m64 lo, __m64 hi)
     return _mm_packs_pu16 (lo, hi);
 }
 
-static force_inline uint32_t
-store8888 (__m64 v)
+static force_inline void
+store (uint32_t *dest, __m64 v)
+{
+#ifdef USE_LOONGSON_MMI
+    asm ("swc1 %1, %0\n\t"
+       : "=m" (*dest)
+       : "f" (v)
+       : "memory"
+    );
+#else
+    *dest = _mm_cvtsi64_si32 (v);
+#endif
+}
+
+static force_inline void
+store8888 (uint32_t *dest, __m64 v)
+{
+    v = pack8888 (v, _mm_setzero_si64 ());
+    store (dest, v);
+}
+
+static force_inline pixman_bool_t
+is_equal (__m64 a, __m64 b)
+{
+#ifdef USE_LOONGSON_MMI
+    /* __m64 is double, we can compare directly. */
+    return a == b;
+#else
+    return _mm_movemask_pi8 (_mm_cmpeq_pi8 (a, b)) == 0xff;
+#endif
+}
+
+static force_inline pixman_bool_t
+is_opaque (__m64 v)
 {
-    return _mm_cvtsi64_si32 (pack8888 (v, _mm_setzero_si64 ()));
+#ifdef USE_LOONGSON_MMI
+    return is_equal (_mm_and_si64 (v, MC (full_alpha)), MC (full_alpha));
+#else
+    __m64 ffs = _mm_cmpeq_pi8 (v, v);
+    return (_mm_movemask_pi8 (_mm_cmpeq_pi8 (v, ffs)) & 0x40);
+#endif
+}
+
+static force_inline pixman_bool_t
+is_zero (__m64 v)
+{
+    return is_equal (v, _mm_setzero_si64 ());
 }
 
 /* Expand 16 bits positioned at @pos (0-3) of a mmx register into
@@ -379,7 +501,11 @@ expand565 (__m64 pixel, int pos)
     __m64 t1, t2;
 
     /* move pixel to low 16 bit and zero the rest */
+#ifdef USE_LOONGSON_MMI
+    p = loongson_extract_pi16 (p, pos);
+#else
     p = shift (shift (p, (3 - pos) * 16), -48);
+#endif
 
     t1 = shift (p, 36 - 11);
     t2 = shift (p, 16 - 5);
@@ -418,6 +544,15 @@ pack_565 (__m64 pixel, __m64 target, int pos)
     g = _mm_and_si64 (p, MC (565_g));
     b = _mm_and_si64 (p, MC (565_b));
 
+#ifdef USE_LOONGSON_MMI
+    r = shift (r, -(32 - 8));
+    g = shift (g, -(16 - 3));
+    b = shift (b, -(0  + 3));
+
+    p = _mm_or_si64 (r, g);
+    p = _mm_or_si64 (p, b);
+    return loongson_insert_pi16 (t, p, pos);
+#else
     r = shift (r, -(32 - 8) + pos * 16);
     g = shift (g, -(16 - 3) + pos * 16);
     b = shift (b, -(0  + 3) + pos * 16);
@@ -435,11 +570,43 @@ pack_565 (__m64 pixel, __m64 target, int pos)
     p = _mm_or_si64 (g, p);
 
     return _mm_or_si64 (b, p);
+#endif
+}
+
+static force_inline __m64
+pack_4xpacked565 (__m64 a, __m64 b)
+{
+    __m64 rb0 = _mm_and_si64 (a, MC (packed_565_rb));
+    __m64 rb1 = _mm_and_si64 (b, MC (packed_565_rb));
+
+    __m64 t0 = _mm_madd_pi16 (rb0, MC (565_pack_multiplier));
+    __m64 t1 = _mm_madd_pi16 (rb1, MC (565_pack_multiplier));
+
+    __m64 g0 = _mm_and_si64 (a, MC (packed_565_g));
+    __m64 g1 = _mm_and_si64 (b, MC (packed_565_g));
+
+    t0 = _mm_or_si64 (t0, g0);
+    t1 = _mm_or_si64 (t1, g1);
+
+    t0 = shift(t0, -5);
+#ifdef USE_ARM_IWMMXT
+    t1 = shift(t1, -5);
+    return _mm_packs_pu32 (t0, t1);
+#else
+    t1 = shift(t1, -5 + 16);
+    return _mm_shuffle_pi16 (_mm_or_si64 (t0, t1), _MM_SHUFFLE (3, 1, 2, 0));
+#endif
 }
 
 #ifndef _MSC_VER
 
 static force_inline __m64
+pack_4x565 (__m64 v0, __m64 v1, __m64 v2, __m64 v3)
+{
+    return pack_4xpacked565 (pack8888 (v0, v1), pack8888 (v2, v3));
+}
+
+static force_inline __m64
 pix_add_mul (__m64 x, __m64 a, __m64 y, __m64 b)
 {
     x = pix_multiply (x, a);
@@ -450,32 +617,34 @@ pix_add_mul (__m64 x, __m64 a, __m64 y, __m64 b)
 
 #else
 
+/* MSVC only handles a "pass by register" of up to three SSE intrinsics */
+
+#define pack_4x565(v0, v1, v2, v3) \
+    pack_4xpacked565 (pack8888 (v0, v1), pack8888 (v2, v3))
+
 #define pix_add_mul(x, a, y, b)         \
     ( x = pix_multiply (x, a),  \
-      y = pix_multiply (y, a),  \
+      y = pix_multiply (y, b),  \
       pix_add (x, y) )
 
 #endif
 
 /* --------------- MMX code patch for fbcompose.c --------------------- */
 
-static force_inline uint32_t
+static force_inline __m64
 combine (const uint32_t *src, const uint32_t *mask)
 {
-    uint32_t ssrc = *src;
+    __m64 vsrc = load8888 (src);
 
     if (mask)
     {
-       __m64 m = load8888 (*mask);
-       __m64 s = load8888 (ssrc);
+       __m64 m = load8888 (mask);
 
        m = expand_alpha (m);
-       s = pix_multiply (s, m);
-
-       ssrc = store8888 (s);
+       vsrc = pix_multiply (vsrc, m);
     }
 
-    return ssrc;
+    return vsrc;
 }
 
 static void
@@ -490,19 +659,16 @@ mmx_combine_over_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       uint32_t ssrc = combine (src, mask);
-       uint32_t a = ssrc >> 24;
+       __m64 vsrc = combine (src, mask);
 
-       if (a == 0xff)
+       if (is_opaque (vsrc))
        {
-           *dest = ssrc;
+           store8888 (dest, vsrc);
        }
-       else if (ssrc)
+       else if (!is_zero (vsrc))
        {
-           __m64 s, sa;
-           s = load8888 (ssrc);
-           sa = expand_alpha (s);
-           *dest = store8888 (over (s, sa, load8888 (*dest)));
+           __m64 sa = expand_alpha (vsrc);
+           store8888 (dest, over (vsrc, sa, load8888 (dest)));
        }
 
        ++dest;
@@ -526,11 +692,11 @@ mmx_combine_over_reverse_u (pixman_implementation_t *imp,
     while (dest < end)
     {
        __m64 d, da;
-       uint32_t s = combine (src, mask);
+       __m64 s = combine (src, mask);
 
-       d = load8888 (*dest);
+       d = load8888 (dest);
        da = expand_alpha (d);
-       *dest = store8888 (over (d, da, load8888 (s)));
+       store8888 (dest, over (d, da, s));
 
        ++dest;
        ++src;
@@ -552,14 +718,14 @@ mmx_combine_in_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       __m64 x, a;
+       __m64 a;
+       __m64 x = combine (src, mask);
 
-       x = load8888 (combine (src, mask));
-       a = load8888 (*dest);
+       a = load8888 (dest);
        a = expand_alpha (a);
        x = pix_multiply (x, a);
 
-       *dest = store8888 (x);
+       store8888 (dest, x);
 
        ++dest;
        ++src;
@@ -581,13 +747,13 @@ mmx_combine_in_reverse_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       __m64 x, a;
+       __m64 a = combine (src, mask);
+       __m64 x;
 
-       x = load8888 (*dest);
-       a = load8888 (combine (src, mask));
+       x = load8888 (dest);
        a = expand_alpha (a);
        x = pix_multiply (x, a);
-       *dest = store8888 (x);
+       store8888 (dest, x);
 
        ++dest;
        ++src;
@@ -609,14 +775,14 @@ mmx_combine_out_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       __m64 x, a;
+       __m64 a;
+       __m64 x = combine (src, mask);
 
-       x = load8888 (combine (src, mask));
-       a = load8888 (*dest);
+       a = load8888 (dest);
        a = expand_alpha (a);
        a = negate (a);
        x = pix_multiply (x, a);
-       *dest = store8888 (x);
+       store8888 (dest, x);
 
        ++dest;
        ++src;
@@ -638,15 +804,15 @@ mmx_combine_out_reverse_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       __m64 x, a;
+       __m64 a = combine (src, mask);
+       __m64 x;
 
-       x = load8888 (*dest);
-       a = load8888 (combine (src, mask));
+       x = load8888 (dest);
        a = expand_alpha (a);
        a = negate (a);
        x = pix_multiply (x, a);
 
-       *dest = store8888 (x);
+       store8888 (dest, x);
 
        ++dest;
        ++src;
@@ -668,15 +834,15 @@ mmx_combine_atop_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       __m64 s, da, d, sia;
+       __m64 da, d, sia;
+       __m64 s = combine (src, mask);
 
-       s = load8888 (combine (src, mask));
-       d = load8888 (*dest);
+       d = load8888 (dest);
        sia = expand_alpha (s);
        sia = negate (sia);
        da = expand_alpha (d);
        s = pix_add_mul (s, da, d, sia);
-       *dest = store8888 (s);
+       store8888 (dest, s);
 
        ++dest;
        ++src;
@@ -700,15 +866,15 @@ mmx_combine_atop_reverse_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       __m64 s, dia, d, sa;
+       __m64 dia, d, sa;
+       __m64 s = combine (src, mask);
 
-       s = load8888 (combine (src, mask));
-       d = load8888 (*dest);
+       d = load8888 (dest);
        sa = expand_alpha (s);
        dia = expand_alpha (d);
        dia = negate (dia);
        s = pix_add_mul (s, dia, d, sa);
-       *dest = store8888 (s);
+       store8888 (dest, s);
 
        ++dest;
        ++src;
@@ -730,16 +896,16 @@ mmx_combine_xor_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       __m64 s, dia, d, sia;
+       __m64 dia, d, sia;
+       __m64 s = combine (src, mask);
 
-       s = load8888 (combine (src, mask));
-       d = load8888 (*dest);
+       d = load8888 (dest);
        sia = expand_alpha (s);
        dia = expand_alpha (d);
        sia = negate (sia);
        dia = negate (dia);
        s = pix_add_mul (s, dia, d, sia);
-       *dest = store8888 (s);
+       store8888 (dest, s);
 
        ++dest;
        ++src;
@@ -761,12 +927,12 @@ mmx_combine_add_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       __m64 s, d;
+       __m64 d;
+       __m64 s = combine (src, mask);
 
-       s = load8888 (combine (src, mask));
-       d = load8888 (*dest);
+       d = load8888 (dest);
        s = pix_add (s, d);
-       *dest = store8888 (s);
+       store8888 (dest, s);
 
        ++dest;
        ++src;
@@ -788,22 +954,25 @@ mmx_combine_saturate_u (pixman_implementation_t *imp,
 
     while (dest < end)
     {
-       uint32_t s = combine (src, mask);
+       uint32_t s, sa, da;
        uint32_t d = *dest;
-       __m64 ms = load8888 (s);
-       __m64 md = load8888 (d);
-       uint32_t sa = s >> 24;
-       uint32_t da = ~d >> 24;
+       __m64 ms = combine (src, mask);
+       __m64 md = load8888 (dest);
+
+       store8888(&s, ms);
+       da = ~d >> 24;
+       sa = s >> 24;
 
        if (sa > da)
        {
-           __m64 msa = load8888 (DIV_UN8 (da, sa) << 24);
+           uint32_t quot = DIV_UN8 (da, sa) << 24;
+           __m64 msa = load8888 (&quot);
            msa = expand_alpha (msa);
            ms = pix_multiply (ms, msa);
        }
 
        md = pix_add (md, ms);
-       *dest = store8888 (md);
+       store8888 (dest, md);
 
        ++src;
        ++dest;
@@ -825,11 +994,11 @@ mmx_combine_src_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
 
        s = pix_multiply (s, a);
-       *dest = store8888 (s);
+       store8888 (dest, s);
 
        ++src;
        ++mask;
@@ -850,12 +1019,12 @@ mmx_combine_over_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
        __m64 sa = expand_alpha (s);
 
-       *dest = store8888 (in_over (s, sa, a, d));
+       store8888 (dest, in_over (s, sa, a, d));
 
        ++src;
        ++dest;
@@ -876,12 +1045,12 @@ mmx_combine_over_reverse_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
        __m64 da = expand_alpha (d);
 
-       *dest = store8888 (over (d, da, in (s, a)));
+       store8888 (dest, over (d, da, in (s, a)));
 
        ++src;
        ++dest;
@@ -902,14 +1071,14 @@ mmx_combine_in_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
        __m64 da = expand_alpha (d);
 
        s = pix_multiply (s, a);
        s = pix_multiply (s, da);
-       *dest = store8888 (s);
+       store8888 (dest, s);
 
        ++src;
        ++dest;
@@ -930,14 +1099,14 @@ mmx_combine_in_reverse_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
        __m64 sa = expand_alpha (s);
 
        a = pix_multiply (a, sa);
        d = pix_multiply (d, a);
-       *dest = store8888 (d);
+       store8888 (dest, d);
 
        ++src;
        ++dest;
@@ -958,15 +1127,15 @@ mmx_combine_out_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
        __m64 da = expand_alpha (d);
 
        da = negate (da);
        s = pix_multiply (s, a);
        s = pix_multiply (s, da);
-       *dest = store8888 (s);
+       store8888 (dest, s);
 
        ++src;
        ++dest;
@@ -987,15 +1156,15 @@ mmx_combine_out_reverse_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
        __m64 sa = expand_alpha (s);
 
        a = pix_multiply (a, sa);
        a = negate (a);
        d = pix_multiply (d, a);
-       *dest = store8888 (d);
+       store8888 (dest, d);
 
        ++src;
        ++dest;
@@ -1016,9 +1185,9 @@ mmx_combine_atop_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
        __m64 da = expand_alpha (d);
        __m64 sa = expand_alpha (s);
 
@@ -1026,7 +1195,7 @@ mmx_combine_atop_ca (pixman_implementation_t *imp,
        a = pix_multiply (a, sa);
        a = negate (a);
        d = pix_add_mul (d, a, s, da);
-       *dest = store8888 (d);
+       store8888 (dest, d);
 
        ++src;
        ++dest;
@@ -1047,9 +1216,9 @@ mmx_combine_atop_reverse_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
        __m64 da = expand_alpha (d);
        __m64 sa = expand_alpha (s);
 
@@ -1057,7 +1226,7 @@ mmx_combine_atop_reverse_ca (pixman_implementation_t *imp,
        a = pix_multiply (a, sa);
        da = negate (da);
        d = pix_add_mul (d, a, s, da);
-       *dest = store8888 (d);
+       store8888 (dest, d);
 
        ++src;
        ++dest;
@@ -1078,9 +1247,9 @@ mmx_combine_xor_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
        __m64 da = expand_alpha (d);
        __m64 sa = expand_alpha (s);
 
@@ -1089,7 +1258,7 @@ mmx_combine_xor_ca (pixman_implementation_t *imp,
        da = negate (da);
        a = negate (a);
        d = pix_add_mul (d, a, s, da);
-       *dest = store8888 (d);
+       store8888 (dest, d);
 
        ++src;
        ++dest;
@@ -1110,13 +1279,13 @@ mmx_combine_add_ca (pixman_implementation_t *imp,
 
     while (src < end)
     {
-       __m64 a = load8888 (*mask);
-       __m64 s = load8888 (*src);
-       __m64 d = load8888 (*dest);
+       __m64 a = load8888 (mask);
+       __m64 s = load8888 (src);
+       __m64 d = load8888 (dest);
 
        s = pix_multiply (s, a);
        d = pix_add (s, d);
-       *dest = store8888 (d);
+       store8888 (dest, d);
 
        ++src;
        ++dest;
@@ -1147,7 +1316,7 @@ mmx_composite_over_n_8888 (pixman_implementation_t *imp,
 
     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
 
-    vsrc = load8888 (src);
+    vsrc = load8888 (&src);
     vsrca = expand_alpha (vsrc);
 
     while (height--)
@@ -1160,7 +1329,7 @@ mmx_composite_over_n_8888 (pixman_implementation_t *imp,
 
        while (w && (unsigned long)dst & 7)
        {
-           *dst = store8888 (over (vsrc, vsrca, load8888 (*dst)));
+           store8888 (dst, over (vsrc, vsrca, load8888 (dst)));
 
            w--;
            dst++;
@@ -1186,7 +1355,7 @@ mmx_composite_over_n_8888 (pixman_implementation_t *imp,
 
        if (w)
        {
-           *dst = store8888 (over (vsrc, vsrca, load8888 (*dst)));
+           store8888 (dst, over (vsrc, vsrca, load8888 (dst)));
        }
     }
 
@@ -1213,7 +1382,7 @@ mmx_composite_over_n_0565 (pixman_implementation_t *imp,
 
     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
 
-    vsrc = load8888 (src);
+    vsrc = load8888 (&src);
     vsrca = expand_alpha (vsrc);
 
     while (height--)
@@ -1238,16 +1407,14 @@ mmx_composite_over_n_0565 (pixman_implementation_t *imp,
 
        while (w >= 4)
        {
-           __m64 vdest;
-
-           vdest = *(__m64 *)dst;
+           __m64 vdest = *(__m64 *)dst;
 
-           vdest = pack_565 (over (vsrc, vsrca, expand565 (vdest, 0)), vdest, 0);
-           vdest = pack_565 (over (vsrc, vsrca, expand565 (vdest, 1)), vdest, 1);
-           vdest = pack_565 (over (vsrc, vsrca, expand565 (vdest, 2)), vdest, 2);
-           vdest = pack_565 (over (vsrc, vsrca, expand565 (vdest, 3)), vdest, 3);
+           __m64 v0 = over (vsrc, vsrca, expand565 (vdest, 0));
+           __m64 v1 = over (vsrc, vsrca, expand565 (vdest, 1));
+           __m64 v2 = over (vsrc, vsrca, expand565 (vdest, 2));
+           __m64 v3 = over (vsrc, vsrca, expand565 (vdest, 3));
 
-           *(__m64 *)dst = vdest;
+           *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3);
 
            dst += 4;
            w -= 4;
@@ -1292,7 +1459,7 @@ mmx_composite_over_n_8888_8888_ca (pixman_implementation_t *imp,
     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
     PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1);
 
-    vsrc = load8888 (src);
+    vsrc = load8888 (&src);
     vsrca = expand_alpha (vsrc);
 
     while (height--)
@@ -1307,9 +1474,9 @@ mmx_composite_over_n_8888_8888_ca (pixman_implementation_t *imp,
 
            if (m)
            {
-               __m64 vdest = load8888 (*q);
-               vdest = in_over (vsrc, vsrca, load8888 (m), vdest);
-               *q = store8888 (vdest);
+               __m64 vdest = load8888 (q);
+               vdest = in_over (vsrc, vsrca, load8888 (&m), vdest);
+               store8888 (q, vdest);
            }
 
            twidth--;
@@ -1328,9 +1495,9 @@ mmx_composite_over_n_8888_8888_ca (pixman_implementation_t *imp,
                __m64 dest0, dest1;
                __m64 vdest = *(__m64 *)q;
 
-               dest0 = in_over (vsrc, vsrca, load8888 (m0),
+               dest0 = in_over (vsrc, vsrca, load8888 (&m0),
                                 expand8888 (vdest, 0));
-               dest1 = in_over (vsrc, vsrca, load8888 (m1),
+               dest1 = in_over (vsrc, vsrca, load8888 (&m1),
                                 expand8888 (vdest, 1));
 
                *(__m64 *)q = pack8888 (dest0, dest1);
@@ -1341,15 +1508,15 @@ mmx_composite_over_n_8888_8888_ca (pixman_implementation_t *imp,
            twidth -= 2;
        }
 
-       while (twidth)
+       if (twidth)
        {
            uint32_t m = *(uint32_t *)p;
 
            if (m)
            {
-               __m64 vdest = load8888 (*q);
-               vdest = in_over (vsrc, vsrca, load8888 (m), vdest);
-               *q = store8888 (vdest);
+               __m64 vdest = load8888 (q);
+               vdest = in_over (vsrc, vsrca, load8888 (&m), vdest);
+               store8888 (q, vdest);
            }
 
            twidth--;
@@ -1384,7 +1551,7 @@ mmx_composite_over_8888_n_8888 (pixman_implementation_t *imp,
     mask = _pixman_image_get_solid (imp, mask_image, dest_image->bits.format);
     mask &= 0xff000000;
     mask = mask | mask >> 8 | mask >> 16 | mask >> 24;
-    vmask = load8888 (mask);
+    vmask = load8888 (&mask);
 
     while (height--)
     {
@@ -1396,10 +1563,10 @@ mmx_composite_over_8888_n_8888 (pixman_implementation_t *imp,
 
        while (w && (unsigned long)dst & 7)
        {
-           __m64 s = load8888 (*src);
-           __m64 d = load8888 (*dst);
+           __m64 s = load8888 (src);
+           __m64 d = load8888 (dst);
 
-           *dst = store8888 (in_over (s, expand_alpha (s), vmask, d));
+           store8888 (dst, in_over (s, expand_alpha (s), vmask, d));
 
            w--;
            dst++;
@@ -1408,7 +1575,7 @@ mmx_composite_over_8888_n_8888 (pixman_implementation_t *imp,
 
        while (w >= 2)
        {
-           __m64 vs = (__m64)ldq_u((uint64_t *)src);
+           __m64 vs = ldq_u ((__m64 *)src);
            __m64 vd = *(__m64 *)dst;
            __m64 vsrc0 = expand8888 (vs, 0);
            __m64 vsrc1 = expand8888 (vs, 1);
@@ -1424,10 +1591,10 @@ mmx_composite_over_8888_n_8888 (pixman_implementation_t *imp,
 
        if (w)
        {
-           __m64 s = load8888 (*src);
-           __m64 d = load8888 (*dst);
+           __m64 s = load8888 (src);
+           __m64 d = load8888 (dst);
 
-           *dst = store8888 (in_over (s, expand_alpha (s), vmask, d));
+           store8888 (dst, in_over (s, expand_alpha (s), vmask, d));
        }
     }
 
@@ -1455,7 +1622,7 @@ mmx_composite_over_x888_n_8888 (pixman_implementation_t *imp,
 
     mask &= 0xff000000;
     mask = mask | mask >> 8 | mask >> 16 | mask >> 24;
-    vmask = load8888 (mask);
+    vmask = load8888 (&mask);
     srca = MC (4x00ff);
 
     while (height--)
@@ -1468,10 +1635,11 @@ mmx_composite_over_x888_n_8888 (pixman_implementation_t *imp,
 
        while (w && (unsigned long)dst & 7)
        {
-           __m64 s = load8888 (*src | 0xff000000);
-           __m64 d = load8888 (*dst);
+           uint32_t ssrc = *src | 0xff000000;
+           __m64 s = load8888 (&ssrc);
+           __m64 d = load8888 (dst);
 
-           *dst = store8888 (in_over (s, srca, vmask, d));
+           store8888 (dst, in_over (s, srca, vmask, d));
 
            w--;
            dst++;
@@ -1489,14 +1657,14 @@ mmx_composite_over_x888_n_8888 (pixman_implementation_t *imp,
            __m64 vd6 = *(__m64 *)(dst + 12);
            __m64 vd7 = *(__m64 *)(dst + 14);
 
-           __m64 vs0 = (__m64)ldq_u((uint64_t *)(src + 0));
-           __m64 vs1 = (__m64)ldq_u((uint64_t *)(src + 2));
-           __m64 vs2 = (__m64)ldq_u((uint64_t *)(src + 4));
-           __m64 vs3 = (__m64)ldq_u((uint64_t *)(src + 6));
-           __m64 vs4 = (__m64)ldq_u((uint64_t *)(src + 8));
-           __m64 vs5 = (__m64)ldq_u((uint64_t *)(src + 10));
-           __m64 vs6 = (__m64)ldq_u((uint64_t *)(src + 12));
-           __m64 vs7 = (__m64)ldq_u((uint64_t *)(src + 14));
+           __m64 vs0 = ldq_u ((__m64 *)(src + 0));
+           __m64 vs1 = ldq_u ((__m64 *)(src + 2));
+           __m64 vs2 = ldq_u ((__m64 *)(src + 4));
+           __m64 vs3 = ldq_u ((__m64 *)(src + 6));
+           __m64 vs4 = ldq_u ((__m64 *)(src + 8));
+           __m64 vs5 = ldq_u ((__m64 *)(src + 10));
+           __m64 vs6 = ldq_u ((__m64 *)(src + 12));
+           __m64 vs7 = ldq_u ((__m64 *)(src + 14));
 
            vd0 = pack8888 (
                in_over (expandx888 (vs0, 0), srca, vmask, expand8888 (vd0, 0)),
@@ -1546,10 +1714,11 @@ mmx_composite_over_x888_n_8888 (pixman_implementation_t *imp,
 
        while (w)
        {
-           __m64 s = load8888 (*src | 0xff000000);
-           __m64 d = load8888 (*dst);
+           uint32_t ssrc = *src | 0xff000000;
+           __m64 s = load8888 (&ssrc);
+           __m64 d = load8888 (dst);
 
-           *dst = store8888 (in_over (s, srca, vmask, d));
+           store8888 (dst, in_over (s, srca, vmask, d));
 
            w--;
            dst++;
@@ -1597,9 +1766,9 @@ mmx_composite_over_8888_8888 (pixman_implementation_t *imp,
            else if (s)
            {
                __m64 ms, sa;
-               ms = load8888 (s);
+               ms = load8888 (&s);
                sa = expand_alpha (ms);
-               *dst = store8888 (over (ms, sa, load8888 (*dst)));
+               store8888 (dst, over (ms, sa, load8888 (dst)));
            }
 
            dst++;
@@ -1640,7 +1809,7 @@ mmx_composite_over_8888_0565 (pixman_implementation_t *imp,
 
        while (w && (unsigned long)dst & 7)
        {
-           __m64 vsrc = load8888 (*src);
+           __m64 vsrc = load8888 (src);
            uint64_t d = *dst;
            __m64 vdest = expand565 (to_m64 (d), 0);
 
@@ -1658,22 +1827,19 @@ mmx_composite_over_8888_0565 (pixman_implementation_t *imp,
 
        while (w >= 4)
        {
-           __m64 vsrc0, vsrc1, vsrc2, vsrc3;
-           __m64 vdest;
+           __m64 vdest = *(__m64 *)dst;
 
-           vsrc0 = load8888 (*(src + 0));
-           vsrc1 = load8888 (*(src + 1));
-           vsrc2 = load8888 (*(src + 2));
-           vsrc3 = load8888 (*(src + 3));
+           __m64 vsrc0 = load8888 ((src + 0));
+           __m64 vsrc1 = load8888 ((src + 1));
+           __m64 vsrc2 = load8888 ((src + 2));
+           __m64 vsrc3 = load8888 ((src + 3));
 
-           vdest = *(__m64 *)dst;
+           __m64 v0 = over (vsrc0, expand_alpha (vsrc0), expand565 (vdest, 0));
+           __m64 v1 = over (vsrc1, expand_alpha (vsrc1), expand565 (vdest, 1));
+           __m64 v2 = over (vsrc2, expand_alpha (vsrc2), expand565 (vdest, 2));
+           __m64 v3 = over (vsrc3, expand_alpha (vsrc3), expand565 (vdest, 3));
 
-           vdest = pack_565 (over (vsrc0, expand_alpha (vsrc0), expand565 (vdest, 0)), vdest, 0);
-           vdest = pack_565 (over (vsrc1, expand_alpha (vsrc1), expand565 (vdest, 1)), vdest, 1);
-           vdest = pack_565 (over (vsrc2, expand_alpha (vsrc2), expand565 (vdest, 2)), vdest, 2);
-           vdest = pack_565 (over (vsrc3, expand_alpha (vsrc3), expand565 (vdest, 3)), vdest, 3);
-
-           *(__m64 *)dst = vdest;
+           *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3);
 
            w -= 4;
            dst += 4;
@@ -1684,7 +1850,7 @@ mmx_composite_over_8888_0565 (pixman_implementation_t *imp,
 
        while (w)
        {
-           __m64 vsrc = load8888 (*src);
+           __m64 vsrc = load8888 (src);
            uint64_t d = *dst;
            __m64 vdest = expand565 (to_m64 (d), 0);
 
@@ -1727,7 +1893,7 @@ mmx_composite_over_n_8_8888 (pixman_implementation_t *imp,
     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
     PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
 
-    vsrc = load8888 (src);
+    vsrc = load8888 (&src);
     vsrca = expand_alpha (vsrc);
 
     while (height--)
@@ -1748,9 +1914,9 @@ mmx_composite_over_n_8_8888 (pixman_implementation_t *imp,
            {
                __m64 vdest = in_over (vsrc, vsrca,
                                       expand_alpha_rev (to_m64 (m)),
-                                      load8888 (*dst));
+                                      load8888 (dst));
 
-               *dst = store8888 (vdest);
+               store8888 (dst, vdest);
            }
 
            w--;
@@ -1799,11 +1965,11 @@ mmx_composite_over_n_8_8888 (pixman_implementation_t *imp,
 
            if (m)
            {
-               __m64 vdest = load8888 (*dst);
+               __m64 vdest = load8888 (dst);
 
                vdest = in_over (
                    vsrc, vsrca, expand_alpha_rev (to_m64 (m)), vdest);
-               *dst = store8888 (vdest);
+               store8888 (dst, vdest);
            }
        }
     }
@@ -1882,14 +2048,14 @@ pixman_fill_mmx (uint32_t *bits,
        byte_line += stride;
        w = byte_width;
 
-       while (w >= 1 && ((unsigned long)d & 1))
+       if (w >= 1 && ((unsigned long)d & 1))
        {
            *(uint8_t *)d = (xor & 0xff);
            w--;
            d++;
        }
 
-       while (w >= 2 && ((unsigned long)d & 3))
+       if (w >= 2 && ((unsigned long)d & 3))
        {
            *(uint16_t *)d = xor;
            w -= 2;
@@ -1942,13 +2108,13 @@ pixman_fill_mmx (uint32_t *bits,
            w -= 4;
            d += 4;
        }
-       while (w >= 2)
+       if (w >= 2)
        {
            *(uint16_t *)d = xor;
            w -= 2;
            d += 2;
        }
-       while (w >= 1)
+       if (w >= 1)
        {
            *(uint8_t *)d = (xor & 0xff);
            w--;
@@ -1962,6 +2128,60 @@ pixman_fill_mmx (uint32_t *bits,
 }
 
 static void
+mmx_composite_src_x888_0565 (pixman_implementation_t *imp,
+                             pixman_composite_info_t *info)
+{
+    PIXMAN_COMPOSITE_ARGS (info);
+    uint16_t    *dst_line, *dst;
+    uint32_t    *src_line, *src, s;
+    int dst_stride, src_stride;
+    int32_t w;
+
+    PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
+    PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
+
+    while (height--)
+    {
+       dst = dst_line;
+       dst_line += dst_stride;
+       src = src_line;
+       src_line += src_stride;
+       w = width;
+
+       while (w && (unsigned long)dst & 7)
+       {
+           s = *src++;
+           *dst = CONVERT_8888_TO_0565 (s);
+           dst++;
+           w--;
+       }
+
+       while (w >= 4)
+       {
+           __m64 vdest;
+           __m64 vsrc0 = ldq_u ((__m64 *)(src + 0));
+           __m64 vsrc1 = ldq_u ((__m64 *)(src + 2));
+
+           vdest = pack_4xpacked565 (vsrc0, vsrc1);
+
+           *(__m64 *)dst = vdest;
+
+           w -= 4;
+           src += 4;
+           dst += 4;
+       }
+
+       while (w)
+       {
+           s = *src++;
+           *dst = CONVERT_8888_TO_0565 (s);
+           dst++;
+           w--;
+       }
+    }
+}
+
+static void
 mmx_composite_src_n_8_8888 (pixman_implementation_t *imp,
                             pixman_composite_info_t *info)
 {
@@ -1992,7 +2212,7 @@ mmx_composite_src_n_8_8888 (pixman_implementation_t *imp,
     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
     PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
 
-    vsrc = load8888 (src);
+    vsrc = load8888 (&src);
 
     while (height--)
     {
@@ -2012,7 +2232,7 @@ mmx_composite_src_n_8_8888 (pixman_implementation_t *imp,
            {
                __m64 vdest = in (vsrc, expand_alpha_rev (to_m64 (m)));
 
-               *dst = store8888 (vdest);
+               store8888 (dst, vdest);
            }
            else
            {
@@ -2063,10 +2283,10 @@ mmx_composite_src_n_8_8888 (pixman_implementation_t *imp,
 
            if (m)
            {
-               __m64 vdest = load8888 (*dst);
+               __m64 vdest = load8888 (dst);
 
                vdest = in (vsrc, expand_alpha_rev (to_m64 (m)));
-               *dst = store8888 (vdest);
+               store8888 (dst, vdest);
            }
            else
            {
@@ -2089,7 +2309,7 @@ mmx_composite_over_n_8_0565 (pixman_implementation_t *imp,
     int dst_stride, mask_stride;
     int32_t w;
     __m64 vsrc, vsrca, tmp;
-    uint64_t srcsrcsrcsrc, src16;
+    __m64 srcsrcsrcsrc;
 
     CHECKPOINT ();
 
@@ -2102,15 +2322,11 @@ mmx_composite_over_n_8_0565 (pixman_implementation_t *imp,
     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
     PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
 
-    vsrc = load8888 (src);
+    vsrc = load8888 (&src);
     vsrca = expand_alpha (vsrc);
 
     tmp = pack_565 (vsrc, _mm_setzero_si64 (), 0);
-    src16 = to_uint64 (tmp);
-
-    srcsrcsrcsrc =
-       (uint64_t)src16 << 48 | (uint64_t)src16 << 32 |
-       (uint64_t)src16 << 16 | (uint64_t)src16;
+    srcsrcsrcsrc = expand_alpha_rev (tmp);
 
     while (height--)
     {
@@ -2154,29 +2370,26 @@ mmx_composite_over_n_8_0565 (pixman_implementation_t *imp,
 
            if (srca == 0xff && (m0 & m1 & m2 & m3) == 0xff)
            {
-               *(uint64_t *)dst = srcsrcsrcsrc;
+               *(__m64 *)dst = srcsrcsrcsrc;
            }
            else if (m0 | m1 | m2 | m3)
            {
-               __m64 vdest;
-               __m64 vm0, vm1, vm2, vm3;
-
-               vdest = *(__m64 *)dst;
+               __m64 vdest = *(__m64 *)dst;
 
-               vm0 = to_m64 (m0);
-               vdest = pack_565 (in_over (vsrc, vsrca, expand_alpha_rev (vm0),
-                                          expand565 (vdest, 0)), vdest, 0);
-               vm1 = to_m64 (m1);
-               vdest = pack_565 (in_over (vsrc, vsrca, expand_alpha_rev (vm1),
-                                          expand565 (vdest, 1)), vdest, 1);
-               vm2 = to_m64 (m2);
-               vdest = pack_565 (in_over (vsrc, vsrca, expand_alpha_rev (vm2),
-                                          expand565 (vdest, 2)), vdest, 2);
-               vm3 = to_m64 (m3);
-               vdest = pack_565 (in_over (vsrc, vsrca, expand_alpha_rev (vm3),
-                                          expand565 (vdest, 3)), vdest, 3);
-
-               *(__m64 *)dst = vdest;
+               __m64 vm0 = to_m64 (m0);
+               __m64 v0 = in_over (vsrc, vsrca, expand_alpha_rev (vm0),
+                                          expand565 (vdest, 0));
+               __m64 vm1 = to_m64 (m1);
+               __m64 v1 = in_over (vsrc, vsrca, expand_alpha_rev (vm1),
+                                          expand565 (vdest, 1));
+               __m64 vm2 = to_m64 (m2);
+               __m64 v2 = in_over (vsrc, vsrca, expand_alpha_rev (vm2),
+                                          expand565 (vdest, 2));
+               __m64 vm3 = to_m64 (m3);
+               __m64 v3 = in_over (vsrc, vsrca, expand_alpha_rev (vm3),
+                                          expand565 (vdest, 3));
+
+               *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3);;
            }
 
            w -= 4;
@@ -2241,7 +2454,7 @@ mmx_composite_over_pixbuf_0565 (pixman_implementation_t *imp,
 
        while (w && (unsigned long)dst & 7)
        {
-           __m64 vsrc = load8888 (*src);
+           __m64 vsrc = load8888 (src);
            uint64_t d = *dst;
            __m64 vdest = expand565 (to_m64 (d), 0);
 
@@ -2273,24 +2486,23 @@ mmx_composite_over_pixbuf_0565 (pixman_implementation_t *imp,
 
            if ((a0 & a1 & a2 & a3) == 0xFF)
            {
-               __m64 vdest;
-               vdest = pack_565 (invert_colors (load8888 (s0)), _mm_setzero_si64 (), 0);
-               vdest = pack_565 (invert_colors (load8888 (s1)), vdest, 1);
-               vdest = pack_565 (invert_colors (load8888 (s2)), vdest, 2);
-               vdest = pack_565 (invert_colors (load8888 (s3)), vdest, 3);
+               __m64 v0 = invert_colors (load8888 (&s0));
+               __m64 v1 = invert_colors (load8888 (&s1));
+               __m64 v2 = invert_colors (load8888 (&s2));
+               __m64 v3 = invert_colors (load8888 (&s3));
 
-               *(__m64 *)dst = vdest;
+               *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3);
            }
            else if (s0 | s1 | s2 | s3)
            {
                __m64 vdest = *(__m64 *)dst;
 
-               vdest = pack_565 (over_rev_non_pre (load8888 (s0), expand565 (vdest, 0)), vdest, 0);
-               vdest = pack_565 (over_rev_non_pre (load8888 (s1), expand565 (vdest, 1)), vdest, 1);
-               vdest = pack_565 (over_rev_non_pre (load8888 (s2), expand565 (vdest, 2)), vdest, 2);
-               vdest = pack_565 (over_rev_non_pre (load8888 (s3), expand565 (vdest, 3)), vdest, 3);
+               __m64 v0 = over_rev_non_pre (load8888 (&s0), expand565 (vdest, 0));
+               __m64 v1 = over_rev_non_pre (load8888 (&s1), expand565 (vdest, 1));
+               __m64 v2 = over_rev_non_pre (load8888 (&s2), expand565 (vdest, 2));
+               __m64 v3 = over_rev_non_pre (load8888 (&s3), expand565 (vdest, 3));
 
-               *(__m64 *)dst = vdest;
+               *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3);
            }
 
            w -= 4;
@@ -2302,7 +2514,7 @@ mmx_composite_over_pixbuf_0565 (pixman_implementation_t *imp,
 
        while (w)
        {
-           __m64 vsrc = load8888 (*src);
+           __m64 vsrc = load8888 (src);
            uint64_t d = *dst;
            __m64 vdest = expand565 (to_m64 (d), 0);
 
@@ -2349,10 +2561,10 @@ mmx_composite_over_pixbuf_8888 (pixman_implementation_t *imp,
 
        while (w && (unsigned long)dst & 7)
        {
-           __m64 s = load8888 (*src);
-           __m64 d = load8888 (*dst);
+           __m64 s = load8888 (src);
+           __m64 d = load8888 (dst);
 
-           *dst = store8888 (over_rev_non_pre (s, d));
+           store8888 (dst, over_rev_non_pre (s, d));
 
            w--;
            dst++;
@@ -2361,7 +2573,7 @@ mmx_composite_over_pixbuf_8888 (pixman_implementation_t *imp,
 
        while (w >= 2)
        {
-           uint64_t s0, s1;
+           uint32_t s0, s1;
            unsigned char a0, a1;
            __m64 d0, d1;
 
@@ -2373,8 +2585,8 @@ mmx_composite_over_pixbuf_8888 (pixman_implementation_t *imp,
 
            if ((a0 & a1) == 0xFF)
            {
-               d0 = invert_colors (load8888 (s0));
-               d1 = invert_colors (load8888 (s1));
+               d0 = invert_colors (load8888 (&s0));
+               d1 = invert_colors (load8888 (&s1));
 
                *(__m64 *)dst = pack8888 (d0, d1);
            }
@@ -2382,8 +2594,8 @@ mmx_composite_over_pixbuf_8888 (pixman_implementation_t *imp,
            {
                __m64 vdest = *(__m64 *)dst;
 
-               d0 = over_rev_non_pre (load8888 (s0), expand8888 (vdest, 0));
-               d1 = over_rev_non_pre (load8888 (s1), expand8888 (vdest, 1));
+               d0 = over_rev_non_pre (load8888 (&s0), expand8888 (vdest, 0));
+               d1 = over_rev_non_pre (load8888 (&s1), expand8888 (vdest, 1));
 
                *(__m64 *)dst = pack8888 (d0, d1);
            }
@@ -2395,10 +2607,10 @@ mmx_composite_over_pixbuf_8888 (pixman_implementation_t *imp,
 
        if (w)
        {
-           __m64 s = load8888 (*src);
-           __m64 d = load8888 (*dst);
+           __m64 s = load8888 (src);
+           __m64 d = load8888 (dst);
 
-           *dst = store8888 (over_rev_non_pre (s, d));
+           store8888 (dst, over_rev_non_pre (s, d));
        }
     }
 
@@ -2426,7 +2638,7 @@ mmx_composite_over_n_8888_0565_ca (pixman_implementation_t *imp,
     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
     PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1);
 
-    vsrc = load8888 (src);
+    vsrc = load8888 (&src);
     vsrca = expand_alpha (vsrc);
 
     while (height--)
@@ -2443,7 +2655,7 @@ mmx_composite_over_n_8888_0565_ca (pixman_implementation_t *imp,
            {
                uint64_t d = *q;
                __m64 vdest = expand565 (to_m64 (d), 0);
-               vdest = pack_565 (in_over (vsrc, vsrca, load8888 (m), vdest), vdest, 0);
+               vdest = pack_565 (in_over (vsrc, vsrca, load8888 (&m), vdest), vdest, 0);
                *q = to_uint64 (vdest);
            }
 
@@ -2465,12 +2677,12 @@ mmx_composite_over_n_8888_0565_ca (pixman_implementation_t *imp,
            {
                __m64 vdest = *(__m64 *)q;
 
-               vdest = pack_565 (in_over (vsrc, vsrca, load8888 (m0), expand565 (vdest, 0)), vdest, 0);
-               vdest = pack_565 (in_over (vsrc, vsrca, load8888 (m1), expand565 (vdest, 1)), vdest, 1);
-               vdest = pack_565 (in_over (vsrc, vsrca, load8888 (m2), expand565 (vdest, 2)), vdest, 2);
-               vdest = pack_565 (in_over (vsrc, vsrca, load8888 (m3), expand565 (vdest, 3)), vdest, 3);
+               __m64 v0 = in_over (vsrc, vsrca, load8888 (&m0), expand565 (vdest, 0));
+               __m64 v1 = in_over (vsrc, vsrca, load8888 (&m1), expand565 (vdest, 1));
+               __m64 v2 = in_over (vsrc, vsrca, load8888 (&m2), expand565 (vdest, 2));
+               __m64 v3 = in_over (vsrc, vsrca, load8888 (&m3), expand565 (vdest, 3));
 
-               *(__m64 *)q = vdest;
+               *(__m64 *)q = pack_4x565 (v0, v1, v2, v3);
            }
            twidth -= 4;
            p += 4;
@@ -2486,7 +2698,7 @@ mmx_composite_over_n_8888_0565_ca (pixman_implementation_t *imp,
            {
                uint64_t d = *q;
                __m64 vdest = expand565 (to_m64 (d), 0);
-               vdest = pack_565 (in_over (vsrc, vsrca, load8888 (m), vdest), vdest, 0);
+               vdest = pack_565 (in_over (vsrc, vsrca, load8888 (&m), vdest), vdest, 0);
                *q = to_uint64 (vdest);
            }
 
@@ -2522,7 +2734,7 @@ mmx_composite_in_n_8_8 (pixman_implementation_t *imp,
 
     sa = src >> 24;
 
-    vsrc = load8888 (src);
+    vsrc = load8888 (&src);
     vsrca = expand_alpha (vsrc);
 
     while (height--)
@@ -2554,10 +2766,10 @@ mmx_composite_in_n_8_8 (pixman_implementation_t *imp,
            __m64 vmask;
            __m64 vdest;
 
-           vmask = load8888 (ldl_u((uint32_t *)mask));
-           vdest = load8888 (*(uint32_t *)dst);
+           vmask = load8888u ((uint32_t *)mask);
+           vdest = load8888 ((uint32_t *)dst);
 
-           *(uint32_t *)dst = store8888 (in (in (vsrca, vmask), vdest));
+           store8888 ((uint32_t *)dst, in (in (vsrca, vmask), vdest));
 
            dst += 4;
            mask += 4;
@@ -2624,7 +2836,7 @@ mmx_composite_in_8_8 (pixman_implementation_t *imp,
            uint32_t *s = (uint32_t *)src;
            uint32_t *d = (uint32_t *)dst;
 
-           *d = store8888 (in (load8888 (ldl_u((uint32_t *)s)), load8888 (*d)));
+           store8888 (d, in (load8888u (s), load8888 (d)));
 
            w -= 4;
            dst += 4;
@@ -2672,7 +2884,7 @@ mmx_composite_add_n_8_8 (pixman_implementation_t *imp,
     if (src == 0)
        return;
 
-    vsrc = load8888 (src);
+    vsrc = load8888 (&src);
     vsrca = expand_alpha (vsrc);
 
     while (height--)
@@ -2705,10 +2917,10 @@ mmx_composite_add_n_8_8 (pixman_implementation_t *imp,
            __m64 vmask;
            __m64 vdest;
 
-           vmask = load8888 (ldl_u((uint32_t *)mask));
-           vdest = load8888 (*(uint32_t *)dst);
+           vmask = load8888u ((uint32_t *)mask);
+           vdest = load8888 ((uint32_t *)dst);
 
-           *(uint32_t *)dst = store8888 (_mm_adds_pu8 (in (vsrca, vmask), vdest));
+           store8888 ((uint32_t *)dst, _mm_adds_pu8 (in (vsrca, vmask), vdest));
 
            dst += 4;
            mask += 4;
@@ -2775,7 +2987,7 @@ mmx_composite_add_8_8 (pixman_implementation_t *imp,
 
        while (w >= 8)
        {
-           *(__m64*)dst = _mm_adds_pu8 ((__m64)ldq_u((uint64_t *)src), *(__m64*)dst);
+           *(__m64*)dst = _mm_adds_pu8 (ldq_u ((__m64 *)src), *(__m64*)dst);
            dst += 8;
            src += 8;
            w -= 8;
@@ -2803,7 +3015,6 @@ mmx_composite_add_8888_8888 (pixman_implementation_t *imp,
                              pixman_composite_info_t *info)
 {
     PIXMAN_COMPOSITE_ARGS (info);
-    __m64 dst64;
     uint32_t    *dst_line, *dst;
     uint32_t    *src_line, *src;
     int dst_stride, src_stride;
@@ -2824,8 +3035,8 @@ mmx_composite_add_8888_8888 (pixman_implementation_t *imp,
 
        while (w && (unsigned long)dst & 7)
        {
-           *dst = _mm_cvtsi64_si32 (_mm_adds_pu8 (_mm_cvtsi32_si64 (*src),
-                                                  _mm_cvtsi32_si64 (*dst)));
+           store (dst, _mm_adds_pu8 (load ((const uint32_t *)src),
+                                     load ((const uint32_t *)dst)));
            dst++;
            src++;
            w--;
@@ -2833,8 +3044,7 @@ mmx_composite_add_8888_8888 (pixman_implementation_t *imp,
 
        while (w >= 2)
        {
-           dst64 = _mm_adds_pu8 ((__m64)ldq_u((uint64_t *)src), *(__m64*)dst);
-           *(uint64_t*)dst = to_uint64 (dst64);
+           *(__m64 *)dst = _mm_adds_pu8 (ldq_u ((__m64 *)src), *(__m64*)dst);
            dst += 2;
            src += 2;
            w -= 2;
@@ -2842,8 +3052,8 @@ mmx_composite_add_8888_8888 (pixman_implementation_t *imp,
 
        if (w)
        {
-           *dst = _mm_cvtsi64_si32 (_mm_adds_pu8 (_mm_cvtsi32_si64 (*src),
-                                                  _mm_cvtsi32_si64 (*dst)));
+           store (dst, _mm_adds_pu8 (load ((const uint32_t *)src),
+                                     load ((const uint32_t *)dst)));
 
        }
     }
@@ -2906,7 +3116,7 @@ pixman_blt_mmx (uint32_t *src_bits,
        dst_bytes += dst_stride;
        w = byte_width;
 
-       while (w >= 1 && ((unsigned long)d & 1))
+       if (w >= 1 && ((unsigned long)d & 1))
        {
            *(uint8_t *)d = *(uint8_t *)s;
            w -= 1;
@@ -2914,7 +3124,7 @@ pixman_blt_mmx (uint32_t *src_bits,
            d += 1;
        }
 
-       while (w >= 2 && ((unsigned long)d & 3))
+       if (w >= 2 && ((unsigned long)d & 3))
        {
            *(uint16_t *)d = *(uint16_t *)s;
            w -= 2;
@@ -2924,7 +3134,7 @@ pixman_blt_mmx (uint32_t *src_bits,
 
        while (w >= 4 && ((unsigned long)d & 7))
        {
-           *(uint32_t *)d = ldl_u((uint32_t *)s);
+           *(uint32_t *)d = ldl_u ((uint32_t *)s);
 
            w -= 4;
            s += 4;
@@ -2958,14 +3168,14 @@ pixman_blt_mmx (uint32_t *src_bits,
                  "%mm0", "%mm1", "%mm2", "%mm3",
                  "%mm4", "%mm5", "%mm6", "%mm7");
 #else
-           __m64 v0 = ldq_u((uint64_t *)(s + 0));
-           __m64 v1 = ldq_u((uint64_t *)(s + 8));
-           __m64 v2 = ldq_u((uint64_t *)(s + 16));
-           __m64 v3 = ldq_u((uint64_t *)(s + 24));
-           __m64 v4 = ldq_u((uint64_t *)(s + 32));
-           __m64 v5 = ldq_u((uint64_t *)(s + 40));
-           __m64 v6 = ldq_u((uint64_t *)(s + 48));
-           __m64 v7 = ldq_u((uint64_t *)(s + 56));
+           __m64 v0 = ldq_u ((__m64 *)(s + 0));
+           __m64 v1 = ldq_u ((__m64 *)(s + 8));
+           __m64 v2 = ldq_u ((__m64 *)(s + 16));
+           __m64 v3 = ldq_u ((__m64 *)(s + 24));
+           __m64 v4 = ldq_u ((__m64 *)(s + 32));
+           __m64 v5 = ldq_u ((__m64 *)(s + 40));
+           __m64 v6 = ldq_u ((__m64 *)(s + 48));
+           __m64 v7 = ldq_u ((__m64 *)(s + 56));
            *(__m64 *)(d + 0)  = v0;
            *(__m64 *)(d + 8)  = v1;
            *(__m64 *)(d + 16) = v2;
@@ -2982,7 +3192,7 @@ pixman_blt_mmx (uint32_t *src_bits,
        }
        while (w >= 4)
        {
-           *(uint32_t *)d = ldl_u((uint32_t *)s);
+           *(uint32_t *)d = ldl_u ((uint32_t *)s);
 
            w -= 4;
            s += 4;
@@ -3017,7 +3227,6 @@ mmx_composite_copy_area (pixman_implementation_t *imp,
                     src_x, src_y, dest_x, dest_y, width, height);
 }
 
-#if 0
 static void
 mmx_composite_over_x888_8_8888 (pixman_implementation_t *imp,
                                 pixman_composite_info_t *info)
@@ -3050,19 +3259,20 @@ mmx_composite_over_x888_8_8888 (pixman_implementation_t *imp,
 
            if (m)
            {
-               __m64 s = load8888 (*src | 0xff000000);
+               uint32_t ssrc = *src | 0xff000000;
+               __m64 s = load8888 (&ssrc);
 
                if (m == 0xff)
                {
-                   *dst = store8888 (s);
+                   store8888 (dst, s);
                }
                else
                {
                    __m64 sa = expand_alpha (s);
                    __m64 vm = expand_alpha_rev (to_m64 (m));
-                   __m64 vdest = in_over (s, sa, vm, load8888 (*dst));
+                   __m64 vdest = in_over (s, sa, vm, load8888 (dst));
 
-                   *dst = store8888 (vdest);
+                   store8888 (dst, vdest);
                }
            }
 
@@ -3074,7 +3284,190 @@ mmx_composite_over_x888_8_8888 (pixman_implementation_t *imp,
 
     _mm_empty ();
 }
-#endif
+
+static uint32_t *
+mmx_fetch_x8r8g8b8 (pixman_iter_t *iter, const uint32_t *mask)
+{
+    int w = iter->width;
+    uint32_t *dst = iter->buffer;
+    uint32_t *src = (uint32_t *)iter->bits;
+
+    iter->bits += iter->stride;
+
+    while (w && ((unsigned long)dst) & 7)
+    {
+       *dst++ = (*src++) | 0xff000000;
+       w--;
+    }
+
+    while (w >= 8)
+    {
+       __m64 vsrc1 = ldq_u ((__m64 *)(src + 0));
+       __m64 vsrc2 = ldq_u ((__m64 *)(src + 2));
+       __m64 vsrc3 = ldq_u ((__m64 *)(src + 4));
+       __m64 vsrc4 = ldq_u ((__m64 *)(src + 6));
+
+       *(__m64 *)(dst + 0) = _mm_or_si64 (vsrc1, MC (ff000000));
+       *(__m64 *)(dst + 2) = _mm_or_si64 (vsrc2, MC (ff000000));
+       *(__m64 *)(dst + 4) = _mm_or_si64 (vsrc3, MC (ff000000));
+       *(__m64 *)(dst + 6) = _mm_or_si64 (vsrc4, MC (ff000000));
+
+       dst += 8;
+       src += 8;
+       w -= 8;
+    }
+
+    while (w)
+    {
+       *dst++ = (*src++) | 0xff000000;
+       w--;
+    }
+
+    return iter->buffer;
+}
+
+static uint32_t *
+mmx_fetch_r5g6b5 (pixman_iter_t *iter, const uint32_t *mask)
+{
+    int w = iter->width;
+    uint32_t *dst = iter->buffer;
+    uint16_t *src = (uint16_t *)iter->bits;
+
+    iter->bits += iter->stride;
+
+    while (w && ((unsigned long)dst) & 0x0f)
+    {
+       uint16_t s = *src++;
+
+       *dst++ = CONVERT_0565_TO_8888 (s);
+       w--;
+    }
+
+    while (w >= 4)
+    {
+       __m64 vsrc = ldq_u ((__m64 *)src);
+
+       __m64 mm0 = expand565 (vsrc, 0);
+       __m64 mm1 = expand565 (vsrc, 1);
+       __m64 mm2 = expand565 (vsrc, 2);
+       __m64 mm3 = expand565 (vsrc, 3);
+
+       *(__m64 *)(dst + 0) = _mm_or_si64 (pack8888 (mm0, mm1), MC (ff000000));
+       *(__m64 *)(dst + 2) = _mm_or_si64 (pack8888 (mm2, mm3), MC (ff000000));
+
+       dst += 4;
+       src += 4;
+       w -= 4;
+    }
+
+    while (w)
+    {
+       uint16_t s = *src++;
+
+       *dst++ = CONVERT_0565_TO_8888 (s);
+       w--;
+    }
+
+    return iter->buffer;
+}
+
+static uint32_t *
+mmx_fetch_a8 (pixman_iter_t *iter, const uint32_t *mask)
+{
+    int w = iter->width;
+    uint32_t *dst = iter->buffer;
+    uint8_t *src = iter->bits;
+
+    iter->bits += iter->stride;
+
+    while (w && (((unsigned long)dst) & 15))
+    {
+        *dst++ = *(src++) << 24;
+        w--;
+    }
+
+    while (w >= 8)
+    {
+       __m64 mm0 = ldq_u ((__m64 *)src);
+
+       __m64 mm1 = _mm_unpacklo_pi8  (_mm_setzero_si64(), mm0);
+       __m64 mm2 = _mm_unpackhi_pi8  (_mm_setzero_si64(), mm0);
+       __m64 mm3 = _mm_unpacklo_pi16 (_mm_setzero_si64(), mm1);
+       __m64 mm4 = _mm_unpackhi_pi16 (_mm_setzero_si64(), mm1);
+       __m64 mm5 = _mm_unpacklo_pi16 (_mm_setzero_si64(), mm2);
+       __m64 mm6 = _mm_unpackhi_pi16 (_mm_setzero_si64(), mm2);
+
+       *(__m64 *)(dst + 0) = mm3;
+       *(__m64 *)(dst + 2) = mm4;
+       *(__m64 *)(dst + 4) = mm5;
+       *(__m64 *)(dst + 6) = mm6;
+
+       dst += 8;
+       src += 8;
+       w -= 8;
+    }
+
+    while (w)
+    {
+       *dst++ = *(src++) << 24;
+       w--;
+    }
+
+    return iter->buffer;
+}
+
+typedef struct
+{
+    pixman_format_code_t       format;
+    pixman_iter_get_scanline_t get_scanline;
+} fetcher_info_t;
+
+static const fetcher_info_t fetchers[] =
+{
+    { PIXMAN_x8r8g8b8,         mmx_fetch_x8r8g8b8 },
+    { PIXMAN_r5g6b5,           mmx_fetch_r5g6b5 },
+    { PIXMAN_a8,               mmx_fetch_a8 },
+    { PIXMAN_null }
+};
+
+static void
+mmx_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
+{
+    pixman_image_t *image = iter->image;
+    int x = iter->x;
+    int y = iter->y;
+    int width = iter->width;
+    int height = iter->height;
+
+#define FLAGS                                                          \
+    (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE)
+
+    if ((iter->flags & ITER_NARROW)                            &&
+       (image->common.flags & FLAGS) == FLAGS                  &&
+       x >= 0 && y >= 0                                        &&
+       x + width <= image->bits.width                          &&
+       y + height <= image->bits.height)
+    {
+       const fetcher_info_t *f;
+
+       for (f = &fetchers[0]; f->format != PIXMAN_null; f++)
+       {
+           if (image->common.extended_format_code == f->format)
+           {
+               uint8_t *b = (uint8_t *)image->bits.bits;
+               int s = image->bits.rowstride * 4;
+
+               iter->bits = b + s * iter->y + x * PIXMAN_FORMAT_BPP (f->format) / 8;
+               iter->stride = s;
+
+               iter->get_scanline = f->get_scanline;
+               return;
+           }
+       }
+    }
+
+    imp->delegate->src_iter_init (imp->delegate, iter);
+}
 
 static const pixman_fast_path_t mmx_fast_paths[] =
 {
@@ -3104,18 +3497,14 @@ static const pixman_fast_path_t mmx_fast_paths[] =
     PIXMAN_STD_FAST_PATH    (OVER, a8r8g8b8, solid,    x8r8g8b8, mmx_composite_over_8888_n_8888    ),
     PIXMAN_STD_FAST_PATH    (OVER, a8b8g8r8, solid,    a8b8g8r8, mmx_composite_over_8888_n_8888    ),
     PIXMAN_STD_FAST_PATH    (OVER, a8b8g8r8, solid,    x8b8g8r8, mmx_composite_over_8888_n_8888    ),
-#if 0
-    /* FIXME: This code is commented out since it's apparently
-     * not actually faster than the generic code.
-     */
     PIXMAN_STD_FAST_PATH    (OVER, x8r8g8b8, a8,       x8r8g8b8, mmx_composite_over_x888_8_8888    ),
     PIXMAN_STD_FAST_PATH    (OVER, x8r8g8b8, a8,       a8r8g8b8, mmx_composite_over_x888_8_8888    ),
     PIXMAN_STD_FAST_PATH    (OVER, x8b8g8r8, a8,       x8b8g8r8, mmx_composite_over_x888_8_8888    ),
     PIXMAN_STD_FAST_PATH    (OVER, x8b8g8r8, a8,       a8b8g8r8, mmx_composite_over_x888_8_8888    ),
-#endif
     PIXMAN_STD_FAST_PATH    (OVER, solid,    null,     a8r8g8b8, mmx_composite_over_n_8888         ),
     PIXMAN_STD_FAST_PATH    (OVER, solid,    null,     x8r8g8b8, mmx_composite_over_n_8888         ),
     PIXMAN_STD_FAST_PATH    (OVER, solid,    null,     r5g6b5,   mmx_composite_over_n_0565         ),
+    PIXMAN_STD_FAST_PATH    (OVER, solid,    null,     b5g6r5,   mmx_composite_over_n_0565         ),
     PIXMAN_STD_FAST_PATH    (OVER, x8r8g8b8, null,     x8r8g8b8, mmx_composite_copy_area           ),
     PIXMAN_STD_FAST_PATH    (OVER, x8b8g8r8, null,     x8b8g8r8, mmx_composite_copy_area           ),
 
@@ -3131,6 +3520,10 @@ static const pixman_fast_path_t mmx_fast_paths[] =
     PIXMAN_STD_FAST_PATH    (ADD,  a8,       null,     a8,       mmx_composite_add_8_8            ),
     PIXMAN_STD_FAST_PATH    (ADD,  solid,    a8,       a8,       mmx_composite_add_n_8_8           ),
 
+    PIXMAN_STD_FAST_PATH    (SRC,  a8r8g8b8, null,     r5g6b5,   mmx_composite_src_x888_0565       ),
+    PIXMAN_STD_FAST_PATH    (SRC,  a8b8g8r8, null,     b5g6r5,   mmx_composite_src_x888_0565       ),
+    PIXMAN_STD_FAST_PATH    (SRC,  x8r8g8b8, null,     r5g6b5,   mmx_composite_src_x888_0565       ),
+    PIXMAN_STD_FAST_PATH    (SRC,  x8b8g8r8, null,     b5g6r5,   mmx_composite_src_x888_0565       ),
     PIXMAN_STD_FAST_PATH    (SRC,  solid,    a8,       a8r8g8b8, mmx_composite_src_n_8_8888        ),
     PIXMAN_STD_FAST_PATH    (SRC,  solid,    a8,       x8r8g8b8, mmx_composite_src_n_8_8888        ),
     PIXMAN_STD_FAST_PATH    (SRC,  solid,    a8,       a8b8g8r8, mmx_composite_src_n_8_8888        ),
@@ -3231,7 +3624,9 @@ _pixman_implementation_create_mmx (pixman_implementation_t *fallback)
     imp->blt = mmx_blt;
     imp->fill = mmx_fill;
 
+    imp->src_iter_init = mmx_src_iter_init;
+
     return imp;
 }
 
-#endif /* USE_X86_MMX || USE_ARM_IWMMXT */
+#endif /* USE_X86_MMX || USE_ARM_IWMMXT || USE_LOONGSON_MMI */
index 906a491..d835de6 100644 (file)
@@ -76,12 +76,39 @@ noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
     {
        iter->get_scanline = _pixman_iter_get_scanline_noop;
     }
-    else if ((iter->flags & ITER_NARROW)                               &&
+    else if (image->common.extended_format_code == PIXMAN_solid                &&
+            ((image->common.flags & (FAST_PATH_BITS_IMAGE | FAST_PATH_NO_ALPHA_MAP)) ==
+             (FAST_PATH_BITS_IMAGE | FAST_PATH_NO_ALPHA_MAP)))
+    {
+       bits_image_t *bits = &image->bits;
+
+       if (iter->flags & ITER_NARROW)
+       {
+           uint32_t color = bits->fetch_pixel_32 (bits, 0, 0);
+           uint32_t *buffer = iter->buffer;
+           uint32_t *end = buffer + iter->width;
+
+           while (buffer < end)
+               *(buffer++) = color;
+       }
+       else
+       {
+           uint64_t color = bits->fetch_pixel_64 (bits, 0, 0);
+           uint64_t *buffer = (uint64_t *)iter->buffer;
+           uint64_t *end = buffer + iter->width;
+
+           while (buffer < end)
+               *(buffer++) = color;
+       }
+
+       iter->get_scanline = _pixman_iter_get_scanline_noop;
+    }
+    else if (image->common.extended_format_code == PIXMAN_a8r8g8b8     &&
+            (iter->flags & ITER_NARROW)                                &&
             (image->common.flags & FLAGS) == FLAGS                     &&
             iter->x >= 0 && iter->y >= 0                               &&
             iter->x + iter->width <= image->bits.width                 &&
-            iter->y + iter->height <= image->bits.height               &&
-            image->common.extended_format_code == PIXMAN_a8r8g8b8)
+            iter->y + iter->height <= image->bits.height)
     {
        iter->buffer =
            image->bits.bits + iter->y * image->bits.rowstride + iter->x;
index cbd48f3..826b7a3 100644 (file)
@@ -299,29 +299,29 @@ typedef struct
     uint32_t                left_rb;
     uint32_t                right_ag;
     uint32_t                right_rb;
-    int32_t                 left_x;
-    int32_t                 right_x;
-    int32_t                 stepper;
+    pixman_fixed_t         left_x;
+    pixman_fixed_t          right_x;
+    pixman_fixed_t          stepper;
 
     pixman_gradient_stop_t *stops;
     int                     num_stops;
-    unsigned int            spread;
+    pixman_repeat_t        repeat;
 
-    int                     need_reset;
+    pixman_bool_t           need_reset;
 } pixman_gradient_walker_t;
 
 void
 _pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
                               gradient_t *              gradient,
-                              unsigned int              spread);
+                             pixman_repeat_t           repeat);
 
 void
 _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
-                               pixman_fixed_32_32_t      pos);
+                               pixman_fixed_48_16_t      pos);
 
 uint32_t
 _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker,
-                               pixman_fixed_32_32_t      x);
+                               pixman_fixed_48_16_t      x);
 
 /*
  * Edges
@@ -475,34 +475,11 @@ pixman_implementation_t *
 _pixman_implementation_create (pixman_implementation_t *delegate,
                               const pixman_fast_path_t *fast_paths);
 
-void
-_pixman_implementation_combine_32 (pixman_implementation_t *imp,
-                                   pixman_op_t              op,
-                                   uint32_t *               dest,
-                                   const uint32_t *         src,
-                                   const uint32_t *         mask,
-                                   int                      width);
-void
-_pixman_implementation_combine_64 (pixman_implementation_t *imp,
-                                   pixman_op_t              op,
-                                   uint64_t *               dest,
-                                   const uint64_t *         src,
-                                   const uint64_t *         mask,
-                                   int                      width);
-void
-_pixman_implementation_combine_32_ca (pixman_implementation_t *imp,
-                                      pixman_op_t              op,
-                                      uint32_t *               dest,
-                                      const uint32_t *         src,
-                                      const uint32_t *         mask,
-                                      int                      width);
-void
-_pixman_implementation_combine_64_ca (pixman_implementation_t *imp,
-                                      pixman_op_t              op,
-                                      uint64_t *               dest,
-                                      const uint64_t *         src,
-                                      const uint64_t *         mask,
-                                      int                      width);
+pixman_combine_32_func_t
+_pixman_implementation_lookup_combiner (pixman_implementation_t *imp,
+                                       pixman_op_t              op,
+                                       pixman_bool_t            component_alpha,
+                                       pixman_bool_t            wide);
 
 pixman_bool_t
 _pixman_implementation_blt (pixman_implementation_t *imp,
@@ -562,7 +539,7 @@ _pixman_implementation_create_fast_path (pixman_implementation_t *fallback);
 pixman_implementation_t *
 _pixman_implementation_create_noop (pixman_implementation_t *fallback);
 
-#if defined USE_X86_MMX || defined USE_ARM_IWMMXT
+#if defined USE_X86_MMX || defined USE_ARM_IWMMXT || defined USE_LOONGSON_MMI
 pixman_implementation_t *
 _pixman_implementation_create_mmx (pixman_implementation_t *fallback);
 #endif
@@ -582,6 +559,11 @@ pixman_implementation_t *
 _pixman_implementation_create_arm_neon (pixman_implementation_t *fallback);
 #endif
 
+#ifdef USE_MIPS_DSPR2
+pixman_implementation_t *
+_pixman_implementation_create_mips_dspr2 (pixman_implementation_t *fallback);
+#endif
+
 #ifdef USE_VMX
 pixman_implementation_t *
 _pixman_implementation_create_vmx (pixman_implementation_t *fallback);
@@ -954,10 +936,11 @@ _pixman_log_error (const char *function, const char *message);
 static inline uint64_t
 oil_profile_stamp_rdtsc (void)
 {
-    uint64_t ts;
+    uint32_t hi, lo;
 
-    __asm__ __volatile__ ("rdtsc\n" : "=A" (ts));
-    return ts;
+    __asm__ __volatile__ ("rdtsc\n" : "=a" (lo), "=d" (hi));
+
+    return lo | (((uint64_t)hi) << 32);
 }
 
 #define OIL_STAMP oil_profile_stamp_rdtsc
@@ -998,4 +981,7 @@ void pixman_timer_register (pixman_timer_t *timer);
 
 #endif /* PIXMAN_TIMERS */
 
+void _pixman_arm_check_neon(void);
+void _pixman_arm_check_v6(void);
+
 #endif /* PIXMAN_PRIVATE_H */
index 47beb52..70c282d 100644 (file)
@@ -828,8 +828,7 @@ pixman_op (region_type_t *  new_reg,               /* Place to store result
     {
         if (!pixman_rect_alloc (new_reg, new_size))
         {
-            if (old_data)
-               free (old_data);
+            free (old_data);
             return FALSE;
        }
     }
@@ -1005,8 +1004,7 @@ pixman_op (region_type_t *  new_reg,               /* Place to store result
         APPEND_REGIONS (new_reg, r2_band_end, r2_end);
     }
 
-    if (old_data)
-       free (old_data);
+    free (old_data);
 
     if (!(numRects = new_reg->data->numRects))
     {
@@ -1027,8 +1025,7 @@ pixman_op (region_type_t *  new_reg,               /* Place to store result
     return TRUE;
 
 bail:
-    if (old_data)
-       free (old_data);
+    free (old_data);
 
     return pixman_break (new_reg);
 }
@@ -2359,6 +2356,16 @@ PREFIX (_reset) (region_type_t *region, box_type_t *box)
     region->data = NULL;
 }
 
+PIXMAN_EXPORT void
+PREFIX (_clear) (region_type_t *region)
+{
+    GOOD (region);
+    FREE_DATA (region);
+
+    region->extents = *pixman_region_empty_box;
+    region->data = pixman_region_empty_data;
+}
+
 /* box is "return" value */
 PIXMAN_EXPORT int
 PREFIX (_contains_point) (region_type_t * region,
index c419511..e217ca3 100644 (file)
@@ -3291,7 +3291,7 @@ pixman_fill_sse2 (uint32_t *bits,
        byte_line += stride;
        w = byte_width;
 
-       while (w >= 1 && ((unsigned long)d & 1))
+       if (w >= 1 && ((unsigned long)d & 1))
        {
            *(uint8_t *)d = data;
            w -= 1;
@@ -5982,7 +5982,7 @@ sse2_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
     int height = iter->height;
 
 #define FLAGS                                                          \
-    (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM)
+    (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE)
 
     if ((iter->flags & ITER_NARROW)                            &&
        (image->common.flags & FLAGS) == FLAGS                  &&
index c99f03e..adf5d7b 100644 (file)
@@ -139,7 +139,7 @@ _pixman_edge_multi_init (pixman_edge_t * e,
     if (ne > 0)
     {
        int nx = ne / e->dy;
-       ne -= nx * e->dy;
+       ne -= nx * (pixman_fixed_48_16_t)e->dy;
        stepx += nx * e->signdx;
     }
 
index d2af51a..2ec2594 100644 (file)
@@ -220,16 +220,33 @@ pixman_expand (uint64_t *           dst,
     for (i = width - 1; i >= 0; i--)
     {
        const uint32_t pixel = src[i];
-       const uint8_t a = (pixel >> a_shift) & a_mask,
-                     r = (pixel >> r_shift) & r_mask,
-                     g = (pixel >> g_shift) & g_mask,
-                     b = (pixel >> b_shift) & b_mask;
-       const uint64_t
-           a16 = a_size ? unorm_to_unorm (a, a_size, 16) : 0xffff,
-           r16 = unorm_to_unorm (r, r_size, 16),
-           g16 = unorm_to_unorm (g, g_size, 16),
-           b16 = unorm_to_unorm (b, b_size, 16);
+       uint8_t a, r, g, b;
+       uint64_t a16, r16, g16, b16;
+
+       if (a_size)
+       {
+           a = (pixel >> a_shift) & a_mask;
+           a16 = unorm_to_unorm (a, a_size, 16);
+       }
+       else
+       {
+           a16 = 0xffff;
+       }
 
+       if (r_size)
+       {
+           r = (pixel >> r_shift) & r_mask;
+           g = (pixel >> g_shift) & g_mask;
+           b = (pixel >> b_shift) & b_mask;
+           r16 = unorm_to_unorm (r, r_size, 16);
+           g16 = unorm_to_unorm (g, g_size, 16);
+           b16 = unorm_to_unorm (b, b_size, 16);
+       }
+       else
+       {
+           r16 = g16 = b16 = 0;
+       }
+       
        dst[i] = a16 << 48 | r16 << 32 | g16 << 16 | b16;
     }
 }
index c57092a..18d9513 100644 (file)
@@ -466,6 +466,7 @@ pixman_bool_t           pixman_region_equal              (pixman_region16_t *reg
 pixman_bool_t           pixman_region_selfcheck          (pixman_region16_t *region);
 void                    pixman_region_reset              (pixman_region16_t *region,
                                                          pixman_box16_t    *box);
+void                   pixman_region_clear              (pixman_region16_t *region);
 /*
  * 32 bit regions
  */
@@ -560,6 +561,7 @@ pixman_bool_t           pixman_region32_equal              (pixman_region32_t *r
 pixman_bool_t           pixman_region32_selfcheck          (pixman_region32_t *region);
 void                    pixman_region32_reset              (pixman_region32_t *region,
                                                            pixman_box32_t    *box);
+void                   pixman_region32_clear              (pixman_region32_t *region);
 
 
 /* Copy / Fill / Misc */
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 307ba0c..c88d087
@@ -19,7 +19,26 @@ BENCHS  = $(patsubst %,   $(CFG_VAR)/%.exe, $(BENCHMARKS))
 all: inform $(TESTS) $(BENCHS)
 
 check: inform $(TESTS)
-       @for test in $(TESTS) ; do ./$$test && echo "PASS: $$test" || echo "FAIL: $$test" ; done
+       @failures=0 ; \
+       total=0 ; \
+       for test in $(TESTS) ; \
+       do \
+               total=`expr $$total + 1` ; \
+               if ./$$test ; \
+               then echo "PASS: $$test" ; \
+               else echo "FAIL: $$test" ; \
+                    failures=`expr $$failures + 1` ; \
+               fi ; \
+       done ; \
+       if test $$failures -eq 0 ; \
+       then banner="All $$total tests passed" ; \
+       else banner="$$failures of $$total tests failed" ; \
+       fi ; \
+       dashes=`echo "$$banner" | sed s/./=/g`; \
+       echo "$$dashes" ; \
+       echo "$$banner" ; \
+       echo "$$dashes" ; \
+       test $$failures -eq 0
 
 $(CFG_VAR)/libutils.lib: $(libutils_OBJECTS)
        @$(AR) $(PIXMAN_ARFLAGS) -OUT:$@ $^
index 6163e7c..93c6caa 100644 (file)
@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "pixman.h"
+#include "utils.h"
 
 int
 main (int argc, char **argv)
old mode 100755 (executable)
new mode 100644 (file)
index 554b309..0c5757e 100644 (file)
@@ -2,8 +2,8 @@
 #include <stdlib.h>
 #include "utils.h"
 
-#define WIDTH 100
-#define HEIGHT 100
+#define WIDTH 48
+#define HEIGHT 48
 
 static const pixman_format_code_t formats[] =
 {
@@ -70,24 +70,6 @@ make_image (pixman_format_code_t format)
     return image;
 }
 
-static pixman_image_t *
-create_image (pixman_format_code_t format, pixman_format_code_t alpha_format,
-             int alpha_origin_x, int alpha_origin_y)
-{
-    pixman_image_t *image = make_image (format);
-
-    if (alpha_format != PIXMAN_null)
-    {
-       pixman_image_t *alpha = make_image (alpha_format);
-
-       pixman_image_set_alpha_map (image, alpha,
-                                   alpha_origin_x, alpha_origin_y);
-       pixman_image_unref (alpha);
-    }
-
-    return image;
-}
-
 static uint8_t
 get_alpha (pixman_image_t *image, int x, int y, int orig_x, int orig_y)
 {
@@ -139,7 +121,44 @@ get_alpha (pixman_image_t *image, int x, int y, int orig_x, int orig_y)
     return r;
 }
 
-#define ARRAY_LENGTH(A) ((int) (sizeof (A) / sizeof ((A) [0])))
+static uint16_t
+get_red (pixman_image_t *image, int x, int y, int orig_x, int orig_y)
+{
+    uint8_t *bits;
+    uint16_t r;
+
+    bits = (uint8_t *)image->bits.bits;
+
+    if (image->bits.format == PIXMAN_a8)
+    {
+       r = 0x00;
+    }
+    else if (image->bits.format == PIXMAN_a2r10g10b10)
+    {
+       r = ((uint32_t *)bits)[y * WIDTH + x] >> 14;
+       r &= 0xffc0;
+       r |= (r >> 10);
+    }
+    else if (image->bits.format == PIXMAN_a8r8g8b8)
+    {
+       r = ((uint32_t *)bits)[y * WIDTH + x] >> 16;
+       r &= 0xff;
+       r |= r << 8;
+    }
+    else if (image->bits.format == PIXMAN_a4r4g4b4)
+    {
+       r = ((uint16_t *)bits)[y * WIDTH + x] >> 8;
+       r &= 0xf;
+       r |= r << 4;
+       r |= r << 8;
+    }
+    else
+    {
+       assert (0);
+    }
+
+    return r;
+}
 
 static int
 run_test (int s, int d, int sa, int da, int soff, int doff)
@@ -148,10 +167,10 @@ run_test (int s, int d, int sa, int da, int soff, int doff)
     pixman_format_code_t df = formats[d];
     pixman_format_code_t saf = alpha_formats[sa];
     pixman_format_code_t daf = alpha_formats[da];
-    pixman_image_t *src, *dst, *orig_dst;
+    pixman_image_t *src, *dst, *orig_dst, *alpha, *orig_alpha;
     pixman_transform_t t1;
     int j, k;
-    int n_alpha_bits;
+    int n_alpha_bits, n_red_bits;
 
     soff = origins[soff];
     doff = origins[doff];
@@ -160,10 +179,37 @@ run_test (int s, int d, int sa, int da, int soff, int doff)
     if (daf != PIXMAN_null)
        n_alpha_bits = PIXMAN_FORMAT_A (daf);
 
+    n_red_bits = PIXMAN_FORMAT_R (df);
+
+    /* Source */
+    src = make_image (sf);
+    if (saf != PIXMAN_null)
+    {
+       alpha = make_image (saf);
+       pixman_image_set_alpha_map (src, alpha, soff, soff);
+       pixman_image_unref (alpha);
+    }
+
+    /* Destination */
+    orig_dst = make_image (df);
+    dst = make_image (df);
+    pixman_image_composite (PIXMAN_OP_SRC, orig_dst, NULL, dst,
+                           0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+
+    if (daf != PIXMAN_null)
+    {
+       orig_alpha = make_image (daf);
+       alpha = make_image (daf);
+
+       pixman_image_composite (PIXMAN_OP_SRC, orig_alpha, NULL, alpha,
+                               0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
 
-    src = create_image (sf, saf, soff, soff);
-    orig_dst = create_image (df, daf, doff, doff);
-    dst = create_image (df, daf, doff, doff);
+       pixman_image_set_alpha_map (orig_dst, orig_alpha, doff, doff);
+       pixman_image_set_alpha_map (dst, alpha, doff, doff);
+
+       pixman_image_unref (orig_alpha);
+       pixman_image_unref (alpha);
+    }
 
     /* Transformations, repeats and filters on destinations should be ignored,
      * so just set some random ones.
@@ -177,9 +223,6 @@ run_test (int s, int d, int sa, int da, int soff, int doff)
     pixman_image_set_filter (dst, PIXMAN_FILTER_BILINEAR, NULL, 0);
     pixman_image_set_repeat (dst, PIXMAN_REPEAT_REFLECT);
 
-    pixman_image_composite (PIXMAN_OP_SRC, orig_dst, NULL, dst,
-                           0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
-
     pixman_image_composite (PIXMAN_OP_ADD, src, NULL, dst,
                            0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
 
@@ -187,21 +230,22 @@ run_test (int s, int d, int sa, int da, int soff, int doff)
     {
        for (k = MAX (doff, 0); k < MIN (WIDTH, WIDTH + doff); ++k)
        {
-           uint8_t sa, da, oda, ref;
+           uint8_t sa, da, oda, refa;
+           uint16_t sr, dr, odr, refr;
 
            sa = get_alpha (src, k, j, soff, soff);
            da = get_alpha (dst, k, j, doff, doff);
            oda = get_alpha (orig_dst, k, j, doff, doff);
 
            if (sa + oda > 255)
-               ref = 255;
+               refa = 255;
            else
-               ref = sa + oda;
+               refa = sa + oda;
 
-           if (da >> (8 - n_alpha_bits) != ref >> (8 - n_alpha_bits))
+           if (da >> (8 - n_alpha_bits) != refa >> (8 - n_alpha_bits))
            {
                printf ("\nWrong alpha value at (%d, %d). Should be 0x%x; got 0x%x. Source was 0x%x, original dest was 0x%x\n",
-                       k, j, ref, da, sa, oda);
+                       k, j, refa, da, sa, oda);
 
                printf ("src: %s, alpha: %s, origin %d %d\ndst: %s, alpha: %s, origin: %d %d\n\n",
                        format_name (sf),
@@ -212,6 +256,38 @@ run_test (int s, int d, int sa, int da, int soff, int doff)
                        doff, doff);
                return 1;
            }
+
+           /* There are cases where we go through the 8 bit compositing
+            * path even with 10bpc formats. This results in incorrect
+            * results here, so only do the red check for narrow formats
+            */
+           if (n_red_bits <= 8)
+           {
+               sr = get_red (src, k, j, soff, soff);
+               dr = get_red (dst, k, j, doff, doff);
+               odr = get_red (orig_dst, k, j, doff, doff);
+
+               if (sr + odr > 0xffff)
+                   refr = 0xffff;
+               else
+                   refr = sr + odr;
+
+               if (abs ((dr >> (16 - n_red_bits)) - (refr >> (16 - n_red_bits))) > 1)
+               {
+                   printf ("%d red bits\n", n_red_bits);
+                   printf ("\nWrong red value at (%d, %d). Should be 0x%x; got 0x%x. Source was 0x%x, original dest was 0x%x\n",
+                           k, j, refr, dr, sr, odr);
+
+                   printf ("src: %s, alpha: %s, origin %d %d\ndst: %s, alpha: %s, origin: %d %d\n\n",
+                           format_name (sf),
+                           format_name (saf),
+                           soff, soff,
+                           format_name (df),
+                           format_name (daf),
+                           doff, doff);
+                   return 1;
+               }
+           }
        }
     }
 
old mode 100755 (executable)
new mode 100644 (file)
index 4f931c4..feea308
@@ -5,7 +5,6 @@
  * 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"
@@ -104,7 +103,7 @@ free_random_image (uint32_t initcrc,
                mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
            }
 
-           for (i = 0; i < 32; i++)
+           for (i = 0; i * PIXMAN_FORMAT_BPP (fmt) < 32; i++)
                mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt));
 
            for (i = 0; i < stride * height / 4; i++)
@@ -281,7 +280,7 @@ test_composite (int testnum, int verbose)
 
     lcg_srand (testnum);
 
-    op = op_list[lcg_rand_n (sizeof (op_list) / sizeof (op_list[0]))];
+    op = op_list[lcg_rand_n (ARRAY_LENGTH (op_list))];
 
     if (lcg_rand_n (8))
     {
@@ -425,6 +424,6 @@ main (int argc, const char *argv[])
     }
 
     return fuzzer_test_main("blitters", 2000000,
-                           0x29137844,
+                           0xA364B5BF,
                            test_composite, argc, argv);
 }
old mode 100755 (executable)
new mode 100644 (file)
index fa6d8a9..ff03b50
@@ -1,6 +1,5 @@
 /* Based loosely on scaling-test */
 
-#include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include "utils.h"
old mode 100755 (executable)
new mode 100644 (file)
index 408c363..94b4825
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-#define PIXMAN_USE_INTERNAL_API
-#include <pixman.h>
 #include <stdio.h>
 #include <stdlib.h> /* abort() */
 #include <math.h>
 #include <time.h>
 #include "utils.h"
 
-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;
@@ -482,147 +474,19 @@ do_composite (pixman_op_t op,
     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)
+static uint32_t
+get_value (pixman_image_t *image)
 {
-#define MASK(x) ((1 << (x)) - 1)
-#define round_pix(pix, m)                                              \
-    ((int)((pix) * (MASK(m)) + .5) / (double) (MASK(m)))
-
-    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));
+    uint32_t value = *(uint32_t *)pixman_image_get_data (image);
 
-#undef round_pix
-#undef MASK
-}
-
-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_RGBA:
-       as = 0;
-       bs = PIXMAN_FORMAT_BPP (format) - (b + g + r);
-       gs = b + bs;
-       rs = 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);
+       pixman_format_code_t format = pixman_image_get_format (image);
+       value >>= 8 * sizeof(value) - PIXMAN_FORMAT_BPP (format);
     }
-    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, pixman_format_code_t format)
-{
-    double rscale, gscale, bscale, ascale;
-    double rdiff, gdiff, bdiff, adiff;
-
-    rscale = 1.0 * ((1 << PIXMAN_FORMAT_R (format)) - 1);
-    gscale = 1.0 * ((1 << PIXMAN_FORMAT_G (format)) - 1);
-    bscale = 1.0 * ((1 << PIXMAN_FORMAT_B (format)) - 1);
-    ascale = 1.0 * ((1 << PIXMAN_FORMAT_A (format)) - 1);
-
-    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;
+#endif
 
-    return MAX (MAX (MAX (rdiff, gdiff), bdiff), adiff);
+    return value;
 }
 
 static char *
@@ -630,10 +494,10 @@ describe_image (image_t *info, char *buf)
 {
     if (info->size)
     {
-       sprintf (buf, "%s %dx%d%s",
+       sprintf (buf, "%s, %dx%d%s",
                 info->format->name,
                 info->size, info->size,
-                info->repeat ? "R" :"");
+                info->repeat ? " R" :"");
     }
     else
     {
@@ -643,52 +507,41 @@ describe_image (image_t *info, char *buf)
     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 char *
+describe_color (const color_t *color, char *buf)
+{
+    sprintf (buf, "%.3f %.3f %.3f %.3f",
+            color->r, color->g, color->b, color->a);
+
+    return buf;
+}
+
 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_bool_t component_alpha,
+               int testno)
 {
     pixman_color_t fill;
-    pixman_rectangle16_t rect;
-    color_t expected, result, tdst, tsrc, tmsk;
-    double diff;
-    pixman_bool_t success = TRUE;
+    color_t expected, tdst, tsrc, tmsk;
+    pixel_checker_t checker;
+    pixman_image_t *solid;
 
+    /* Initialize dst */
     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);
+    solid = pixman_image_create_solid_fill (&fill);
+    pixman_image_composite32 (PIXMAN_OP_SRC, solid, NULL, dst->image,
+                             0, 0, 0, 0, 0, 0, dst->size, dst->size);
+    pixman_image_unref (solid);
 
-    if (mask != NULL)
+    if (mask)
     {
        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;
-           }
-       }
+       pixman_image_composite (op->op, src->image, mask->image, dst->image,
+                               0, 0, 0, 0, 0, 0, dst->size, dst->size);
     }
     else
     {
@@ -698,71 +551,81 @@ composite_test (image_t *dst,
                                0, 0,
                                dst->size, dst->size);
     }
-    get_pixel (dst->image, dst->format->format, &result);
 
     tdst = *dst->color;
-    color_correct (dst->format->format, &tdst);
+    round_color (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, dst->format->format);
-
-    /* FIXME: We should find out what deviation is acceptable. 3.0
-     * is clearly absurd for 2 bit formats for example. On the other
-     * hand currently 1.0 does not work.
-     */
-    if (diff > 3.0)
+       round_color (src->format->format, &tsrc);
+
+    if (mask)
     {
-       char buf[40];
+       tmsk = *mask->color;
+       if (mask->size)
+           round_color (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;
+       }
+    }
 
-       sprintf (buf, "%s %scomposite",
-                op->name,
-                component_alpha ? "CA " : "");
+    do_composite (op->op,
+                 &tsrc,
+                 mask? &tmsk : NULL,
+                 &tdst,
+                 &expected,
+                 component_alpha);
 
-       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);
+    pixel_checker_init (&checker, dst->format->format);
 
+    if (!pixel_checker_check (&checker, get_value (dst->image), &expected))
+    {
+       char buf[40], buf2[40];
+       int a, r, g, b;
+       uint32_t pixel;
+
+       printf ("---- Test %d failed ----\n", testno);
+       printf ("Operator:      %s %s\n",
+                op->name, component_alpha ? "CA" : "");
+
+       printf ("Source:        %s\n", describe_image (src, buf));
        if (mask != NULL)
+           printf ("Mask:          %s\n", describe_image (mask, buf));
+
+       printf ("Destination:   %s\n\n", describe_image (dst, buf));
+       printf ("               R     G     B     A         Rounded\n");
+       printf ("Source color:  %s     %s\n",
+               describe_color (src->color, buf),
+               describe_color (&tsrc, buf2));
+       if (mask)
        {
-           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));
-           printf ("mask: %s, ", describe_image (mask, buf));
-           printf ("dst: %s\n\n", describe_image (dst, 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));
-           printf ("dst: %s\n\n", describe_image (dst, buf));
+           printf ("Mask color:    %s     %s\n",
+                   describe_color (mask->color, buf),
+                   describe_color (&tmsk, buf2));
        }
+       printf ("Dest. color:   %s     %s\n",
+               describe_color (dst->color, buf),
+               describe_color (&tdst, buf2));
 
-       success = FALSE;
-    }
+       pixel = get_value (dst->image);
+
+       printf ("Expected:      %s\n", describe_color (&expected, buf));
 
-    return success;
+       pixel_checker_split_pixel (&checker, pixel, &a, &r, &g, &b);
+
+       printf ("Got:           %5d %5d %5d %5d  [pixel: 0x%08x]\n", r, g, b, a, pixel);
+       pixel_checker_get_min (&checker, &expected, &a, &r, &g, &b);
+       printf ("Min accepted:  %5d %5d %5d %5d\n", r, g, b, a);
+       pixel_checker_get_max (&checker, &expected, &a, &r, &g, &b);
+       printf ("Max accepted:  %5d %5d %5d %5d\n", r, g, b, a);
+
+       return FALSE;
+    }
+    return TRUE;
 }
 
 static void
@@ -782,18 +645,18 @@ image_init (image_t *info,
 
     if (info->size)
     {
-       pixman_rectangle16_t rect;
+       pixman_image_t *solid;
 
        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);
+       solid = pixman_image_create_solid_fill (&fill);
+       pixman_image_composite32 (PIXMAN_OP_SRC, solid, NULL, info->image,
+                                 0, 0, 0, 0, 0, 0, info->size, info->size);
+       pixman_image_unref (solid);
 
-       if (size & REPEAT)
+       if (sizes[size] & REPEAT)
        {
            pixman_image_set_repeat (info->image, PIXMAN_REPEAT_NORMAL);
            info->repeat = PIXMAN_REPEAT_NORMAL;
@@ -838,7 +701,7 @@ run_test (uint32_t seed)
     int ok;
 
     lcg_srand (seed);
-    
+
     image_init (&dst, random_color(), random_format(), 1);
     image_init (&src, random_color(), random_format(), random_size());
     image_init (&mask, random_color(), random_format(), random_size());
@@ -850,14 +713,14 @@ run_test (uint32_t seed)
     switch (ca)
     {
     case 0:
-       ok = composite_test (&dst, op, &src, NULL, FALSE);
+       ok = composite_test (&dst, op, &src, NULL, FALSE, seed);
        break;
     case 1:
-       ok = composite_test (&dst, op, &src, &mask, FALSE);
+       ok = composite_test (&dst, op, &src, &mask, FALSE, seed);
        break;
     case 2:
        ok = composite_test (&dst, op, &src, &mask,
-                            mask.size? TRUE : FALSE);
+                            mask.size? TRUE : FALSE, seed);
        break;
     default:
        ok = FALSE;
@@ -881,7 +744,7 @@ main (int argc, char **argv)
     if (argc > 1)
     {
        char *end;
-       
+
        i = strtol (argv[1], &end, 0);
 
        if (end != argv[1])
@@ -902,7 +765,7 @@ main (int argc, char **argv)
        seed = get_random_seed();
     else
        seed = 1;
-    
+
 #ifdef USE_OPENMP
 #   pragma omp parallel for default(none) shared(result, argv, seed)
 #endif
@@ -911,10 +774,10 @@ main (int argc, char **argv)
        if (!result && !run_test (i + seed))
        {
            printf ("Test 0x%08X failed.\n", seed + i);
-           
+
            result = seed + i;
        }
     }
-    
+
     return result;
 }
old mode 100755 (executable)
new mode 100644 (file)
index 9f80eec..04e8cc5
@@ -1,11 +1,7 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "pixman.h"
+#include "utils.h"
 
 #define SIZE 1024
 
@@ -107,7 +103,7 @@ static testcase_t testcases[] =
     },
 };
 
-int n_test_cases = sizeof(testcases)/sizeof(testcases[0]);
+int n_test_cases = ARRAY_LENGTH (testcases);
 
 
 static uint32_t
old mode 100644 (file)
new mode 100755 (executable)
index c85712d..73e5bbc 100644 (file)
@@ -106,17 +106,17 @@ main (int argc, char **argv)
        if (i == 0)
        {
            stops = onestop;
-           num_stops = sizeof(onestop) / sizeof(onestop[0]);
+           num_stops = ARRAY_LENGTH (onestop);
        }
        else if (i == 1)
        {
            stops = subsetstops;
-           num_stops = sizeof(subsetstops) / sizeof(subsetstops[0]);
+           num_stops = ARRAY_LENGTH (subsetstops);
        }
        else
        {
            stops = stops01;
-           num_stops = sizeof(stops01) / sizeof(stops01[0]);
+           num_stops = ARRAY_LENGTH (stops01);
        }
        
        for (j = 0; j < 3; ++j)
index bdafb35..8a39a46 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#define PIXMAN_USE_INTERNAL_API
-#include <pixman.h>
-
 #include "utils.h"
 
 #define SOLID_FLAG 1
@@ -586,6 +582,8 @@ tests_tbl[] =
     { "add_1555_1555",         PIXMAN_a1r5g5b5,    0, PIXMAN_OP_ADD,     PIXMAN_null,     0, PIXMAN_a1r5g5b5 },
     { "add_0565_2x10",         PIXMAN_r5g6b5,      0, PIXMAN_OP_ADD,     PIXMAN_null,     0, PIXMAN_x2r10g10b10 },
     { "add_2a10_2a10",         PIXMAN_a2r10g10b10, 0, PIXMAN_OP_ADD,     PIXMAN_null,     0, PIXMAN_a2r10g10b10 },
+    { "in_n_8_8",              PIXMAN_a8r8g8b8,    1, PIXMAN_OP_IN,      PIXMAN_a8,       0, PIXMAN_a8 },
+    { "in_8_8",                PIXMAN_a8,          0, PIXMAN_OP_IN,      PIXMAN_null,     0, PIXMAN_a8 },
     { "src_n_2222",            PIXMAN_a8r8g8b8,    1, PIXMAN_OP_SRC,     PIXMAN_null,     0, PIXMAN_a2r2g2b2 },
     { "src_n_0565",            PIXMAN_a8r8g8b8,    1, PIXMAN_OP_SRC,     PIXMAN_null,     0, PIXMAN_r5g6b5 },
     { "src_n_1555",            PIXMAN_a8r8g8b8,    1, PIXMAN_OP_SRC,     PIXMAN_null,     0, PIXMAN_a1r5g5b5 },
@@ -630,6 +628,7 @@ tests_tbl[] =
     { "over_n_0565",           PIXMAN_a8r8g8b8,    1, PIXMAN_OP_OVER,    PIXMAN_null,     0, PIXMAN_r5g6b5 },
     { "over_n_1555",           PIXMAN_a8r8g8b8,    1, PIXMAN_OP_OVER,    PIXMAN_null,     0, PIXMAN_a1r5g5b5 },
     { "over_8888_0565",        PIXMAN_a8r8g8b8,    0, PIXMAN_OP_OVER,    PIXMAN_null,     0, PIXMAN_r5g6b5 },
+    { "over_8888_8888",        PIXMAN_a8r8g8b8,    0, PIXMAN_OP_OVER,    PIXMAN_null,     0, PIXMAN_a8r8g8b8 },
     { "over_8888_x888",        PIXMAN_a8r8g8b8,    0, PIXMAN_OP_OVER,    PIXMAN_null,     0, PIXMAN_x8r8g8b8 },
     { "over_x888_8_0565",      PIXMAN_x8r8g8b8,    0, PIXMAN_OP_OVER,    PIXMAN_a8,       0, PIXMAN_r5g6b5 },
     { "over_x888_8_8888",      PIXMAN_x8r8g8b8,    0, PIXMAN_OP_OVER,    PIXMAN_a8,       0, PIXMAN_a8r8g8b8 },
@@ -653,6 +652,7 @@ tests_tbl[] =
     { "over_8888_n_x888",      PIXMAN_a8r8g8b8,    0, PIXMAN_OP_OVER,    PIXMAN_a8,       1, PIXMAN_x8r8g8b8 },
     { "over_8888_n_0565",      PIXMAN_a8r8g8b8,    0, PIXMAN_OP_OVER,    PIXMAN_a8,       1, PIXMAN_r5g6b5 },
     { "over_8888_n_1555",      PIXMAN_a8r8g8b8,    0, PIXMAN_OP_OVER,    PIXMAN_a8,       1, PIXMAN_a1r5g5b5 },
+    { "over_x888_n_8888",      PIXMAN_x8r8g8b8,    0, PIXMAN_OP_OVER,    PIXMAN_a8,       1, PIXMAN_a8r8g8b8 },
     { "outrev_n_8_0565",       PIXMAN_a8r8g8b8,    1, PIXMAN_OP_OUT_REV, PIXMAN_a8,       0, PIXMAN_r5g6b5 },
     { "outrev_n_8_1555",       PIXMAN_a8r8g8b8,    1, PIXMAN_OP_OUT_REV, PIXMAN_a8,       0, PIXMAN_a1r5g5b5 },
     { "outrev_n_8_x888",       PIXMAN_a8r8g8b8,    1, PIXMAN_OP_OUT_REV, PIXMAN_a8,       0, PIXMAN_x8r8g8b8 },
@@ -707,7 +707,7 @@ main (int argc, char *argv[])
             x / 1000000., x / 4000000);
     printf ("---\n");
 
-    for (i = 0; i < sizeof(tests_tbl) / sizeof(tests_tbl[0]); i++)
+    for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
     {
        if (strcmp (pattern, "all") == 0 || strstr (tests_tbl[i].testname, pattern))
        {
index 4f9e5a2..0d19b50 100644 (file)
@@ -1,6 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include "pixman.h"
+#include "utils.h"
 
 typedef struct
 {
@@ -94,7 +94,7 @@ main (int argc, char **argv)
 {
     int i;
 
-    for (i = 0; i < sizeof (info) / sizeof (info[0]); ++i)
+    for (i = 0; i < ARRAY_LENGTH (info); ++i)
        test_composite (&info[i]);
     
     return 0;
index b660fdf..9524e28 100644 (file)
@@ -1,4 +1,3 @@
-#include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include "utils.h"
@@ -74,7 +73,7 @@ random_coord (pixman_region32_t *region, pixman_bool_t x)
     case 3:
        return begin;
     default:
-       return (begin + end) / 2;
+       return (end - begin) / 2 + begin;
     }
     return 0;
 }
@@ -164,7 +163,7 @@ main (int argc, const char *argv[])
 {
     return fuzzer_test_main ("region_contains",
                             1000000,
-                            0xD7C297CC,
+                            0xD2BF8C73,
                             test_region_contains_rectangle,
                             argc, argv);
 }
index 0e96a5e..5a03027 100644 (file)
@@ -1,5 +1,5 @@
-#include <pixman.h>
 #include <assert.h>
+#include "utils.h"
 
 /* Pixman had a bug where 32bit regions where clipped to 16bit sizes when
  * pixman_region32_translate() was called. This test exercises that bug.
index 40323d4..0dac892 100644 (file)
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include "pixman.h"
+#include "utils.h"
 
 /*
  * We have a source image filled with solid color, set NORMAL or PAD repeat,
@@ -32,8 +32,8 @@ run_test (int32_t             dst_width,
     pixman_transform_t transform;
     uint32_t *         srcbuf;
     uint32_t *         dstbuf;
-    pixman_box32_t     box = { 0, 0, src_width, src_height };
     pixman_color_t     color_cc = { 0xcccc, 0xcccc, 0xcccc, 0xcccc };
+    pixman_image_t *   solid;
     int result;
     int i;
 
@@ -62,7 +62,10 @@ run_test (int32_t            dst_width,
         PIXMAN_a8r8g8b8, src_width, src_height,
        srcbuf + (src_width + 10) * 5 + 5, (src_width + 10) * 4);
 
-    pixman_image_fill_boxes (PIXMAN_OP_SRC, src_img, &color_cc, 1, &box);
+    solid = pixman_image_create_solid_fill (&color_cc);
+    pixman_image_composite32 (PIXMAN_OP_SRC, solid, NULL, src_img,
+                             0, 0, 0, 0, 0, 0, src_width, src_height);
+    pixman_image_unref (solid);
 
     dst_img = pixman_image_create_bits (
         PIXMAN_a8r8g8b8, dst_width, dst_height, dstbuf, dst_width * 4);
@@ -130,12 +133,11 @@ do_test (int32_t          dst_size,
         int32_t                src_offs,
         int32_t                scale_factor)
 {
-#define N_ELEMENTS(a)  (sizeof (a) / sizeof ((a)[0]))
     int i, j;
 
-    for (i = 0; i < N_ELEMENTS(filters); ++i)
+    for (i = 0; i < ARRAY_LENGTH (filters); ++i)
     {
-       for (j = 0; j < N_ELEMENTS (repeats); ++j)
+       for (j = 0; j < ARRAY_LENGTH (repeats); ++j)
        {
            /* horizontal test */
            if (run_test (dst_size, 1,
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 82370f7..6f2da14
@@ -7,7 +7,6 @@
  * 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"
old mode 100755 (executable)
new mode 100644 (file)
index 571420a..3174621
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include "utils.h"
 #include <sys/types.h>
 
@@ -165,7 +166,8 @@ fake_reader (const void *src, int size)
     uint32_t r = lcg_rand_u32 ();
 
     assert (size == 1 || size == 2 || size == 4);
-    return r & ((1 << (size * 8)) - 1);
+
+    return r >> (32 - (size * 8));
 }
 
 static void
old mode 100755 (executable)
new mode 100644 (file)
index 7485e62..4e4cac2
@@ -1,5 +1,5 @@
 #include <stdlib.h>
-#include <pixman.h>
+#include "utils.h"
 
 int
 main()
@@ -22,6 +22,6 @@ main()
 
     dst = pixman_image_create_bits (PIXMAN_a8, 1, 1, NULL, -1);
 
-    pixman_add_trapezoids (dst, 0, 0, sizeof (traps)/sizeof (traps[0]), traps);
+    pixman_add_trapezoids (dst, 0, 0, ARRAY_LENGTH (traps), traps);
     return (0);
 }
old mode 100755 (executable)
new mode 100644 (file)
index adabd75..c1bf6dc
@@ -2,6 +2,7 @@
 
 #include "utils.h"
 #include <signal.h>
+#include <stdlib.h>
 
 #ifdef HAVE_GETTIMEOFDAY
 #include <sys/time.h>
@@ -339,17 +340,15 @@ make_random_bytes (int n_bytes)
     return bytes;
 }
 
-#ifdef HAVE_LIBPNG
-
-static void
-pngify_pixels (uint32_t *pixels, int n_pixels)
+void
+a8r8g8b8_to_rgba_np (uint32_t *dst, uint32_t *src, int n_pixels)
 {
+    uint8_t *dst8 = (uint8_t *)dst;
     int i;
 
     for (i = 0; i < n_pixels; ++i)
     {
-       uint32_t p = pixels[i];
-       uint8_t *out = (uint8_t *)&(pixels[i]);
+       uint32_t p = src[i];
        uint8_t a, r, g, b;
 
        a = (p & 0xff000000) >> 24;
@@ -359,18 +358,27 @@ pngify_pixels (uint32_t *pixels, int n_pixels)
 
        if (a != 0)
        {
-           r = (r * 255) / a;
-           g = (g * 255) / a;
-           b = (b * 255) / a;
+#define DIVIDE(c, a)                                                   \
+           do                                                          \
+           {                                                           \
+               int t = ((c) * 255) / a;                                \
+               (c) = t < 0? 0 : t > 255? 255 : t;                      \
+           } while (0)
+
+           DIVIDE (r, a);
+           DIVIDE (g, a);
+           DIVIDE (b, a);
        }
 
-       *out++ = r;
-       *out++ = g;
-       *out++ = b;
-       *out++ = a;
+       *dst8++ = r;
+       *dst8++ = g;
+       *dst8++ = b;
+       *dst8++ = a;
     }
 }
 
+#ifdef HAVE_LIBPNG
+
 pixman_bool_t
 write_png (pixman_image_t *image, const char *filename)
 {
@@ -397,7 +405,7 @@ write_png (pixman_image_t *image, const char *filename)
     pixman_image_composite32 (
        PIXMAN_OP_SRC, image, NULL, copy, 0, 0, 0, 0, 0, 0, width, height);
 
-    pngify_pixels (data, height * width);
+    a8r8g8b8_to_rgba_np (data, data, height * width);
 
     for (i = 0; i < height; ++i)
        row_pointers[i] = (png_bytep)(data + i * width);
@@ -702,3 +710,178 @@ initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb)
        assert (palette->ent[CONVERT_15 (palette->rgba[i], is_rgb)] == i);
     }
 }
+
+static double
+round_channel (double p, int m)
+{
+    int t;
+    double r;
+
+    t = p * ((1 << m));
+    t -= t >> m;
+
+    r = t / (double)((1 << m) - 1);
+
+    return r;
+}
+
+void
+round_color (pixman_format_code_t format, color_t *color)
+{
+    if (PIXMAN_FORMAT_R (format) == 0)
+    {
+       color->r = 0.0;
+       color->g = 0.0;
+       color->b = 0.0;
+    }
+    else
+    {
+       color->r = round_channel (color->r, PIXMAN_FORMAT_R (format));
+       color->g = round_channel (color->g, PIXMAN_FORMAT_G (format));
+       color->b = round_channel (color->b, PIXMAN_FORMAT_B (format));
+    }
+
+    if (PIXMAN_FORMAT_A (format) == 0)
+       color->a = 1;
+    else
+       color->a = round_channel (color->a, PIXMAN_FORMAT_A (format));
+}
+
+/* Check whether @pixel is a valid quantization of the a, r, g, b
+ * parameters. Some slack is permitted.
+ */
+void
+pixel_checker_init (pixel_checker_t *checker, pixman_format_code_t format)
+{
+    assert (PIXMAN_FORMAT_VIS (format));
+
+    checker->format = format;
+
+    switch (PIXMAN_FORMAT_TYPE (format))
+    {
+    case PIXMAN_TYPE_A:
+       checker->bs = 0;
+       checker->gs = 0;
+       checker->rs = 0;
+       checker->as = 0;
+       break;
+
+    case PIXMAN_TYPE_ARGB:
+       checker->bs = 0;
+       checker->gs = checker->bs + PIXMAN_FORMAT_B (format);
+       checker->rs = checker->gs + PIXMAN_FORMAT_G (format);
+       checker->as = checker->rs + PIXMAN_FORMAT_R (format);
+       break;
+
+    case PIXMAN_TYPE_ABGR:
+       checker->rs = 0;
+       checker->gs = checker->rs + PIXMAN_FORMAT_R (format);
+       checker->bs = checker->gs + PIXMAN_FORMAT_G (format);
+       checker->as = checker->bs + PIXMAN_FORMAT_B (format);
+       break;
+
+    case PIXMAN_TYPE_BGRA:
+       /* With BGRA formats we start counting at the high end of the pixel */
+       checker->bs = PIXMAN_FORMAT_BPP (format) - PIXMAN_FORMAT_B (format);
+       checker->gs = checker->bs - PIXMAN_FORMAT_B (format);
+       checker->rs = checker->gs - PIXMAN_FORMAT_G (format);
+       checker->as = checker->rs - PIXMAN_FORMAT_R (format);
+       break;
+
+    case PIXMAN_TYPE_RGBA:
+       /* With BGRA formats we start counting at the high end of the pixel */
+       checker->rs = PIXMAN_FORMAT_BPP (format) - PIXMAN_FORMAT_R (format);
+       checker->gs = checker->rs - PIXMAN_FORMAT_R (format);
+       checker->bs = checker->gs - PIXMAN_FORMAT_G (format);
+       checker->as = checker->bs - PIXMAN_FORMAT_B (format);
+       break;
+
+    default:
+       assert (0);
+       break;
+    }
+
+    checker->am = ((1 << PIXMAN_FORMAT_A (format)) - 1) << checker->as;
+    checker->rm = ((1 << PIXMAN_FORMAT_R (format)) - 1) << checker->rs;
+    checker->gm = ((1 << PIXMAN_FORMAT_G (format)) - 1) << checker->gs;
+    checker->bm = ((1 << PIXMAN_FORMAT_B (format)) - 1) << checker->bs;
+
+    checker->aw = PIXMAN_FORMAT_A (format);
+    checker->rw = PIXMAN_FORMAT_R (format);
+    checker->gw = PIXMAN_FORMAT_G (format);
+    checker->bw = PIXMAN_FORMAT_B (format);
+}
+
+void
+pixel_checker_split_pixel (const pixel_checker_t *checker, uint32_t pixel,
+                          int *a, int *r, int *g, int *b)
+{
+    *a = (pixel & checker->am) >> checker->as;
+    *r = (pixel & checker->rm) >> checker->rs;
+    *g = (pixel & checker->gm) >> checker->gs;
+    *b = (pixel & checker->bm) >> checker->bs;
+}
+
+static int32_t
+convert (double v, uint32_t width, uint32_t mask, uint32_t shift, double def)
+{
+    int32_t r;
+
+    if (!mask)
+       v = def;
+
+    r = (v * ((mask >> shift) + 1));
+    r -= r >> width;
+
+    return r;
+}
+
+static void
+get_limits (const pixel_checker_t *checker, double limit,
+           color_t *color,
+           int *ao, int *ro, int *go, int *bo)
+{
+    *ao = convert (color->a + limit, checker->aw, checker->am, checker->as, 1.0);
+    *ro = convert (color->r + limit, checker->rw, checker->rm, checker->rs, 0.0);
+    *go = convert (color->g + limit, checker->gw, checker->gm, checker->gs, 0.0);
+    *bo = convert (color->b + limit, checker->bw, checker->bm, checker->bs, 0.0);
+}
+
+/* The acceptable deviation in units of [0.0, 1.0]
+ */
+#define DEVIATION (0.004)
+
+void
+pixel_checker_get_max (const pixel_checker_t *checker, color_t *color,
+                      int *am, int *rm, int *gm, int *bm)
+{
+    get_limits (checker, DEVIATION, color, am, rm, gm, bm);
+}
+
+void
+pixel_checker_get_min (const pixel_checker_t *checker, color_t *color,
+                      int *am, int *rm, int *gm, int *bm)
+{
+    get_limits (checker, - DEVIATION, color, am, rm, gm, bm);
+}
+
+pixman_bool_t
+pixel_checker_check (const pixel_checker_t *checker, uint32_t pixel,
+                    color_t *color)
+{
+    int32_t a_lo, a_hi, r_lo, r_hi, g_lo, g_hi, b_lo, b_hi;
+    int32_t ai, ri, gi, bi;
+    pixman_bool_t result;
+
+    pixel_checker_get_min (checker, color, &a_lo, &r_lo, &g_lo, &b_lo);
+    pixel_checker_get_max (checker, color, &a_hi, &r_hi, &g_hi, &b_hi);
+    pixel_checker_split_pixel (checker, pixel, &ai, &ri, &gi, &bi);
+
+    result =
+       a_lo <= ai && ai <= a_hi        &&
+       r_lo <= ri && ri <= r_hi        &&
+       g_lo <= gi && gi <= g_hi        &&
+       b_lo <= bi && bi <= b_hi;
+
+    return result;
+}
old mode 100755 (executable)
new mode 100644 (file)
index b23925c..01af316
@@ -2,7 +2,6 @@
 #include <config.h>
 #endif
 
-#include <stdlib.h>
 #include <assert.h>
 #include "pixman-private.h" /* For 'inline' definition */
 
@@ -108,6 +107,15 @@ fail_after (int seconds, const char *msg);
 /* If possible, enable traps for floating point exceptions */
 void enable_fp_exceptions(void);
 
+/* Converts a8r8g8b8 pixels to pixels that
+ *  - are not premultiplied,
+ *  - are stored in this order in memory: R, G, B, A, regardless of
+ *    the endianness of the computer.
+ * It is allowed for @src and @dst to point to the same memory buffer.
+ */
+void
+a8r8g8b8_to_rgba_np (uint32_t *dst, uint32_t *src, int n_pixels);
+
 pixman_bool_t
 write_png (pixman_image_t *image, const char *filename);
 
@@ -152,3 +160,38 @@ aligned_malloc (size_t align, size_t size);
 
 void
 initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb);
+
+typedef struct
+{
+    double r, g, b, a;
+} color_t;
+
+void
+round_color (pixman_format_code_t format, color_t *color);
+
+typedef struct
+{
+    pixman_format_code_t format;
+    uint32_t am, rm, gm, bm;
+    uint32_t as, rs, gs, bs;
+    uint32_t aw, rw, gw, bw;
+} pixel_checker_t;
+
+void
+pixel_checker_init (pixel_checker_t *checker, pixman_format_code_t format);
+
+void
+pixel_checker_split_pixel (const pixel_checker_t *checker, uint32_t pixel,
+                          int *a, int *r, int *g, int *b);
+
+void
+pixel_checker_get_max (const pixel_checker_t *checker, color_t *color,
+                      int *a, int *r, int *g, int *b);
+
+void
+pixel_checker_get_min (const pixel_checker_t *checker, color_t *color,
+                      int *a, int *r, int *g, int *b);
+
+pixman_bool_t
+pixel_checker_check (const pixel_checker_t *checker,
+                    uint32_t pixel, color_t *color);