pixman: Branch 'master' - 3 commits
Søren Sandmann Pedersen
sandmann at kemper.freedesktop.org
Thu Sep 19 18:45:27 PDT 2013
test/affine-test.c | 46 ++++++++++++++++++------------------
test/blitters-test.c | 31 +++++++++---------------
test/composite-traps-test.c | 46 ++++++++++++++++--------------------
test/rotate-test.c | 17 ++++++++++---
test/scaling-test.c | 55 +++++++++++++++++++++++++-------------------
test/utils.c | 38 ++++++++++++++++++++++++++++++
test/utils.h | 4 +++
7 files changed, 143 insertions(+), 94 deletions(-)
New commits:
commit aa5c45254eb60ce4c85a25b5343474fb160ffa7c
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date: Wed Sep 11 22:17:33 2013 -0400
test: Test negative strides
Pixman supports negative strides, but up until now they haven't been
tested outside of stress-test. This commit adds testing of negative
strides to blitters-test, scaling-test, affine-test, rotate-test, and
composite-traps-test.
diff --git a/test/affine-test.c b/test/affine-test.c
index 03d296f..8e19023 100644
--- a/test/affine-test.c
+++ b/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;
@@ -281,6 +293,12 @@ test_composite (int testnum,
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);
@@ -289,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/test/blitters-test.c b/test/blitters-test.c
index 2120daf..af94835 100644
--- a/test/blitters-test.c
+++ b/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);
@@ -385,6 +395,6 @@ main (int argc, const char *argv[])
}
return fuzzer_test_main("blitters", 2000000,
- 0x0CF3283B,
+ 0xAC8FDA98,
test_composite, argc, argv);
}
diff --git a/test/composite-traps-test.c b/test/composite-traps-test.c
index 44d5012..86a0355 100644
--- a/test/composite-traps-test.c
+++ b/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);
@@ -219,6 +231,9 @@ test_composite (int testnum,
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);
@@ -232,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/test/rotate-test.c b/test/rotate-test.c
index 9d2a620..18ca60d 100644
--- a/test/rotate-test.c
+++ b/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/test/scaling-test.c b/test/scaling-test.c
index 0778d2d..e2f7fa9 100644
--- a/test/scaling-test.c
+++ b/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);
@@ -349,6 +367,15 @@ test_composite (int testnum,
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);
@@ -358,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/test/utils.c b/test/utils.c
index a693f30..3400747 100644
--- a/test/utils.c
+++ b/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)
commit 4312f077365bf9f59423b1694136089c6da6216b
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date: Thu Sep 12 12:52:02 2013 -0400
test: Share the image printing code
The affine-test, blitters-test, and scaling-test all have the ability
to print out the bytes of the destination image. Share this code by
moving it to utils.c.
At the same time make the code work correctly with negative strides.
diff --git a/test/affine-test.c b/test/affine-test.c
index 3a37d7f..03d296f 100644
--- a/test/affine-test.c
+++ b/test/affine-test.c
@@ -276,17 +276,7 @@ test_composite (int testnum,
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);
diff --git a/test/blitters-test.c b/test/blitters-test.c
index a2c6ff4..2120daf 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -222,7 +222,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 +354,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);
diff --git a/test/composite-traps-test.c b/test/composite-traps-test.c
index 34ae340..44d5012 100644
--- a/test/composite-traps-test.c
+++ b/test/composite-traps-test.c
@@ -217,17 +217,7 @@ test_composite (int testnum,
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");
- }
- }
+ print_image (dst_img);
fence_free (dst_bits);
diff --git a/test/scaling-test.c b/test/scaling-test.c
index 04ecb63..0778d2d 100644
--- a/test/scaling-test.c
+++ b/test/scaling-test.c
@@ -343,17 +343,7 @@ test_composite (int testnum,
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);
diff --git a/test/utils.c b/test/utils.c
index 3d1ba22..a693f30 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -238,6 +238,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/test/utils.h b/test/utils.h
index c278151..28b7193 100644
--- a/test/utils.h
+++ b/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
commit 51d71354568a54114ced87d8ae1529c88a53f635
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date: Thu Sep 12 12:24:52 2013 -0400
{scaling,affine,composite-traps}-test: Use compute_crc32_for_image()
By using this function instead of compute_crc32() the alpha masking
code and the call to image_endian_swap() are not duplicated.
diff --git a/test/affine-test.c b/test/affine-test.c
index c1649ed..3a37d7f 100644
--- a/test/affine-test.c
+++ b/test/affine-test.c
@@ -273,15 +273,8 @@ 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;
@@ -298,7 +291,6 @@ test_composite (int testnum,
pixman_image_unref (src_img);
pixman_image_unref (dst_img);
- crc32 = compute_crc32 (0, dstbuf, dst_stride * dst_height);
free (srcbuf);
free (dstbuf);
diff --git a/test/composite-traps-test.c b/test/composite-traps-test.c
index 2983eae..34ae340 100644
--- a/test/composite-traps-test.c
+++ b/test/composite-traps-test.c
@@ -214,14 +214,7 @@ 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)
{
@@ -236,8 +229,6 @@ test_composite (int testnum,
}
}
- crc32 = compute_crc32 (0, dst_bits, dst_stride * dst_height);
-
fence_free (dst_bits);
pixman_image_unref (src_img);
diff --git a/test/scaling-test.c b/test/scaling-test.c
index b4142a7..04ecb63 100644
--- a/test/scaling-test.c
+++ b/test/scaling-test.c
@@ -340,15 +340,8 @@ 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;
@@ -366,7 +359,6 @@ test_composite (int testnum,
pixman_image_unref (mask_img);
pixman_image_unref (dst_img);
- crc32 = compute_crc32 (0, dstbuf, dst_stride * dst_height);
free (srcbuf);
free (maskbuf);
free (dstbuf);
More information about the xorg-commit
mailing list