test: Fix stride calculation in stress-test
authorSiarhei Siamashka <siarhei.siamashka@gmail.com>
Tue, 12 Jun 2018 14:38:57 +0000 (17:38 +0300)
committerAdam Jackson <ajax@redhat.com>
Fri, 6 Jul 2018 18:44:22 +0000 (14:44 -0400)
Currently the number of bits per pixel is used instead of the
number of bytes per pixel when calculating image strides. This
does not cause any real problems, but the gaps between scanlines
are excessively large.

This patch actually converts bits to bytes and rounds up the result
to the nearest byte boundary.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Reviewed-by: soren.sandmann@gmail.com
test/stress-test.c

index 1f03c754307a7e79f94712c6433905e97d73d552..85d12932c9aa43835ed98e0aaa923e9aecd32ec0 100644 (file)
@@ -291,7 +291,7 @@ create_random_bits_image (alpha_preference_t alpha_preference)
     {
     default:
     case 0:
-       stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);
+       stride = (width * PIXMAN_FORMAT_BPP (format) + 7) / 8 + prng_rand_n (17);
        stride = (stride + 3) & (~3);
        bits = (uint32_t *)make_random_bytes (height * stride);
        break;
@@ -302,7 +302,7 @@ create_random_bits_image (alpha_preference_t alpha_preference)
        break;
 
     case 2: /* Zero-filled */
-       stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);
+       stride = (width * PIXMAN_FORMAT_BPP (format) + 7) / 8 + prng_rand_n (17);
        stride = (stride + 3) & (~3);
        bits = fence_malloc (height * stride);
        if (!bits)
@@ -311,7 +311,7 @@ create_random_bits_image (alpha_preference_t alpha_preference)
        break;
 
     case 3: /* Filled with 0xFF */
-       stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);
+       stride = (width * PIXMAN_FORMAT_BPP (format) + 7) / 8 + prng_rand_n (17);
        stride = (stride + 3) & (~3);
        bits = fence_malloc (height * stride);
        if (!bits)
@@ -327,7 +327,7 @@ create_random_bits_image (alpha_preference_t alpha_preference)
        break;
 
     case 5: /* bits is a real pointer, has read/write functions */
-       stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);
+       stride = (width * PIXMAN_FORMAT_BPP (format) + 7) / 8 + prng_rand_n (17);
        stride = (stride + 3) & (~3);
        bits = fence_malloc (height * stride);
        if (!bits)
@@ -338,7 +338,7 @@ create_random_bits_image (alpha_preference_t alpha_preference)
        break;
 
     case 6: /* bits is a real pointer, stride is negative */
-       stride = (width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17));
+       stride = (width * PIXMAN_FORMAT_BPP (format) + 7) / 8 + prng_rand_n (17);
        stride = (stride + 3) & (~3);
        bits = (uint32_t *)make_random_bytes (height * stride);
        if (!bits)