summaryrefslogtreecommitdiffstats
path: root/qemu/pixman/test
diff options
context:
space:
mode:
authorRajithaY <rajithax.yerrumsetty@intel.com>2017-04-25 03:31:15 -0700
committerRajitha Yerrumchetty <rajithax.yerrumsetty@intel.com>2017-05-22 06:48:08 +0000
commitbb756eebdac6fd24e8919e2c43f7d2c8c4091f59 (patch)
treeca11e03542edf2d8f631efeca5e1626d211107e3 /qemu/pixman/test
parenta14b48d18a9ed03ec191cf16b162206998a895ce (diff)
Adding qemu as a submodule of KVMFORNFV
This Patch includes the changes to add qemu as a submodule to kvmfornfv repo and make use of the updated latest qemu for the execution of all testcase Change-Id: I1280af507a857675c7f81d30c95255635667bdd7 Signed-off-by:RajithaY<rajithax.yerrumsetty@intel.com>
Diffstat (limited to 'qemu/pixman/test')
-rw-r--r--qemu/pixman/test/Makefile.am13
-rw-r--r--qemu/pixman/test/Makefile.sources49
-rw-r--r--qemu/pixman/test/Makefile.win3254
-rw-r--r--qemu/pixman/test/a1-trap-test.c58
-rw-r--r--qemu/pixman/test/affine-test.c324
-rw-r--r--qemu/pixman/test/alpha-loop.c35
-rw-r--r--qemu/pixman/test/alphamap.c315
-rw-r--r--qemu/pixman/test/blitters-test.c399
-rw-r--r--qemu/pixman/test/check-formats.c352
-rw-r--r--qemu/pixman/test/combiner-test.c151
-rw-r--r--qemu/pixman/test/composite-traps-test.c252
-rw-r--r--qemu/pixman/test/composite.c536
-rw-r--r--qemu/pixman/test/fetch-test.c205
-rwxr-xr-xqemu/pixman/test/fuzzer-find-diff.pl75
-rw-r--r--qemu/pixman/test/glyph-test.c332
-rw-r--r--qemu/pixman/test/gradient-crash-test.c158
-rw-r--r--qemu/pixman/test/infinite-loop.c39
-rw-r--r--qemu/pixman/test/lowlevel-blt-bench.c820
-rw-r--r--qemu/pixman/test/matrix-test.c235
-rw-r--r--qemu/pixman/test/oob-test.c101
-rw-r--r--qemu/pixman/test/pdf-op-test.c83
-rw-r--r--qemu/pixman/test/pixel-test.c267
-rw-r--r--qemu/pixman/test/prng-test.c175
-rw-r--r--qemu/pixman/test/radial-perf-test.c58
-rw-r--r--qemu/pixman/test/region-contains-test.c169
-rw-r--r--qemu/pixman/test/region-test.c125
-rw-r--r--qemu/pixman/test/region-translate-test.c30
-rw-r--r--qemu/pixman/test/rotate-test.c120
-rw-r--r--qemu/pixman/test/scaling-bench.c80
-rw-r--r--qemu/pixman/test/scaling-crash-test.c219
-rw-r--r--qemu/pixman/test/scaling-helpers-test.c92
-rw-r--r--qemu/pixman/test/scaling-test.c402
-rw-r--r--qemu/pixman/test/stress-test.c1040
-rw-r--r--qemu/pixman/test/thread-test.c199
-rw-r--r--qemu/pixman/test/trap-crasher.c39
-rw-r--r--qemu/pixman/test/utils-prng.c298
-rw-r--r--qemu/pixman/test/utils-prng.h170
-rw-r--r--qemu/pixman/test/utils.c1618
-rw-r--r--qemu/pixman/test/utils.h247
39 files changed, 0 insertions, 9934 deletions
diff --git a/qemu/pixman/test/Makefile.am b/qemu/pixman/test/Makefile.am
deleted file mode 100644
index 88dc36d2a..000000000
--- a/qemu/pixman/test/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-include $(top_srcdir)/test/Makefile.sources
-
-AM_CFLAGS = $(OPENMP_CFLAGS) $(PTHREAD_CFLAGS)
-AM_LDFLAGS = $(OPENMP_CFLAGS) $(TESTPROGS_EXTRA_LDFLAGS) $(PTHREAD_LDFLAGS)
-LDADD = libutils.la $(top_builddir)/pixman/libpixman-1.la -lm $(PNG_LIBS) $(PTHREAD_LIBS)
-AM_CPPFLAGS = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman $(PNG_CFLAGS)
-
-libutils_la_SOURCES = $(libutils_sources) $(libutils_headers)
-
-noinst_LTLIBRARIES = libutils.la
-noinst_PROGRAMS = $(TESTPROGRAMS) $(OTHERPROGRAMS)
-
-TESTS = $(TESTPROGRAMS)
diff --git a/qemu/pixman/test/Makefile.sources b/qemu/pixman/test/Makefile.sources
deleted file mode 100644
index 2ae5d9f8d..000000000
--- a/qemu/pixman/test/Makefile.sources
+++ /dev/null
@@ -1,49 +0,0 @@
-# Tests (sorted by expected completion time)
-TESTPROGRAMS = \
- prng-test \
- a1-trap-test \
- pdf-op-test \
- region-test \
- region-translate-test \
- combiner-test \
- pixel-test \
- fetch-test \
- rotate-test \
- oob-test \
- infinite-loop \
- trap-crasher \
- alpha-loop \
- thread-test \
- scaling-crash-test \
- scaling-helpers-test \
- gradient-crash-test \
- region-contains-test \
- alphamap \
- matrix-test \
- stress-test \
- composite-traps-test \
- blitters-test \
- glyph-test \
- scaling-test \
- affine-test \
- composite \
- $(NULL)
-
-# Other programs
-OTHERPROGRAMS = \
- lowlevel-blt-bench \
- radial-perf-test \
- check-formats \
- scaling-bench \
- $(NULL)
-
-# Utility functions
-libutils_sources = \
- utils.c \
- utils-prng.c \
- $(NULL)
-
-libutils_headers = \
- utils.h \
- utils-prng.h \
- $(NULL)
diff --git a/qemu/pixman/test/Makefile.win32 b/qemu/pixman/test/Makefile.win32
deleted file mode 100644
index 6cfb4a780..000000000
--- a/qemu/pixman/test/Makefile.win32
+++ /dev/null
@@ -1,54 +0,0 @@
-default: all
-
-top_srcdir = ..
-include $(top_srcdir)/test/Makefile.sources
-include $(top_srcdir)/Makefile.win32.common
-
-TEST_LDADD = \
- $(top_builddir)/pixman/$(CFG_VAR)/$(LIBRARY).lib \
- $(CFG_VAR)/libutils.lib \
- $(NULL)
-
-libutils_OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(libutils_sources))
-
-SOURCES = $(patsubst %, %.c, $(TESTPROGRAMS) $(OTHERPROGRAMS))
-OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(SOURCES))
-TESTS = $(patsubst %, $(CFG_VAR)/%.exe, $(TESTPROGRAMS))
-OTHERS = $(patsubst %, $(CFG_VAR)/%.exe, $(OTHERPROGRAMS))
-
-all: pixman inform $(TESTS) $(OTHERS)
-
-check: pixman inform $(TESTS)
- @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:$@ $^
-
-$(CFG_VAR)/%.exe: $(CFG_VAR)/%.obj $(TEST_LDADD)
- @$(LD) $(PIXMAN_LDFLAGS) -OUT:$@ $^
-
-$(top_builddir)/pixman/$(CFG_VAR)/$(LIBRARY).lib: pixman
-
-pixman:
- @$(MAKE) -C $(top_builddir)/pixman -f Makefile.win32
-
-.PHONY: all check pixman
diff --git a/qemu/pixman/test/a1-trap-test.c b/qemu/pixman/test/a1-trap-test.c
deleted file mode 100644
index c2b488316..000000000
--- a/qemu/pixman/test/a1-trap-test.c
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "utils.h"
-
-int
-main (int argc, char **argv)
-{
-#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);
-
- assert (bits[0] == 0xffff0000);
- assert (bits[1] == 0xffffffff);
- assert (bits[1 * WIDTH + 0] == 0xffffffff);
- assert (bits[1 * WIDTH + 1] == 0xffffffff);
-
- /* The check-formats test depends on operator_name() and format_name() returning
- * these precise formats, so if those change, check-formats.c must be updated too.
- */
- assert (
- strcmp (operator_name (PIXMAN_OP_DISJOINT_OVER), "PIXMAN_OP_DISJOINT_OVER") == 0);
- assert (
- strcmp (format_name (PIXMAN_r5g6b5), "r5g6b5") == 0);
-
- return 0;
-}
diff --git a/qemu/pixman/test/affine-test.c b/qemu/pixman/test/affine-test.c
deleted file mode 100644
index 8e19023a3..000000000
--- a/qemu/pixman/test/affine-test.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Test program, which can detect some problems with affine transformations
- * in pixman. Testing is done by running lots of random SRC and OVER
- * compositing operations a8r8g8b8, x8a8r8g8b8, r5g6b5 and a8 color formats
- * with random scaled, rotated and translated transforms.
- *
- * Script 'fuzzer-find-diff.pl' can be used to narrow down the problem in
- * the case of test failure.
- */
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "utils.h"
-
-#define MAX_SRC_WIDTH 16
-#define MAX_SRC_HEIGHT 16
-#define MAX_DST_WIDTH 16
-#define MAX_DST_HEIGHT 16
-#define MAX_STRIDE 4
-
-/*
- * Composite operation with pseudorandom images
- */
-uint32_t
-test_composite (int testnum,
- int verbose)
-{
- int i;
- pixman_image_t * src_img;
- pixman_image_t * dst_img;
- pixman_transform_t transform;
- pixman_region16_t clip;
- int src_width, src_height;
- int dst_width, dst_height;
- int src_stride, dst_stride;
- int src_x, src_y;
- int dst_x, dst_y;
- int src_bpp;
- int dst_bpp;
- int w, h;
- pixman_fixed_t scale_x = 65536, scale_y = 65536;
- pixman_fixed_t translate_x = 0, translate_y = 0;
- 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 ();
-
- prng_srand (testnum);
-
- src_bpp = (prng_rand_n (2) == 0) ? 2 : 4;
- dst_bpp = (prng_rand_n (2) == 0) ? 2 : 4;
- op = (prng_rand_n (2) == 0) ? PIXMAN_OP_SRC : PIXMAN_OP_OVER;
-
- src_width = prng_rand_n (MAX_SRC_WIDTH) + 1;
- src_height = prng_rand_n (MAX_SRC_HEIGHT) + 1;
- dst_width = prng_rand_n (MAX_DST_WIDTH) + 1;
- dst_height = prng_rand_n (MAX_DST_HEIGHT) + 1;
- src_stride = src_width * src_bpp + prng_rand_n (MAX_STRIDE) * src_bpp;
- dst_stride = dst_width * dst_bpp + prng_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) + prng_rand_n (src_width * 3 / 2);
- src_y = -(src_height / 4) + prng_rand_n (src_height * 3 / 2);
- dst_x = -(dst_width / 4) + prng_rand_n (dst_width * 3 / 2);
- dst_y = -(dst_height / 4) + prng_rand_n (dst_height * 3 / 2);
- w = prng_rand_n (dst_width * 3 / 2 - dst_x);
- h = prng_rand_n (dst_height * 3 / 2 - dst_y);
-
- srcbuf = (uint32_t *)malloc (src_stride * src_height);
- dstbuf = (uint32_t *)malloc (dst_stride * dst_height);
-
- prng_randmemset (srcbuf, src_stride * src_height, 0);
- prng_randmemset (dstbuf, dst_stride * dst_height, 0);
-
- if (prng_rand_n (2) == 0)
- {
- srcbuf += (src_stride / 4) * (src_height - 1);
- src_stride = - src_stride;
- }
-
- if (prng_rand_n (2) == 0)
- {
- dstbuf += (dst_stride / 4) * (dst_height - 1);
- dst_stride = - dst_stride;
- }
-
- src_fmt = src_bpp == 4 ? (prng_rand_n (2) == 0 ?
- PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8) : PIXMAN_r5g6b5;
-
- dst_fmt = dst_bpp == 4 ? (prng_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 (prng_rand_n (3) > 0)
- {
- scale_x = -65536 * 3 + prng_rand_n (65536 * 6);
- if (prng_rand_n (2))
- scale_y = -65536 * 3 + prng_rand_n (65536 * 6);
- else
- scale_y = scale_x;
- pixman_transform_init_scale (&transform, scale_x, scale_y);
- }
- if (prng_rand_n (3) > 0)
- {
- translate_x = -65536 * 3 + prng_rand_n (6 * 65536);
- if (prng_rand_n (2))
- translate_y = -65536 * 3 + prng_rand_n (6 * 65536);
- else
- translate_y = translate_x;
- pixman_transform_translate (&transform, NULL, translate_x, translate_y);
- }
-
- if (prng_rand_n (4) > 0)
- {
- int c, s, tx = 0, ty = 0;
- switch (prng_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 = prng_rand_n (2 * 65536) - 65536;
- s = prng_rand_n (2 * 65536) - 65536;
- break;
- }
- pixman_transform_rotate (&transform, NULL, c, s);
- pixman_transform_translate (&transform, NULL, tx, ty);
- }
-
- if (prng_rand_n (8) == 0)
- {
- /* Flip random bits */
- int maxflipcount = 8;
- while (maxflipcount--)
- {
- int i = prng_rand_n (2);
- int j = prng_rand_n (3);
- int bitnum = prng_rand_n (32);
- transform.matrix[i][j] ^= 1 << bitnum;
- if (prng_rand_n (2))
- break;
- }
- }
-
- pixman_image_set_transform (src_img, &transform);
-
- switch (prng_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 (prng_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)
- {
-#define M(r,c) \
- transform.matrix[r][c]
-
- printf ("src_fmt=%s, dst_fmt=%s\n", format_name (src_fmt), format_name (dst_fmt));
- printf ("op=%s, repeat=%d, transform=\n",
- operator_name (op), repeat);
- printf (" { { { 0x%08x, 0x%08x, 0x%08x },\n"
- " { 0x%08x, 0x%08x, 0x%08x },\n"
- " { 0x%08x, 0x%08x, 0x%08x },\n"
- " } };\n",
- M(0,0), M(0,1), M(0,2),
- M(1,0), M(1,1), M(1,2),
- M(2,0), M(2,1), M(2,2));
- 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 (prng_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[2];
- int n = prng_rand_n (2) + 1;
-
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = prng_rand_n (src_width);
- clip_boxes[i].y1 = prng_rand_n (src_height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + prng_rand_n (src_width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + prng_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 (prng_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[2];
- int n = prng_rand_n (2) + 1;
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = prng_rand_n (dst_width);
- clip_boxes[i].y1 = prng_rand_n (dst_height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + prng_rand_n (dst_width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + prng_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);
-
- crc32 = compute_crc32_for_image (0, dst_img);
-
- if (verbose)
- print_image (dst_img);
-
- pixman_image_unref (src_img);
- pixman_image_unref (dst_img);
-
- if (src_stride < 0)
- srcbuf += (src_stride / 4) * (src_height - 1);
-
- if (dst_stride < 0)
- dstbuf += (dst_stride / 4) * (dst_height - 1);
-
- free (srcbuf);
- free (dstbuf);
-
- FLOAT_REGS_CORRUPTION_DETECTOR_FINISH ();
- return crc32;
-}
-
-#if BILINEAR_INTERPOLATION_BITS == 7
-#define CHECKSUM 0xBE724CFE
-#elif BILINEAR_INTERPOLATION_BITS == 4
-#define CHECKSUM 0x79BBE501
-#else
-#define CHECKSUM 0x00000000
-#endif
-
-int
-main (int argc, const char *argv[])
-{
- pixman_disable_out_of_bounds_workaround ();
-
- return fuzzer_test_main ("affine", 8000000, CHECKSUM,
- test_composite, argc, argv);
-}
diff --git a/qemu/pixman/test/alpha-loop.c b/qemu/pixman/test/alpha-loop.c
deleted file mode 100644
index 4d4384d00..000000000
--- a/qemu/pixman/test/alpha-loop.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "utils.h"
-
-#define WIDTH 400
-#define HEIGHT 200
-
-int
-main (int argc, char **argv)
-{
- pixman_image_t *a, *d, *s;
- uint8_t *alpha;
- uint32_t *src, *dest;
-
- prng_srand (0);
-
- alpha = make_random_bytes (WIDTH * HEIGHT);
- src = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * 4);
- dest = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * 4);
-
- a = pixman_image_create_bits (PIXMAN_a8, WIDTH, HEIGHT, (uint32_t *)alpha, WIDTH);
- d = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, dest, WIDTH * 4);
- s = pixman_image_create_bits (PIXMAN_a2r10g10b10, WIDTH, HEIGHT, src, WIDTH * 4);
-
- fail_after (5, "Infinite loop detected: 5 seconds without progress\n");
-
- pixman_image_set_alpha_map (s, a, 0, 0);
- pixman_image_set_alpha_map (a, s, 0, 0);
-
- pixman_image_composite (PIXMAN_OP_SRC, s, NULL, d, 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
-
- pixman_image_unref (s);
-
- return 0;
-}
diff --git a/qemu/pixman/test/alphamap.c b/qemu/pixman/test/alphamap.c
deleted file mode 100644
index 4d09076fb..000000000
--- a/qemu/pixman/test/alphamap.c
+++ /dev/null
@@ -1,315 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "utils.h"
-
-#define WIDTH 48
-#define HEIGHT 48
-
-static const pixman_format_code_t formats[] =
-{
- PIXMAN_a8r8g8b8,
- PIXMAN_a2r10g10b10,
- PIXMAN_a4r4g4b4,
- PIXMAN_a8
-};
-
-static const pixman_format_code_t alpha_formats[] =
-{
- PIXMAN_null,
- PIXMAN_a8,
- PIXMAN_a2r10g10b10,
- PIXMAN_a4r4g4b4
-};
-
-static const int origins[] =
-{
- 0, 10, -100
-};
-
-static void
-on_destroy (pixman_image_t *image, void *data)
-{
- uint32_t *bits = pixman_image_get_data (image);
-
- fence_free (bits);
-}
-
-static pixman_image_t *
-make_image (pixman_format_code_t format)
-{
- uint32_t *bits;
- uint8_t bpp = PIXMAN_FORMAT_BPP (format) / 8;
- pixman_image_t *image;
-
- bits = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * bpp);
-
- image = pixman_image_create_bits (format, WIDTH, HEIGHT, bits, WIDTH * bpp);
-
- if (image && bits)
- pixman_image_set_destroy_function (image, on_destroy, NULL);
-
- return image;
-}
-
-static uint8_t
-get_alpha (pixman_image_t *image, int x, int y, int orig_x, int orig_y)
-{
- uint8_t *bits;
- uint8_t r;
-
- if (image->common.alpha_map)
- {
- if (x - orig_x >= 0 && x - orig_x < WIDTH &&
- y - orig_y >= 0 && y - orig_y < HEIGHT)
- {
- image = (pixman_image_t *)image->common.alpha_map;
-
- x -= orig_x;
- y -= orig_y;
- }
- else
- {
- return 0;
- }
- }
-
- bits = (uint8_t *)image->bits.bits;
-
- if (image->bits.format == PIXMAN_a8)
- {
- r = bits[y * WIDTH + x];
- }
- else if (image->bits.format == PIXMAN_a2r10g10b10)
- {
- r = ((uint32_t *)bits)[y * WIDTH + x] >> 30;
- r |= r << 2;
- r |= r << 4;
- }
- else if (image->bits.format == PIXMAN_a8r8g8b8)
- {
- r = ((uint32_t *)bits)[y * WIDTH + x] >> 24;
- }
- else if (image->bits.format == PIXMAN_a4r4g4b4)
- {
- r = ((uint16_t *)bits)[y * WIDTH + x] >> 12;
- r |= r << 4;
- }
- else
- {
- assert (0);
- }
-
- return r;
-}
-
-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)
-{
- pixman_format_code_t sf = formats[s];
- 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, *alpha, *orig_alpha;
- pixman_transform_t t1;
- int j, k;
- int n_alpha_bits, n_red_bits;
-
- soff = origins[soff];
- doff = origins[doff];
-
- n_alpha_bits = PIXMAN_FORMAT_A (df);
- 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);
-
- 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.
- */
- pixman_transform_init_identity (&t1);
- pixman_transform_scale (&t1, NULL, pixman_int_to_fixed (100), pixman_int_to_fixed (11));
- pixman_transform_rotate (&t1, NULL, pixman_double_to_fixed (0.5), pixman_double_to_fixed (0.11));
- pixman_transform_translate (&t1, NULL, pixman_int_to_fixed (11), pixman_int_to_fixed (17));
-
- pixman_image_set_transform (dst, &t1);
- pixman_image_set_filter (dst, PIXMAN_FILTER_BILINEAR, NULL, 0);
- pixman_image_set_repeat (dst, PIXMAN_REPEAT_REFLECT);
-
- pixman_image_composite (PIXMAN_OP_ADD, src, NULL, dst,
- 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
-
- for (j = MAX (doff, 0); j < MIN (HEIGHT, HEIGHT + doff); ++j)
- {
- for (k = MAX (doff, 0); k < MIN (WIDTH, WIDTH + doff); ++k)
- {
- 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)
- refa = 255;
- else
- refa = sa + oda;
-
- 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, refa, da, sa, oda);
-
- 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;
- }
-
- /* 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;
- }
- }
- }
- }
-
- pixman_image_set_alpha_map (src, NULL, 0, 0);
- pixman_image_set_alpha_map (dst, NULL, 0, 0);
- pixman_image_set_alpha_map (orig_dst, NULL, 0, 0);
-
- pixman_image_unref (src);
- pixman_image_unref (dst);
- pixman_image_unref (orig_dst);
-
- return 0;
-}
-
-int
-main (int argc, char **argv)
-{
- int i, j, a, b, x, y;
-
- prng_srand (0);
-
- for (i = 0; i < ARRAY_LENGTH (formats); ++i)
- {
- for (j = 0; j < ARRAY_LENGTH (formats); ++j)
- {
- for (a = 0; a < ARRAY_LENGTH (alpha_formats); ++a)
- {
- for (b = 0; b < ARRAY_LENGTH (alpha_formats); ++b)
- {
- for (x = 0; x < ARRAY_LENGTH (origins); ++x)
- {
- for (y = 0; y < ARRAY_LENGTH (origins); ++y)
- {
- if (run_test (i, j, a, b, x, y) != 0)
- return 1;
- }
- }
- }
- }
- }
- }
-
- return 0;
-}
diff --git a/qemu/pixman/test/blitters-test.c b/qemu/pixman/test/blitters-test.c
deleted file mode 100644
index ea03f475d..000000000
--- a/qemu/pixman/test/blitters-test.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * Test program, which stresses the use of different color formats and
- * compositing operations.
- *
- * Script 'fuzzer-find-diff.pl' can be used to narrow down the problem in
- * the case of test failure.
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include "utils.h"
-
-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, 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 && prng_rand_n (4) != 0)
- n = N_MOST_LIKELY_FORMATS;
- fmt = allowed_formats[prng_rand_n (n)];
-
- width = prng_rand_n (max_width) + 1;
- height = prng_rand_n (max_height) + 1;
- stride = (width * PIXMAN_FORMAT_BPP (fmt) + 7) / 8 +
- prng_rand_n (max_extra_stride + 1);
- stride = (stride + 3) & ~3;
-
- /* do the allocation */
- buf = aligned_malloc (64, stride * height);
-
- if (prng_rand_n (4) == 0)
- {
- /* uniform distribution */
- prng_randmemset (buf, stride * height, 0);
- }
- else
- {
- /* significantly increased probability for 0x00 and 0xFF */
- prng_randmemset (buf, stride * height, RANDMEMSET_MORE_00_AND_FF);
- }
-
- /* test negative stride */
- if (prng_rand_n (4) == 0)
- {
- buf += (stride / 4) * (height - 1);
- stride = - stride;
- }
-
- 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 (prng_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;
- uint32_t *data = pixman_image_get_data (img);
-
- if (fmt != PIXMAN_null)
- crc32 = compute_crc32_for_image (initcrc, img);
-
- if (img->bits.rowstride < 0)
- data += img->bits.rowstride * (img->bits.height - 1);
-
- 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,
-#if 0 /* These are going to use floating point in the near future */
- PIXMAN_x2r10g10b10,
- PIXMAN_a2r10g10b10,
- PIXMAN_x2b10g10r10,
- PIXMAN_a2b10g10r10,
-#endif
- 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)
-{
- 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 *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;
-
- prng_srand (testnum);
-
- op = op_list[prng_rand_n (ARRAY_LENGTH (op_list))];
-
- if (prng_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);
-
- srcbuf = pixman_image_get_data (src_img);
-
- src_x = prng_rand_n (src_width);
- src_y = prng_rand_n (src_height);
- dst_x = prng_rand_n (dst_width);
- dst_y = prng_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) &&
- (prng_rand_n (4) == 0))
- {
- /* PIXBUF */
- mask_fmt = prng_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 (prng_rand_n (2))
- {
- if (prng_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 (prng_rand_n (2))
- pixman_image_set_component_alpha (mask_img, 1);
-
- mask_x = prng_rand_n (pixman_image_get_width (mask_img));
- mask_y = prng_rand_n (pixman_image_get_height (mask_img));
- }
-
-
- w = prng_rand_n (dst_width - dst_x + 1);
- h = prng_rand_n (dst_height - dst_y + 1);
-
- if (verbose)
- {
- printf ("op=%s\n", operator_name (op));
- printf ("src_fmt=%s, dst_fmt=%s, mask_fmt=%s\n",
- format_name (src_fmt), format_name (dst_fmt),
- format_name (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)
- print_image (dst_img);
-
- 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;
-}
-
-int
-main (int argc, const char *argv[])
-{
- int i;
-
- prng_srand (0);
-
- for (i = 1; i <= 8; i++)
- {
- initialize_palette (&(rgb_palette[i]), i, TRUE);
- initialize_palette (&(y_palette[i]), i, FALSE);
- }
-
- return fuzzer_test_main("blitters", 2000000,
- 0xE0A07495,
- test_composite, argc, argv);
-}
diff --git a/qemu/pixman/test/check-formats.c b/qemu/pixman/test/check-formats.c
deleted file mode 100644
index 7edc198c1..000000000
--- a/qemu/pixman/test/check-formats.c
+++ /dev/null
@@ -1,352 +0,0 @@
-#include <ctype.h>
-#include "utils.h"
-
-static int
-check_op (pixman_op_t op,
- pixman_format_code_t src_format,
- pixman_format_code_t dest_format)
-{
- uint32_t src_alpha_mask, src_green_mask;
- uint32_t dest_alpha_mask, dest_green_mask;
- pixel_checker_t src_checker, dest_checker;
- pixman_image_t *si, *di;
- uint32_t sa, sg, da, dg;
- uint32_t s, d;
- int retval = 0;
-
- pixel_checker_init (&src_checker, src_format);
- pixel_checker_init (&dest_checker, dest_format);
-
- pixel_checker_get_masks (
- &src_checker, &src_alpha_mask, NULL, &src_green_mask, NULL);
- pixel_checker_get_masks (
- &dest_checker, &dest_alpha_mask, NULL, &dest_green_mask, NULL);
-
- /* printf ("masks: %x %x %x %x\n", */
- /* src_alpha_mask, src_green_mask, */
- /* dest_alpha_mask, dest_green_mask); */
-
- si = pixman_image_create_bits (src_format, 1, 1, &s, 4);
- di = pixman_image_create_bits (dest_format, 1, 1, &d, 4);
-
- sa = 0;
- do
- {
- sg = 0;
- do
- {
- da = 0;
- do
- {
- dg = 0;
- do
- {
- color_t src_color, dest_color, result_color;
- uint32_t orig_d;
-
- s = sa | sg;
- d = da | dg;
-
- orig_d = d;
-
- pixel_checker_convert_pixel_to_color (&src_checker, s, &src_color);
- pixel_checker_convert_pixel_to_color (&dest_checker, d, &dest_color);
-
- do_composite (op, &src_color, NULL, &dest_color, &result_color, FALSE);
-
-
- if (!is_little_endian())
- {
- s <<= 32 - PIXMAN_FORMAT_BPP (src_format);
- d <<= 32 - PIXMAN_FORMAT_BPP (dest_format);
- }
-
- pixman_image_composite32 (op, si, NULL, di,
- 0, 0, 0, 0, 0, 0, 1, 1);
-
- if (!is_little_endian())
- d >>= (32 - PIXMAN_FORMAT_BPP (dest_format));
-
- if (!pixel_checker_check (&dest_checker, d, &result_color))
- {
- printf ("---- test failed ----\n");
- printf ("operator: %-32s\n", operator_name (op));
- printf ("source: %-12s pixel: %08x\n", format_name (src_format), s);
- printf ("dest: %-12s pixel: %08x\n", format_name (dest_format), orig_d);
- printf ("got: %-12s pixel: %08x\n", format_name (dest_format), d);
-
- retval = 1;
- }
-
- dg -= dest_green_mask;
- dg &= dest_green_mask;
- }
- while (dg != 0);
-
- da -= dest_alpha_mask;
- da &= dest_alpha_mask;
- }
- while (da != 0);
-
- sg -= src_green_mask;
- sg &= src_green_mask;
- }
- while (sg != 0);
-
- sa -= src_alpha_mask;
- sa &= src_alpha_mask;
- }
- while (sa != 0);
-
- pixman_image_unref (si);
- pixman_image_unref (di);
-
- return retval;
-}
-
-static const pixman_op_t op_list[] =
-{
- 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,
-};
-
-static const pixman_format_code_t format_list[] =
-{
- PIXMAN_a8r8g8b8,
- PIXMAN_x8r8g8b8,
- PIXMAN_a8b8g8r8,
- PIXMAN_x8b8g8r8,
- PIXMAN_b8g8r8a8,
- PIXMAN_b8g8r8x8,
- PIXMAN_r8g8b8a8,
- PIXMAN_r8g8b8x8,
- PIXMAN_x14r6g6b6,
- PIXMAN_x2r10g10b10,
- PIXMAN_a2r10g10b10,
- PIXMAN_x2b10g10r10,
- PIXMAN_a2b10g10r10,
- PIXMAN_a8r8g8b8_sRGB,
- PIXMAN_r8g8b8,
- PIXMAN_b8g8r8,
- PIXMAN_r5g6b5,
- PIXMAN_b5g6r5,
- PIXMAN_a1r5g5b5,
- PIXMAN_x1r5g5b5,
- PIXMAN_a1b5g5r5,
- PIXMAN_x1b5g5r5,
- PIXMAN_a4r4g4b4,
- PIXMAN_x4r4g4b4,
- PIXMAN_a4b4g4r4,
- PIXMAN_x4b4g4r4,
- PIXMAN_a8,
- PIXMAN_r3g3b2,
- PIXMAN_b2g3r3,
- PIXMAN_a2r2g2b2,
- PIXMAN_a2b2g2r2,
- PIXMAN_x4a4,
- PIXMAN_a4,
- PIXMAN_r1g2b1,
- PIXMAN_b1g2r1,
- PIXMAN_a1r1g1b1,
- PIXMAN_a1b1g1r1,
- PIXMAN_a1,
-};
-
-static pixman_format_code_t
-format_from_string (const char *s)
-{
- int i;
-
- for (i = 0; i < ARRAY_LENGTH (format_list); ++i)
- {
- if (strcasecmp (format_name (format_list[i]), s) == 0)
- return format_list[i];
- }
-
- return PIXMAN_null;
-}
-
-static void
-emit (const char *s, int *n_chars)
-{
- *n_chars += printf ("%s,", s);
- if (*n_chars > 60)
- {
- printf ("\n ");
- *n_chars = 0;
- }
- else
- {
- printf (" ");
- (*n_chars)++;
- }
-}
-
-static void
-list_formats (void)
-{
- int n_chars;
- int i;
-
- printf ("Formats:\n ");
-
- n_chars = 0;
- for (i = 0; i < ARRAY_LENGTH (format_list); ++i)
- emit (format_name (format_list[i]), &n_chars);
-
- printf ("\n\n");
-}
-
-static void
-list_operators (void)
-{
- char short_name [128] = { 0 };
- int i, n_chars;
-
- printf ("Operators:\n ");
-
- n_chars = 0;
- for (i = 0; i < ARRAY_LENGTH (op_list); ++i)
- {
- pixman_op_t op = op_list[i];
- int j;
-
- snprintf (short_name, sizeof (short_name) - 1, "%s",
- operator_name (op) + strlen ("PIXMAN_OP_"));
-
- for (j = 0; short_name[j] != '\0'; ++j)
- short_name[j] = tolower (short_name[j]);
-
- emit (short_name, &n_chars);
- }
-
- printf ("\n\n");
-}
-
-static pixman_op_t
-operator_from_string (const char *s)
-{
- char full_name[128] = { 0 };
- int i;
-
- snprintf (full_name, (sizeof full_name) - 1, "PIXMAN_OP_%s", s);
-
- for (i = 0; i < ARRAY_LENGTH (op_list); ++i)
- {
- pixman_op_t op = op_list[i];
-
- if (strcasecmp (operator_name (op), full_name) == 0)
- return op;
- }
-
- return PIXMAN_OP_NONE;
-}
-
-int
-main (int argc, char **argv)
-{
- enum { OPTION_OP, OPTION_SRC, OPTION_DEST, LAST_OPTION } option;
- pixman_format_code_t src_fmt, dest_fmt;
- pixman_op_t op;
-
- op = PIXMAN_OP_NONE;
- src_fmt = PIXMAN_null;
- dest_fmt = PIXMAN_null;
-
- argc--;
- argv++;
-
- for (option = OPTION_OP; option < LAST_OPTION; ++option)
- {
- char *arg = NULL;
-
- if (argc)
- {
- argc--;
- arg = *argv++;
- }
-
- switch (option)
- {
- case OPTION_OP:
- if (!arg)
- printf (" - missing operator\n");
- else if ((op = operator_from_string (arg)) == PIXMAN_OP_NONE)
- printf (" - unknown operator %s\n", arg);
- break;
-
- case OPTION_SRC:
- if (!arg)
- printf (" - missing source format\n");
- else if ((src_fmt = format_from_string (arg)) == PIXMAN_null)
- printf (" - unknown source format %s\n", arg);
- break;
-
- case OPTION_DEST:
- if (!arg)
- printf (" - missing destination format\n");
- else if ((dest_fmt = format_from_string (arg)) == PIXMAN_null)
- printf (" - unknown destination format %s\n", arg);
- break;
-
- default:
- assert (0);
- break;
- }
- }
-
- while (argc--)
- {
- op = PIXMAN_OP_NONE;
- printf (" - unexpected argument: %s\n", *argv++);
- }
-
- if (op == PIXMAN_OP_NONE || src_fmt == PIXMAN_null || dest_fmt == PIXMAN_null)
- {
- printf ("\nUsage:\n check-formats <operator> <src-format> <dest-format>\n\n");
- list_operators();
- list_formats();
-
- return -1;
- }
-
- return check_op (op, src_fmt, dest_fmt);
-}
diff --git a/qemu/pixman/test/combiner-test.c b/qemu/pixman/test/combiner-test.c
deleted file mode 100644
index 01f63a56e..000000000
--- a/qemu/pixman/test/combiner-test.c
+++ /dev/null
@@ -1,151 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "utils.h"
-#include <sys/types.h>
-#include "pixman-private.h"
-
-static const 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,
- PIXMAN_OP_SOFT_LIGHT,
- PIXMAN_OP_HSL_HUE,
- PIXMAN_OP_HSL_SATURATION,
- PIXMAN_OP_HSL_COLOR,
- PIXMAN_OP_HSL_LUMINOSITY,
-};
-
-static float
-rand_float (void)
-{
- uint32_t u = prng_rand();
-
- return *(float *)&u;
-}
-
-static void
-random_floats (argb_t *argb, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- argb_t *p = argb + i;
-
- p->a = rand_float();
- p->r = rand_float();
- p->g = rand_float();
- p->b = rand_float();
- }
-}
-
-#define WIDTH 512
-
-static pixman_combine_float_func_t
-lookup_combiner (pixman_implementation_t *imp, pixman_op_t op,
- pixman_bool_t component_alpha)
-{
- pixman_combine_float_func_t f;
-
- do
- {
- if (component_alpha)
- f = imp->combine_float_ca[op];
- else
- f = imp->combine_float[op];
-
- imp = imp->fallback;
- }
- while (!f);
-
- return f;
-}
-
-int
-main ()
-{
- pixman_implementation_t *impl;
- argb_t *src_bytes = malloc (WIDTH * sizeof (argb_t));
- argb_t *mask_bytes = malloc (WIDTH * sizeof (argb_t));
- argb_t *dest_bytes = malloc (WIDTH * sizeof (argb_t));
- int i;
-
- enable_divbyzero_exceptions();
-
- impl = _pixman_internal_only_get_implementation();
-
- prng_srand (0);
-
- for (i = 0; i < ARRAY_LENGTH (op_list); ++i)
- {
- pixman_op_t op = op_list[i];
- pixman_combine_float_func_t combiner;
- int ca;
-
- for (ca = 0; ca < 2; ++ca)
- {
- combiner = lookup_combiner (impl, op, ca);
-
- random_floats (src_bytes, WIDTH);
- random_floats (mask_bytes, WIDTH);
- random_floats (dest_bytes, WIDTH);
-
- combiner (impl, op,
- (float *)dest_bytes,
- (float *)mask_bytes,
- (float *)src_bytes,
- WIDTH);
- }
- }
-
- return 0;
-}
diff --git a/qemu/pixman/test/composite-traps-test.c b/qemu/pixman/test/composite-traps-test.c
deleted file mode 100644
index 86a035564..000000000
--- a/qemu/pixman/test/composite-traps-test.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/* Based loosely on scaling-test */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "utils.h"
-
-#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)[prng_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 prng_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 ();
-
- prng_srand (testnum);
-
- op = RANDOM_ELT (operators);
- mask_format = RANDOM_ELT (mask_formats);
-
- /* Create source image */
-
- if (prng_rand_n (4) == 0)
- {
- src_img = pixman_image_create_solid_fill (
- &(colors[prng_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 = prng_rand_n (MAX_SRC_WIDTH) + 1;
- int src_height = prng_rand_n (MAX_SRC_HEIGHT) + 1;
- int src_stride = src_width * src_bpp + prng_rand_n (MAX_STRIDE) * src_bpp;
- uint32_t *bits, *orig;
-
- src_x = -(src_width / 4) + prng_rand_n (src_width * 3 / 2);
- src_y = -(src_height / 4) + prng_rand_n (src_height * 3 / 2);
-
- src_stride = (src_stride + 3) & ~3;
-
- orig = bits = (uint32_t *)make_random_bytes (src_stride * src_height);
-
- if (prng_rand_n (2) == 0)
- {
- bits += (src_stride / 4) * (src_height - 1);
- src_stride = - src_stride;
- }
-
- src_img = pixman_image_create_bits (
- src_format, src_width, src_height, bits, src_stride);
-
- pixman_image_set_destroy_function (src_img, destroy_bits, orig);
-
- if (prng_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[2];
- int n = prng_rand_n (2) + 1;
-
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = prng_rand_n (src_width);
- clip_boxes[i].y1 = prng_rand_n (src_height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + prng_rand_n (src_width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + prng_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 = prng_rand_n (MAX_DST_WIDTH) + 1;
- dst_height = prng_rand_n (MAX_DST_HEIGHT) + 1;
- dst_stride = dst_width * dst_bpp + prng_rand_n (MAX_STRIDE) * dst_bpp;
- dst_stride = (dst_stride + 3) & ~3;
-
- dst_bits = (uint32_t *)make_random_bytes (dst_stride * dst_height);
-
- if (prng_rand_n (2) == 0)
- {
- dst_bits += (dst_stride / 4) * (dst_height - 1);
- dst_stride = - dst_stride;
- }
-
- dst_x = -(dst_width / 4) + prng_rand_n (dst_width * 3 / 2);
- dst_y = -(dst_height / 4) + prng_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 = prng_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 (prng_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[2];
- int n = prng_rand_n (2) + 1;
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = prng_rand_n (dst_width);
- clip_boxes[i].y1 = prng_rand_n (dst_height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + prng_rand_n (dst_width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + prng_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);
-
- crc32 = compute_crc32_for_image (0, dst_img);
-
- if (verbose)
- print_image (dst_img);
-
- if (dst_stride < 0)
- dst_bits += (dst_stride / 4) * (dst_height - 1);
-
- fence_free (dst_bits);
-
- pixman_image_unref (src_img);
- pixman_image_unref (dst_img);
- fence_free (traps);
-
- FLOAT_REGS_CORRUPTION_DETECTOR_FINISH ();
- return crc32;
-}
-
-int
-main (int argc, const char *argv[])
-{
- return fuzzer_test_main("composite traps", 40000, 0xAF41D210,
- test_composite, argc, argv);
-}
diff --git a/qemu/pixman/test/composite.c b/qemu/pixman/test/composite.c
deleted file mode 100644
index 9e51a8f65..000000000
--- a/qemu/pixman/test/composite.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- * Copyright © 2005 Eric Anholt
- * Copyright © 2009 Chris Wilson
- * Copyright © 2010 Soeren Sandmann
- * Copyright © 2010 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 Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Eric Anholt makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-#include <stdio.h>
-#include <stdlib.h> /* abort() */
-#include <math.h>
-#include <time.h>
-#include "utils.h"
-
-typedef struct image_t image_t;
-
-static const color_t colors[] =
-{
- { 1.0, 1.0, 1.0, 1.0 },
- { 1.0, 1.0, 1.0, 0.0 },
- { 0.0, 0.0, 0.0, 1.0 },
- { 0.0, 0.0, 0.0, 0.0 },
- { 1.0, 0.0, 0.0, 1.0 },
- { 0.0, 1.0, 0.0, 1.0 },
- { 0.0, 0.0, 1.0, 1.0 },
- { 0.5, 0.0, 0.0, 0.5 },
-};
-
-static uint16_t
-_color_double_to_short (double d)
-{
- uint32_t i;
-
- i = (uint32_t) (d * 65536);
- i -= (i >> 16);
-
- return i;
-}
-
-static void
-compute_pixman_color (const color_t *color,
- pixman_color_t *out)
-{
- out->red = _color_double_to_short (color->r);
- out->green = _color_double_to_short (color->g);
- out->blue = _color_double_to_short (color->b);
- out->alpha = _color_double_to_short (color->a);
-}
-
-#define REPEAT 0x01000000
-#define FLAGS 0xff000000
-
-static const int sizes[] =
-{
- 0,
- 1,
- 1 | REPEAT,
- 10
-};
-
-static const pixman_format_code_t formats[] =
-{
- /* 32 bpp formats */
- PIXMAN_a8r8g8b8,
- PIXMAN_x8r8g8b8,
- PIXMAN_a8b8g8r8,
- PIXMAN_x8b8g8r8,
- PIXMAN_b8g8r8a8,
- PIXMAN_b8g8r8x8,
- PIXMAN_r8g8b8a8,
- PIXMAN_r8g8b8x8,
- PIXMAN_x2r10g10b10,
- PIXMAN_x2b10g10r10,
- PIXMAN_a2r10g10b10,
- PIXMAN_a2b10g10r10,
-
- /* sRGB formats */
- PIXMAN_a8r8g8b8_sRGB,
-
- /* 24 bpp formats */
- PIXMAN_r8g8b8,
- PIXMAN_b8g8r8,
- PIXMAN_r5g6b5,
- PIXMAN_b5g6r5,
-
- /* 16 bpp formats */
- PIXMAN_x1r5g5b5,
- PIXMAN_x1b5g5r5,
- PIXMAN_a1r5g5b5,
- PIXMAN_a1b5g5r5,
- PIXMAN_a4b4g4r4,
- PIXMAN_x4b4g4r4,
- PIXMAN_a4r4g4b4,
- PIXMAN_x4r4g4b4,
-
- /* 8 bpp formats */
- PIXMAN_a8,
- PIXMAN_r3g3b2,
- PIXMAN_b2g3r3,
- PIXMAN_a2r2g2b2,
- PIXMAN_a2b2g2r2,
- PIXMAN_x4a4,
-
- /* 4 bpp formats */
- PIXMAN_a4,
- PIXMAN_r1g2b1,
- PIXMAN_b1g2r1,
- PIXMAN_a1r1g1b1,
- PIXMAN_a1b1g1r1,
-
- /* 1 bpp formats */
- PIXMAN_a1,
-};
-
-struct image_t
-{
- pixman_image_t *image;
- pixman_format_code_t format;
- const color_t *color;
- pixman_repeat_t repeat;
- int size;
-};
-
-static const pixman_op_t operators[] =
-{
- 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,
-};
-
-static uint32_t
-get_value (pixman_image_t *image)
-{
- uint32_t value = *(uint32_t *)pixman_image_get_data (image);
-
-#ifdef WORDS_BIGENDIAN
- {
- pixman_format_code_t format = pixman_image_get_format (image);
- value >>= 8 * sizeof(value) - PIXMAN_FORMAT_BPP (format);
- }
-#endif
-
- return value;
-}
-
-static char *
-describe_image (image_t *info, char *buf)
-{
- if (info->size)
- {
- sprintf (buf, "%s, %dx%d%s",
- format_name (info->format),
- info->size, info->size,
- info->repeat ? " R" :"");
- }
- else
- {
- sprintf (buf, "solid");
- }
-
- return buf;
-}
-
-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,
- pixman_op_t op,
- image_t *src,
- image_t *mask,
- pixman_bool_t component_alpha,
- int testno)
-{
- color_t expected, tdst, tsrc, tmsk;
- pixel_checker_t checker;
-
- if (mask)
- {
- pixman_image_set_component_alpha (mask->image, component_alpha);
-
- pixman_image_composite (op, src->image, mask->image, dst->image,
- 0, 0, 0, 0, 0, 0, dst->size, dst->size);
- }
- else
- {
- pixman_image_composite (op, src->image, NULL, dst->image,
- 0, 0,
- 0, 0,
- 0, 0,
- dst->size, dst->size);
- }
-
- tdst = *dst->color;
- tsrc = *src->color;
-
- if (mask)
- {
- tmsk = *mask->color;
- }
-
- /* It turns out that by construction all source, mask etc. colors are
- * linear because they are made from fills, and fills are always in linear
- * color space. However, if they have been converted to bitmaps, we need
- * to simulate the sRGB approximation to pass the test cases.
- */
- if (src->size)
- {
- if (PIXMAN_FORMAT_TYPE (src->format) == PIXMAN_TYPE_ARGB_SRGB)
- {
- tsrc.r = convert_linear_to_srgb (tsrc.r);
- tsrc.g = convert_linear_to_srgb (tsrc.g);
- tsrc.b = convert_linear_to_srgb (tsrc.b);
- round_color (src->format, &tsrc);
- tsrc.r = convert_srgb_to_linear (tsrc.r);
- tsrc.g = convert_srgb_to_linear (tsrc.g);
- tsrc.b = convert_srgb_to_linear (tsrc.b);
- }
- else
- {
- round_color (src->format, &tsrc);
- }
- }
-
- if (mask && mask->size)
- {
- if (PIXMAN_FORMAT_TYPE (mask->format) == PIXMAN_TYPE_ARGB_SRGB)
- {
- tmsk.r = convert_linear_to_srgb (tmsk.r);
- tmsk.g = convert_linear_to_srgb (tmsk.g);
- tmsk.b = convert_linear_to_srgb (tmsk.b);
- round_color (mask->format, &tmsk);
- tmsk.r = convert_srgb_to_linear (tmsk.r);
- tmsk.g = convert_srgb_to_linear (tmsk.g);
- tmsk.b = convert_srgb_to_linear (tmsk.b);
- }
- else
- {
- round_color (mask->format, &tmsk);
- }
- }
-
- if (mask)
- {
- if (component_alpha && PIXMAN_FORMAT_R (mask->format) == 0)
- {
- /* Ax component-alpha masks expand alpha into
- * all color channels.
- */
- tmsk.r = tmsk.g = tmsk.b = tmsk.a;
- }
- }
-
- if (PIXMAN_FORMAT_TYPE (dst->format) == PIXMAN_TYPE_ARGB_SRGB)
- {
- tdst.r = convert_linear_to_srgb (tdst.r);
- tdst.g = convert_linear_to_srgb (tdst.g);
- tdst.b = convert_linear_to_srgb (tdst.b);
- round_color (dst->format, &tdst);
- tdst.r = convert_srgb_to_linear (tdst.r);
- tdst.g = convert_srgb_to_linear (tdst.g);
- tdst.b = convert_srgb_to_linear (tdst.b);
- }
- else
- {
- round_color (dst->format, &tdst);
- }
-
- do_composite (op,
- &tsrc,
- mask? &tmsk : NULL,
- &tdst,
- &expected,
- component_alpha);
-
- pixel_checker_init (&checker, dst->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",
- operator_name (op), 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 ("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));
-
- pixel = get_value (dst->image);
-
- printf ("Expected: %s\n", describe_color (&expected, buf));
-
- 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
-image_init (image_t *info,
- int color,
- int format,
- int size)
-{
- pixman_color_t fill;
-
- info->color = &colors[color];
- compute_pixman_color (info->color, &fill);
-
- info->format = formats[format];
- info->size = sizes[size] & ~FLAGS;
- info->repeat = PIXMAN_REPEAT_NONE;
-
- if (info->size)
- {
- pixman_image_t *solid;
-
- info->image = pixman_image_create_bits (info->format,
- info->size, info->size,
- NULL, 0);
-
- 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 (sizes[size] & REPEAT)
- {
- pixman_image_set_repeat (info->image, PIXMAN_REPEAT_NORMAL);
- info->repeat = PIXMAN_REPEAT_NORMAL;
- }
- }
- else
- {
- info->image = pixman_image_create_solid_fill (&fill);
- }
-}
-
-static void
-image_fini (image_t *info)
-{
- pixman_image_unref (info->image);
-}
-
-static int
-random_size (void)
-{
- return prng_rand_n (ARRAY_LENGTH (sizes));
-}
-
-static int
-random_color (void)
-{
- return prng_rand_n (ARRAY_LENGTH (colors));
-}
-
-static int
-random_format (void)
-{
- return prng_rand_n (ARRAY_LENGTH (formats));
-}
-
-static pixman_bool_t
-run_test (uint32_t seed)
-{
- image_t src, mask, dst;
- pixman_op_t op;
- int ca;
- int ok;
-
- prng_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());
-
- op = operators [prng_rand_n (ARRAY_LENGTH (operators))];
-
- ca = prng_rand_n (3);
-
- switch (ca)
- {
- case 0:
- ok = composite_test (&dst, op, &src, NULL, FALSE, seed);
- break;
- case 1:
- ok = composite_test (&dst, op, &src, &mask, FALSE, seed);
- break;
- case 2:
- ok = composite_test (&dst, op, &src, &mask,
- mask.size? TRUE : FALSE, seed);
- break;
- default:
- ok = FALSE;
- break;
- }
-
- image_fini (&src);
- image_fini (&mask);
- image_fini (&dst);
-
- return ok;
-}
-
-int
-main (int argc, char **argv)
-{
-#define N_TESTS (8 * 1024 * 1024)
- int result = 0;
- uint32_t seed;
- int32_t i;
-
- if (argc > 1)
- {
- char *end;
-
- i = strtol (argv[1], &end, 0);
-
- if (end != argv[1])
- {
- if (!run_test (i))
- return 1;
- else
- return 0;
- }
- else
- {
- printf ("Usage:\n\n %s <number>\n\n", argv[0]);
- return -1;
- }
- }
-
- if (getenv ("PIXMAN_RANDOMIZE_TESTS"))
- seed = get_random_seed();
- else
- seed = 1;
-
-#ifdef USE_OPENMP
-# pragma omp parallel for default(none) shared(result, argv, seed)
-#endif
- for (i = 0; i <= N_TESTS; ++i)
- {
- if (!result && !run_test (i + seed))
- {
- printf ("Test 0x%08X failed.\n", seed + i);
-
- result = seed + i;
- }
- }
-
- return result;
-}
diff --git a/qemu/pixman/test/fetch-test.c b/qemu/pixman/test/fetch-test.c
deleted file mode 100644
index 04e8cc583..000000000
--- a/qemu/pixman/test/fetch-test.c
+++ /dev/null
@@ -1,205 +0,0 @@
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "utils.h"
-
-#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);
- }
-}
-
-
-int
-main (int argc, char **argv)
-{
- 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;
- }
- }
- }
- }
- }
-
- return ret;
-}
diff --git a/qemu/pixman/test/fuzzer-find-diff.pl b/qemu/pixman/test/fuzzer-find-diff.pl
deleted file mode 100755
index e1d67fbf7..000000000
--- a/qemu/pixman/test/fuzzer-find-diff.pl
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/env perl
-
-$usage = "Usage:
- fuzzer-find-diff.pl reference_binary new_binary [number_of_tests_to_run]
-
-The first two input arguments are the commands to run the test programs
-based on fuzzer_test_main() function from 'util.c' (preferably they should
-be statically compiled, this can be achieved via '--disable-shared' pixman
-configure option). The third optional argument is the number of test rounds
-to run (if not specified, then testing runs infinitely or until some problem
-is detected).
-
-Usage examples:
- fuzzer-find-diff.pl ./blitters-test-with-sse-disabled ./blitters-test 9000000
- fuzzer-find-diff.pl ./blitters-test \"ssh ppc64_host /path/to/blitters-test\"
-";
-
-$#ARGV >= 1 or die $usage;
-
-$batch_size = 10000;
-
-if ($#ARGV >= 2) {
- $number_of_tests = int($ARGV[2]);
-} else {
- $number_of_tests = -1
-}
-
-sub test_range {
- my $min = shift;
- my $max = shift;
-
- # check that [$min, $max] range is "bad", otherwise return
- if (`$ARGV[0] $min $max 2>/dev/null` eq `$ARGV[1] $min $max 2>/dev/null`) {
- return;
- }
-
- # check that $min itself is "good", otherwise return
- if (`$ARGV[0] $min 2>/dev/null` ne `$ARGV[1] $min 2>/dev/null`) {
- return $min;
- }
-
- # start bisecting
- while ($max != $min + 1) {
- my $avg = int(($min + $max) / 2);
- my $res1 = `$ARGV[0] $min $avg 2>/dev/null`;
- my $res2 = `$ARGV[1] $min $avg 2>/dev/null`;
- if ($res1 ne $res2) {
- $max = $avg;
- } else {
- $min = $avg;
- }
- }
- return $max;
-}
-
-$base = 1;
-while ($number_of_tests <= 0 || $base <= $number_of_tests) {
- printf("testing %-12d\r", $base + $batch_size - 1);
- my $res = test_range($base, $base + $batch_size - 1);
- if ($res) {
- printf("Failure: results are different for test %d:\n", $res);
-
- printf("\n-- ref --\n");
- print `$ARGV[0] $res`;
- printf("-- new --\n");
- print `$ARGV[1] $res`;
-
- printf("The problematic conditions can be reproduced by running:\n");
- printf("$ARGV[1] %d\n", $res);
-
- exit(1);
- }
- $base += $batch_size;
-}
-printf("Success: %d tests finished\n", $base - 1);
diff --git a/qemu/pixman/test/glyph-test.c b/qemu/pixman/test/glyph-test.c
deleted file mode 100644
index 1811add73..000000000
--- a/qemu/pixman/test/glyph-test.c
+++ /dev/null
@@ -1,332 +0,0 @@
-#include <stdlib.h>
-#include "utils.h"
-
-static const pixman_format_code_t glyph_formats[] =
-{
- PIXMAN_a8r8g8b8,
- PIXMAN_a8,
- PIXMAN_a4,
- PIXMAN_a1,
- PIXMAN_x8r8g8b8,
- PIXMAN_r3g3b2,
- PIXMAN_null,
-};
-
-static const pixman_format_code_t formats[] =
-{
- 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,
-#if 0
- /* These use floating point */
- PIXMAN_x2r10g10b10,
- PIXMAN_a2r10g10b10,
- PIXMAN_x2b10g10r10,
- PIXMAN_a2b10g10r10,
-#endif
- 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_x4a4,
- PIXMAN_a4,
- PIXMAN_r1g2b1,
- PIXMAN_b1g2r1,
- PIXMAN_a1r1g1b1,
- PIXMAN_a1b1g1r1,
- PIXMAN_null,
-};
-
-static const pixman_op_t operators[] =
-{
- 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
-};
-
-enum
-{
- ALLOW_CLIPPED = (1 << 0),
- ALLOW_ALPHA_MAP = (1 << 1),
- ALLOW_SOURCE_CLIPPING = (1 << 2),
- ALLOW_REPEAT = (1 << 3),
- ALLOW_SOLID = (1 << 4),
- ALLOW_FENCED_MEMORY = (1 << 5),
-};
-
-static void
-destroy_fenced (pixman_image_t *image, void *data)
-{
- fence_free (data);
-}
-
-static void
-destroy_malloced (pixman_image_t *image, void *data)
-{
- free (data);
-}
-
-static pixman_format_code_t
-random_format (const pixman_format_code_t *formats)
-{
- int i;
- i = 0;
- while (formats[i] != PIXMAN_null)
- ++i;
- return formats[prng_rand_n (i)];
-}
-
-static pixman_image_t *
-create_image (int max_size, const pixman_format_code_t *formats, uint32_t flags)
-{
- int width, height;
- pixman_image_t *image;
- pixman_format_code_t format;
- uint32_t *data;
- int bpp;
- int stride;
- int i;
- pixman_image_destroy_func_t destroy;
-
- if ((flags & ALLOW_SOLID) && prng_rand_n (4) == 0)
- {
- pixman_color_t color;
-
- color.alpha = prng_rand();
- color.red = prng_rand();
- color.green = prng_rand();
- color.blue = prng_rand();
-
- return pixman_image_create_solid_fill (&color);
- }
-
- width = prng_rand_n (max_size) + 1;
- height = prng_rand_n (max_size) + 1;
- format = random_format (formats);
-
- bpp = PIXMAN_FORMAT_BPP (format);
- stride = (width * bpp + 7) / 8 + prng_rand_n (17);
- stride = (stride + 3) & ~3;
-
- if (prng_rand_n (64) == 0)
- {
- if (!(data = (uint32_t *)make_random_bytes (stride * height)))
- {
- fprintf (stderr, "Out of memory\n");
- abort ();
- }
- destroy = destroy_fenced;
- }
- else
- {
- data = malloc (stride * height);
- prng_randmemset (data, height * stride, 0);
- destroy = destroy_malloced;
- }
-
- image = pixman_image_create_bits (format, width, height, data, stride);
- pixman_image_set_destroy_function (image, destroy, data);
-
- if ((flags & ALLOW_CLIPPED) && prng_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[8];
- pixman_region16_t clip;
- int n = prng_rand_n (8) + 1;
-
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = prng_rand_n (width);
- clip_boxes[i].y1 = prng_rand_n (height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + prng_rand_n (width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + prng_rand_n (height - clip_boxes[i].y1);
- }
-
- pixman_region_init_rects (&clip, clip_boxes, n);
- pixman_image_set_clip_region (image, &clip);
- pixman_region_fini (&clip);
- }
-
- if ((flags & ALLOW_SOURCE_CLIPPING) && prng_rand_n (4) == 0)
- {
- pixman_image_set_source_clipping (image, TRUE);
- pixman_image_set_has_client_clip (image, TRUE);
- }
-
- if ((flags & ALLOW_ALPHA_MAP) && prng_rand_n (16) == 0)
- {
- pixman_image_t *alpha_map;
- int alpha_x, alpha_y;
-
- alpha_x = prng_rand_n (width);
- alpha_y = prng_rand_n (height);
- alpha_map =
- create_image (max_size, formats, (flags & ~(ALLOW_ALPHA_MAP | ALLOW_SOLID)));
- pixman_image_set_alpha_map (image, alpha_map, alpha_x, alpha_y);
- pixman_image_unref (alpha_map);
- }
-
- if ((flags & ALLOW_REPEAT) && prng_rand_n (2) == 0)
- pixman_image_set_repeat (image, prng_rand_n (4));
-
- image_endian_swap (image);
-
- return image;
-}
-
-#define KEY1(p) ((void *)(((uintptr_t)p) ^ (0xa7e23dfaUL)))
-#define KEY2(p) ((void *)(((uintptr_t)p) ^ (0xabcd9876UL)))
-
-#define MAX_GLYPHS 32
-
-uint32_t
-test_glyphs (int testnum, int verbose)
-{
- pixman_image_t *glyph_images[MAX_GLYPHS];
- pixman_glyph_t glyphs[4 * MAX_GLYPHS];
- uint32_t crc32 = 0;
- pixman_image_t *source, *dest;
- int n_glyphs, i;
- pixman_glyph_cache_t *cache;
-
- prng_srand (testnum);
-
- cache = pixman_glyph_cache_create ();
-
- source = create_image (300, formats,
- ALLOW_CLIPPED | ALLOW_ALPHA_MAP |
- ALLOW_SOURCE_CLIPPING |
- ALLOW_REPEAT | ALLOW_SOLID);
-
- dest = create_image (128, formats,
- ALLOW_CLIPPED | ALLOW_ALPHA_MAP |
- ALLOW_SOURCE_CLIPPING);
-
- pixman_glyph_cache_freeze (cache);
-
- n_glyphs = prng_rand_n (MAX_GLYPHS);
- for (i = 0; i < n_glyphs; ++i)
- glyph_images[i] = create_image (32, glyph_formats, 0);
-
- for (i = 0; i < 4 * n_glyphs; ++i)
- {
- int g = prng_rand_n (n_glyphs);
- pixman_image_t *glyph_img = glyph_images[g];
- void *key1 = KEY1 (glyph_img);
- void *key2 = KEY2 (glyph_img);
- const void *glyph;
-
- if (!(glyph = pixman_glyph_cache_lookup (cache, key1, key2)))
- {
- glyph =
- pixman_glyph_cache_insert (cache, key1, key2, 5, 8, glyph_img);
- }
-
- glyphs[i].glyph = glyph;
- glyphs[i].x = prng_rand_n (128);
- glyphs[i].y = prng_rand_n (128);
- }
-
- if (prng_rand_n (2) == 0)
- {
- int src_x = prng_rand_n (300) - 150;
- int src_y = prng_rand_n (300) - 150;
- int mask_x = prng_rand_n (64) - 32;
- int mask_y = prng_rand_n (64) - 32;
- int dest_x = prng_rand_n (64) - 32;
- int dest_y = prng_rand_n (64) - 32;
- int width = prng_rand_n (64);
- int height = prng_rand_n (64);
- pixman_op_t op = operators[prng_rand_n (ARRAY_LENGTH (operators))];
- pixman_format_code_t format = random_format (glyph_formats);
-
- pixman_composite_glyphs (
- op,
- source, dest, format,
- src_x, src_y,
- mask_x, mask_y,
- dest_x, dest_y,
- width, height,
- cache, 4 * n_glyphs, glyphs);
- }
- else
- {
- pixman_op_t op = operators[prng_rand_n (ARRAY_LENGTH (operators))];
- int src_x = prng_rand_n (300) - 150;
- int src_y = prng_rand_n (300) - 150;
- int dest_x = prng_rand_n (64) - 32;
- int dest_y = prng_rand_n (64) - 32;
-
- pixman_composite_glyphs_no_mask (
- op, source, dest,
- src_x, src_y,
- dest_x, dest_y,
- cache, 4 * n_glyphs, glyphs);
- }
-
- pixman_glyph_cache_thaw (cache);
-
- for (i = 0; i < n_glyphs; ++i)
- {
- pixman_image_t *img = glyph_images[i];
- void *key1, *key2;
-
- key1 = KEY1 (img);
- key2 = KEY2 (img);
-
- pixman_glyph_cache_remove (cache, key1, key2);
- pixman_image_unref (glyph_images[i]);
- }
-
- crc32 = compute_crc32_for_image (0, dest);
-
- pixman_image_unref (source);
- pixman_image_unref (dest);
-
- pixman_glyph_cache_destroy (cache);
-
- return crc32;
-}
-
-int
-main (int argc, const char *argv[])
-{
- return fuzzer_test_main ("glyph", 30000,
- 0xFA478A79,
- test_glyphs, argc, argv);
-}
diff --git a/qemu/pixman/test/gradient-crash-test.c b/qemu/pixman/test/gradient-crash-test.c
deleted file mode 100644
index 962d1cbe8..000000000
--- a/qemu/pixman/test/gradient-crash-test.c
+++ /dev/null
@@ -1,158 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "utils.h"
-
-int
-main (int argc, char **argv)
-{
-#define WIDTH 400
-#define HEIGHT 200
-
- uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
- pixman_image_t *src_img;
- pixman_image_t *dest_img;
- int i, j, 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_divbyzero_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);
-
- return 0;
-}
diff --git a/qemu/pixman/test/infinite-loop.c b/qemu/pixman/test/infinite-loop.c
deleted file mode 100644
index 02addaab2..000000000
--- a/qemu/pixman/test/infinite-loop.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "utils.h"
-
-int
-main (int argc, char **argv)
-{
-#define SRC_WIDTH 16
-#define SRC_HEIGHT 12
-#define DST_WIDTH 7
-#define DST_HEIGHT 2
-
- static const pixman_transform_t transform = {
- { { 0x200017bd, 0x00000000, 0x000e6465 },
- { 0x00000000, 0x000a42fd, 0x000e6465 },
- { 0x00000000, 0x00000000, 0x00010000 },
- }
- };
- pixman_image_t *src, *dest;
-
- src = pixman_image_create_bits (
- PIXMAN_a8r8g8b8, SRC_WIDTH, SRC_HEIGHT, NULL, -1);
- dest = pixman_image_create_bits (
- PIXMAN_a8r8g8b8, DST_WIDTH, DST_HEIGHT, NULL, -1);
-
- pixman_image_set_transform (src, &transform);
- pixman_image_set_repeat (src, PIXMAN_REPEAT_NORMAL);
- pixman_image_set_filter (src, PIXMAN_FILTER_BILINEAR, NULL, 0);
-
- if (argc == 1 || strcmp (argv[1], "-nf") != 0)
- fail_after (1, "infinite loop detected");
-
- pixman_image_composite (
- PIXMAN_OP_OVER, src, NULL, dest, -3, -3, 0, 0, 0, 0, 6, 2);
-
- return 0;
-}
diff --git a/qemu/pixman/test/lowlevel-blt-bench.c b/qemu/pixman/test/lowlevel-blt-bench.c
deleted file mode 100644
index 1049e21e7..000000000
--- a/qemu/pixman/test/lowlevel-blt-bench.c
+++ /dev/null
@@ -1,820 +0,0 @@
-/*
- * Copyright © 2009 Nokia Corporation
- * Copyright © 2010 Movial Creative Technologies Oy
- *
- * 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 (including the next
- * paragraph) 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "utils.h"
-
-#define SOLID_FLAG 1
-#define CA_FLAG 2
-
-#define L1CACHE_SIZE (8 * 1024)
-#define L2CACHE_SIZE (128 * 1024)
-
-/* This is applied to both L1 and L2 tests - alternatively, you could
- * parameterise bench_L or split it into two functions. It could be
- * read at runtime on some architectures, but it only really matters
- * that it's a number that's an integer divisor of both cacheline
- * lengths, and further, it only really matters for caches that don't
- * do allocate0on-write. */
-#define CACHELINE_LENGTH (32) /* bytes */
-
-#define WIDTH 1920
-#define HEIGHT 1080
-#define BUFSIZE (WIDTH * HEIGHT * 4)
-#define XWIDTH 256
-#define XHEIGHT 256
-#define TILEWIDTH 32
-#define TINYWIDTH 8
-
-#define EXCLUDE_OVERHEAD 1
-
-uint32_t *dst;
-uint32_t *src;
-uint32_t *mask;
-
-double bandwidth = 0;
-
-double
-bench_memcpy ()
-{
- int64_t n = 0, total;
- double t1, t2;
- int x = 0;
-
- t1 = gettime ();
- while (1)
- {
- memcpy (dst, src, BUFSIZE - 64);
- memcpy (src, dst, BUFSIZE - 64);
- n += 4 * (BUFSIZE - 64);
- t2 = gettime ();
- if (t2 - t1 > 0.5)
- break;
- }
- n = total = n * 5;
- t1 = gettime ();
- while (n > 0)
- {
- if (++x >= 64)
- x = 0;
- memcpy ((char *)dst + 1, (char *)src + x, BUFSIZE - 64);
- memcpy ((char *)src + 1, (char *)dst + x, BUFSIZE - 64);
- n -= 4 * (BUFSIZE - 64);
- }
- t2 = gettime ();
- return (double)total / (t2 - t1);
-}
-
-static pixman_bool_t use_scaling = FALSE;
-static pixman_filter_t filter = PIXMAN_FILTER_NEAREST;
-
-/* nearly 1x scale factor */
-static pixman_transform_t m =
-{
- {
- { pixman_fixed_1 + 1, 0, 0 },
- { 0, pixman_fixed_1, 0 },
- { 0, 0, pixman_fixed_1 }
- }
-};
-
-static void
-pixman_image_composite_wrapper (pixman_implementation_t *impl,
- pixman_composite_info_t *info)
-{
- if (use_scaling)
- {
- pixman_image_set_filter (info->src_image, filter, NULL, 0);
- pixman_image_set_transform(info->src_image, &m);
- }
- pixman_image_composite (info->op,
- info->src_image, info->mask_image, info->dest_image,
- info->src_x, info->src_y,
- info->mask_x, info->mask_y,
- info->dest_x, info->dest_y,
- info->width, info->height);
-}
-
-static void
-pixman_image_composite_empty (pixman_implementation_t *impl,
- pixman_composite_info_t *info)
-{
- if (use_scaling)
- {
- pixman_image_set_filter (info->src_image, filter, NULL, 0);
- pixman_image_set_transform(info->src_image, &m);
- }
- pixman_image_composite (info->op,
- info->src_image, info->mask_image, info->dest_image,
- 0, 0, 0, 0, 0, 0, 1, 1);
-}
-
-static inline void
-call_func (pixman_composite_func_t func,
- 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)
-{
- pixman_composite_info_t info;
-
- info.op = op;
- info.src_image = src_image;
- info.mask_image = mask_image;
- info.dest_image = dest_image;
- info.src_x = src_x;
- info.src_y = src_y;
- info.mask_x = mask_x;
- info.mask_y = mask_y;
- info.dest_x = dest_x;
- info.dest_y = dest_y;
- info.width = width;
- info.height = height;
-
- func (0, &info);
-}
-
-void
-noinline
-bench_L (pixman_op_t op,
- pixman_image_t * src_img,
- pixman_image_t * mask_img,
- pixman_image_t * dst_img,
- int64_t n,
- pixman_composite_func_t func,
- int width,
- int lines_count)
-{
- int64_t i, j, k;
- int x = 0;
- int q = 0;
- volatile int qx;
-
- for (i = 0; i < n; i++)
- {
- /* For caches without allocate-on-write, we need to force the
- * destination buffer back into the cache on each iteration,
- * otherwise if they are evicted during the test, they remain
- * uncached. This doesn't matter for tests which read the
- * destination buffer, or for caches that do allocate-on-write,
- * but in those cases this loop just adds constant time, which
- * should be successfully cancelled out.
- */
- for (j = 0; j < lines_count; j++)
- {
- for (k = 0; k < width + 62; k += CACHELINE_LENGTH / sizeof *dst)
- {
- q += dst[j * WIDTH + k];
- }
- q += dst[j * WIDTH + width + 62];
- }
- if (++x >= 64)
- x = 0;
- call_func (func, op, src_img, mask_img, dst_img, x, 0, x, 0, 63 - x, 0, width, lines_count);
- }
- qx = q;
-}
-
-void
-noinline
-bench_M (pixman_op_t op,
- pixman_image_t * src_img,
- pixman_image_t * mask_img,
- pixman_image_t * dst_img,
- int64_t n,
- pixman_composite_func_t func)
-{
- int64_t i;
- int x = 0;
-
- for (i = 0; i < n; i++)
- {
- if (++x >= 64)
- x = 0;
- call_func (func, op, src_img, mask_img, dst_img, x, 0, x, 0, 1, 0, WIDTH - 64, HEIGHT);
- }
-}
-
-double
-noinline
-bench_HT (pixman_op_t op,
- pixman_image_t * src_img,
- pixman_image_t * mask_img,
- pixman_image_t * dst_img,
- int64_t n,
- pixman_composite_func_t func)
-{
- double pix_cnt = 0;
- int x = 0;
- int y = 0;
- int64_t i;
-
- srand (0);
- for (i = 0; i < n; i++)
- {
- int w = (rand () % (TILEWIDTH * 2)) + 1;
- int h = (rand () % (TILEWIDTH * 2)) + 1;
- if (x + w > WIDTH)
- {
- x = 0;
- y += TILEWIDTH * 2;
- }
- if (y + h > HEIGHT)
- {
- y = 0;
- }
- call_func (func, op, src_img, mask_img, dst_img, x, y, x, y, x, y, w, h);
- x += w;
- pix_cnt += w * h;
- }
- return pix_cnt;
-}
-
-double
-noinline
-bench_VT (pixman_op_t op,
- pixman_image_t * src_img,
- pixman_image_t * mask_img,
- pixman_image_t * dst_img,
- int64_t n,
- pixman_composite_func_t func)
-{
- double pix_cnt = 0;
- int x = 0;
- int y = 0;
- int64_t i;
-
- srand (0);
- for (i = 0; i < n; i++)
- {
- int w = (rand () % (TILEWIDTH * 2)) + 1;
- int h = (rand () % (TILEWIDTH * 2)) + 1;
- if (y + h > HEIGHT)
- {
- y = 0;
- x += TILEWIDTH * 2;
- }
- if (x + w > WIDTH)
- {
- x = 0;
- }
- call_func (func, op, src_img, mask_img, dst_img, x, y, x, y, x, y, w, h);
- y += h;
- pix_cnt += w * h;
- }
- return pix_cnt;
-}
-
-double
-noinline
-bench_R (pixman_op_t op,
- pixman_image_t * src_img,
- pixman_image_t * mask_img,
- pixman_image_t * dst_img,
- int64_t n,
- pixman_composite_func_t func,
- int maxw,
- int maxh)
-{
- double pix_cnt = 0;
- int64_t i;
-
- if (maxw <= TILEWIDTH * 2 || maxh <= TILEWIDTH * 2)
- {
- printf("error: maxw <= TILEWIDTH * 2 || maxh <= TILEWIDTH * 2\n");
- return 0;
- }
-
- srand (0);
- for (i = 0; i < n; i++)
- {
- int w = (rand () % (TILEWIDTH * 2)) + 1;
- int h = (rand () % (TILEWIDTH * 2)) + 1;
- int sx = rand () % (maxw - TILEWIDTH * 2);
- int sy = rand () % (maxh - TILEWIDTH * 2);
- int dx = rand () % (maxw - TILEWIDTH * 2);
- int dy = rand () % (maxh - TILEWIDTH * 2);
- call_func (func, op, src_img, mask_img, dst_img, sx, sy, sx, sy, dx, dy, w, h);
- pix_cnt += w * h;
- }
- return pix_cnt;
-}
-
-double
-noinline
-bench_RT (pixman_op_t op,
- pixman_image_t * src_img,
- pixman_image_t * mask_img,
- pixman_image_t * dst_img,
- int64_t n,
- pixman_composite_func_t func,
- int maxw,
- int maxh)
-{
- double pix_cnt = 0;
- int64_t i;
-
- if (maxw <= TINYWIDTH * 2 || maxh <= TINYWIDTH * 2)
- {
- printf("error: maxw <= TINYWIDTH * 2 || maxh <= TINYWIDTH * 2\n");
- return 0;
- }
-
- srand (0);
- for (i = 0; i < n; i++)
- {
- int w = (rand () % (TINYWIDTH * 2)) + 1;
- int h = (rand () % (TINYWIDTH * 2)) + 1;
- int sx = rand () % (maxw - TINYWIDTH * 2);
- int sy = rand () % (maxh - TINYWIDTH * 2);
- int dx = rand () % (maxw - TINYWIDTH * 2);
- int dy = rand () % (maxh - TINYWIDTH * 2);
- call_func (func, op, src_img, mask_img, dst_img, sx, sy, sx, sy, dx, dy, w, h);
- pix_cnt += w * h;
- }
- return pix_cnt;
-}
-
-void
-bench_composite (char * testname,
- int src_fmt,
- int src_flags,
- int op,
- int mask_fmt,
- int mask_flags,
- int dst_fmt,
- double npix)
-{
- pixman_image_t * src_img;
- pixman_image_t * dst_img;
- pixman_image_t * mask_img;
- pixman_image_t * xsrc_img;
- pixman_image_t * xdst_img;
- pixman_image_t * xmask_img;
- double t1, t2, t3, pix_cnt;
- int64_t n, l1test_width, nlines;
- double bytes_per_pix = 0;
- pixman_bool_t bench_pixbuf = FALSE;
-
- pixman_composite_func_t func = pixman_image_composite_wrapper;
-
- if (!(src_flags & SOLID_FLAG))
- {
- bytes_per_pix += (src_fmt >> 24) / 8.0;
- src_img = pixman_image_create_bits (src_fmt,
- WIDTH, HEIGHT,
- src,
- WIDTH * 4);
- xsrc_img = pixman_image_create_bits (src_fmt,
- XWIDTH, XHEIGHT,
- src,
- XWIDTH * 4);
- }
- else
- {
- src_img = pixman_image_create_bits (src_fmt,
- 1, 1,
- src,
- 4);
- xsrc_img = pixman_image_create_bits (src_fmt,
- 1, 1,
- src,
- 4);
- pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL);
- pixman_image_set_repeat (xsrc_img, PIXMAN_REPEAT_NORMAL);
- }
-
- bytes_per_pix += (dst_fmt >> 24) / 8.0;
- dst_img = pixman_image_create_bits (dst_fmt,
- WIDTH, HEIGHT,
- dst,
- WIDTH * 4);
-
- mask_img = NULL;
- xmask_img = NULL;
- if (strcmp (testname, "pixbuf") == 0 || strcmp (testname, "rpixbuf") == 0)
- {
- bench_pixbuf = TRUE;
- }
- if (!(mask_flags & SOLID_FLAG) && mask_fmt != PIXMAN_null)
- {
- bytes_per_pix += (mask_fmt >> 24) / ((op == PIXMAN_OP_SRC) ? 8.0 : 4.0);
- mask_img = pixman_image_create_bits (mask_fmt,
- WIDTH, HEIGHT,
- bench_pixbuf ? src : mask,
- WIDTH * 4);
- xmask_img = pixman_image_create_bits (mask_fmt,
- XWIDTH, XHEIGHT,
- bench_pixbuf ? src : mask,
- XWIDTH * 4);
- }
- else if (mask_fmt != PIXMAN_null)
- {
- mask_img = pixman_image_create_bits (mask_fmt,
- 1, 1,
- mask,
- 4);
- xmask_img = pixman_image_create_bits (mask_fmt,
- 1, 1,
- mask,
- 4 * 4);
- pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL);
- pixman_image_set_repeat (xmask_img, PIXMAN_REPEAT_NORMAL);
- }
- if ((mask_flags & CA_FLAG) && mask_fmt != PIXMAN_null)
- {
- pixman_image_set_component_alpha (mask_img, 1);
- }
- xdst_img = pixman_image_create_bits (dst_fmt,
- XWIDTH, XHEIGHT,
- dst,
- XWIDTH * 4);
-
-
- printf ("%24s %c", testname, func != pixman_image_composite_wrapper ?
- '-' : '=');
-
- memcpy (dst, src, BUFSIZE);
- memcpy (src, dst, BUFSIZE);
-
- l1test_width = L1CACHE_SIZE / 8 - 64;
- if (l1test_width < 1)
- l1test_width = 1;
- if (l1test_width > WIDTH - 64)
- l1test_width = WIDTH - 64;
- n = 1 + npix / (l1test_width * 8);
- t1 = gettime ();
-#if EXCLUDE_OVERHEAD
- bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, 1);
-#endif
- t2 = gettime ();
- bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, 1);
- t3 = gettime ();
- printf (" L1:%7.2f", (double)n * l1test_width * 1 /
- ((t3 - t2) - (t2 - t1)) / 1000000.);
- fflush (stdout);
-
- memcpy (dst, src, BUFSIZE);
- memcpy (src, dst, BUFSIZE);
-
- nlines = (L2CACHE_SIZE / l1test_width) /
- ((PIXMAN_FORMAT_BPP(src_fmt) + PIXMAN_FORMAT_BPP(dst_fmt)) / 8);
- if (nlines < 1)
- nlines = 1;
- n = 1 + npix / (l1test_width * nlines);
- t1 = gettime ();
-#if EXCLUDE_OVERHEAD
- bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, nlines);
-#endif
- t2 = gettime ();
- bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, nlines);
- t3 = gettime ();
- printf (" L2:%7.2f", (double)n * l1test_width * nlines /
- ((t3 - t2) - (t2 - t1)) / 1000000.);
- fflush (stdout);
-
- memcpy (dst, src, BUFSIZE);
- memcpy (src, dst, BUFSIZE);
-
- n = 1 + npix / (WIDTH * HEIGHT);
- t1 = gettime ();
-#if EXCLUDE_OVERHEAD
- bench_M (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty);
-#endif
- t2 = gettime ();
- bench_M (op, src_img, mask_img, dst_img, n, func);
- t3 = gettime ();
- printf (" M:%6.2f (%6.2f%%)",
- ((double)n * (WIDTH - 64) * HEIGHT / ((t3 - t2) - (t2 - t1))) / 1000000.,
- ((double)n * (WIDTH - 64) * HEIGHT / ((t3 - t2) - (t2 - t1)) * bytes_per_pix) * (100.0 / bandwidth) );
- fflush (stdout);
-
- memcpy (dst, src, BUFSIZE);
- memcpy (src, dst, BUFSIZE);
-
- n = 1 + npix / (8 * TILEWIDTH * TILEWIDTH);
- t1 = gettime ();
-#if EXCLUDE_OVERHEAD
- pix_cnt = bench_HT (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty);
-#endif
- t2 = gettime ();
- pix_cnt = bench_HT (op, src_img, mask_img, dst_img, n, func);
- t3 = gettime ();
- printf (" HT:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
- fflush (stdout);
-
- memcpy (dst, src, BUFSIZE);
- memcpy (src, dst, BUFSIZE);
-
- n = 1 + npix / (8 * TILEWIDTH * TILEWIDTH);
- t1 = gettime ();
-#if EXCLUDE_OVERHEAD
- pix_cnt = bench_VT (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty);
-#endif
- t2 = gettime ();
- pix_cnt = bench_VT (op, src_img, mask_img, dst_img, n, func);
- t3 = gettime ();
- printf (" VT:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
- fflush (stdout);
-
- memcpy (dst, src, BUFSIZE);
- memcpy (src, dst, BUFSIZE);
-
- n = 1 + npix / (8 * TILEWIDTH * TILEWIDTH);
- t1 = gettime ();
-#if EXCLUDE_OVERHEAD
- pix_cnt = bench_R (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, WIDTH, HEIGHT);
-#endif
- t2 = gettime ();
- pix_cnt = bench_R (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT);
- t3 = gettime ();
- printf (" R:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
- fflush (stdout);
-
- memcpy (dst, src, BUFSIZE);
- memcpy (src, dst, BUFSIZE);
-
- n = 1 + npix / (16 * TINYWIDTH * TINYWIDTH);
- t1 = gettime ();
-#if EXCLUDE_OVERHEAD
- pix_cnt = bench_RT (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, WIDTH, HEIGHT);
-#endif
- t2 = gettime ();
- pix_cnt = bench_RT (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT);
- t3 = gettime ();
- printf (" RT:%6.2f (%4.0fKops/s)\n", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000., (double) n / ((t3 - t2) * 1000));
-
- if (mask_img) {
- pixman_image_unref (mask_img);
- pixman_image_unref (xmask_img);
- }
- pixman_image_unref (src_img);
- pixman_image_unref (dst_img);
- pixman_image_unref (xsrc_img);
- pixman_image_unref (xdst_img);
-}
-
-#define PIXMAN_OP_OUT_REV (PIXMAN_OP_OUT_REVERSE)
-
-struct
-{
- char *testname;
- int src_fmt;
- int src_flags;
- int op;
- int mask_fmt;
- int mask_flags;
- int dst_fmt;
-}
-tests_tbl[] =
-{
- { "add_8_8_8", PIXMAN_a8, 0, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a8 },
- { "add_n_8_8", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a8 },
- { "add_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
- { "add_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
- { "add_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
- { "add_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 },
- { "add_n_8_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a4r4g4b4 },
- { "add_n_8_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a2r2g2b2 },
- { "add_n_8_2x10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_x2r10g10b10 },
- { "add_n_8_2a10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a2r10g10b10 },
- { "add_n_8", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8 },
- { "add_n_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
- { "add_n_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
- { "add_n_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_r5g6b5 },
- { "add_n_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a1r5g5b5 },
- { "add_n_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a4r4g4b4 },
- { "add_n_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r2g2b2 },
- { "add_n_2x10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x2r10g10b10 },
- { "add_n_2a10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r10g10b10 },
- { "add_8_8", PIXMAN_a8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8 },
- { "add_x888_x888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
- { "add_8888_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
- { "add_8888_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_r5g6b5 },
- { "add_8888_1555", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a1r5g5b5 },
- { "add_8888_4444", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a4r4g4b4 },
- { "add_8888_2222", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r2g2b2 },
- { "add_0565_0565", PIXMAN_r5g6b5, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_r5g6b5 },
- { "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 },
- { "src_n_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a4r4g4b4 },
- { "src_n_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
- { "src_n_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
- { "src_n_2x10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x2r10g10b10 },
- { "src_n_2a10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r10g10b10 },
- { "src_8888_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
- { "src_0565_8888", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
- { "src_8888_4444", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a4r4g4b4 },
- { "src_8888_2222", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r2g2b2 },
- { "src_8888_2x10", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x2r10g10b10 },
- { "src_8888_2a10", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r10g10b10 },
- { "src_0888_0565", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
- { "src_0888_8888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
- { "src_0888_x888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
- { "src_0888_8888_rev", PIXMAN_b8g8r8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
- { "src_0888_0565_rev", PIXMAN_b8g8r8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
- { "src_x888_x888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
- { "src_x888_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
- { "src_8888_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
- { "src_0565_0565", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
- { "src_1555_0565", PIXMAN_a1r5g5b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
- { "src_0565_1555", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a1r5g5b5 },
- { "src_8_8", PIXMAN_a8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8 },
- { "src_n_8", PIXMAN_a8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8 },
- { "src_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
- { "src_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 },
- { "src_n_8_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a4r4g4b4 },
- { "src_n_8_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a2r2g2b2 },
- { "src_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
- { "src_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
- { "src_n_8_2x10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x2r10g10b10 },
- { "src_n_8_2a10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a2r10g10b10 },
- { "src_8888_8_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
- { "src_0888_8_0565", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
- { "src_0888_8_8888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
- { "src_0888_8_x888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
- { "src_x888_8_x888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
- { "src_x888_8_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
- { "src_0565_8_0565", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
- { "src_1555_8_0565", PIXMAN_a1r5g5b5, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
- { "src_0565_8_1555", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 },
- { "over_n_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
- { "over_n_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
- { "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 },
- { "over_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
- { "over_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 },
- { "over_n_8_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a4r4g4b4 },
- { "over_n_8_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a2r2g2b2 },
- { "over_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
- { "over_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
- { "over_n_8_2x10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_x2r10g10b10 },
- { "over_n_8_2a10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a2r10g10b10 },
- { "over_n_8888_8888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a8r8g8b8 },
- { "over_n_8888_x888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_x8r8g8b8 },
- { "over_n_8888_0565_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_r5g6b5 },
- { "over_n_8888_1555_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a1r5g5b5 },
- { "over_n_8888_4444_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a4r4g4b4 },
- { "over_n_8888_2222_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a2r2g2b2 },
- { "over_n_8888_2x10_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_x2r10g10b10 },
- { "over_n_8888_2a10_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a2r10g10b10 },
- { "over_8888_n_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_a8r8g8b8 },
- { "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 },
- { "outrev_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
- { "outrev_n_8888_0565_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_r5g6b5 },
- { "outrev_n_8888_1555_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_a1r5g5b5 },
- { "outrev_n_8888_x888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_x8r8g8b8 },
- { "outrev_n_8888_8888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_a8r8g8b8 },
- { "over_reverse_n_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER_REVERSE, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
- { "pixbuf", PIXMAN_x8b8g8r8, 0, PIXMAN_OP_SRC, PIXMAN_a8b8g8r8, 0, PIXMAN_a8r8g8b8 },
- { "rpixbuf", PIXMAN_x8b8g8r8, 0, PIXMAN_OP_SRC, PIXMAN_a8b8g8r8, 0, PIXMAN_a8b8g8r8 },
-};
-
-int
-main (int argc, char *argv[])
-{
- double x;
- int i;
- const char *pattern = NULL;
- for (i = 1; i < argc; i++)
- {
- if (argv[i][0] == '-')
- {
- if (strchr (argv[i] + 1, 'b'))
- {
- use_scaling = TRUE;
- filter = PIXMAN_FILTER_BILINEAR;
- }
- else if (strchr (argv[i] + 1, 'n'))
- {
- use_scaling = TRUE;
- filter = PIXMAN_FILTER_NEAREST;
- }
- }
- else
- {
- pattern = argv[i];
- }
- }
-
- if (!pattern)
- {
- printf ("Usage: lowlevel-blt-bench [-b] [-n] pattern\n");
- printf (" -n : benchmark nearest scaling\n");
- printf (" -b : benchmark bilinear scaling\n");
- return 1;
- }
-
- src = aligned_malloc (4096, BUFSIZE * 3);
- memset (src, 0xCC, BUFSIZE * 3);
- dst = src + (BUFSIZE / 4);
- mask = dst + (BUFSIZE / 4);
-
- printf ("Benchmark for a set of most commonly used functions\n");
- printf ("---\n");
- printf ("All results are presented in millions of pixels per second\n");
- printf ("L1 - small Xx1 rectangle (fitting L1 cache), always blitted at the same\n");
- printf (" memory location with small drift in horizontal direction\n");
- printf ("L2 - small XxY rectangle (fitting L2 cache), always blitted at the same\n");
- printf (" memory location with small drift in horizontal direction\n");
- printf ("M - large %dx%d rectangle, always blitted at the same\n",
- WIDTH - 64, HEIGHT);
- printf (" memory location with small drift in horizontal direction\n");
- printf ("HT - random rectangles with %dx%d average size are copied from\n",
- TILEWIDTH, TILEWIDTH);
- printf (" one %dx%d buffer to another, traversing from left to right\n",
- WIDTH, HEIGHT);
- printf (" and from top to bottom\n");
- printf ("VT - random rectangles with %dx%d average size are copied from\n",
- TILEWIDTH, TILEWIDTH);
- printf (" one %dx%d buffer to another, traversing from top to bottom\n",
- WIDTH, HEIGHT);
- printf (" and from left to right\n");
- printf ("R - random rectangles with %dx%d average size are copied from\n",
- TILEWIDTH, TILEWIDTH);
- printf (" random locations of one %dx%d buffer to another\n",
- WIDTH, HEIGHT);
- printf ("RT - as R, but %dx%d average sized rectangles are copied\n",
- TINYWIDTH, TINYWIDTH);
- printf ("---\n");
- bandwidth = x = bench_memcpy ();
- printf ("reference memcpy speed = %.1fMB/s (%.1fMP/s for 32bpp fills)\n",
- x / 1000000., x / 4000000);
- if (use_scaling)
- {
- printf ("---\n");
- if (filter == PIXMAN_FILTER_BILINEAR)
- printf ("BILINEAR scaling\n");
- else if (filter == PIXMAN_FILTER_NEAREST)
- printf ("NEAREST scaling\n");
- else
- printf ("UNKNOWN scaling\n");
- }
- printf ("---\n");
-
- for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
- {
- if (strcmp (pattern, "all") == 0 || strcmp (tests_tbl[i].testname, pattern) == 0)
- {
- bench_composite (tests_tbl[i].testname,
- tests_tbl[i].src_fmt,
- tests_tbl[i].src_flags,
- tests_tbl[i].op,
- tests_tbl[i].mask_fmt,
- tests_tbl[i].mask_flags,
- tests_tbl[i].dst_fmt,
- bandwidth/8);
- }
- }
-
- free (src);
- return 0;
-}
diff --git a/qemu/pixman/test/matrix-test.c b/qemu/pixman/test/matrix-test.c
deleted file mode 100644
index 0a5f203f5..000000000
--- a/qemu/pixman/test/matrix-test.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright © 2012 Siarhei Siamashka <siarhei.siamashka@gmail.com>
- *
- * 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 (including the next
- * paragraph) 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.
- */
-
-#include "utils.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-
-#ifdef HAVE_FLOAT128
-
-#define pixman_fixed_to_float128(x) (((__float128)(x)) / 65536.0Q)
-
-typedef struct { __float128 v[3]; } pixman_vector_f128_t;
-typedef struct { __float128 m[3][3]; } pixman_transform_f128_t;
-
-pixman_bool_t
-pixman_transform_point_f128 (const pixman_transform_f128_t *t,
- const pixman_vector_f128_t *v,
- pixman_vector_f128_t *result)
-{
- int i;
- for (i = 0; i < 3; i++)
- {
- result->v[i] = t->m[i][0] * v->v[0] +
- t->m[i][1] * v->v[1] +
- t->m[i][2] * v->v[2];
- }
- if (result->v[2] != 0)
- {
- result->v[0] /= result->v[2];
- result->v[1] /= result->v[2];
- result->v[2] = 1;
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-
-pixman_bool_t does_it_fit_fixed_48_16 (__float128 x)
-{
- if (x >= 65536.0Q * 65536.0Q * 32768.0Q)
- return FALSE;
- if (x <= -65536.0Q * 65536.0Q * 32768.0Q)
- return FALSE;
- return TRUE;
-}
-
-#endif
-
-static inline uint32_t
-byteswap32 (uint32_t x)
-{
- return ((x & ((uint32_t)0xFF << 24)) >> 24) |
- ((x & ((uint32_t)0xFF << 16)) >> 8) |
- ((x & ((uint32_t)0xFF << 8)) << 8) |
- ((x & ((uint32_t)0xFF << 0)) << 24);
-}
-
-static inline uint64_t
-byteswap64 (uint64_t x)
-{
- return ((x & ((uint64_t)0xFF << 56)) >> 56) |
- ((x & ((uint64_t)0xFF << 48)) >> 40) |
- ((x & ((uint64_t)0xFF << 40)) >> 24) |
- ((x & ((uint64_t)0xFF << 32)) >> 8) |
- ((x & ((uint64_t)0xFF << 24)) << 8) |
- ((x & ((uint64_t)0xFF << 16)) << 24) |
- ((x & ((uint64_t)0xFF << 8)) << 40) |
- ((x & ((uint64_t)0xFF << 0)) << 56);
-}
-
-static void
-byteswap_transform (pixman_transform_t *t)
-{
- int i, j;
-
- if (is_little_endian ())
- return;
-
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
- t->matrix[i][j] = byteswap32 (t->matrix[i][j]);
-}
-
-static void
-byteswap_vector_48_16 (pixman_vector_48_16_t *v)
-{
- int i;
-
- if (is_little_endian ())
- return;
-
- for (i = 0; i < 3; i++)
- v->v[i] = byteswap64 (v->v[i]);
-}
-
-uint32_t
-test_matrix (int testnum, int verbose)
-{
- uint32_t crc32 = 0;
- int i, j, k;
- pixman_bool_t is_affine;
-
- prng_srand (testnum);
-
- for (i = 0; i < 100; i++)
- {
- pixman_bool_t transform_ok;
- pixman_transform_t ti;
- pixman_vector_48_16_t vi, result_i;
-#ifdef HAVE_FLOAT128
- pixman_transform_f128_t tf;
- pixman_vector_f128_t vf, result_f;
-#endif
- prng_randmemset (&ti, sizeof(ti), 0);
- prng_randmemset (&vi, sizeof(vi), 0);
- byteswap_transform (&ti);
- byteswap_vector_48_16 (&vi);
-
- for (j = 0; j < 3; j++)
- {
- /* make sure that "vi" contains 31.16 fixed point data */
- vi.v[j] >>= 17;
- /* and apply random shift */
- if (prng_rand_n (3) == 0)
- vi.v[j] >>= prng_rand_n (46);
- }
-
- if (prng_rand_n (2))
- {
- /* random shift for the matrix */
- for (j = 0; j < 3; j++)
- for (k = 0; k < 3; k++)
- ti.matrix[j][k] >>= prng_rand_n (30);
- }
-
- if (prng_rand_n (2))
- {
- /* affine matrix */
- ti.matrix[2][0] = 0;
- ti.matrix[2][1] = 0;
- ti.matrix[2][2] = pixman_fixed_1;
- }
-
- if (prng_rand_n (2))
- {
- /* cartesian coordinates */
- vi.v[2] = pixman_fixed_1;
- }
-
- is_affine = (ti.matrix[2][0] == 0 && ti.matrix[2][1] == 0 &&
- ti.matrix[2][2] == pixman_fixed_1 &&
- vi.v[2] == pixman_fixed_1);
-
- transform_ok = TRUE;
- if (is_affine && prng_rand_n (2))
- pixman_transform_point_31_16_affine (&ti, &vi, &result_i);
- else
- transform_ok = pixman_transform_point_31_16 (&ti, &vi, &result_i);
-
-#ifdef HAVE_FLOAT128
- /* compare with a reference 128-bit floating point implementation */
- for (j = 0; j < 3; j++)
- {
- vf.v[j] = pixman_fixed_to_float128 (vi.v[j]);
- for (k = 0; k < 3; k++)
- {
- tf.m[j][k] = pixman_fixed_to_float128 (ti.matrix[j][k]);
- }
- }
-
- if (pixman_transform_point_f128 (&tf, &vf, &result_f))
- {
- if (transform_ok ||
- (does_it_fit_fixed_48_16 (result_f.v[0]) &&
- does_it_fit_fixed_48_16 (result_f.v[1]) &&
- does_it_fit_fixed_48_16 (result_f.v[2])))
- {
- for (j = 0; j < 3; j++)
- {
- double diff = fabs (result_f.v[j] -
- pixman_fixed_to_float128 (result_i.v[j]));
-
- if (is_affine && diff > (0.51 / 65536.0))
- {
- printf ("%d:%d: bad precision for affine (%.12f)\n",
- testnum, i, diff);
- abort ();
- }
- else if (diff > (0.71 / 65536.0))
- {
- printf ("%d:%d: bad precision for projective (%.12f)\n",
- testnum, i, diff);
- abort ();
- }
- }
- }
- }
-#endif
- byteswap_vector_48_16 (&result_i);
- crc32 = compute_crc32 (crc32, &result_i, sizeof (result_i));
- }
- return crc32;
-}
-
-int
-main (int argc, const char *argv[])
-{
- return fuzzer_test_main ("matrix", 20000,
- 0xBEBF98C3,
- test_matrix, argc, argv);
-}
diff --git a/qemu/pixman/test/oob-test.c b/qemu/pixman/test/oob-test.c
deleted file mode 100644
index 0d19b504a..000000000
--- a/qemu/pixman/test/oob-test.c
+++ /dev/null
@@ -1,101 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "utils.h"
-
-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);
-}
-
-
-
-int
-main (int argc, char **argv)
-{
- int i;
-
- for (i = 0; i < ARRAY_LENGTH (info); ++i)
- test_composite (&info[i]);
-
- return 0;
-}
diff --git a/qemu/pixman/test/pdf-op-test.c b/qemu/pixman/test/pdf-op-test.c
deleted file mode 100644
index dcb3a603a..000000000
--- a/qemu/pixman/test/pdf-op-test.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <stdlib.h>
-#include "utils.h"
-
-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,
-};
-
-int
-main ()
-{
- int o, s, m, d;
-
- enable_divbyzero_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);
- }
- }
-
- return 0;
-}
diff --git a/qemu/pixman/test/pixel-test.c b/qemu/pixman/test/pixel-test.c
deleted file mode 100644
index 8c525d202..000000000
--- a/qemu/pixman/test/pixel-test.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright © 2013 Soeren Sandmann
- * Copyright © 2013 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 (including the next
- * paragraph) 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.
- */
-#include <stdio.h>
-#include <stdlib.h> /* abort() */
-#include <math.h>
-#include <time.h>
-#include "utils.h"
-
-typedef struct pixel_combination_t pixel_combination_t;
-struct pixel_combination_t
-{
- pixman_op_t op;
- pixman_format_code_t src_format;
- uint32_t src_pixel;
- pixman_format_code_t dest_format;
- uint32_t dest_pixel;
-};
-
-static const pixel_combination_t regressions[] =
-{
- { PIXMAN_OP_OVER,
- PIXMAN_a8r8g8b8, 0x0f00c300,
- PIXMAN_x14r6g6b6, 0x003c0,
- },
- { PIXMAN_OP_DISJOINT_XOR,
- PIXMAN_a4r4g4b4, 0xd0c0,
- PIXMAN_a8r8g8b8, 0x5300ea00,
- },
- { PIXMAN_OP_OVER,
- PIXMAN_a8r8g8b8, 0x20c6bf00,
- PIXMAN_r5g6b5, 0xb9ff
- },
- { PIXMAN_OP_OVER,
- PIXMAN_a8r8g8b8, 0x204ac7ff,
- PIXMAN_r5g6b5, 0xc1ff
- },
- { PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0xffc3,
- PIXMAN_a8r8g8b8, 0x102d00dd
- },
- { PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0x1f00,
- PIXMAN_a8r8g8b8, 0x1bdf0c89
- },
- { PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0xf9d2,
- PIXMAN_a8r8g8b8, 0x1076bcf7
- },
- { PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0x00c3,
- PIXMAN_a8r8g8b8, 0x1bfe9ae5
- },
- { PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0x09ff,
- PIXMAN_a8r8g8b8, 0x0b00c16c
- },
- { PIXMAN_OP_DISJOINT_ATOP,
- PIXMAN_a2r2g2b2, 0xbc,
- PIXMAN_a8r8g8b8, 0x9efff1ff
- },
- { PIXMAN_OP_DISJOINT_ATOP,
- PIXMAN_a4r4g4b4, 0xae5f,
- PIXMAN_a8r8g8b8, 0xf215b675
- },
- { PIXMAN_OP_DISJOINT_ATOP_REVERSE,
- PIXMAN_a8r8g8b8, 0xce007980,
- PIXMAN_a8r8g8b8, 0x80ffe4ad
- },
- { PIXMAN_OP_DISJOINT_XOR,
- PIXMAN_a8r8g8b8, 0xb8b07bea,
- PIXMAN_a4r4g4b4, 0x939c
- },
- { PIXMAN_OP_CONJOINT_ATOP_REVERSE,
- PIXMAN_r5g6b5, 0x0063,
- PIXMAN_a8r8g8b8, 0x10bb1ed7,
- },
-};
-
-static void
-fill (pixman_image_t *image, uint32_t pixel)
-{
- uint8_t *data = (uint8_t *)pixman_image_get_data (image);
- int bytes_per_pixel = PIXMAN_FORMAT_BPP (pixman_image_get_format (image)) / 8;
- int n_bytes = pixman_image_get_stride (image) * pixman_image_get_height (image);
- int i;
-
- switch (bytes_per_pixel)
- {
- case 4:
- for (i = 0; i < n_bytes / 4; ++i)
- ((uint32_t *)data)[i] = pixel;
- break;
-
- case 2:
- pixel &= 0xffff;
- for (i = 0; i < n_bytes / 2; ++i)
- ((uint16_t *)data)[i] = pixel;
- break;
-
- case 1:
- pixel &= 0xff;
- for (i = 0; i < n_bytes; ++i)
- ((uint8_t *)data)[i] = pixel;
- break;
-
- default:
- assert (0);
- break;
- }
-}
-
-static uint32_t
-access (pixman_image_t *image, int x, int y)
-{
- int bytes_per_pixel;
- int stride;
- uint32_t result;
- uint8_t *location;
-
- if (x < 0 || x >= image->bits.width || y < 0 || y >= image->bits.height)
- return 0;
-
- bytes_per_pixel = PIXMAN_FORMAT_BPP (image->bits.format) / 8;
- stride = image->bits.rowstride * 4;
-
- location = (uint8_t *)image->bits.bits + y * stride + x * bytes_per_pixel;
-
- if (bytes_per_pixel == 4)
- result = *(uint32_t *)location;
- else if (bytes_per_pixel == 2)
- result = *(uint16_t *)location;
- else if (bytes_per_pixel == 1)
- result = *(uint8_t *)location;
- else
- assert (0);
-
- return result;
-}
-
-static pixman_bool_t
-verify (int test_no, const pixel_combination_t *combination, int size)
-{
- pixman_image_t *src, *dest;
- pixel_checker_t src_checker, dest_checker;
- color_t source_color, dest_color, reference_color;
- pixman_bool_t result = TRUE;
- int i, j;
-
- /* Compute reference color */
- pixel_checker_init (&src_checker, combination->src_format);
- pixel_checker_init (&dest_checker, combination->dest_format);
- pixel_checker_convert_pixel_to_color (
- &src_checker, combination->src_pixel, &source_color);
- pixel_checker_convert_pixel_to_color (
- &dest_checker, combination->dest_pixel, &dest_color);
- do_composite (combination->op,
- &source_color, NULL, &dest_color,
- &reference_color, FALSE);
-
- src = pixman_image_create_bits (
- combination->src_format, size, size, NULL, -1);
- dest = pixman_image_create_bits (
- combination->dest_format, size, size, NULL, -1);
-
- fill (src, combination->src_pixel);
- fill (dest, combination->dest_pixel);
-
- pixman_image_composite32 (
- combination->op, src, NULL, dest, 0, 0, 0, 0, 0, 0, size, size);
-
- for (j = 0; j < size; ++j)
- {
- for (i = 0; i < size; ++i)
- {
- uint32_t computed = access (dest, i, j);
- int32_t a, r, g, b;
-
- if (!pixel_checker_check (&dest_checker, computed, &reference_color))
- {
- printf ("----------- Test %d failed ----------\n", test_no);
-
- printf (" operator: %s\n", operator_name (combination->op));
- printf (" src format: %s\n", format_name (combination->src_format));
- printf (" dest format: %s\n", format_name (combination->dest_format));
- printf (" - source ARGB: %f %f %f %f (pixel: %8x)\n",
- source_color.a, source_color.r, source_color.g, source_color.b,
- combination->src_pixel);
- pixel_checker_split_pixel (&src_checker, combination->src_pixel,
- &a, &r, &g, &b);
- printf (" %8d %8d %8d %8d\n", a, r, g, b);
-
- printf (" - dest ARGB: %f %f %f %f (pixel: %8x)\n",
- dest_color.a, dest_color.r, dest_color.g, dest_color.b,
- combination->dest_pixel);
- pixel_checker_split_pixel (&dest_checker, combination->dest_pixel,
- &a, &r, &g, &b);
- printf (" %8d %8d %8d %8d\n", a, r, g, b);
-
- pixel_checker_split_pixel (&dest_checker, computed, &a, &r, &g, &b);
- printf (" - expected ARGB: %f %f %f %f\n",
- reference_color.a, reference_color.r, reference_color.g, reference_color.b);
-
- pixel_checker_get_min (&dest_checker, &reference_color, &a, &r, &g, &b);
- printf (" min acceptable: %8d %8d %8d %8d\n", a, r, g, b);
-
- pixel_checker_split_pixel (&dest_checker, computed, &a, &r, &g, &b);
- printf (" got: %8d %8d %8d %8d (pixel: %8x)\n", a, r, g, b, computed);
-
- pixel_checker_get_max (&dest_checker, &reference_color, &a, &r, &g, &b);
- printf (" max acceptable: %8d %8d %8d %8d\n", a, r, g, b);
-
- result = FALSE;
- goto done;
- }
- }
- }
-
-done:
- pixman_image_unref (src);
- pixman_image_unref (dest);
-
- return result;
-}
-
-int
-main (int argc, char **argv)
-{
- int result = 0;
- int i, j;
-
- for (i = 0; i < ARRAY_LENGTH (regressions); ++i)
- {
- const pixel_combination_t *combination = &(regressions[i]);
-
- for (j = 1; j < 34; ++j)
- {
- if (!verify (i, combination, j))
- {
- result = 1;
- break;
- }
- }
- }
-
- return result;
-}
diff --git a/qemu/pixman/test/prng-test.c b/qemu/pixman/test/prng-test.c
deleted file mode 100644
index c1d9320cc..000000000
--- a/qemu/pixman/test/prng-test.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright © 2012 Siarhei Siamashka <siarhei.siamashka@gmail.com>
- *
- * Based on the public domain implementation of small noncryptographic PRNG
- * authored by Bob Jenkins: http://burtleburtle.net/bob/rand/smallprng.html
- *
- * 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 (including the next
- * paragraph) 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.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include "utils-prng.h"
-#include "utils.h"
-
-/* The original code from http://www.burtleburtle.net/bob/rand/smallprng.html */
-
-typedef uint32_t u4;
-typedef struct ranctx { u4 a; u4 b; u4 c; u4 d; } ranctx;
-
-#define rot(x,k) (((x)<<(k))|((x)>>(32-(k))))
-u4 ranval( ranctx *x ) {
- u4 e = x->a - rot(x->b, 27);
- x->a = x->b ^ rot(x->c, 17);
- x->b = x->c + x->d;
- x->c = x->d + e;
- x->d = e + x->a;
- return x->d;
-}
-
-void raninit( ranctx *x, u4 seed ) {
- u4 i;
- x->a = 0xf1ea5eed, x->b = x->c = x->d = seed;
- for (i=0; i<20; ++i) {
- (void)ranval(x);
- }
-}
-
-/*****************************************************************************/
-
-#define BUFSIZE (8 * 1024 * 1024)
-#define N 50
-
-void bench (void)
-{
- double t1, t2;
- int i;
- prng_t prng;
- uint8_t *buf = aligned_malloc (16, BUFSIZE + 1);
-
- prng_srand_r (&prng, 1234);
- t1 = gettime();
- for (i = 0; i < N; i++)
- prng_randmemset_r (&prng, buf, BUFSIZE, 0);
- t2 = gettime();
- printf ("aligned randmemset : %.2f MB/s\n",
- (double)BUFSIZE * N / 1000000. / (t2 - t1));
-
- t1 = gettime();
- for (i = 0; i < N; i++)
- prng_randmemset_r (&prng, buf + 1, BUFSIZE, 0);
- t2 = gettime();
- printf ("unaligned randmemset : %.2f MB/s\n",
- (double)BUFSIZE * N / 1000000. / (t2 - t1));
-
- t1 = gettime();
- for (i = 0; i < N; i++)
- {
- prng_randmemset_r (&prng, buf, BUFSIZE, RANDMEMSET_MORE_00_AND_FF);
- }
- t2 = gettime ();
- printf ("aligned randmemset (more 00 and FF) : %.2f MB/s\n",
- (double)BUFSIZE * N / 1000000. / (t2 - t1));
-
- t1 = gettime();
- for (i = 0; i < N; i++)
- {
- prng_randmemset_r (&prng, buf + 1, BUFSIZE, RANDMEMSET_MORE_00_AND_FF);
- }
- t2 = gettime ();
- printf ("unaligned randmemset (more 00 and FF) : %.2f MB/s\n",
- (double)BUFSIZE * N / 1000000. / (t2 - t1));
-
- free (buf);
-}
-
-#define SMALLBUFSIZE 100
-
-int main (int argc, char *argv[])
-{
- const uint32_t ref_crc[RANDMEMSET_MORE_00_AND_FF + 1] =
- {
- 0xBA06763D, 0x103FC550, 0x8B59ABA5, 0xD82A0F39,
- 0xD2321099, 0xFD8C5420, 0xD3B7C42A, 0xFC098093,
- 0x85E01DE0, 0x6680F8F7, 0x4D32DD3C, 0xAE52382B,
- 0x149E6CB5, 0x8B336987, 0x15DCB2B3, 0x8A71B781
- };
- uint32_t crc1, crc2;
- uint32_t ref, seed, seed0, seed1, seed2, seed3;
- prng_rand_128_data_t buf;
- uint8_t *bytebuf = aligned_malloc(16, SMALLBUFSIZE + 1);
- ranctx x;
- prng_t prng;
- prng_randmemset_flags_t flags;
-
- if (argc > 1 && strcmp(argv[1], "-bench") == 0)
- {
- bench ();
- return 0;
- }
-
- /* basic test */
- raninit (&x, 0);
- prng_srand_r (&prng, 0);
- assert (ranval (&x) == prng_rand_r (&prng));
-
- /* test for simd code */
- seed = 0;
- prng_srand_r (&prng, seed);
- seed0 = (seed = seed * 1103515245 + 12345);
- seed1 = (seed = seed * 1103515245 + 12345);
- seed2 = (seed = seed * 1103515245 + 12345);
- seed3 = (seed = seed * 1103515245 + 12345);
- prng_rand_128_r (&prng, &buf);
-
- raninit (&x, seed0);
- ref = ranval (&x);
- assert (ref == buf.w[0]);
-
- raninit (&x, seed1);
- ref = ranval (&x);
- assert (ref == buf.w[1]);
-
- raninit (&x, seed2);
- ref = ranval (&x);
- assert (ref == buf.w[2]);
-
- raninit (&x, seed3);
- ref = ranval (&x);
- assert (ref == buf.w[3]);
-
- /* test for randmemset */
- for (flags = 0; flags <= RANDMEMSET_MORE_00_AND_FF; flags++)
- {
- prng_srand_r (&prng, 1234);
- prng_randmemset_r (&prng, bytebuf, 16, flags);
- prng_randmemset_r (&prng, bytebuf + 16, SMALLBUFSIZE - 17, flags);
- crc1 = compute_crc32 (0, bytebuf, SMALLBUFSIZE - 1);
- prng_srand_r (&prng, 1234);
- prng_randmemset_r (&prng, bytebuf + 1, SMALLBUFSIZE - 1, flags);
- crc2 = compute_crc32 (0, bytebuf + 1, SMALLBUFSIZE - 1);
- assert (ref_crc[flags] == crc1);
- assert (ref_crc[flags] == crc2);
- }
-
- free (bytebuf);
-
- return 0;
-}
diff --git a/qemu/pixman/test/radial-perf-test.c b/qemu/pixman/test/radial-perf-test.c
deleted file mode 100644
index 71092e27b..000000000
--- a/qemu/pixman/test/radial-perf-test.c
+++ /dev/null
@@ -1,58 +0,0 @@
-#include "utils.h"
-#include <stdio.h>
-
-int
-main ()
-{
- static const pixman_point_fixed_t inner = { 0x0000, 0x0000 };
- static const pixman_point_fixed_t outer = { 0x0000, 0x0000 };
- static const pixman_fixed_t r_inner = 0;
- static const pixman_fixed_t r_outer = 64 << 16;
- static const pixman_gradient_stop_t stops[] = {
- { 0x00000, { 0x6666, 0x6666, 0x6666, 0xffff } },
- { 0x10000, { 0x0000, 0x0000, 0x0000, 0xffff } }
- };
- static const pixman_transform_t transform = {
- { { 0x0, 0x26ee, 0x0},
- { 0xffffeeef, 0x0, 0x0},
- { 0x0, 0x0, 0x10000}
- }
- };
- static const pixman_color_t z = { 0x0000, 0x0000, 0x0000, 0x0000 };
- pixman_image_t *dest, *radial, *zero;
- int i;
- double before, after;
-
- dest = pixman_image_create_bits (
- PIXMAN_x8r8g8b8, 640, 429, NULL, -1);
- zero = pixman_image_create_solid_fill (&z);
- radial = pixman_image_create_radial_gradient (
- &inner, &outer, r_inner, r_outer, stops, ARRAY_LENGTH (stops));
- pixman_image_set_transform (radial, &transform);
- pixman_image_set_repeat (radial, PIXMAN_REPEAT_PAD);
-
-#define N_COMPOSITE 500
-
- before = gettime();
- for (i = 0; i < N_COMPOSITE; ++i)
- {
- before -= gettime();
-
- pixman_image_composite (
- PIXMAN_OP_SRC, zero, NULL, dest,
- 0, 0, 0, 0, 0, 0, 640, 429);
-
- before += gettime();
-
- pixman_image_composite32 (
- PIXMAN_OP_OVER, radial, NULL, dest,
- - 150, -158, 0, 0, 0, 0, 640, 361);
- }
-
- after = gettime();
-
- write_png (dest, "radial.png");
-
- printf ("Average time to composite: %f\n", (after - before) / N_COMPOSITE);
- return 0;
-}
diff --git a/qemu/pixman/test/region-contains-test.c b/qemu/pixman/test/region-contains-test.c
deleted file mode 100644
index 096e65179..000000000
--- a/qemu/pixman/test/region-contains-test.c
+++ /dev/null
@@ -1,169 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include "utils.h"
-
-static void
-make_random_region (pixman_region32_t *region)
-{
- int n_boxes;
-
- pixman_region32_init (region);
-
- n_boxes = prng_rand_n (64);
- while (n_boxes--)
- {
- int32_t x, y;
- uint32_t w, h;
-
- x = (int32_t)prng_rand() >> 2;
- y = (int32_t)prng_rand() >> 2;
- w = prng_rand() >> 2;
- h = prng_rand() >> 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 (prng_rand_n (14))
- {
- bb = pixman_region32_rectangles (region, &n_boxes);
- if (n_boxes == 0)
- goto use_extent;
- b = bb + prng_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 (prng_rand_n (5))
- {
- case 0:
- return begin - prng_rand();
- case 1:
- return end + prng_rand ();
- 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;
-
- prng_srand (i);
-
- make_random_region (&region);
-
- box.x1 = random_coord (&region, TRUE);
- box.x2 = box.x1 + prng_rand ();
- box.y1 = random_coord (&region, FALSE);
- box.y2 = box.y1 + prng_rand ();
-
- 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;
-}
-
-int
-main (int argc, const char *argv[])
-{
- return fuzzer_test_main ("region_contains",
- 1000000,
- 0x548E0F3F,
- test_region_contains_rectangle,
- argc, argv);
-}
diff --git a/qemu/pixman/test/region-test.c b/qemu/pixman/test/region-test.c
deleted file mode 100644
index bfc219bc7..000000000
--- a/qemu/pixman/test/region-test.c
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "utils.h"
-
-int
-main ()
-{
- 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
- };
-
- prng_srand (0);
-
- /* 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,
- prng_rand_n (image_size),
- prng_rand_n (image_size),
- prng_rand_n (25),
- prng_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);
-
- return 0;
-}
diff --git a/qemu/pixman/test/region-translate-test.c b/qemu/pixman/test/region-translate-test.c
deleted file mode 100644
index 5a03027e8..000000000
--- a/qemu/pixman/test/region-translate-test.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#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.
- */
-
-#define LARGE 32000
-
-int
-main (int argc, char **argv)
-{
- 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);
-
- return 0;
-}
diff --git a/qemu/pixman/test/rotate-test.c b/qemu/pixman/test/rotate-test.c
deleted file mode 100644
index 18ca60d9b..000000000
--- a/qemu/pixman/test/rotate-test.c
+++ /dev/null
@@ -1,120 +0,0 @@
-#include <stdlib.h>
-#include "utils.h"
-
-#define WIDTH 32
-#define HEIGHT 32
-
-static const pixman_format_code_t formats[] =
-{
- PIXMAN_a8r8g8b8,
- PIXMAN_a8b8g8r8,
- PIXMAN_x8r8g8b8,
- PIXMAN_x8b8g8r8,
- PIXMAN_r5g6b5,
- PIXMAN_b5g6r5,
- PIXMAN_a8,
- PIXMAN_a1,
-};
-
-static const pixman_op_t ops[] =
-{
- PIXMAN_OP_OVER,
- PIXMAN_OP_SRC,
- PIXMAN_OP_ADD,
-};
-
-#define TRANSFORM(v00, v01, v10, v11) \
- { { { v00, v01, WIDTH * pixman_fixed_1 / 2 }, \
- { v10, v11, HEIGHT * pixman_fixed_1 / 2 }, \
- { 0, 0, pixman_fixed_1 } } }
-
-#define F1 pixman_fixed_1
-
-static const pixman_transform_t transforms[] =
-{
- TRANSFORM (0, -1, 1, 0), /* wrong 90 degree rotation */
- TRANSFORM (0, 1, -1, 0), /* wrong 270 degree rotation */
- TRANSFORM (1, 0, 0, 1), /* wrong identity */
- TRANSFORM (-1, 0, 0, -1), /* wrong 180 degree rotation */
- TRANSFORM (0, -F1, F1, 0), /* correct 90 degree rotation */
- TRANSFORM (0, F1, -F1, 0), /* correct 270 degree rotation */
- TRANSFORM (F1, 0, 0, F1), /* correct identity */
- TRANSFORM (-F1, 0, 0, -F1), /* correct 180 degree rotation */
-};
-
-#define RANDOM_FORMAT() \
- (formats[prng_rand_n (ARRAY_LENGTH (formats))])
-
-#define RANDOM_OP() \
- (ops[prng_rand_n (ARRAY_LENGTH (ops))])
-
-#define RANDOM_TRANSFORM() \
- (&(transforms[prng_rand_n (ARRAY_LENGTH (transforms))]))
-
-static void
-on_destroy (pixman_image_t *image, void *data)
-{
- free (data);
-}
-
-static pixman_image_t *
-make_image (void)
-{
- pixman_format_code_t format = RANDOM_FORMAT();
- uint32_t *bytes, *orig;
- pixman_image_t *image;
- int stride;
-
- orig = bytes = malloc (WIDTH * HEIGHT * 4);
- prng_randmemset (bytes, WIDTH * HEIGHT * 4, 0);
-
- stride = WIDTH * 4;
- if (prng_rand_n (2) == 0)
- {
- bytes += (stride / 4) * (HEIGHT - 1);
- stride = - stride;
- }
-
- image = pixman_image_create_bits (
- format, WIDTH, HEIGHT, bytes, stride);
-
- pixman_image_set_transform (image, RANDOM_TRANSFORM());
- pixman_image_set_destroy_function (image, on_destroy, orig);
- pixman_image_set_repeat (image, PIXMAN_REPEAT_NORMAL);
-
- image_endian_swap (image);
-
- return image;
-}
-
-static uint32_t
-test_transform (int testnum, int verbose)
-{
- pixman_image_t *src, *dest;
- uint32_t crc;
-
- prng_srand (testnum);
-
- src = make_image ();
- dest = make_image ();
-
- pixman_image_composite (RANDOM_OP(),
- src, NULL, dest,
- 0, 0, 0, 0, WIDTH / 2, HEIGHT / 2,
- WIDTH, HEIGHT);
-
- crc = compute_crc32_for_image (0, dest);
-
- pixman_image_unref (src);
- pixman_image_unref (dest);
-
- return crc;
-}
-
-int
-main (int argc, const char *argv[])
-{
- return fuzzer_test_main ("rotate", 15000,
- 0x81E9EC2F,
- test_transform, argc, argv);
-}
diff --git a/qemu/pixman/test/scaling-bench.c b/qemu/pixman/test/scaling-bench.c
deleted file mode 100644
index 365e79850..000000000
--- a/qemu/pixman/test/scaling-bench.c
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <stdlib.h>
-#include "utils.h"
-
-#define SOURCE_WIDTH 320
-#define SOURCE_HEIGHT 240
-#define TEST_REPEATS 3
-
-static pixman_image_t *
-make_source (void)
-{
- size_t n_bytes = (SOURCE_WIDTH + 2) * (SOURCE_HEIGHT + 2) * 4;
- uint32_t *data = malloc (n_bytes);
- pixman_image_t *source;
-
- prng_randmemset (data, n_bytes, 0);
-
- source = pixman_image_create_bits (
- PIXMAN_a8r8g8b8, SOURCE_WIDTH + 2, SOURCE_HEIGHT + 2,
- data,
- (SOURCE_WIDTH + 2) * 4);
-
- pixman_image_set_filter (source, PIXMAN_FILTER_BILINEAR, NULL, 0);
-
- return source;
-}
-
-int
-main ()
-{
- double scale;
- pixman_image_t *src;
-
- prng_srand (23874);
-
- src = make_source ();
- printf ("# %-6s %-22s %-14s %-12s\n",
- "ratio",
- "resolutions",
- "time / ms",
- "time per pixel / ns");
- for (scale = 0.1; scale < 10.005; scale += 0.01)
- {
- int i;
- int dest_width = SOURCE_WIDTH * scale + 0.5;
- int dest_height = SOURCE_HEIGHT * scale + 0.5;
- int dest_byte_stride = (dest_width * 4 + 15) & ~15;
- pixman_fixed_t s = (1 / scale) * 65536.0 + 0.5;
- pixman_transform_t transform;
- pixman_image_t *dest;
- double t1, t2, t = -1;
- uint32_t *dest_buf = aligned_malloc (16, dest_byte_stride * dest_height);
- memset (dest_buf, 0, dest_byte_stride * dest_height);
-
- pixman_transform_init_scale (&transform, s, s);
- pixman_image_set_transform (src, &transform);
-
- dest = pixman_image_create_bits (
- PIXMAN_a8r8g8b8, dest_width, dest_height, dest_buf, dest_byte_stride);
-
- for (i = 0; i < TEST_REPEATS; i++)
- {
- t1 = gettime();
- pixman_image_composite (
- PIXMAN_OP_OVER, src, NULL, dest,
- scale, scale, 0, 0, 0, 0, dest_width, dest_height);
- t2 = gettime();
- if (t < 0 || t2 - t1 < t)
- t = t2 - t1;
- }
-
- printf ("%6.2f : %4dx%-4d => %4dx%-4d : %12.4f : %12.4f\n",
- scale, SOURCE_WIDTH, SOURCE_HEIGHT, dest_width, dest_height,
- t * 1000, (t / (dest_width * dest_height)) * 1000000000);
-
- pixman_image_unref (dest);
- free (dest_buf);
- }
-
- return 0;
-}
diff --git a/qemu/pixman/test/scaling-crash-test.c b/qemu/pixman/test/scaling-crash-test.c
deleted file mode 100644
index 0dac892b5..000000000
--- a/qemu/pixman/test/scaling-crash-test.c
+++ /dev/null
@@ -1,219 +0,0 @@
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "utils.h"
-
-/*
- * We have a source image filled with solid color, set NORMAL or PAD repeat,
- * and some transform which results in nearest neighbour scaling.
- *
- * The expected result is 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;
-}
-
-int
-main (int argc, char *argv[])
-{
- 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);
-
- return 0;
-}
diff --git a/qemu/pixman/test/scaling-helpers-test.c b/qemu/pixman/test/scaling-helpers-test.c
deleted file mode 100644
index cd5ace0b2..000000000
--- a/qemu/pixman/test/scaling-helpers-test.c
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include "utils.h"
-#include "pixman-inlines.h"
-
-/* 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;
- }
-}
-
-int
-main (void)
-{
- int i;
- prng_srand (0);
- 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 = prng_rand_n(10000 << 16) - (3000 << 16);
- int32_t width = prng_rand_n(10000);
- int32_t source_image_width = prng_rand_n(10000) + 1;
- pixman_fixed_t unit_x = prng_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);
- }
-
- return 0;
-}
diff --git a/qemu/pixman/test/scaling-test.c b/qemu/pixman/test/scaling-test.c
deleted file mode 100644
index e2f7fa9f4..000000000
--- a/qemu/pixman/test/scaling-test.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Test program, which can detect some problems with nearest neighbour
- * and bilinear scaling in pixman. Testing is done by running lots
- * of random SRC and OVER compositing operations a8r8g8b8, x8a8r8g8b8
- * and r5g6b5 color formats.
- *
- * Script 'fuzzer-find-diff.pl' can be used to narrow down the problem in
- * the case of test failure.
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include "utils.h"
-
-#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
- */
-
-static pixman_format_code_t
-get_format (int bpp)
-{
- if (bpp == 4)
- {
- switch (prng_rand_n (4))
- {
- default:
- case 0:
- return PIXMAN_a8r8g8b8;
- case 1:
- return PIXMAN_x8r8g8b8;
- case 2:
- return PIXMAN_a8b8g8r8;
- case 3:
- return PIXMAN_x8b8g8r8;
- }
- }
- else
- {
- return PIXMAN_r5g6b5;
- }
-}
-
-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 ();
-
- prng_srand (testnum);
-
- src_bpp = (prng_rand_n (2) == 0) ? 2 : 4;
- dst_bpp = (prng_rand_n (2) == 0) ? 2 : 4;
- switch (prng_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 = prng_rand_n (MAX_SRC_WIDTH) + 1;
- src_height = prng_rand_n (MAX_SRC_HEIGHT) + 1;
-
- if (prng_rand_n (2))
- {
- mask_width = prng_rand_n (MAX_SRC_WIDTH) + 1;
- mask_height = prng_rand_n (MAX_SRC_HEIGHT) + 1;
- }
- else
- {
- mask_width = mask_height = 1;
- }
-
- dst_width = prng_rand_n (MAX_DST_WIDTH) + 1;
- dst_height = prng_rand_n (MAX_DST_HEIGHT) + 1;
- src_stride = src_width * src_bpp + prng_rand_n (MAX_STRIDE) * src_bpp;
- mask_stride = mask_width * mask_bpp + prng_rand_n (MAX_STRIDE) * mask_bpp;
- dst_stride = dst_width * dst_bpp + prng_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) + prng_rand_n (src_width * 3 / 2);
- src_y = -(src_height / 4) + prng_rand_n (src_height * 3 / 2);
- mask_x = -(mask_width / 4) + prng_rand_n (mask_width * 3 / 2);
- mask_y = -(mask_height / 4) + prng_rand_n (mask_height * 3 / 2);
- dst_x = -(dst_width / 4) + prng_rand_n (dst_width * 3 / 2);
- dst_y = -(dst_height / 4) + prng_rand_n (dst_height * 3 / 2);
- w = prng_rand_n (dst_width * 3 / 2 - dst_x);
- h = prng_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);
-
- prng_randmemset (srcbuf, src_stride * src_height, 0);
- prng_randmemset (maskbuf, mask_stride * mask_height, 0);
- prng_randmemset (dstbuf, dst_stride * dst_height, 0);
-
- src_fmt = get_format (src_bpp);
- dst_fmt = get_format (dst_bpp);
-
- if (prng_rand_n (2))
- {
- srcbuf += (src_stride / 4) * (src_height - 1);
- src_stride = - src_stride;
- }
-
- if (prng_rand_n (2))
- {
- maskbuf += (mask_stride / 4) * (mask_height - 1);
- mask_stride = - mask_stride;
- }
-
- if (prng_rand_n (2))
- {
- dstbuf += (dst_stride / 4) * (dst_height - 1);
- dst_stride = - dst_stride;
- }
-
- 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 (prng_rand_n (4) > 0)
- {
- scale_x = -32768 * 3 + prng_rand_n (65536 * 5);
- scale_y = -32768 * 3 + prng_rand_n (65536 * 5);
- translate_x = prng_rand_n (65536);
- translate_y = prng_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 (prng_rand_n (2) > 0)
- {
- mask_scale_x = -32768 * 3 + prng_rand_n (65536 * 5);
- mask_scale_y = -32768 * 3 + prng_rand_n (65536 * 5);
- mask_translate_x = prng_rand_n (65536);
- mask_translate_y = prng_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 (prng_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 (prng_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 (prng_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 (prng_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=%s, dst_fmt=%s\n",
- format_name (src_fmt), format_name (dst_fmt));
- printf ("op=%s, scale_x=%d, scale_y=%d, repeat=%d\n",
- operator_name (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 (prng_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[2];
- int n = prng_rand_n (2) + 1;
-
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = prng_rand_n (src_width);
- clip_boxes[i].y1 = prng_rand_n (src_height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + prng_rand_n (src_width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + prng_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 (prng_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[2];
- int n = prng_rand_n (2) + 1;
-
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = prng_rand_n (mask_width);
- clip_boxes[i].y1 = prng_rand_n (mask_height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + prng_rand_n (mask_width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + prng_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 (prng_rand_n (8) == 0)
- {
- pixman_box16_t clip_boxes[2];
- int n = prng_rand_n (2) + 1;
- for (i = 0; i < n; i++)
- {
- clip_boxes[i].x1 = prng_rand_n (dst_width);
- clip_boxes[i].y1 = prng_rand_n (dst_height);
- clip_boxes[i].x2 =
- clip_boxes[i].x1 + prng_rand_n (dst_width - clip_boxes[i].x1);
- clip_boxes[i].y2 =
- clip_boxes[i].y1 + prng_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 (prng_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);
-
- crc32 = compute_crc32_for_image (0, dst_img);
-
- if (verbose)
- print_image (dst_img);
-
- pixman_image_unref (src_img);
- pixman_image_unref (mask_img);
- pixman_image_unref (dst_img);
-
- if (src_stride < 0)
- srcbuf += (src_stride / 4) * (src_height - 1);
-
- if (mask_stride < 0)
- maskbuf += (mask_stride / 4) * (mask_height - 1);
-
- if (dst_stride < 0)
- dstbuf += (dst_stride / 4) * (dst_height - 1);
-
- free (srcbuf);
- free (maskbuf);
- free (dstbuf);
-
- FLOAT_REGS_CORRUPTION_DETECTOR_FINISH ();
- return crc32;
-}
-
-#if BILINEAR_INTERPOLATION_BITS == 7
-#define CHECKSUM 0x92E0F068
-#elif BILINEAR_INTERPOLATION_BITS == 4
-#define CHECKSUM 0x8EFFA1E5
-#else
-#define CHECKSUM 0x00000000
-#endif
-
-int
-main (int argc, const char *argv[])
-{
- pixman_disable_out_of_bounds_workaround ();
-
- return fuzzer_test_main("scaling", 8000000, CHECKSUM,
- test_composite, argc, argv);
-}
diff --git a/qemu/pixman/test/stress-test.c b/qemu/pixman/test/stress-test.c
deleted file mode 100644
index 1f03c7543..000000000
--- a/qemu/pixman/test/stress-test.c
+++ /dev/null
@@ -1,1040 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "utils.h"
-#include <sys/types.h>
-
-#if 0
-#define fence_malloc malloc
-#define fence_free free
-#define make_random_bytes malloc
-#endif
-
-static const pixman_format_code_t image_formats[] =
-{
- PIXMAN_a8r8g8b8,
- PIXMAN_x8r8g8b8,
- PIXMAN_r5g6b5,
- PIXMAN_r3g3b2,
- PIXMAN_a8,
- PIXMAN_a8b8g8r8,
- PIXMAN_x8b8g8r8,
- PIXMAN_b8g8r8a8,
- PIXMAN_b8g8r8x8,
- PIXMAN_r8g8b8a8,
- PIXMAN_r8g8b8x8,
- PIXMAN_x14r6g6b6,
- PIXMAN_r8g8b8,
- PIXMAN_b8g8r8,
- PIXMAN_a8r8g8b8_sRGB,
- PIXMAN_r5g6b5,
- PIXMAN_b5g6r5,
- PIXMAN_x2r10g10b10,
- PIXMAN_a2r10g10b10,
- PIXMAN_x2b10g10r10,
- PIXMAN_a2b10g10r10,
- PIXMAN_a1r5g5b5,
- PIXMAN_x1r5g5b5,
- PIXMAN_a1b5g5r5,
- PIXMAN_x1b5g5r5,
- PIXMAN_a4r4g4b4,
- PIXMAN_x4r4g4b4,
- PIXMAN_a4b4g4r4,
- PIXMAN_x4b4g4r4,
- PIXMAN_a8,
- PIXMAN_r3g3b2,
- PIXMAN_b2g3r3,
- PIXMAN_a2r2g2b2,
- PIXMAN_a2b2g2r2,
- PIXMAN_c8,
- PIXMAN_g8,
- PIXMAN_x4c4,
- PIXMAN_x4g4,
- PIXMAN_c4,
- PIXMAN_g4,
- PIXMAN_g1,
- PIXMAN_x4a4,
- PIXMAN_a4,
- PIXMAN_r1g2b1,
- PIXMAN_b1g2r1,
- PIXMAN_a1r1g1b1,
- PIXMAN_a1b1g1r1,
- PIXMAN_a1
-};
-
-static pixman_filter_t filters[] =
-{
- PIXMAN_FILTER_NEAREST,
- PIXMAN_FILTER_BILINEAR,
- PIXMAN_FILTER_FAST,
- PIXMAN_FILTER_GOOD,
- PIXMAN_FILTER_BEST,
- PIXMAN_FILTER_CONVOLUTION
-};
-
-static int
-get_size (void)
-{
- switch (prng_rand_n (28))
- {
- case 0:
- return 1;
-
- case 1:
- return 2;
-
- default:
- case 2:
- return prng_rand_n (100);
-
- case 4:
- return prng_rand_n (2000) + 1000;
-
- case 5:
- return 65535;
-
- case 6:
- return 65536;
-
- case 7:
- return prng_rand_n (64000) + 63000;
- }
-}
-
-static void
-destroy (pixman_image_t *image, void *data)
-{
- if (image->type == BITS && image->bits.free_me != image->bits.bits)
- {
- uint32_t *bits;
-
- if (image->bits.bits != (void *)0x01)
- {
- bits = image->bits.bits;
-
- if (image->bits.rowstride < 0)
- bits -= (- image->bits.rowstride * (image->bits.height - 1));
-
- fence_free (bits);
- }
- }
-
- free (data);
-}
-
-static uint32_t
-real_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
-real_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);
- break;
- }
-}
-
-static uint32_t
-fake_reader (const void *src, int size)
-{
- uint32_t r = prng_rand ();
-
- assert (size == 1 || size == 2 || size == 4);
-
- return r >> (32 - (size * 8));
-}
-
-static void
-fake_writer (void *src, uint32_t value, int size)
-{
- assert (size == 1 || size == 2 || size == 4);
-}
-
-static int32_t
-log_rand (void)
-{
- uint32_t mask;
-
- mask = (1 << prng_rand_n (10)) - 1;
-
- return (prng_rand () & mask) - (mask >> 1);
-}
-
-static int32_t
-rand_x (pixman_image_t *image)
-{
- if (image->type == BITS)
- return prng_rand_n (image->bits.width);
- else
- return log_rand ();
-}
-
-static int32_t
-rand_y (pixman_image_t *image)
-{
- if (image->type == BITS)
- return prng_rand_n (image->bits.height);
- else
- return log_rand ();
-}
-
-typedef enum
-{
- DONT_CARE,
- PREFER_ALPHA,
- REQUIRE_ALPHA
-} alpha_preference_t;
-
-static pixman_format_code_t
-random_format (alpha_preference_t alpha)
-{
- pixman_format_code_t format;
- int n = prng_rand_n (ARRAY_LENGTH (image_formats));
-
- if (alpha >= PREFER_ALPHA &&
- (alpha == REQUIRE_ALPHA || prng_rand_n (4) != 0))
- {
- do
- {
- format = image_formats[n++ % ARRAY_LENGTH (image_formats)];
- } while (PIXMAN_FORMAT_TYPE (format) != PIXMAN_TYPE_A);
- }
- else
- {
- format = image_formats[n];
- }
-
- return format;
-}
-
-static pixman_image_t *
-create_random_bits_image (alpha_preference_t alpha_preference)
-{
- pixman_format_code_t format;
- pixman_indexed_t *indexed;
- pixman_image_t *image;
- int width, height, stride;
- uint32_t *bits;
- pixman_read_memory_func_t read_func = NULL;
- pixman_write_memory_func_t write_func = NULL;
- pixman_filter_t filter;
- pixman_fixed_t *coefficients = NULL;
- int n_coefficients = 0;
-
- /* format */
- format = random_format (alpha_preference);
-
- indexed = NULL;
- if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR)
- {
- indexed = malloc (sizeof (pixman_indexed_t));
-
- initialize_palette (indexed, PIXMAN_FORMAT_BPP (format), TRUE);
- }
- else if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY)
- {
- indexed = malloc (sizeof (pixman_indexed_t));
-
- initialize_palette (indexed, PIXMAN_FORMAT_BPP (format), FALSE);
- }
- else
- {
- indexed = NULL;
- }
-
- /* size */
- width = get_size ();
- height = get_size ();
-
- while ((uint64_t)width * height > 200000)
- {
- if (prng_rand_n(2) == 0)
- height = 200000 / width;
- else
- width = 200000 / height;
- }
-
- if (height == 0)
- height = 1;
- if (width == 0)
- width = 1;
-
- /* bits */
- switch (prng_rand_n (7))
- {
- default:
- case 0:
- stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);
- stride = (stride + 3) & (~3);
- bits = (uint32_t *)make_random_bytes (height * stride);
- break;
-
- case 1:
- stride = 0;
- bits = NULL;
- break;
-
- case 2: /* Zero-filled */
- stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);
- stride = (stride + 3) & (~3);
- bits = fence_malloc (height * stride);
- if (!bits)
- return NULL;
- memset (bits, 0, height * stride);
- break;
-
- case 3: /* Filled with 0xFF */
- stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);
- stride = (stride + 3) & (~3);
- bits = fence_malloc (height * stride);
- if (!bits)
- return NULL;
- memset (bits, 0xff, height * stride);
- break;
-
- case 4: /* bits is a bad pointer, has read/write functions */
- stride = 232;
- bits = (void *)0x01;
- read_func = fake_reader;
- write_func = fake_writer;
- break;
-
- case 5: /* bits is a real pointer, has read/write functions */
- stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);
- stride = (stride + 3) & (~3);
- bits = fence_malloc (height * stride);
- if (!bits)
- return NULL;
- memset (bits, 0xff, height * stride);
- read_func = real_reader;
- write_func = real_writer;
- break;
-
- case 6: /* bits is a real pointer, stride is negative */
- stride = (width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17));
- stride = (stride + 3) & (~3);
- bits = (uint32_t *)make_random_bytes (height * stride);
- if (!bits)
- return NULL;
- bits += ((height - 1) * stride) / 4;
- stride = - stride;
- break;
- }
-
- /* Filter */
- filter = filters[prng_rand_n (ARRAY_LENGTH (filters))];
- if (filter == PIXMAN_FILTER_CONVOLUTION)
- {
- int width = prng_rand_n (3);
- int height = prng_rand_n (4);
-
- n_coefficients = width * height + 2;
- coefficients = malloc (n_coefficients * sizeof (pixman_fixed_t));
-
- if (coefficients)
- {
- int i;
-
- for (i = 0; i < width * height; ++i)
- coefficients[i + 2] = prng_rand();
-
- coefficients[0] = width << 16;
- coefficients[1] = height << 16;
- }
- else
- {
- filter = PIXMAN_FILTER_BEST;
- }
- }
-
- /* Finally create the image */
- image = pixman_image_create_bits (format, width, height, bits, stride);
- if (!image)
- return NULL;
-
- pixman_image_set_indexed (image, indexed);
- pixman_image_set_destroy_function (image, destroy, indexed);
- pixman_image_set_accessors (image, read_func, write_func);
- pixman_image_set_filter (image, filter, coefficients, n_coefficients);
-
- return image;
-}
-
-static pixman_repeat_t repeats[] =
-{
- PIXMAN_REPEAT_NONE,
- PIXMAN_REPEAT_NORMAL,
- PIXMAN_REPEAT_REFLECT,
- PIXMAN_REPEAT_PAD
-};
-
-static uint32_t
-absolute (int32_t i)
-{
- return i < 0? -i : i;
-}
-
-static void
-set_general_properties (pixman_image_t *image, pixman_bool_t allow_alpha_map)
-{
- pixman_repeat_t repeat;
-
- /* Set properties that are generic to all images */
-
- /* Repeat */
- repeat = repeats[prng_rand_n (ARRAY_LENGTH (repeats))];
- pixman_image_set_repeat (image, repeat);
-
- /* Alpha map */
- if (allow_alpha_map && prng_rand_n (4) == 0)
- {
- pixman_image_t *alpha_map;
- int16_t x, y;
-
- alpha_map = create_random_bits_image (DONT_CARE);
-
- if (alpha_map)
- {
- set_general_properties (alpha_map, FALSE);
-
- x = rand_x (image) - image->bits.width / 2;
- y = rand_y (image) - image->bits.height / 2;
-
- pixman_image_set_alpha_map (image, alpha_map, x, y);
-
- pixman_image_unref (alpha_map);
- }
- }
-
- /* Component alpha */
- pixman_image_set_component_alpha (image, prng_rand_n (3) == 0);
-
- /* Clip region */
- if (prng_rand_n (8) < 2)
- {
- pixman_region32_t region;
- int i, n_rects;
-
- pixman_region32_init (&region);
-
- switch (prng_rand_n (12))
- {
- case 0:
- n_rects = 0;
- break;
-
- case 1: case 2: case 3:
- n_rects = 1;
- break;
-
- case 4: case 5:
- n_rects = 2;
- break;
-
- case 6: case 7:
- n_rects = 3;
- break;
-
- default:
- n_rects = prng_rand_n (100);
- break;
- }
-
- for (i = 0; i < n_rects; ++i)
- {
- uint32_t width, height;
- int x, y;
-
- x = log_rand();
- y = log_rand();
- width = absolute (log_rand ()) + 1;
- height = absolute (log_rand ()) + 1;
-
- pixman_region32_union_rect (
- &region, &region, x, y, width, height);
- }
-
- if (image->type == BITS && prng_rand_n (8) != 0)
- {
- uint32_t width, height;
- int x, y;
- int i;
-
- /* Also add a couple of clip rectangles inside the image
- * so that compositing will actually take place.
- */
- for (i = 0; i < 5; ++i)
- {
- x = prng_rand_n (2 * image->bits.width) - image->bits.width;
- y = prng_rand_n (2 * image->bits.height) - image->bits.height;
- width = prng_rand_n (image->bits.width) - x + 10;
- height = prng_rand_n (image->bits.height) - y + 10;
-
- if (width + x < x)
- width = INT32_MAX - x;
- if (height + y < y)
- height = INT32_MAX - y;
-
- pixman_region32_union_rect (
- &region, &region, x, y, width, height);
- }
- }
-
- pixman_image_set_clip_region32 (image, &region);
-
- pixman_region32_fini (&region);
- }
-
- /* Whether source clipping is enabled */
- pixman_image_set_source_clipping (image, !!prng_rand_n (2));
-
- /* Client clip */
- pixman_image_set_has_client_clip (image, !!prng_rand_n (2));
-
- /* Transform */
- if (prng_rand_n (5) < 2)
- {
- pixman_transform_t xform;
- int i, j, k;
- uint32_t tx, ty, sx, sy;
- uint32_t c, s;
-
- memset (&xform, 0, sizeof xform);
- xform.matrix[0][0] = pixman_fixed_1;
- xform.matrix[1][1] = pixman_fixed_1;
- xform.matrix[2][2] = pixman_fixed_1;
-
- for (k = 0; k < 3; ++k)
- {
- switch (prng_rand_n (4))
- {
- case 0:
- /* rotation */
- c = prng_rand_n (2 * 65536) - 65536;
- s = prng_rand_n (2 * 65536) - 65536;
- pixman_transform_rotate (&xform, NULL, c, s);
- break;
-
- case 1:
- /* translation */
- tx = prng_rand();
- ty = prng_rand();
- pixman_transform_translate (&xform, NULL, tx, ty);
- break;
-
- case 2:
- /* scale */
- sx = prng_rand();
- sy = prng_rand();
- pixman_transform_scale (&xform, NULL, sx, sy);
- break;
-
- case 3:
- if (prng_rand_n (16) == 0)
- {
- /* random */
- for (i = 0; i < 3; ++i)
- for (j = 0; j < 3; ++j)
- xform.matrix[i][j] = prng_rand();
- break;
- }
- else if (prng_rand_n (16) == 0)
- {
- /* zero */
- memset (&xform, 0, sizeof xform);
- }
- break;
- }
- }
-
- pixman_image_set_transform (image, &xform);
- }
-}
-
-static pixman_color_t
-random_color (void)
-{
- pixman_color_t color =
- {
- prng_rand() & 0xffff,
- prng_rand() & 0xffff,
- prng_rand() & 0xffff,
- prng_rand() & 0xffff,
- };
-
- return color;
-}
-
-
-static pixman_image_t *
-create_random_solid_image (void)
-{
- pixman_color_t color = random_color();
- pixman_image_t *image = pixman_image_create_solid_fill (&color);
-
- return image;
-}
-
-static pixman_gradient_stop_t *
-create_random_stops (int *n_stops)
-{
- pixman_fixed_t step;
- pixman_fixed_t s;
- int i;
- pixman_gradient_stop_t *stops;
-
- *n_stops = prng_rand_n (50) + 1;
-
- step = pixman_fixed_1 / *n_stops;
-
- stops = malloc (*n_stops * sizeof (pixman_gradient_stop_t));
-
- s = 0;
- for (i = 0; i < (*n_stops) - 1; ++i)
- {
- stops[i].x = s;
- stops[i].color = random_color();
-
- s += step;
- }
-
- stops[*n_stops - 1].x = pixman_fixed_1;
- stops[*n_stops - 1].color = random_color();
-
- return stops;
-}
-
-static pixman_point_fixed_t
-create_random_point (void)
-{
- pixman_point_fixed_t p;
-
- p.x = log_rand ();
- p.y = log_rand ();
-
- return p;
-}
-
-static pixman_image_t *
-create_random_linear_image (void)
-{
- int n_stops;
- pixman_gradient_stop_t *stops;
- pixman_point_fixed_t p1, p2;
- pixman_image_t *result;
-
- stops = create_random_stops (&n_stops);
- if (!stops)
- return NULL;
-
- p1 = create_random_point ();
- p2 = create_random_point ();
-
- result = pixman_image_create_linear_gradient (&p1, &p2, stops, n_stops);
-
- free (stops);
-
- return result;
-}
-
-static pixman_image_t *
-create_random_radial_image (void)
-{
- int n_stops;
- pixman_gradient_stop_t *stops;
- pixman_point_fixed_t inner_c, outer_c;
- pixman_fixed_t inner_r, outer_r;
- pixman_image_t *result;
-
- inner_c = create_random_point();
- outer_c = create_random_point();
- inner_r = prng_rand();
- outer_r = prng_rand();
-
- stops = create_random_stops (&n_stops);
-
- if (!stops)
- return NULL;
-
- result = pixman_image_create_radial_gradient (
- &inner_c, &outer_c, inner_r, outer_r, stops, n_stops);
-
- free (stops);
-
- return result;
-}
-
-static pixman_image_t *
-create_random_conical_image (void)
-{
- pixman_gradient_stop_t *stops;
- int n_stops;
- pixman_point_fixed_t c;
- pixman_fixed_t angle;
- pixman_image_t *result;
-
- c = create_random_point();
- angle = prng_rand();
-
- stops = create_random_stops (&n_stops);
-
- if (!stops)
- return NULL;
-
- result = pixman_image_create_conical_gradient (&c, angle, stops, n_stops);
-
- free (stops);
-
- return result;
-}
-
-static pixman_image_t *
-create_random_image (void)
-{
- pixman_image_t *result;
-
- switch (prng_rand_n (5))
- {
- default:
- case 0:
- result = create_random_bits_image (DONT_CARE);
- break;
-
- case 1:
- result = create_random_solid_image ();
- break;
-
- case 2:
- result = create_random_linear_image ();
- break;
-
- case 3:
- result = create_random_radial_image ();
- break;
-
- case 4:
- result = create_random_conical_image ();
- break;
- }
-
- if (result)
- set_general_properties (result, TRUE);
-
- return result;
-}
-
-static void
-random_line (pixman_line_fixed_t *line, int width, int height)
-{
- line->p1.x = prng_rand_n (width) << 16;
- line->p1.y = prng_rand_n (height) << 16;
- line->p2.x = prng_rand_n (width) << 16;
- line->p2.y = prng_rand_n (height) << 16;
-}
-
-static pixman_trapezoid_t *
-create_random_trapezoids (int *n_traps, int height, int width)
-{
- pixman_trapezoid_t *trapezoids;
- int i;
-
- *n_traps = prng_rand_n (16) + 1;
-
- trapezoids = malloc (sizeof (pixman_trapezoid_t) * *n_traps);
-
- for (i = 0; i < *n_traps; ++i)
- {
- pixman_trapezoid_t *t = &(trapezoids[i]);
-
- t->top = prng_rand_n (height) << 16;
- t->bottom = prng_rand_n (height) << 16;
-
- random_line (&t->left, height, width);
- random_line (&t->right, height, width);
- }
-
- return trapezoids;
-}
-
-static const 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,
- PIXMAN_OP_SOFT_LIGHT,
- PIXMAN_OP_HSL_HUE,
- PIXMAN_OP_HSL_SATURATION,
- PIXMAN_OP_HSL_COLOR,
- PIXMAN_OP_HSL_LUMINOSITY,
-};
-
-static void
-run_test (uint32_t seed, pixman_bool_t verbose, uint32_t mod)
-{
- pixman_image_t *source, *mask, *dest;
- pixman_op_t op;
-
- if (verbose)
- {
- if (mod == 0 || (seed % mod) == 0)
- printf ("Seed 0x%08x\n", seed);
- }
-
- source = mask = dest = NULL;
-
- prng_srand (seed);
-
- if (prng_rand_n (8) == 0)
- {
- int n_traps;
- pixman_trapezoid_t *trapezoids;
- int p = prng_rand_n (3);
-
- if (p == 0)
- dest = create_random_bits_image (DONT_CARE);
- else
- dest = create_random_bits_image (REQUIRE_ALPHA);
-
- if (!dest)
- goto out;
-
- set_general_properties (dest, TRUE);
-
- if (!(trapezoids = create_random_trapezoids (
- &n_traps, dest->bits.width, dest->bits.height)))
- {
- goto out;
- }
-
- switch (p)
- {
- case 0:
- source = create_random_image ();
-
- if (source)
- {
- op = op_list [prng_rand_n (ARRAY_LENGTH (op_list))];
-
- pixman_composite_trapezoids (
- op, source, dest,
- random_format (REQUIRE_ALPHA),
- rand_x (source), rand_y (source),
- rand_x (dest), rand_y (dest),
- n_traps, trapezoids);
- }
- break;
-
- case 1:
- pixman_rasterize_trapezoid (
- dest, &trapezoids[prng_rand_n (n_traps)],
- rand_x (dest), rand_y (dest));
- break;
-
- case 2:
- pixman_add_trapezoids (
- dest, rand_x (dest), rand_y (dest), n_traps, trapezoids);
- break;
- }
-
- free (trapezoids);
- }
- else
- {
- dest = create_random_bits_image (DONT_CARE);
- source = create_random_image ();
- mask = create_random_image ();
-
- if (source && mask && dest)
- {
- set_general_properties (dest, TRUE);
-
- op = op_list [prng_rand_n (ARRAY_LENGTH (op_list))];
-
- pixman_image_composite32 (op,
- source, mask, dest,
- rand_x (source), rand_y (source),
- rand_x (mask), rand_y (mask),
- 0, 0,
- dest->bits.width,
- dest->bits.height);
- }
- }
-
-out:
- if (source)
- pixman_image_unref (source);
- if (mask)
- pixman_image_unref (mask);
- if (dest)
- pixman_image_unref (dest);
-}
-
-static pixman_bool_t
-get_int (char *s, uint32_t *i)
-{
- char *end;
- int p;
-
- p = strtol (s, &end, 0);
-
- if (end != s && *end == 0)
- {
- *i = p;
- return TRUE;
- }
-
- return FALSE;
-}
-
-int
-main (int argc, char **argv)
-{
- int verbose = FALSE;
- uint32_t seed = 1;
- uint32_t n_tests = 8000;
- uint32_t mod = 0;
- pixman_bool_t use_threads = TRUE;
- int32_t i;
-
- pixman_disable_out_of_bounds_workaround ();
-
- enable_divbyzero_exceptions();
-
- if (getenv ("VERBOSE") != NULL)
- verbose = TRUE;
-
- for (i = 1; i < argc; ++i)
- {
- if (strcmp (argv[i], "-v") == 0)
- {
- verbose = TRUE;
-
- if (i + 1 < argc)
- {
- get_int (argv[i + 1], &mod);
- i++;
- }
- }
- else if (strcmp (argv[i], "-s") == 0 && i + 1 < argc)
- {
- get_int (argv[i + 1], &seed);
- use_threads = FALSE;
- i++;
- }
- else if (strcmp (argv[i], "-n") == 0 && i + 1 < argc)
- {
- get_int (argv[i + 1], &n_tests);
- i++;
- }
- else
- {
- if (strcmp (argv[i], "-h") != 0)
- printf ("Unknown option '%s'\n\n", argv[i]);
-
- printf ("Options:\n\n"
- "-n <number> Number of tests to run\n"
- "-s <seed> Seed of first test (ignored if PIXMAN_RANDOMIZE_TESTS is set)\n"
- "-v Print out seeds\n"
- "-v <n> Print out every n'th seed\n\n");
-
- exit (-1);
- }
- }
-
- if (getenv ("PIXMAN_RANDOMIZE_TESTS"))
- {
- seed = get_random_seed();
- printf ("First seed: 0x%08x\n", seed);
- }
-
- if (use_threads)
- {
-#ifdef USE_OPENMP
-# pragma omp parallel for default(none) shared(verbose, n_tests, mod, seed)
-#endif
- for (i = 0; i < (int32_t)n_tests; ++i)
- run_test (seed + i, verbose, mod);
- }
- else
- {
- for (i = 0; i < (int32_t)n_tests; ++i)
- run_test (seed + i, verbose, mod);
- }
-
- return 0;
-}
diff --git a/qemu/pixman/test/thread-test.c b/qemu/pixman/test/thread-test.c
deleted file mode 100644
index 0b07b269d..000000000
--- a/qemu/pixman/test/thread-test.c
+++ /dev/null
@@ -1,199 +0,0 @@
-#include "utils.h"
-
-#ifndef HAVE_PTHREADS
-
-int main ()
-{
- printf ("Skipped thread-test - pthreads not supported\n");
- return 0;
-}
-
-#else
-
-#include <stdlib.h>
-#include <pthread.h>
-
-typedef struct
-{
- int thread_no;
- uint32_t *dst_buf;
- prng_t prng_state;
-} info_t;
-
-static const pixman_op_t operators[] =
-{
- 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,
-};
-
-static const pixman_format_code_t formats[] =
-{
- PIXMAN_a8r8g8b8,
- PIXMAN_r5g6b5,
- PIXMAN_a8,
- PIXMAN_a4,
- PIXMAN_a1,
- PIXMAN_b5g6r5,
- PIXMAN_r8g8b8a8,
- PIXMAN_a4r4g4b4
-};
-
-#define N_ROUNDS 8192
-
-#define RAND_ELT(arr) \
- arr[prng_rand_r(&info->prng_state) % ARRAY_LENGTH (arr)]
-
-#define DEST_WIDTH (7)
-
-static void *
-thread (void *data)
-{
- info_t *info = data;
- uint32_t crc32 = 0x0;
- uint32_t src_buf[64];
- pixman_image_t *dst_img, *src_img;
- int i;
-
- prng_srand_r (&info->prng_state, info->thread_no);
-
- for (i = 0; i < N_ROUNDS; ++i)
- {
- pixman_op_t op;
- int rand1, rand2;
-
- prng_randmemset_r (&info->prng_state, info->dst_buf,
- DEST_WIDTH * sizeof (uint32_t), 0);
- prng_randmemset_r (&info->prng_state, src_buf,
- sizeof (src_buf), 0);
-
- src_img = pixman_image_create_bits (
- RAND_ELT (formats), 4, 4, src_buf, 16);
- dst_img = pixman_image_create_bits (
- RAND_ELT (formats), DEST_WIDTH, 1, info->dst_buf,
- DEST_WIDTH * sizeof (uint32_t));
-
- image_endian_swap (src_img);
- image_endian_swap (dst_img);
-
- rand2 = prng_rand_r (&info->prng_state) % 4;
- rand1 = prng_rand_r (&info->prng_state) % 4;
- op = RAND_ELT (operators);
-
- pixman_image_composite32 (
- op,
- src_img, NULL, dst_img,
- rand1, rand2, 0, 0, 0, 0, DEST_WIDTH, 1);
-
- crc32 = compute_crc32_for_image (crc32, dst_img);
-
- pixman_image_unref (src_img);
- pixman_image_unref (dst_img);
- }
-
- return (void *)(uintptr_t)crc32;
-}
-
-static inline uint32_t
-byteswap32 (uint32_t x)
-{
- return ((x & ((uint32_t)0xFF << 24)) >> 24) |
- ((x & ((uint32_t)0xFF << 16)) >> 8) |
- ((x & ((uint32_t)0xFF << 8)) << 8) |
- ((x & ((uint32_t)0xFF << 0)) << 24);
-}
-
-int
-main (void)
-{
- uint32_t dest[16 * DEST_WIDTH];
- info_t info[16] = { { 0 } };
- pthread_t threads[16];
- void *retvals[16];
- uint32_t crc32s[16], crc32;
- int i;
-
- for (i = 0; i < 16; ++i)
- {
- info[i].thread_no = i;
- info[i].dst_buf = &dest[i * DEST_WIDTH];
- }
-
- for (i = 0; i < 16; ++i)
- pthread_create (&threads[i], NULL, thread, &info[i]);
-
- for (i = 0; i < 16; ++i)
- pthread_join (threads[i], &retvals[i]);
-
- for (i = 0; i < 16; ++i)
- {
- crc32s[i] = (uintptr_t)retvals[i];
-
- if (is_little_endian())
- crc32s[i] = byteswap32 (crc32s[i]);
- }
-
- crc32 = compute_crc32 (0, crc32s, sizeof crc32s);
-
-#define EXPECTED 0xE299B18E
-
- if (crc32 != EXPECTED)
- {
- printf ("thread-test failed. Got checksum 0x%08X, expected 0x%08X\n",
- crc32, EXPECTED);
- return 1;
- }
-
- return 0;
-}
-
-#endif
-
diff --git a/qemu/pixman/test/trap-crasher.c b/qemu/pixman/test/trap-crasher.c
deleted file mode 100644
index 77be1c98b..000000000
--- a/qemu/pixman/test/trap-crasher.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <stdlib.h>
-#include "utils.h"
-
-int
-main()
-{
- pixman_image_t *dst;
- pixman_trapezoid_t traps[] = {
- {
- 2147483646,
- 2147483647,
- {
- { 0, 0 },
- { 0, 2147483647 }
- },
- {
- { 65536, 0 },
- { 0, 2147483647 }
- }
- },
- {
- 32768,
- - 2147483647,
- {
- { 0, 0 },
- { 0, 2147483647 }
- },
- {
- { 65536, 0 },
- { 0, 2147483647 }
- }
- },
- };
-
- dst = pixman_image_create_bits (PIXMAN_a8, 1, 1, NULL, -1);
-
- pixman_add_trapezoids (dst, 0, 0, ARRAY_LENGTH (traps), traps);
- return (0);
-}
diff --git a/qemu/pixman/test/utils-prng.c b/qemu/pixman/test/utils-prng.c
deleted file mode 100644
index c27b5be83..000000000
--- a/qemu/pixman/test/utils-prng.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright © 2012 Siarhei Siamashka <siarhei.siamashka@gmail.com>
- *
- * Based on the public domain implementation of small noncryptographic PRNG
- * authored by Bob Jenkins: http://burtleburtle.net/bob/rand/smallprng.html
- *
- * 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 (including the next
- * paragraph) 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.
- */
-
-#include "utils.h"
-#include "utils-prng.h"
-
-#if defined(HAVE_GCC_VECTOR_EXTENSIONS) && defined(__SSE2__)
-#include <xmmintrin.h>
-#endif
-
-void smallprng_srand_r (smallprng_t *x, uint32_t seed)
-{
- uint32_t i;
- x->a = 0xf1ea5eed, x->b = x->c = x->d = seed;
- for (i = 0; i < 20; ++i)
- smallprng_rand_r (x);
-}
-
-/*
- * Set a 32-bit seed for PRNG
- *
- * LCG is used here for generating independent seeds for different
- * smallprng instances (in the case if smallprng is also used for
- * generating these seeds, "Big Crush" test from TestU01 detects
- * some problems in the glued 'prng_rand_128_r' output data).
- * Actually we might be even better using some cryptographic
- * hash for this purpose, but LCG seems to be also enough for
- * passing "Big Crush".
- */
-void prng_srand_r (prng_t *x, uint32_t seed)
-{
-#ifdef HAVE_GCC_VECTOR_EXTENSIONS
- int i;
- prng_rand_128_data_t dummy;
- smallprng_srand_r (&x->p0, seed);
- x->a[0] = x->a[1] = x->a[2] = x->a[3] = 0xf1ea5eed;
- x->b[0] = x->c[0] = x->d[0] = (seed = seed * 1103515245 + 12345);
- x->b[1] = x->c[1] = x->d[1] = (seed = seed * 1103515245 + 12345);
- x->b[2] = x->c[2] = x->d[2] = (seed = seed * 1103515245 + 12345);
- x->b[3] = x->c[3] = x->d[3] = (seed = seed * 1103515245 + 12345);
- for (i = 0; i < 20; ++i)
- prng_rand_128_r (x, &dummy);
-#else
- smallprng_srand_r (&x->p0, seed);
- smallprng_srand_r (&x->p1, (seed = seed * 1103515245 + 12345));
- smallprng_srand_r (&x->p2, (seed = seed * 1103515245 + 12345));
- smallprng_srand_r (&x->p3, (seed = seed * 1103515245 + 12345));
- smallprng_srand_r (&x->p4, (seed = seed * 1103515245 + 12345));
-#endif
-}
-
-static force_inline void
-store_rand_128_data (void *addr, prng_rand_128_data_t *d, int aligned)
-{
-#ifdef HAVE_GCC_VECTOR_EXTENSIONS
- if (aligned)
- {
- *(uint8x16 *)addr = d->vb;
- return;
- }
- else
- {
-#ifdef __SSE2__
- /* workaround for http://gcc.gnu.org/PR55614 */
- _mm_storeu_si128 (addr, _mm_loadu_si128 ((__m128i *)d));
- return;
-#endif
- }
-#endif
- /* we could try something better for unaligned writes (packed attribute),
- * but GCC is not very reliable: http://gcc.gnu.org/PR55454 */
- memcpy (addr, d, 16);
-}
-
-/*
- * Helper function and the actual code for "prng_randmemset_r" function
- */
-static force_inline void
-randmemset_internal (prng_t *prng,
- uint8_t *buf,
- size_t size,
- prng_randmemset_flags_t flags,
- int aligned)
-{
- prng_t local_prng = *prng;
- prng_rand_128_data_t randdata;
- size_t i;
-
- while (size >= 16)
- {
- prng_rand_128_data_t t;
- if (flags == 0)
- {
- prng_rand_128_r (&local_prng, &randdata);
- }
- else
- {
- prng_rand_128_r (&local_prng, &t);
- prng_rand_128_r (&local_prng, &randdata);
-#ifdef HAVE_GCC_VECTOR_EXTENSIONS
- if (flags & RANDMEMSET_MORE_FF)
- {
- const uint8x16 const_C0 =
- {
- 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
- 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0
- };
- randdata.vb |= (t.vb >= const_C0);
- }
- if (flags & RANDMEMSET_MORE_00)
- {
- const uint8x16 const_40 =
- {
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40
- };
- randdata.vb &= (t.vb >= const_40);
- }
- if (flags & RANDMEMSET_MORE_FFFFFFFF)
- {
- const uint32x4 const_C0000000 =
- {
- 0xC0000000, 0xC0000000, 0xC0000000, 0xC0000000
- };
- randdata.vw |= ((t.vw << 30) >= const_C0000000);
- }
- if (flags & RANDMEMSET_MORE_00000000)
- {
- const uint32x4 const_40000000 =
- {
- 0x40000000, 0x40000000, 0x40000000, 0x40000000
- };
- randdata.vw &= ((t.vw << 30) >= const_40000000);
- }
-#else
- #define PROCESS_ONE_LANE(i) \
- if (flags & RANDMEMSET_MORE_FF) \
- { \
- uint32_t mask_ff = (t.w[i] & (t.w[i] << 1)) & 0x80808080; \
- mask_ff |= mask_ff >> 1; \
- mask_ff |= mask_ff >> 2; \
- mask_ff |= mask_ff >> 4; \
- randdata.w[i] |= mask_ff; \
- } \
- if (flags & RANDMEMSET_MORE_00) \
- { \
- uint32_t mask_00 = (t.w[i] | (t.w[i] << 1)) & 0x80808080; \
- mask_00 |= mask_00 >> 1; \
- mask_00 |= mask_00 >> 2; \
- mask_00 |= mask_00 >> 4; \
- randdata.w[i] &= mask_00; \
- } \
- if (flags & RANDMEMSET_MORE_FFFFFFFF) \
- { \
- int32_t mask_ff = ((t.w[i] << 30) & (t.w[i] << 31)) & \
- 0x80000000; \
- randdata.w[i] |= mask_ff >> 31; \
- } \
- if (flags & RANDMEMSET_MORE_00000000) \
- { \
- int32_t mask_00 = ((t.w[i] << 30) | (t.w[i] << 31)) & \
- 0x80000000; \
- randdata.w[i] &= mask_00 >> 31; \
- }
-
- PROCESS_ONE_LANE (0)
- PROCESS_ONE_LANE (1)
- PROCESS_ONE_LANE (2)
- PROCESS_ONE_LANE (3)
-#endif
- }
- if (is_little_endian ())
- {
- store_rand_128_data (buf, &randdata, aligned);
- buf += 16;
- }
- else
- {
-#ifdef HAVE_GCC_VECTOR_EXTENSIONS
- const uint8x16 bswap_shufflemask =
- {
- 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
- };
- randdata.vb = __builtin_shuffle (randdata.vb, bswap_shufflemask);
- store_rand_128_data (buf, &randdata, aligned);
- buf += 16;
-#else
- uint8_t t1, t2, t3, t4;
- #define STORE_ONE_LANE(i) \
- t1 = randdata.b[i * 4 + 3]; \
- t2 = randdata.b[i * 4 + 2]; \
- t3 = randdata.b[i * 4 + 1]; \
- t4 = randdata.b[i * 4 + 0]; \
- *buf++ = t1; \
- *buf++ = t2; \
- *buf++ = t3; \
- *buf++ = t4;
-
- STORE_ONE_LANE (0)
- STORE_ONE_LANE (1)
- STORE_ONE_LANE (2)
- STORE_ONE_LANE (3)
-#endif
- }
- size -= 16;
- }
- i = 0;
- while (i < size)
- {
- uint8_t randbyte = prng_rand_r (&local_prng) & 0xFF;
- if (flags != 0)
- {
- uint8_t t = prng_rand_r (&local_prng) & 0xFF;
- if ((flags & RANDMEMSET_MORE_FF) && (t >= 0xC0))
- randbyte = 0xFF;
- if ((flags & RANDMEMSET_MORE_00) && (t < 0x40))
- randbyte = 0x00;
- if (i % 4 == 0 && i + 4 <= size)
- {
- t = prng_rand_r (&local_prng) & 0xFF;
- if ((flags & RANDMEMSET_MORE_FFFFFFFF) && (t >= 0xC0))
- {
- memset(&buf[i], 0xFF, 4);
- i += 4;
- continue;
- }
- if ((flags & RANDMEMSET_MORE_00000000) && (t < 0x40))
- {
- memset(&buf[i], 0x00, 4);
- i += 4;
- continue;
- }
- }
- }
- buf[i] = randbyte;
- i++;
- }
- *prng = local_prng;
-}
-
-/*
- * Fill memory buffer with random data. Flags argument may be used
- * to tweak some statistics properties:
- * RANDMEMSET_MORE_00 - set ~25% of bytes to 0x00
- * RANDMEMSET_MORE_FF - set ~25% of bytes to 0xFF
- * RANDMEMSET_MORE_00000000 - ~25% chance for 00000000 4-byte clusters
- * RANDMEMSET_MORE_FFFFFFFF - ~25% chance for FFFFFFFF 4-byte clusters
- */
-void prng_randmemset_r (prng_t *prng,
- void *voidbuf,
- size_t size,
- prng_randmemset_flags_t flags)
-{
- uint8_t *buf = (uint8_t *)voidbuf;
- if ((uintptr_t)buf & 15)
- {
- /* unaligned buffer */
- if (flags == 0)
- randmemset_internal (prng, buf, size, 0, 0);
- else if (flags == RANDMEMSET_MORE_00_AND_FF)
- randmemset_internal (prng, buf, size, RANDMEMSET_MORE_00_AND_FF, 0);
- else
- randmemset_internal (prng, buf, size, flags, 0);
- }
- else
- {
- /* aligned buffer */
- if (flags == 0)
- randmemset_internal (prng, buf, size, 0, 1);
- else if (flags == RANDMEMSET_MORE_00_AND_FF)
- randmemset_internal (prng, buf, size, RANDMEMSET_MORE_00_AND_FF, 1);
- else
- randmemset_internal (prng, buf, size, flags, 1);
- }
-}
diff --git a/qemu/pixman/test/utils-prng.h b/qemu/pixman/test/utils-prng.h
deleted file mode 100644
index f9ae8ddf7..000000000
--- a/qemu/pixman/test/utils-prng.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright © 2012 Siarhei Siamashka <siarhei.siamashka@gmail.com>
- *
- * Based on the public domain implementation of small noncryptographic PRNG
- * authored by Bob Jenkins: http://burtleburtle.net/bob/rand/smallprng.html
- *
- * 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 (including the next
- * paragraph) 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.
- */
-
-#ifndef __UTILS_PRNG_H__
-#define __UTILS_PRNG_H__
-
-/*
- * This file provides a fast SIMD-optimized noncryptographic PRNG (pseudorandom
- * number generator), with the output good enough to pass "Big Crush" tests
- * from TestU01 (http://en.wikipedia.org/wiki/TestU01).
- *
- * SIMD code uses http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
- * which is a GCC specific extension. There is also a slower alternative
- * code path, which should work with any C compiler.
- *
- * The "prng_t" structure keeps the internal state of the random number
- * generator. It is possible to have multiple instances of the random number
- * generator active at the same time, in this case each of them needs to have
- * its own "prng_t". All the functions take a pointer to "prng_t"
- * as the first argument.
- *
- * Functions:
- *
- * ----------------------------------------------------------------------------
- * void prng_srand_r (prng_t *prng, uint32_t seed);
- *
- * Initialize the pseudorandom number generator. The sequence of preudorandom
- * numbers is deterministic and only depends on "seed". Any two generators
- * initialized with the same seed will produce exactly the same sequence.
- *
- * ----------------------------------------------------------------------------
- * uint32_t prng_rand_r (prng_t *prng);
- *
- * Generate a single uniformly distributed 32-bit pseudorandom value.
- *
- * ----------------------------------------------------------------------------
- * void prng_randmemset_r (prng_t *prng,
- * void *buffer,
- * size_t size,
- * prng_randmemset_flags_t flags);
- *
- * Fills the memory buffer "buffer" with "size" bytes of pseudorandom data.
- * The "flags" argument may be used to tweak some statistics properties:
- * RANDMEMSET_MORE_00 - set ~25% of bytes to 0x00
- * RANDMEMSET_MORE_FF - set ~25% of bytes to 0xFF
- * The flags can be combined. This allows a bit better simulation of typical
- * pixel data, which normally contains a lot of fully transparent or fully
- * opaque pixels.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "pixman-private.h"
-
-/*****************************************************************************/
-
-#ifdef HAVE_GCC_VECTOR_EXTENSIONS
-typedef uint32_t uint32x4 __attribute__ ((vector_size(16)));
-typedef uint8_t uint8x16 __attribute__ ((vector_size(16)));
-#endif
-
-typedef struct
-{
- uint32_t a, b, c, d;
-} smallprng_t;
-
-typedef struct
-{
-#ifdef HAVE_GCC_VECTOR_EXTENSIONS
- uint32x4 a, b, c, d;
-#else
- smallprng_t p1, p2, p3, p4;
-#endif
- smallprng_t p0;
-} prng_t;
-
-typedef union
-{
- uint8_t b[16];
- uint32_t w[4];
-#ifdef HAVE_GCC_VECTOR_EXTENSIONS
- uint8x16 vb;
- uint32x4 vw;
-#endif
-} prng_rand_128_data_t;
-
-/*****************************************************************************/
-
-static force_inline uint32_t
-smallprng_rand_r (smallprng_t *x)
-{
- uint32_t e = x->a - ((x->b << 27) + (x->b >> (32 - 27)));
- x->a = x->b ^ ((x->c << 17) ^ (x->c >> (32 - 17)));
- x->b = x->c + x->d;
- x->c = x->d + e;
- x->d = e + x->a;
- return x->d;
-}
-
-/* Generate 4 bytes (32-bits) of random data */
-static force_inline uint32_t
-prng_rand_r (prng_t *x)
-{
- return smallprng_rand_r (&x->p0);
-}
-
-/* Generate 16 bytes (128-bits) of random data */
-static force_inline void
-prng_rand_128_r (prng_t *x, prng_rand_128_data_t *data)
-{
-#ifdef HAVE_GCC_VECTOR_EXTENSIONS
- uint32x4 e = x->a - ((x->b << 27) + (x->b >> (32 - 27)));
- x->a = x->b ^ ((x->c << 17) ^ (x->c >> (32 - 17)));
- x->b = x->c + x->d;
- x->c = x->d + e;
- x->d = e + x->a;
- data->vw = x->d;
-#else
- data->w[0] = smallprng_rand_r (&x->p1);
- data->w[1] = smallprng_rand_r (&x->p2);
- data->w[2] = smallprng_rand_r (&x->p3);
- data->w[3] = smallprng_rand_r (&x->p4);
-#endif
-}
-
-typedef enum
-{
- RANDMEMSET_MORE_00 = 1, /* ~25% chance for 0x00 bytes */
- RANDMEMSET_MORE_FF = 2, /* ~25% chance for 0xFF bytes */
- RANDMEMSET_MORE_00000000 = 4, /* ~25% chance for 0x00000000 clusters */
- RANDMEMSET_MORE_FFFFFFFF = 8, /* ~25% chance for 0xFFFFFFFF clusters */
- RANDMEMSET_MORE_00_AND_FF = (RANDMEMSET_MORE_00 | RANDMEMSET_MORE_00000000 |
- RANDMEMSET_MORE_FF | RANDMEMSET_MORE_FFFFFFFF)
-} prng_randmemset_flags_t;
-
-/* Set the 32-bit seed for PRNG */
-void prng_srand_r (prng_t *prng, uint32_t seed);
-
-/* Fill memory buffer with random data */
-void prng_randmemset_r (prng_t *prng,
- void *buffer,
- size_t size,
- prng_randmemset_flags_t flags);
-
-#endif
diff --git a/qemu/pixman/test/utils.c b/qemu/pixman/test/utils.c
deleted file mode 100644
index ebe0ccc09..000000000
--- a/qemu/pixman/test/utils.c
+++ /dev/null
@@ -1,1618 +0,0 @@
-#define _GNU_SOURCE
-
-#include "utils.h"
-#include <math.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 generator state
- */
-
-prng_t prng_state_data;
-prng_t *prng_state;
-
-/*----------------------------------------------------------------------------*\
- * 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);
-}
-
-static uint32_t
-compute_crc32_for_image_internal (uint32_t crc32,
- pixman_image_t *img,
- pixman_bool_t remove_alpha,
- pixman_bool_t remove_rgb)
-{
- pixman_format_code_t fmt = pixman_image_get_format (img);
- uint32_t *data = pixman_image_get_data (img);
- int stride = pixman_image_get_stride (img);
- int height = pixman_image_get_height (img);
- uint32_t mask = 0xffffffff;
- int i;
-
- if (stride < 0)
- {
- data += (stride / 4) * (height - 1);
- stride = - stride;
- }
-
- /* mask unused 'x' part */
- if (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt) &&
- PIXMAN_FORMAT_DEPTH (fmt) != 0)
- {
- uint32_t m = (1 << PIXMAN_FORMAT_DEPTH (fmt)) - 1;
-
- if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA ||
- PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_RGBA)
- {
- m <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
- }
-
- mask &= m;
- }
-
- /* mask alpha channel */
- if (remove_alpha && PIXMAN_FORMAT_A (fmt))
- {
- uint32_t m;
-
- if (PIXMAN_FORMAT_BPP (fmt) == 32)
- m = 0xffffffff;
- else
- m = (1 << PIXMAN_FORMAT_BPP (fmt)) - 1;
-
- m >>= PIXMAN_FORMAT_A (fmt);
-
- if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA ||
- PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_RGBA ||
- PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_A)
- {
- /* Alpha is at the bottom of the pixel */
- m <<= PIXMAN_FORMAT_A (fmt);
- }
-
- mask &= m;
- }
-
- /* mask rgb channels */
- if (remove_rgb && PIXMAN_FORMAT_RGB (fmt))
- {
- uint32_t m = ((uint32_t)~0) >> (32 - PIXMAN_FORMAT_BPP (fmt));
- uint32_t size = PIXMAN_FORMAT_R (fmt) + PIXMAN_FORMAT_G (fmt) + PIXMAN_FORMAT_B (fmt);
-
- m &= ~((1 << size) - 1);
-
- if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA ||
- PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_RGBA)
- {
- /* RGB channels are at the top of the pixel */
- m >>= size;
- }
-
- mask &= m;
- }
-
- 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);
-
- return compute_crc32 (crc32, data, stride * height);
-}
-
-uint32_t
-compute_crc32_for_image (uint32_t crc32,
- pixman_image_t *img)
-{
- if (img->common.alpha_map)
- {
- crc32 = compute_crc32_for_image_internal (crc32, img, TRUE, FALSE);
- crc32 = compute_crc32_for_image_internal (
- crc32, (pixman_image_t *)img->common.alpha_map, FALSE, TRUE);
- }
- else
- {
- crc32 = compute_crc32_for_image_internal (crc32, img, FALSE, FALSE);
- }
-
- return crc32;
-}
-
-void
-print_image (pixman_image_t *image)
-{
- int i, j;
- int width, height, stride;
- pixman_format_code_t format;
- uint8_t *buffer;
- int s;
-
- width = pixman_image_get_width (image);
- height = pixman_image_get_height (image);
- stride = pixman_image_get_stride (image);
- format = pixman_image_get_format (image);
- buffer = (uint8_t *)pixman_image_get_data (image);
-
- s = (stride >= 0)? stride : - stride;
-
- printf ("---\n");
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < s; j++)
- {
- if (j == (width * PIXMAN_FORMAT_BPP (format) + 7) / 8)
- printf ("| ");
-
- printf ("%02X ", *((uint8_t *)buffer + i * stride + j));
- }
- printf ("\n");
- }
- printf ("---\n");
-}
-
-/* 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;
- int s = (stride >= 0)? stride : - stride;
-
- switch (bpp)
- {
- case 1:
- for (j = 0; j < s; 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 < s; j++)
- {
- line_data[j] = (line_data[j] >> 4) | (line_data[j] << 4);
- }
- break;
- case 16:
- for (j = 0; j + 2 <= s; 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 <= s; 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 <= s; 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 *)(((uintptr_t)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);
-
- if (!bytes)
- return NULL;
-
- prng_randmemset (bytes, n_bytes, 0);
-
- 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
-
-static void
-color8_to_color16 (uint32_t color8, pixman_color_t *color16)
-{
- color16->alpha = ((color8 & 0xff000000) >> 24);
- color16->red = ((color8 & 0x00ff0000) >> 16);
- color16->green = ((color8 & 0x0000ff00) >> 8);
- color16->blue = ((color8 & 0x000000ff) >> 0);
-
- color16->alpha |= color16->alpha << 8;
- color16->red |= color16->red << 8;
- color16->blue |= color16->blue << 8;
- color16->green |= color16->green << 8;
-}
-
-void
-draw_checkerboard (pixman_image_t *image,
- int check_size,
- uint32_t color1, uint32_t color2)
-{
- pixman_color_t check1, check2;
- pixman_image_t *c1, *c2;
- int n_checks_x, n_checks_y;
- int i, j;
-
- color8_to_color16 (color1, &check1);
- color8_to_color16 (color2, &check2);
-
- c1 = pixman_image_create_solid_fill (&check1);
- c2 = pixman_image_create_solid_fill (&check2);
-
- n_checks_x = (
- pixman_image_get_width (image) + check_size - 1) / check_size;
- n_checks_y = (
- pixman_image_get_height (image) + check_size - 1) / check_size;
-
- for (j = 0; j < n_checks_y; j++)
- {
- for (i = 0; i < n_checks_x; i++)
- {
- pixman_image_t *src;
-
- if (((i ^ j) & 1))
- src = c1;
- else
- src = c2;
-
- pixman_image_composite32 (PIXMAN_OP_SRC, src, NULL, image,
- 0, 0, 0, 0,
- i * check_size, j * check_size,
- check_size, check_size);
- }
- }
-}
-
-static uint32_t
-call_test_function (uint32_t (*test_function)(int testnum, int verbose),
- int testnum,
- int verbose)
-{
- uint32_t retval;
-
-#if defined (__GNUC__) && defined (_WIN32) && (defined (__i386) || defined (__i386__))
- __asm__ (
- /* Deliberately avoid aligning the stack to 16 bytes */
- "pushl %1\n\t"
- "pushl %2\n\t"
- "call *%3\n\t"
- "addl $8, %%esp\n\t"
- : "=a" (retval)
- : "r" (verbose),
- "r" (testnum),
- "r" (test_function)
- : "edx", "ecx"); /* caller save registers */
-#else
- retval = test_function (testnum, verbose);
-#endif
-
- return retval;
-}
-
-/*
- * 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 = call_test_function (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 = call_test_function (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)
-{
- union { double d; uint32_t u32; } t;
- t.d = gettime();
- prng_srand (t.u32);
-
- return prng_rand ();
-}
-
-#ifdef HAVE_SIGACTION
-#ifdef HAVE_ALARM
-static const char *global_msg;
-
-static void
-on_alarm (int signo)
-{
- printf ("%s\n", global_msg);
- exit (1);
-}
-#endif
-#endif
-
-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_divbyzero_exceptions (void)
-{
-#ifdef HAVE_FENV_H
-#ifdef HAVE_FEENABLEEXCEPT
- feenableexcept (FE_DIVBYZERO);
-#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))
-
-double
-convert_srgb_to_linear (double c)
-{
- if (c <= 0.04045)
- return c / 12.92;
- else
- return pow ((c + 0.055) / 1.055, 2.4);
-}
-
-double
-convert_linear_to_srgb (double c)
-{
- if (c <= 0.0031308)
- return c * 12.92;
- else
- return 1.055 * pow (c, 1.0/2.4) - 0.055;
-}
-
-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] = prng_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 = prng_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);
- }
-}
-
-const char *
-operator_name (pixman_op_t op)
-{
- switch (op)
- {
- case PIXMAN_OP_CLEAR: return "PIXMAN_OP_CLEAR";
- case PIXMAN_OP_SRC: return "PIXMAN_OP_SRC";
- case PIXMAN_OP_DST: return "PIXMAN_OP_DST";
- case PIXMAN_OP_OVER: return "PIXMAN_OP_OVER";
- case PIXMAN_OP_OVER_REVERSE: return "PIXMAN_OP_OVER_REVERSE";
- case PIXMAN_OP_IN: return "PIXMAN_OP_IN";
- case PIXMAN_OP_IN_REVERSE: return "PIXMAN_OP_IN_REVERSE";
- case PIXMAN_OP_OUT: return "PIXMAN_OP_OUT";
- case PIXMAN_OP_OUT_REVERSE: return "PIXMAN_OP_OUT_REVERSE";
- case PIXMAN_OP_ATOP: return "PIXMAN_OP_ATOP";
- case PIXMAN_OP_ATOP_REVERSE: return "PIXMAN_OP_ATOP_REVERSE";
- case PIXMAN_OP_XOR: return "PIXMAN_OP_XOR";
- case PIXMAN_OP_ADD: return "PIXMAN_OP_ADD";
- case PIXMAN_OP_SATURATE: return "PIXMAN_OP_SATURATE";
-
- case PIXMAN_OP_DISJOINT_CLEAR: return "PIXMAN_OP_DISJOINT_CLEAR";
- case PIXMAN_OP_DISJOINT_SRC: return "PIXMAN_OP_DISJOINT_SRC";
- case PIXMAN_OP_DISJOINT_DST: return "PIXMAN_OP_DISJOINT_DST";
- case PIXMAN_OP_DISJOINT_OVER: return "PIXMAN_OP_DISJOINT_OVER";
- case PIXMAN_OP_DISJOINT_OVER_REVERSE: return "PIXMAN_OP_DISJOINT_OVER_REVERSE";
- case PIXMAN_OP_DISJOINT_IN: return "PIXMAN_OP_DISJOINT_IN";
- case PIXMAN_OP_DISJOINT_IN_REVERSE: return "PIXMAN_OP_DISJOINT_IN_REVERSE";
- case PIXMAN_OP_DISJOINT_OUT: return "PIXMAN_OP_DISJOINT_OUT";
- case PIXMAN_OP_DISJOINT_OUT_REVERSE: return "PIXMAN_OP_DISJOINT_OUT_REVERSE";
- case PIXMAN_OP_DISJOINT_ATOP: return "PIXMAN_OP_DISJOINT_ATOP";
- case PIXMAN_OP_DISJOINT_ATOP_REVERSE: return "PIXMAN_OP_DISJOINT_ATOP_REVERSE";
- case PIXMAN_OP_DISJOINT_XOR: return "PIXMAN_OP_DISJOINT_XOR";
-
- case PIXMAN_OP_CONJOINT_CLEAR: return "PIXMAN_OP_CONJOINT_CLEAR";
- case PIXMAN_OP_CONJOINT_SRC: return "PIXMAN_OP_CONJOINT_SRC";
- case PIXMAN_OP_CONJOINT_DST: return "PIXMAN_OP_CONJOINT_DST";
- case PIXMAN_OP_CONJOINT_OVER: return "PIXMAN_OP_CONJOINT_OVER";
- case PIXMAN_OP_CONJOINT_OVER_REVERSE: return "PIXMAN_OP_CONJOINT_OVER_REVERSE";
- case PIXMAN_OP_CONJOINT_IN: return "PIXMAN_OP_CONJOINT_IN";
- case PIXMAN_OP_CONJOINT_IN_REVERSE: return "PIXMAN_OP_CONJOINT_IN_REVERSE";
- case PIXMAN_OP_CONJOINT_OUT: return "PIXMAN_OP_CONJOINT_OUT";
- case PIXMAN_OP_CONJOINT_OUT_REVERSE: return "PIXMAN_OP_CONJOINT_OUT_REVERSE";
- case PIXMAN_OP_CONJOINT_ATOP: return "PIXMAN_OP_CONJOINT_ATOP";
- case PIXMAN_OP_CONJOINT_ATOP_REVERSE: return "PIXMAN_OP_CONJOINT_ATOP_REVERSE";
- case PIXMAN_OP_CONJOINT_XOR: return "PIXMAN_OP_CONJOINT_XOR";
-
- case PIXMAN_OP_MULTIPLY: return "PIXMAN_OP_MULTIPLY";
- case PIXMAN_OP_SCREEN: return "PIXMAN_OP_SCREEN";
- case PIXMAN_OP_OVERLAY: return "PIXMAN_OP_OVERLAY";
- case PIXMAN_OP_DARKEN: return "PIXMAN_OP_DARKEN";
- case PIXMAN_OP_LIGHTEN: return "PIXMAN_OP_LIGHTEN";
- case PIXMAN_OP_COLOR_DODGE: return "PIXMAN_OP_COLOR_DODGE";
- case PIXMAN_OP_COLOR_BURN: return "PIXMAN_OP_COLOR_BURN";
- case PIXMAN_OP_HARD_LIGHT: return "PIXMAN_OP_HARD_LIGHT";
- case PIXMAN_OP_SOFT_LIGHT: return "PIXMAN_OP_SOFT_LIGHT";
- case PIXMAN_OP_DIFFERENCE: return "PIXMAN_OP_DIFFERENCE";
- case PIXMAN_OP_EXCLUSION: return "PIXMAN_OP_EXCLUSION";
- case PIXMAN_OP_HSL_HUE: return "PIXMAN_OP_HSL_HUE";
- case PIXMAN_OP_HSL_SATURATION: return "PIXMAN_OP_HSL_SATURATION";
- case PIXMAN_OP_HSL_COLOR: return "PIXMAN_OP_HSL_COLOR";
- case PIXMAN_OP_HSL_LUMINOSITY: return "PIXMAN_OP_HSL_LUMINOSITY";
-
- case PIXMAN_OP_NONE:
- return "<invalid operator 'none'>";
- };
-
- return "<unknown operator>";
-}
-
-const char *
-format_name (pixman_format_code_t format)
-{
- switch (format)
- {
-/* 32bpp formats */
- case PIXMAN_a8r8g8b8: return "a8r8g8b8";
- case PIXMAN_x8r8g8b8: return "x8r8g8b8";
- case PIXMAN_a8b8g8r8: return "a8b8g8r8";
- case PIXMAN_x8b8g8r8: return "x8b8g8r8";
- case PIXMAN_b8g8r8a8: return "b8g8r8a8";
- case PIXMAN_b8g8r8x8: return "b8g8r8x8";
- case PIXMAN_r8g8b8a8: return "r8g8b8a8";
- case PIXMAN_r8g8b8x8: return "r8g8b8x8";
- case PIXMAN_x14r6g6b6: return "x14r6g6b6";
- case PIXMAN_x2r10g10b10: return "x2r10g10b10";
- case PIXMAN_a2r10g10b10: return "a2r10g10b10";
- case PIXMAN_x2b10g10r10: return "x2b10g10r10";
- case PIXMAN_a2b10g10r10: return "a2b10g10r10";
-
-/* sRGB formats */
- case PIXMAN_a8r8g8b8_sRGB: return "a8r8g8b8_sRGB";
-
-/* 24bpp formats */
- case PIXMAN_r8g8b8: return "r8g8b8";
- case PIXMAN_b8g8r8: return "b8g8r8";
-
-/* 16bpp formats */
- case PIXMAN_r5g6b5: return "r5g6b5";
- case PIXMAN_b5g6r5: return "b5g6r5";
-
- case PIXMAN_a1r5g5b5: return "a1r5g5b5";
- case PIXMAN_x1r5g5b5: return "x1r5g5b5";
- case PIXMAN_a1b5g5r5: return "a1b5g5r5";
- case PIXMAN_x1b5g5r5: return "x1b5g5r5";
- case PIXMAN_a4r4g4b4: return "a4r4g4b4";
- case PIXMAN_x4r4g4b4: return "x4r4g4b4";
- case PIXMAN_a4b4g4r4: return "a4b4g4r4";
- case PIXMAN_x4b4g4r4: return "x4b4g4r4";
-
-/* 8bpp formats */
- case PIXMAN_a8: return "a8";
- case PIXMAN_r3g3b2: return "r3g3b2";
- case PIXMAN_b2g3r3: return "b2g3r3";
- case PIXMAN_a2r2g2b2: return "a2r2g2b2";
- case PIXMAN_a2b2g2r2: return "a2b2g2r2";
-
-#if 0
- case PIXMAN_x4c4: return "x4c4";
- case PIXMAN_g8: return "g8";
-#endif
- case PIXMAN_c8: return "x4c4 / c8";
- case PIXMAN_x4g4: return "x4g4 / g8";
-
- case PIXMAN_x4a4: return "x4a4";
-
-/* 4bpp formats */
- case PIXMAN_a4: return "a4";
- case PIXMAN_r1g2b1: return "r1g2b1";
- case PIXMAN_b1g2r1: return "b1g2r1";
- case PIXMAN_a1r1g1b1: return "a1r1g1b1";
- case PIXMAN_a1b1g1r1: return "a1b1g1r1";
-
- case PIXMAN_c4: return "c4";
- case PIXMAN_g4: return "g4";
-
-/* 1bpp formats */
- case PIXMAN_a1: return "a1";
-
- case PIXMAN_g1: return "g1";
-
-/* YUV formats */
- case PIXMAN_yuy2: return "yuy2";
- case PIXMAN_yv12: return "yv12";
- };
-
- /* Fake formats.
- *
- * This is separate switch to prevent GCC from complaining
- * that the values are not in the pixman_format_code_t enum.
- */
- switch ((uint32_t)format)
- {
- case PIXMAN_null: return "null";
- case PIXMAN_solid: return "solid";
- case PIXMAN_pixbuf: return "pixbuf";
- case PIXMAN_rpixbuf: return "rpixbuf";
- case PIXMAN_unknown: return "unknown";
- };
-
- return "<unknown format>";
-};
-
-static double
-calc_op (pixman_op_t op, double src, double dst, double srca, double dsta)
-{
-#define mult_chan(src, dst, Fa, Fb) MIN ((src) * (Fa) + (dst) * (Fb), 1.0)
-
- double Fa, Fb;
-
- switch (op)
- {
- case PIXMAN_OP_CLEAR:
- case PIXMAN_OP_DISJOINT_CLEAR:
- case PIXMAN_OP_CONJOINT_CLEAR:
- return mult_chan (src, dst, 0.0, 0.0);
-
- case PIXMAN_OP_SRC:
- case PIXMAN_OP_DISJOINT_SRC:
- case PIXMAN_OP_CONJOINT_SRC:
- return mult_chan (src, dst, 1.0, 0.0);
-
- case PIXMAN_OP_DST:
- case PIXMAN_OP_DISJOINT_DST:
- case PIXMAN_OP_CONJOINT_DST:
- return mult_chan (src, dst, 0.0, 1.0);
-
- case PIXMAN_OP_OVER:
- return mult_chan (src, dst, 1.0, 1.0 - srca);
-
- case PIXMAN_OP_OVER_REVERSE:
- return mult_chan (src, dst, 1.0 - dsta, 1.0);
-
- case PIXMAN_OP_IN:
- return mult_chan (src, dst, dsta, 0.0);
-
- case PIXMAN_OP_IN_REVERSE:
- return mult_chan (src, dst, 0.0, srca);
-
- case PIXMAN_OP_OUT:
- return mult_chan (src, dst, 1.0 - dsta, 0.0);
-
- case PIXMAN_OP_OUT_REVERSE:
- return mult_chan (src, dst, 0.0, 1.0 - srca);
-
- case PIXMAN_OP_ATOP:
- return mult_chan (src, dst, dsta, 1.0 - srca);
-
- case PIXMAN_OP_ATOP_REVERSE:
- return mult_chan (src, dst, 1.0 - dsta, srca);
-
- case PIXMAN_OP_XOR:
- return mult_chan (src, dst, 1.0 - dsta, 1.0 - srca);
-
- case PIXMAN_OP_ADD:
- return mult_chan (src, dst, 1.0, 1.0);
-
- case PIXMAN_OP_SATURATE:
- case PIXMAN_OP_DISJOINT_OVER_REVERSE:
- if (srca == 0.0)
- Fa = 1.0;
- else
- Fa = MIN (1.0, (1.0 - dsta) / srca);
- return mult_chan (src, dst, Fa, 1.0);
-
- case PIXMAN_OP_DISJOINT_OVER:
- if (dsta == 0.0)
- Fb = 1.0;
- else
- Fb = MIN (1.0, (1.0 - srca) / dsta);
- return mult_chan (src, dst, 1.0, Fb);
-
- case PIXMAN_OP_DISJOINT_IN:
- if (srca == 0.0)
- Fa = 0.0;
- else
- Fa = MAX (0.0, 1.0 - (1.0 - dsta) / srca);
- return mult_chan (src, dst, Fa, 0.0);
-
- case PIXMAN_OP_DISJOINT_IN_REVERSE:
- if (dsta == 0.0)
- Fb = 0.0;
- else
- Fb = MAX (0.0, 1.0 - (1.0 - srca) / dsta);
- return mult_chan (src, dst, 0.0, Fb);
-
- case PIXMAN_OP_DISJOINT_OUT:
- if (srca == 0.0)
- Fa = 1.0;
- else
- Fa = MIN (1.0, (1.0 - dsta) / srca);
- return mult_chan (src, dst, Fa, 0.0);
-
- case PIXMAN_OP_DISJOINT_OUT_REVERSE:
- if (dsta == 0.0)
- Fb = 1.0;
- else
- Fb = MIN (1.0, (1.0 - srca) / dsta);
- return mult_chan (src, dst, 0.0, Fb);
-
- case PIXMAN_OP_DISJOINT_ATOP:
- if (srca == 0.0)
- Fa = 0.0;
- else
- Fa = MAX (0.0, 1.0 - (1.0 - dsta) / srca);
- if (dsta == 0.0)
- Fb = 1.0;
- else
- Fb = MIN (1.0, (1.0 - srca) / dsta);
- return mult_chan (src, dst, Fa, Fb);
-
- case PIXMAN_OP_DISJOINT_ATOP_REVERSE:
- if (srca == 0.0)
- Fa = 1.0;
- else
- Fa = MIN (1.0, (1.0 - dsta) / srca);
- if (dsta == 0.0)
- Fb = 0.0;
- else
- Fb = MAX (0.0, 1.0 - (1.0 - srca) / dsta);
- return mult_chan (src, dst, Fa, Fb);
-
- case PIXMAN_OP_DISJOINT_XOR:
- if (srca == 0.0)
- Fa = 1.0;
- else
- Fa = MIN (1.0, (1.0 - dsta) / srca);
- if (dsta == 0.0)
- Fb = 1.0;
- else
- Fb = MIN (1.0, (1.0 - srca) / dsta);
- return mult_chan (src, dst, Fa, Fb);
-
- case PIXMAN_OP_CONJOINT_OVER:
- if (dsta == 0.0)
- Fb = 0.0;
- else
- Fb = MAX (0.0, 1.0 - srca / dsta);
- return mult_chan (src, dst, 1.0, Fb);
-
- case PIXMAN_OP_CONJOINT_OVER_REVERSE:
- if (srca == 0.0)
- Fa = 0.0;
- else
- Fa = MAX (0.0, 1.0 - dsta / srca);
- return mult_chan (src, dst, Fa, 1.0);
-
- case PIXMAN_OP_CONJOINT_IN:
- if (srca == 0.0)
- Fa = 1.0;
- else
- Fa = MIN (1.0, dsta / srca);
- return mult_chan (src, dst, Fa, 0.0);
-
- case PIXMAN_OP_CONJOINT_IN_REVERSE:
- if (dsta == 0.0)
- Fb = 1.0;
- else
- Fb = MIN (1.0, srca / dsta);
- return mult_chan (src, dst, 0.0, Fb);
-
- case PIXMAN_OP_CONJOINT_OUT:
- if (srca == 0.0)
- Fa = 0.0;
- else
- Fa = MAX (0.0, 1.0 - dsta / srca);
- return mult_chan (src, dst, Fa, 0.0);
-
- case PIXMAN_OP_CONJOINT_OUT_REVERSE:
- if (dsta == 0.0)
- Fb = 0.0;
- else
- Fb = MAX (0.0, 1.0 - srca / dsta);
- return mult_chan (src, dst, 0.0, Fb);
-
- case PIXMAN_OP_CONJOINT_ATOP:
- if (srca == 0.0)
- Fa = 1.0;
- else
- Fa = MIN (1.0, dsta / srca);
- if (dsta == 0.0)
- Fb = 0.0;
- else
- Fb = MAX (0.0, 1.0 - srca / dsta);
- return mult_chan (src, dst, Fa, Fb);
-
- case PIXMAN_OP_CONJOINT_ATOP_REVERSE:
- if (srca == 0.0)
- Fa = 0.0;
- else
- Fa = MAX (0.0, 1.0 - dsta / srca);
- if (dsta == 0.0)
- Fb = 1.0;
- else
- Fb = MIN (1.0, srca / dsta);
- return mult_chan (src, dst, Fa, Fb);
-
- case PIXMAN_OP_CONJOINT_XOR:
- if (srca == 0.0)
- Fa = 0.0;
- else
- Fa = MAX (0.0, 1.0 - dsta / srca);
- if (dsta == 0.0)
- Fb = 0.0;
- else
- Fb = MAX (0.0, 1.0 - srca / dsta);
- return mult_chan (src, dst, Fa, Fb);
-
- case PIXMAN_OP_MULTIPLY:
- case PIXMAN_OP_SCREEN:
- case PIXMAN_OP_OVERLAY:
- case PIXMAN_OP_DARKEN:
- case PIXMAN_OP_LIGHTEN:
- case PIXMAN_OP_COLOR_DODGE:
- case PIXMAN_OP_COLOR_BURN:
- case PIXMAN_OP_HARD_LIGHT:
- case PIXMAN_OP_SOFT_LIGHT:
- case PIXMAN_OP_DIFFERENCE:
- case PIXMAN_OP_EXCLUSION:
- case PIXMAN_OP_HSL_HUE:
- case PIXMAN_OP_HSL_SATURATION:
- case PIXMAN_OP_HSL_COLOR:
- case PIXMAN_OP_HSL_LUMINOSITY:
- default:
- abort();
- return 0; /* silence MSVC */
- }
-#undef mult_chan
-}
-
-void
-do_composite (pixman_op_t op,
- const color_t *src,
- const color_t *mask,
- const color_t *dst,
- color_t *result,
- pixman_bool_t component_alpha)
-{
- color_t srcval, srcalpha;
-
- if (mask == NULL)
- {
- srcval = *src;
-
- srcalpha.r = src->a;
- srcalpha.g = src->a;
- srcalpha.b = src->a;
- srcalpha.a = src->a;
- }
- else if (component_alpha)
- {
- srcval.r = src->r * mask->r;
- srcval.g = src->g * mask->g;
- srcval.b = src->b * mask->b;
- srcval.a = src->a * mask->a;
-
- srcalpha.r = src->a * mask->r;
- srcalpha.g = src->a * mask->g;
- srcalpha.b = src->a * mask->b;
- srcalpha.a = src->a * mask->a;
- }
- else
- {
- srcval.r = src->r * mask->a;
- srcval.g = src->g * mask->a;
- srcval.b = src->b * mask->a;
- srcval.a = src->a * mask->a;
-
- srcalpha.r = src->a * mask->a;
- srcalpha.g = src->a * mask->a;
- srcalpha.b = src->a * mask->a;
- srcalpha.a = src->a * mask->a;
- }
-
- result->r = calc_op (op, srcval.r, dst->r, srcalpha.r, dst->a);
- result->g = calc_op (op, srcval.g, dst->g, srcalpha.g, dst->a);
- result->b = calc_op (op, srcval.b, dst->b, srcalpha.b, dst->a);
- result->a = calc_op (op, srcval.a, dst->a, srcalpha.a, dst->a);
-}
-
-static 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:
- case PIXMAN_TYPE_ARGB_SRGB:
- 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;
-}
-
-void
-pixel_checker_get_masks (const pixel_checker_t *checker,
- uint32_t *am,
- uint32_t *rm,
- uint32_t *gm,
- uint32_t *bm)
-{
- if (am)
- *am = checker->am;
- if (rm)
- *rm = checker->rm;
- if (gm)
- *gm = checker->gm;
- if (bm)
- *bm = checker->bm;
-}
-
-void
-pixel_checker_convert_pixel_to_color (const pixel_checker_t *checker,
- uint32_t pixel, color_t *color)
-{
- int a, r, g, b;
-
- pixel_checker_split_pixel (checker, pixel, &a, &r, &g, &b);
-
- if (checker->am == 0)
- color->a = 1.0;
- else
- color->a = a / (double)(checker->am >> checker->as);
-
- if (checker->rm == 0)
- color->r = 0.0;
- else
- color->r = r / (double)(checker->rm >> checker->rs);
-
- if (checker->gm == 0)
- color->g = 0.0;
- else
- color->g = g / (double)(checker->gm >> checker->gs);
-
- if (checker->bm == 0)
- color->b = 0.0;
- else
- color->b = b / (double)(checker->bm >> checker->bs);
-
- if (PIXMAN_FORMAT_TYPE (checker->format) == PIXMAN_TYPE_ARGB_SRGB)
- {
- color->r = convert_srgb_to_linear (color->r);
- color->g = convert_srgb_to_linear (color->g);
- color->b = convert_srgb_to_linear (color->b);
- }
-}
-
-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)
-{
- color_t tmp;
-
- if (PIXMAN_FORMAT_TYPE (checker->format) == PIXMAN_TYPE_ARGB_SRGB)
- {
- tmp.a = color->a;
- tmp.r = convert_linear_to_srgb (color->r);
- tmp.g = convert_linear_to_srgb (color->g);
- tmp.b = convert_linear_to_srgb (color->b);
-
- color = &tmp;
- }
-
- *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.0064)
-
-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/qemu/pixman/test/utils.h b/qemu/pixman/test/utils.h
deleted file mode 100644
index ebb14d9e4..000000000
--- a/qemu/pixman/test/utils.h
+++ /dev/null
@@ -1,247 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <assert.h>
-#include "pixman-private.h" /* For 'inline' definition */
-#include "utils-prng.h"
-
-#if defined(_MSC_VER)
-#define snprintf _snprintf
-#define strcasecmp _stricmp
-#endif
-
-#define ARRAY_LENGTH(A) ((int) (sizeof (A) / sizeof ((A) [0])))
-
-/* A primitive pseudorandom number generator,
- * taken from POSIX.1-2001 example
- */
-
-extern prng_t prng_state_data;
-extern prng_t *prng_state;
-#ifdef USE_OPENMP
-#pragma omp threadprivate(prng_state_data)
-#pragma omp threadprivate(prng_state)
-#endif
-
-static inline uint32_t
-prng_rand (void)
-{
- return prng_rand_r (prng_state);
-}
-
-static inline void
-prng_srand (uint32_t seed)
-{
- if (!prng_state)
- {
- /* Without setting a seed, PRNG does not work properly (is just
- * returning zeros). So we only initialize the pointer here to
- * make sure that 'prng_srand' is always called before any
- * other 'prng_*' function. The wrongdoers violating this order
- * will get a segfault. */
- prng_state = &prng_state_data;
- }
- prng_srand_r (prng_state, seed);
-}
-
-static inline uint32_t
-prng_rand_n (int max)
-{
- return prng_rand () % max;
-}
-
-static inline void
-prng_randmemset (void *buffer, size_t size, prng_randmemset_flags_t flags)
-{
- prng_randmemset_r (prng_state, buffer, size, flags);
-}
-
-/* CRC 32 computation
- */
-uint32_t
-compute_crc32 (uint32_t in_crc32,
- const void *buf,
- size_t buf_len);
-
-uint32_t
-compute_crc32_for_image (uint32_t in_crc32,
- pixman_image_t *image);
-
-/* Print the image in hexadecimal */
-void
-print_image (pixman_image_t *image);
-
-/* Returns TRUE if running on a little endian system
- */
-static force_inline pixman_bool_t
-is_little_endian (void)
-{
- unsigned long endian_check_var = 1;
- return *(unsigned char *)&endian_check_var == 1;
-}
-
-/* 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_divbyzero_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);
-
-void
-draw_checkerboard (pixman_image_t *image,
- int check_size,
- uint32_t color1, uint32_t color2);
-
-/* 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);
-
-double
-convert_srgb_to_linear (double component);
-
-double
-convert_linear_to_srgb (double component);
-
-void
-initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb);
-
-const char *
-operator_name (pixman_op_t op);
-
-const char *
-format_name (pixman_format_code_t format);
-
-typedef struct
-{
- double r, g, b, a;
-} color_t;
-
-void
-do_composite (pixman_op_t op,
- const color_t *src,
- const color_t *mask,
- const color_t *dst,
- color_t *result,
- pixman_bool_t component_alpha);
-
-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);
-
-void
-pixel_checker_convert_pixel_to_color (const pixel_checker_t *checker,
- uint32_t pixel, color_t *color);
-
-void
-pixel_checker_get_masks (const pixel_checker_t *checker,
- uint32_t *am,
- uint32_t *rm,
- uint32_t *gm,
- uint32_t *bm);