Siarhei Siamashka <[email protected]> writes:

>> > But something unexpectedly broke on PowerPC and maybe other big
>> > endian systems after the following commit:
>> >     http://cgit.freedesktop.org/pixman/commit/?id=aa5c45254eb60ce4
>> 
>> Looks like I forgot to fix up image_endian_swap() to cope with negative
>> strides. I don't have easy access to a PowerPC at the moment, so if you
>> can test the following patch, that would be helpful.
>> 
>> Also available here:
>> 
>>      http://cgit.freedesktop.org/~sandmann/pixman/log/?h=negative-strides
>
> Thanks, this makes sense. But looks like there is something else still
> broken there.

Somehow I missed the "case 16:" case. New patch below; also available in
the negative-strides branch of my repository on fd.o.


Søren


From fa0559eb710ef6252dea5a70ade28a2c167a7a85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <[email protected]>
Date: Thu, 26 Sep 2013 18:56:07 -0400
Subject: [PATCH] utils.c: Make image_endian_swap() deal with negative strides

Use a temporary variable s containing the absolute value of the stride
as the upper bound in the inner loops.

V2: Do this for the bpp == 16 case as well
---
 test/utils.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/test/utils.c b/test/utils.c
index a83fc06..0cd982e 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -297,11 +297,12 @@ image_endian_swap (pixman_image_t *img)
     for (i = 0; i < height; i++)
     {
        uint8_t *line_data = (uint8_t *)data + stride * i;
-       
+       int s = (stride >= 0)? stride : - stride;
+       
        switch (bpp)
        {
        case 1:
-           for (j = 0; j < stride; j++)
+           for (j = 0; j < s; j++)
            {
                line_data[j] =
                    ((line_data[j] & 0x80) >> 7) |
@@ -315,13 +316,13 @@ image_endian_swap (pixman_image_t *img)
            }
            break;
        case 4:
-           for (j = 0; j < stride; j++)
+           for (j = 0; j < s; j++)
            {
                line_data[j] = (line_data[j] >> 4) | (line_data[j] << 4);
            }
            break;
        case 16:
-           for (j = 0; j + 2 <= stride; j += 2)
+           for (j = 0; j + 2 <= s; j += 2)
            {
                char t1 = line_data[j + 0];
                char t2 = line_data[j + 1];
@@ -331,7 +332,7 @@ image_endian_swap (pixman_image_t *img)
            }
            break;
        case 24:
-           for (j = 0; j + 3 <= stride; j += 3)
+           for (j = 0; j + 3 <= s; j += 3)
            {
                char t1 = line_data[j + 0];
                char t2 = line_data[j + 1];
@@ -343,7 +344,7 @@ image_endian_swap (pixman_image_t *img)
            }
            break;
        case 32:
-           for (j = 0; j + 4 <= stride; j += 4)
+           for (j = 0; j + 4 <= s; j += 4)
            {
                char t1 = line_data[j + 0];
                char t2 = line_data[j + 1];
-- 
1.7.1

_______________________________________________
Pixman mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pixman

Reply via email to