aboutsummaryrefslogtreecommitdiff
path: root/pixman/test
diff options
context:
space:
mode:
Diffstat (limited to 'pixman/test')
-rw-r--r--pixman/test/affine-test.c46
-rw-r--r--pixman/test/blitters-test.c31
-rw-r--r--pixman/test/composite-traps-test.c46
-rw-r--r--pixman/test/rotate-test.c17
-rw-r--r--pixman/test/scaling-test.c55
-rw-r--r--pixman/test/utils.c38
-rw-r--r--pixman/test/utils.h4
7 files changed, 143 insertions, 94 deletions
diff --git a/pixman/test/affine-test.c b/pixman/test/affine-test.c
index c1649ed5e..8e19023a3 100644
--- a/pixman/test/affine-test.c
+++ b/pixman/test/affine-test.c
@@ -80,6 +80,18 @@ test_composite (int testnum,
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;
@@ -273,32 +285,20 @@ test_composite (int testnum,
pixman_image_composite (op, src_img, NULL, dst_img,
src_x, src_y, 0, 0, dst_x, dst_y, w, h);
- if (dst_fmt == PIXMAN_x8r8g8b8)
- {
- /* ignore unused part */
- for (i = 0; i < dst_stride * dst_height / 4; i++)
- dstbuf[i] &= 0xFFFFFF;
- }
-
- image_endian_swap (dst_img);
-
+ crc32 = compute_crc32_for_image (0, dst_img);
+
if (verbose)
- {
- int j;
-
- for (i = 0; i < dst_height; i++)
- {
- for (j = 0; j < dst_stride; j++)
- printf ("%02X ", *((uint8_t *)dstbuf + i * dst_stride + j));
-
- printf ("\n");
- }
- }
+ print_image (dst_img);
pixman_image_unref (src_img);
pixman_image_unref (dst_img);
- crc32 = compute_crc32 (0, dstbuf, dst_stride * dst_height);
+ 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);
@@ -307,9 +307,9 @@ test_composite (int testnum,
}
#if BILINEAR_INTERPOLATION_BITS == 7
-#define CHECKSUM 0xBC00B1DF
+#define CHECKSUM 0xBE724CFE
#elif BILINEAR_INTERPOLATION_BITS == 4
-#define CHECKSUM 0xA227306B
+#define CHECKSUM 0x79BBE501
#else
#define CHECKSUM 0x00000000
#endif
diff --git a/pixman/test/blitters-test.c b/pixman/test/blitters-test.c
index a2c6ff4d8..af948350b 100644
--- a/pixman/test/blitters-test.c
+++ b/pixman/test/blitters-test.c
@@ -57,6 +57,13 @@ create_random_image (pixman_format_code_t *allowed_formats,
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)
@@ -89,6 +96,9 @@ free_random_image (uint32_t initcrc,
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);
@@ -222,7 +232,6 @@ static pixman_format_code_t mask_fmt_list[] = {
uint32_t
test_composite (int testnum, int verbose)
{
- int i;
pixman_image_t *src_img = NULL;
pixman_image_t *dst_img = NULL;
pixman_image_t *mask_img = NULL;
@@ -355,23 +364,7 @@ test_composite (int testnum, int verbose)
src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h);
if (verbose)
- {
- int j;
-
- printf ("---\n");
- for (i = 0; i < dst_height; i++)
- {
- for (j = 0; j < dst_stride; j++)
- {
- if (j == (dst_width * PIXMAN_FORMAT_BPP (dst_fmt) + 7) / 8)
- printf ("| ");
-
- printf ("%02X ", *((uint8_t *)dstbuf + i * dst_stride + j));
- }
- printf ("\n");
- }
- printf ("---\n");
- }
+ print_image (dst_img);
free_random_image (0, src_img, PIXMAN_null);
crc32 = free_random_image (0, dst_img, dst_fmt);
@@ -402,6 +395,6 @@ main (int argc, const char *argv[])
}
return fuzzer_test_main("blitters", 2000000,
- 0x0CF3283B,
+ 0xAC8FDA98,
test_composite, argc, argv);
}
diff --git a/pixman/test/composite-traps-test.c b/pixman/test/composite-traps-test.c
index 2983eae83..86a035564 100644
--- a/pixman/test/composite-traps-test.c
+++ b/pixman/test/composite-traps-test.c
@@ -97,19 +97,25 @@ test_composite (int testnum,
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;
+ 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;
- bits = (uint32_t *)make_random_bytes (src_stride * src_height);
+ 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, bits);
+ pixman_image_set_destroy_function (src_img, destroy_bits, orig);
if (prng_rand_n (8) == 0)
{
@@ -153,6 +159,12 @@ test_composite (int testnum,
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);
@@ -214,30 +226,14 @@ test_composite (int testnum,
pixman_composite_trapezoids (op, src_img, dst_img, mask_format,
src_x, src_y, dst_x, dst_y, n_traps, traps);
- if (dst_format == PIXMAN_x8r8g8b8)
- {
- /* ignore unused part */
- for (i = 0; i < dst_stride * dst_height / 4; i++)
- dst_bits[i] &= 0xFFFFFF;
- }
-
- image_endian_swap (dst_img);
+ crc32 = compute_crc32_for_image (0, dst_img);
if (verbose)
- {
- int j;
-
- for (i = 0; i < dst_height; i++)
- {
- for (j = 0; j < dst_stride; j++)
- printf ("%02X ", *((uint8_t *)dst_bits + i * dst_stride + j));
-
- printf ("\n");
- }
- }
-
- crc32 = compute_crc32 (0, dst_bits, dst_stride * dst_height);
+ 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);
@@ -251,6 +247,6 @@ test_composite (int testnum,
int
main (int argc, const char *argv[])
{
- return fuzzer_test_main("composite traps", 40000, 0x749BCC57,
+ return fuzzer_test_main("composite traps", 40000, 0xAF41D210,
test_composite, argc, argv);
}
diff --git a/pixman/test/rotate-test.c b/pixman/test/rotate-test.c
index 9d2a620cb..18ca60d9b 100644
--- a/pixman/test/rotate-test.c
+++ b/pixman/test/rotate-test.c
@@ -61,16 +61,25 @@ static pixman_image_t *
make_image (void)
{
pixman_format_code_t format = RANDOM_FORMAT();
- uint32_t *bytes = malloc (WIDTH * HEIGHT * 4);
+ 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, WIDTH * 4);
+ format, WIDTH, HEIGHT, bytes, stride);
pixman_image_set_transform (image, RANDOM_TRANSFORM());
- pixman_image_set_destroy_function (image, on_destroy, bytes);
+ pixman_image_set_destroy_function (image, on_destroy, orig);
pixman_image_set_repeat (image, PIXMAN_REPEAT_NORMAL);
image_endian_swap (image);
@@ -106,6 +115,6 @@ int
main (int argc, const char *argv[])
{
return fuzzer_test_main ("rotate", 15000,
- 0xECF5E426,
+ 0x81E9EC2F,
test_transform, argc, argv);
}
diff --git a/pixman/test/scaling-test.c b/pixman/test/scaling-test.c
index b4142a796..e2f7fa9f4 100644
--- a/pixman/test/scaling-test.c
+++ b/pixman/test/scaling-test.c
@@ -147,6 +147,24 @@ test_composite (int testnum,
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);
@@ -340,33 +358,24 @@ test_composite (int testnum,
pixman_image_composite (op, src_img, mask_img, dst_img,
src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h);
- if (dst_fmt == PIXMAN_x8r8g8b8 || dst_fmt == PIXMAN_x8b8g8r8)
- {
- /* ignore unused part */
- for (i = 0; i < dst_stride * dst_height / 4; i++)
- dstbuf[i] &= 0xFFFFFF;
- }
-
- image_endian_swap (dst_img);
-
+ crc32 = compute_crc32_for_image (0, dst_img);
+
if (verbose)
- {
- int j;
-
- for (i = 0; i < dst_height; i++)
- {
- for (j = 0; j < dst_stride; j++)
- printf ("%02X ", *((uint8_t *)dstbuf + i * dst_stride + j));
-
- printf ("\n");
- }
- }
+ print_image (dst_img);
pixman_image_unref (src_img);
pixman_image_unref (mask_img);
pixman_image_unref (dst_img);
- crc32 = compute_crc32 (0, dstbuf, dst_stride * dst_height);
+ 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);
@@ -376,9 +385,9 @@ test_composite (int testnum,
}
#if BILINEAR_INTERPOLATION_BITS == 7
-#define CHECKSUM 0xCE8EC6BA
+#define CHECKSUM 0x92E0F068
#elif BILINEAR_INTERPOLATION_BITS == 4
-#define CHECKSUM 0xAB1D39BE
+#define CHECKSUM 0x8EFFA1E5
#else
#define CHECKSUM 0x00000000
#endif
diff --git a/pixman/test/utils.c b/pixman/test/utils.c
index 3d1ba22ae..34007476b 100644
--- a/pixman/test/utils.c
+++ b/pixman/test/utils.c
@@ -150,6 +150,12 @@ compute_crc32_for_image_internal (uint32_t crc32,
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)
@@ -238,6 +244,38 @@ compute_crc32_for_image (uint32_t crc32,
return crc32;
}
+void
+print_image (pixman_image_t *image)
+{
+ int i, j;
+ int width, height, stride;
+ pixman_format_code_t format;
+ uint8_t *buffer;
+
+ 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);
+
+ if (stride < 0)
+ stride = - stride;
+
+ printf ("---\n");
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < stride; 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
diff --git a/pixman/test/utils.h b/pixman/test/utils.h
index c2781516f..28b7193ed 100644
--- a/pixman/test/utils.h
+++ b/pixman/test/utils.h
@@ -63,6 +63,10 @@ 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