From de27f45ddd46fc48ec9598f2f177155328d55580 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Mon, 15 Mar 2010 11:51:09 -0400 Subject: [PATCH] Ensure that only the low 4 bit of 4 bit pixels are stored. In some cases we end up trying to use the STORE_4 macro with an 8 bit values, which resulted in other pixels getting overwritten. Fix this by always masking off the low 4 bits. This fixes blitters-test on big-endian machines. --- pixman/pixman-access.c | 22 ++++++++++++++-------- test/blitters-test.c | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c index 389cf2a..fa0a267 100644 --- a/pixman/pixman-access.c +++ b/pixman/pixman-access.c @@ -2445,9 +2445,12 @@ store_scanline_x4a4 (bits_image_t * image, do \ { \ int bo = 4 * (o); \ - STORE_8 (img, l, bo, (bo & 4 ? \ - (FETCH_8 (img, l, bo) & 0xf0) | (v) : \ - (FETCH_8 (img, l, bo) & 0x0f) | ((v) << 4))); \ + int v4 = (v) & 0x0f; \ + \ + STORE_8 (img, l, bo, ( \ + bo & 4 ? \ + (FETCH_8 (img, l, bo) & 0xf0) | (v4) : \ + (FETCH_8 (img, l, bo) & 0x0f) | (v4 << 4))); \ } while (0) #else @@ -2455,9 +2458,12 @@ store_scanline_x4a4 (bits_image_t * image, do \ { \ int bo = 4 * (o); \ - STORE_8 (img, l, bo, (bo & 4 ? \ - (FETCH_8 (img, l, bo) & 0x0f) | ((v) << 4) : \ - (FETCH_8 (img, l, bo) & 0xf0) | (v))); \ + int v4 = (v) & 0x0f; \ + \ + STORE_8 (img, l, bo, ( \ + bo & 4 ? \ + (FETCH_8 (img, l, bo) & 0x0f) | (v4 << 4) : \ + (FETCH_8 (img, l, bo) & 0xf0) | (v4))); \ } while (0) #endif @@ -2484,11 +2490,11 @@ store_scanline_r1g2b1 (bits_image_t * image, { uint32_t *bits = image->bits + image->rowstride * y; int i; - + for (i = 0; i < width; ++i) { uint32_t pixel; - + SPLIT (values[i]); pixel = (((r >> 4) & 0x8) | ((g >> 5) & 0x6) | diff --git a/test/blitters-test.c b/test/blitters-test.c index c11917d..5e33031 100644 --- a/test/blitters-test.c +++ b/test/blitters-test.c @@ -482,7 +482,7 @@ main (int argc, char *argv[]) /* Predefined value for running with all the fastpath functions disabled. It needs to be updated every time when changes are introduced to this program or behavior of pixman changes! */ - if (crc == 0xEF7A1179) + if (crc == 0xA058F792) { printf ("blitters test passed\n"); } -- 2.7.4