---
.gitignore|1 +
test/Makefile.sources |1 +
test/affine-bench.c | 394 +
3 files changed, 396 insertions(+), 0 deletions(-)
create mode 100644 test/affine-bench.c
diff --git a/.gitignore b/.gitignore
index 0f11496..7da6b6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,6 +46,7 @@ demos/tri-test
pixman/pixman-srgb.c
pixman/pixman-version.h
test/a1-trap-test
+test/affine-bench
test/affine-test
test/alpha-loop
test/alphamap
diff --git a/test/Makefile.sources b/test/Makefile.sources
index c20c34b..8b0e855 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -37,6 +37,7 @@ OTHERPROGRAMS = \
radial-perf-test\
check-formats \
scaling-bench \
+ affine-bench\
$(NULL)
# Utility functions
diff --git a/test/affine-bench.c b/test/affine-bench.c
new file mode 100644
index 000..720d066
--- /dev/null
+++ b/test/affine-bench.c
@@ -0,0 +1,394 @@
+/*
+ * Copyright © 2014 RISC OS Open Ltd
+ *
+ * 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 the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided as is without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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.
+ *
+ * Author: Ben Avison (bavi...@riscosopen.org)
+ */
+
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include ctype.h
+#include stdint.h
+#include utils.h
+
+#ifdef HAVE_GETTIMEOFDAY
+#include sys/time.h
+#else
+#include time.h
+#endif
+
+#define WIDTH 1920
+#define HEIGHT 1080
+#define MAX_L2CACHE_SIZE (8 * 1024 * 1024) /* How much data to read to flush
all cached data to RAM */
+#define PAGE_SIZE (4 * 1024)
+
+typedef struct box_48_16 box_48_16_t;
+
+struct box_48_16
+{
+pixman_fixed_48_16_tx1;
+pixman_fixed_48_16_ty1;
+pixman_fixed_48_16_tx2;
+pixman_fixed_48_16_ty2;
+};
+
+static pixman_bool_t
+compute_transformed_extents (pixman_transform_t *transform,
+ const pixman_box32_t *extents,
+ box_48_16_t *transformed)
+{
+pixman_fixed_48_16_t tx1, ty1, tx2, ty2;
+pixman_fixed_t x1, y1, x2, y2;
+int i;
+
+x1 = pixman_int_to_fixed (extents-x1) + pixman_fixed_1 / 2;
+y1 = pixman_int_to_fixed (extents-y1) + pixman_fixed_1 / 2;
+x2 = pixman_int_to_fixed (extents-x2) - pixman_fixed_1 / 2;
+y2 = pixman_int_to_fixed (extents-y2) - pixman_fixed_1 / 2;
+
+if (!transform)
+{
+transformed-x1 = x1;
+transformed-y1 = y1;
+transformed-x2 = x2;
+transformed-y2 = y2;
+
+return TRUE;
+}
+
+tx1 = ty1 = INT64_MAX;
+tx2 = ty2 = INT64_MIN;
+
+for (i = 0; i 4; ++i)
+{
+pixman_fixed_48_16_t tx, ty;
+pixman_vector_t v;
+
+v.vector[0] = (i 0x01)? x1 : x2;
+v.vector[1] = (i 0x02)? y1 : y2;
+v.vector[2] = pixman_fixed_1;
+
+if (!pixman_transform_point (transform, v))
+return FALSE;
+
+tx = (pixman_fixed_48_16_t)v.vector[0];
+ty = (pixman_fixed_48_16_t)v.vector[1];
+
+if (tx tx1)
+tx1 = tx;
+if (ty ty1)
+ty1 = ty;
+if (tx tx2)
+tx2 = tx;
+if (ty ty2)
+ty2 = ty;
+}
+
+transformed-x1 = tx1;
+transformed-y1 = ty1;
+transformed-x2 = tx2;
+transformed-y2 = ty2;
+
+return TRUE;
+}
+
+static void
+create_image (uint32_t width,
+ uint32_t height,
+ pixman_format_code_t format,
+ pixman_filter_tfilter,
+ const pixman_transform_t *t,
+ uint32_t **bits,
+ pixman_image_t **image)
+{
+uint32_t stride = (width * PIXMAN_FORMAT_BPP(format) + 31) / 32 * 4;
+
+*bits = aligned_malloc (PAGE_SIZE, stride * height);
+memset (*bits, 0xCC, stride * height);
+*image =