aboutsummaryrefslogtreecommitdiff
path: root/pixman/test
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-09-27 15:09:52 +0200
committermarha <marha@users.sourceforge.net>2012-09-27 15:09:52 +0200
commit2cf1e3de4759264eac2fa8ac758ea750636542f8 (patch)
tree80298679c1f3134223c592ad3939739aee333eb8 /pixman/test
parent0ebcd32e91486caccc041c8ca23e39e160b24702 (diff)
downloadvcxsrv-2cf1e3de4759264eac2fa8ac758ea750636542f8.tar.gz
vcxsrv-2cf1e3de4759264eac2fa8ac758ea750636542f8.tar.bz2
vcxsrv-2cf1e3de4759264eac2fa8ac758ea750636542f8.zip
mesa xserver pixman xkeyboard-config git update 27 sep 2012
xserver 0b02150c27e98f996e10d7489f9f67a30e4e3497 pixman aff796d6cee4cb81f0352c2f7d0c994229bd5ca1 xkeyboard-config 33ccc8f4b3f1c6ae95242cf9cb19e8df87f6f37e mesa 6d6aef79742ece3bb570ae44e6c13791aae15e01
Diffstat (limited to 'pixman/test')
-rw-r--r--pixman/test/Makefile.sources2
-rw-r--r--pixman/test/affine-test.c16
-rw-r--r--pixman/test/blitters-test.c2
-rw-r--r--pixman/test/infinite-loop.c39
-rw-r--r--pixman/test/rotate-test.c111
5 files changed, 165 insertions, 5 deletions
diff --git a/pixman/test/Makefile.sources b/pixman/test/Makefile.sources
index fad8c6f69..0f344116d 100644
--- a/pixman/test/Makefile.sources
+++ b/pixman/test/Makefile.sources
@@ -5,7 +5,9 @@ TESTPROGRAMS = \
region-test \
region-translate-test \
fetch-test \
+ rotate-test \
oob-test \
+ infinite-loop \
trap-crasher \
alpha-loop \
scaling-crash-test \
diff --git a/pixman/test/affine-test.c b/pixman/test/affine-test.c
index 6827cc3a8..7bc28b4cd 100644
--- a/pixman/test/affine-test.c
+++ b/pixman/test/affine-test.c
@@ -200,11 +200,19 @@ test_composite (int testnum,
if (verbose)
{
+#define M(r,c) \
+ transform.matrix[r][c]
+
printf ("src_fmt=%08X, dst_fmt=%08X\n", src_fmt, dst_fmt);
- printf ("op=%d, scale_x=%d, scale_y=%d, repeat=%d\n",
- op, scale_x, scale_y, repeat);
- printf ("translate_x=%d, translate_y=%d\n",
- translate_x, translate_y);
+ printf ("op=%d, repeat=%d, transform=\n",
+ 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",
diff --git a/pixman/test/blitters-test.c b/pixman/test/blitters-test.c
index 6a3cc8649..8c46cef97 100644
--- a/pixman/test/blitters-test.c
+++ b/pixman/test/blitters-test.c
@@ -395,6 +395,6 @@ main (int argc, const char *argv[])
}
return fuzzer_test_main("blitters", 2000000,
- 0xA364B5BF,
+ 0x3E1DD2E8,
test_composite, argc, argv);
}
diff --git a/pixman/test/infinite-loop.c b/pixman/test/infinite-loop.c
new file mode 100644
index 000000000..02addaab2
--- /dev/null
+++ b/pixman/test/infinite-loop.c
@@ -0,0 +1,39 @@
+#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/pixman/test/rotate-test.c b/pixman/test/rotate-test.c
new file mode 100644
index 000000000..bc44281e3
--- /dev/null
+++ b/pixman/test/rotate-test.c
@@ -0,0 +1,111 @@
+#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[lcg_rand_n (ARRAY_LENGTH (formats))])
+
+#define RANDOM_OP() \
+ (ops[lcg_rand_n (ARRAY_LENGTH (ops))])
+
+#define RANDOM_TRANSFORM() \
+ (&(transforms[lcg_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 = malloc (WIDTH * HEIGHT * 4);
+ pixman_image_t *image;
+ int i;
+
+ for (i = 0; i < WIDTH * HEIGHT * 4; ++i)
+ ((uint8_t *)bytes)[i] = lcg_rand_n (256);
+
+ image = pixman_image_create_bits (
+ format, WIDTH, HEIGHT, bytes, WIDTH * 4);
+
+ pixman_image_set_transform (image, RANDOM_TRANSFORM());
+ pixman_image_set_destroy_function (image, on_destroy, bytes);
+ pixman_image_set_repeat (image, PIXMAN_REPEAT_NORMAL);
+
+ return image;
+}
+
+static uint32_t
+test_transform (int testnum, int verbose)
+{
+ pixman_image_t *src, *dest;
+ uint32_t crc;
+
+ lcg_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,
+ 0x03A24D51,
+ test_transform, argc, argv);
+}