From afcfc8efc48630f0f349aefc8c86619fc7514647 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Sun, 21 Jun 2009 10:09:22 -0400 Subject: [PATCH] Eliminate MSBFirst, LSBFirst, IMAGE_BYTE_ORDER, and BITMAP_BIT_ORDER. Just use WORDS_BIGENDIAN instead. --- pixman/pixman-access.c | 20 ++++++++++---------- pixman/pixman-private.h | 23 ++++++----------------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c index 269fad0..8a5a1f5 100644 --- a/pixman/pixman-access.c +++ b/pixman/pixman-access.c @@ -216,7 +216,7 @@ fbFetch_b8g8r8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer) const uint8_t *end = pixel + 3*width; while (pixel < end) { uint32_t b = 0xff000000; -#if IMAGE_BYTE_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN b |= (READ(pict, pixel++)); b |= (READ(pict, pixel++) << 8); b |= (READ(pict, pixel++) << 16); @@ -517,7 +517,7 @@ fbFetch_x4a4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer) } #define Fetch8(img,l,o) (READ(img, (uint8_t *)(l) + ((o) >> 2))) -#if IMAGE_BYTE_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN #define Fetch4(img,l,o) ((o) & 2 ? Fetch8(img,l,o) & 0xf : Fetch8(img,l,o) >> 4) #else #define Fetch4(img,l,o) ((o) & 2 ? Fetch8(img,l,o) >> 4 : Fetch8(img,l,o) & 0xf) @@ -624,7 +624,7 @@ fbFetch_a1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer) for (i = 0; i < width; ++i) { uint32_t p = READ(pict, bits + ((i + x) >> 5)); uint32_t a; -#if BITMAP_BIT_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN a = p >> (0x1f - ((i+x) & 0x1f)); #else a = p >> ((i+x) & 0x1f); @@ -646,7 +646,7 @@ fbFetch_g1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer) for (i = 0; i < width; ++i) { uint32_t p = READ(pict, bits + ((i+x) >> 5)); uint32_t a; -#if BITMAP_BIT_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN a = p >> (0x1f - ((i+x) & 0x1f)); #else a = p >> ((i+x) & 0x1f); @@ -1037,7 +1037,7 @@ fbFetchPixel_r8g8b8 (bits_image_t *pict, uint32_t *buffer, int n_pixels) { uint32_t *bits = pict->bits + line*pict->rowstride; uint8_t *pixel = ((uint8_t *) bits) + (offset*3); -#if IMAGE_BYTE_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN buffer[i] = (0xff000000 | (READ(pict, pixel + 0) << 16) | (READ(pict, pixel + 1) << 8) | @@ -1070,7 +1070,7 @@ fbFetchPixel_b8g8r8 (bits_image_t *pict, uint32_t *buffer, int n_pixels) { uint32_t *bits = pict->bits + line*pict->rowstride; uint8_t *pixel = ((uint8_t *) bits) + (offset*3); -#if IMAGE_BYTE_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN buffer[i] = (0xff000000 | (READ(pict, pixel + 2) << 16) | (READ(pict, pixel + 1) << 8) | @@ -1747,7 +1747,7 @@ fbFetchPixel_a1 (bits_image_t *pict, uint32_t *buffer, int n_pixels) uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, bits + (offset >> 5)); uint32_t a; -#if BITMAP_BIT_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN a = pixel >> (0x1f - (offset & 0x1f)); #else a = pixel >> (offset & 0x1f); @@ -1781,7 +1781,7 @@ fbFetchPixel_g1 (bits_image_t *pict, uint32_t *buffer, int n_pixels) uint32_t pixel = READ(pict, bits + (offset >> 5)); const pixman_indexed_t * indexed = pict->indexed; uint32_t a; -#if BITMAP_BIT_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN a = pixel >> (0x1f - (offset & 0x1f)); #else a = pixel >> (offset & 0x1f); @@ -2090,7 +2090,7 @@ fbStore_b8g8r8 (pixman_image_t *image, uint8_t *pixel = ((uint8_t *) bits) + 3*x; for (i = 0; i < width; ++i) { uint32_t val = values[i]; -#if IMAGE_BYTE_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN WRITE(image, pixel++, Blue(val)); WRITE(image, pixel++, Green(val)); WRITE(image, pixel++, Red(val)); @@ -2325,7 +2325,7 @@ fbStore_x4a4 (pixman_image_t *image, } #define Store8(img,l,o,v) (WRITE(img, (uint8_t *)(l) + ((o) >> 3), (v))) -#if IMAGE_BYTE_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN #define Store4(img,l,o,v) Store8(img,l,o,((o) & 4 ? \ (Fetch8(img,l,o) & 0xf0) | (v) : \ (Fetch8(img,l,o) & 0x0f) | ((v) << 4))) diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index a23ed9c..66fab9d 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -17,17 +17,6 @@ #define TRUE 1 #endif -#define MSBFirst 0 -#define LSBFirst 1 - -#ifdef WORDS_BIGENDIAN -# define IMAGE_BYTE_ORDER MSBFirst -# define BITMAP_BIT_ORDER MSBFirst -#else -# define IMAGE_BYTE_ORDER LSBFirst -# define BITMAP_BIT_ORDER LSBFirst -#endif - #undef DEBUG #define DEBUG 0 @@ -437,14 +426,14 @@ _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker, #define FB_STIP_MASK (FB_STIP_UNIT - 1) #define FB_STIP_ALLONES ((uint32_t) -1) -#if BITMAP_BIT_ORDER == LSBFirst -#define FbScrLeft(x,n) ((x) >> (n)) -#define FbScrRight(x,n) ((x) << (n)) -#define FbLeftStipBits(x,n) ((x) & ((((uint32_t) 1) << (n)) - 1)) -#else +#ifdef WORDS_BIGENDIAN #define FbScrLeft(x,n) ((x) << (n)) #define FbScrRight(x,n) ((x) >> (n)) #define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n))) +#else +#define FbScrLeft(x,n) ((x) >> (n)) +#define FbScrRight(x,n) ((x) << (n)) +#define FbLeftStipBits(x,n) ((x) & ((((uint32_t) 1) << (n)) - 1)) #endif #define FbStipLeft(x,n) FbScrLeft(x,n) @@ -472,7 +461,7 @@ _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker, n >>= FB_SHIFT; \ } -#if IMAGE_BYTE_ORDER == MSBFirst +#ifdef WORDS_BIGENDIAN #define Fetch24(img, a) ((unsigned long) (a) & 1 ? \ ((READ(img, a) << 16) | READ(img, (uint16_t *) ((a)+1))) : \ ((READ(img, (uint16_t *) (a)) << 8) | READ(img, (a)+2))) -- 2.7.4