Discussion:
[Pixman] [PATCH] test: Fix stride calculation in stress-test
Siarhei Siamashka
2018-06-12 14:38:57 UTC
Permalink
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 <***@gmail.com>
---
test/stress-test.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/stress-test.c b/test/stress-test.c
index 1f03c75..85d1293 100644
--- a/test/stress-test.c
+++ b/test/stress-test.c
@@ -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)
--
2.16.1
Søren Sandmann
2018-06-12 16:13:31 UTC
Permalink
Reviewed-by: ***@gmail.com

On Tue, Jun 12, 2018 at 10:38 AM, Siarhei Siamashka <
Post by Siarhei Siamashka
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.
---
test/stress-test.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/test/stress-test.c b/test/stress-test.c
index 1f03c75..85d1293 100644
--- a/test/stress-test.c
+++ b/test/stress-test.c
@@ -291,7 +291,7 @@ create_random_bits_image (alpha_preference_t alpha_preference)
{
- 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)
--
2.16.1
_______________________________________________
Pixman mailing list
https://lists.freedesktop.org/mailman/listinfo/pixman
Adam Jackson
2018-07-06 19:00:34 UTC
Permalink
Merged, thanks:

remote: remote: I: patch #229063 updated using rev 018bf2f23033ea0c82df3e4cf48dbb330bec9414
remote: remote: I: 1 patch(es) updated to state Accepted.
remote: To ssh://kemper.freedesktop.org/git/pixman
remote: bd2b491..018bf2f 018bf2f23033ea0c82df3e4cf48dbb330bec9414 -> master
To gitlab.freedesktop.org:pixman/pixman.git
bd2b491..018bf2f master -> master

- ajax

Continue reading on narkive:
Loading...