From e9e326eafe3e4ed221eefbb7ddbd46d5d983505d Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann?= Date: Sat, 19 May 2007 17:05:23 -0400 Subject: [PATCH] Add fbComposeGetSolid() macro --- pixman/pixman-compose.c | 18 --------------- pixman/pixman-pict.c | 59 +++++++++++++++++++++++++++++++++++++++++-------- pixman/pixman-private.h | 53 ++++++++++++++++++++++++++++++-------------- 3 files changed, 87 insertions(+), 43 deletions(-) diff --git a/pixman/pixman-compose.c b/pixman/pixman-compose.c index 800c241..50fa29e 100644 --- a/pixman/pixman-compose.c +++ b/pixman/pixman-compose.c @@ -1691,24 +1691,6 @@ fbStore_c4 (pixman_image_t *image, }); } -#define LOG2_BITMAP_PAD 5 -#define FB_STIP_SHIFT LOG2_BITMAP_PAD -#define FB_STIP_UNIT (1 << FB_STIP_SHIFT) -#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)) -#else -#define FbScrLeft(x,n) ((x) << (n)) -#define FbScrRight(x,n) ((x) >> (n)) -#endif -#define FbStipLeft(x,n) FbScrLeft(x,n) -#define FbStipRight(x,n) FbScrRight(x,n) -#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \ - FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK)) - static FASTCALL void fbStore_a1 (pixman_image_t *image, uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed) diff --git a/pixman/pixman-pict.c b/pixman/pixman-pict.c index c4d8022..0868c51 100644 --- a/pixman/pixman-pict.c +++ b/pixman/pixman-pict.c @@ -26,11 +26,52 @@ #include "pixman.h" #include "pixman-private.h" +#define fbComposeGetSolid(img, res, fmt) do { \ + uint32_t *bits__ = (img)->bits.bits; \ + pixman_format_code_t format__ = (img)->bits.format; \ + \ + switch (PIXMAN_FORMAT_BPP((img)->bits.format)) \ + { \ + case 32: \ + (res) = READ((uint32_t *)bits__); \ + break; \ + case 24: \ + (res) = Fetch24 ((uint8_t *) bits__); \ + break; \ + case 16: \ + (res) = READ((uint16_t *) bits__); \ + (res) = cvt0565to0888(res); \ + break; \ + case 8: \ + (res) = READ((uint8_t *) bits__); \ + (res) = (res) << 24; \ + break; \ + case 1: \ + (res) = READ((uint32_t *) bits__); \ + (res) = FbLeftStipBits((res),1) ? 0xff000000 : 0x00000000; \ + break; \ + default: \ + return; \ + } \ + /* If necessary, convert RGB <--> BGR. */ \ + if (format__ != PIXMAN_FORMAT_TYPE(fmt)) \ + { \ + (res) = (((res) & 0xff000000) | \ + (((res) & 0x00ff0000) >> 16) | \ + (((res) & 0x0000ff00) >> 0) | \ + (((res) & 0x000000ff) << 16)); \ + } \ + /* manage missing src alpha */ \ + if (!PIXMAN_FORMAT_A((img)->bits.format)) \ + (res) |= 0xff000000; \ + } while (0) + +#define FbFullMask(n) ((n) == 32 ? (uint32_t)-1 : ((((uint32_t) 1) << n) - 1)) + /* FIXME: these are just stubs */ -#define fbComposeGetSolid(a,b,c) #define fbComposeGetStart(a,b,c,d,e,f,g) #define fbGetDrawable(a,b,c,d,e,f) -#define FbFullMask(n) ((n) == 32 ? (uint32_t)-1 : ((((uint32_t) 1) << n) - 1)) + #undef READ #undef WRITE #define READ(x) (*(x)) @@ -108,7 +149,7 @@ fbCompositeSolidMask_nx8x8888 (pixman_op_t op, int dstStride, maskStride; uint16_t w; - fbComposeGetSolid(pSrc, src, pDst->format); + fbComposeGetSolid(pSrc, src, pDst->bits.format); dstMask = FbFullMask (PIXMAN_FORMAT_DEPTH (pDst->bits.format)); srca = src >> 24; @@ -170,7 +211,7 @@ fbCompositeSolidMask_nx8888x8888C (pixman_op_t op, uint16_t w; uint32_t m, n, o, p; - fbComposeGetSolid(pSrc, src, pDst->format); + fbComposeGetSolid(pSrc, src, pDst->bits.format); dstMask = FbFullMask (PIXMAN_FORMAT_DEPTH (pDst->bits.format)); srca = src >> 24; @@ -246,7 +287,7 @@ fbCompositeSolidMask_nx8x0888 (pixman_op_t op, int dstStride, maskStride; uint16_t w; - fbComposeGetSolid(pSrc, src, pDst->format); + fbComposeGetSolid(pSrc, src, pDst->bits.format); srca = src >> 24; if (src == 0) @@ -311,7 +352,7 @@ fbCompositeSolidMask_nx8x0565 (pixman_op_t op, int dstStride, maskStride; uint16_t w; - fbComposeGetSolid(pSrc, src, pDst->format); + fbComposeGetSolid(pSrc, src, pDst->bits.format); srca = src >> 24; if (src == 0) @@ -379,7 +420,7 @@ fbCompositeSolidMask_nx8888x0565C (pixman_op_t op, uint16_t w; uint32_t m, n, o; - fbComposeGetSolid(pSrc, src, pDst->format); + fbComposeGetSolid(pSrc, src, pDst->bits.format); srca = src >> 24; if (src == 0) @@ -724,7 +765,7 @@ fbCompositeSrcAdd_8888x8x8 (pixman_op_t op, fbComposeGetStart (pDst, xDst, yDst, uint8_t, dstStride, dstLine, 1); fbComposeGetStart (pMask, xMask, yMask, uint8_t, maskStride, maskLine, 1); - fbComposeGetSolid (pSrc, src, pDst->format); + fbComposeGetSolid (pSrc, src, pDst->bits.format); sa = (src >> 24); while (height--) @@ -830,7 +871,7 @@ fbCompositeSolidMask_nx1xn (pixman_op_t op, int maskXoff, maskYoff; uint32_t src; - fbComposeGetSolid(pSrc, src, pDst->format); + fbComposeGetSolid(pSrc, src, pDst->bits.format); fbGetStipDrawable (pMask->pDrawable, maskBits, maskStride, maskBpp, maskXoff, maskYoff); fbGetDrawable (pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff); diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index ccc7ef8..fbb8cb7 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -20,26 +20,26 @@ #if DEBUG -#define return_if_fail(expr) \ - do \ - { \ - if (!(expr)) \ - { \ +#define return_if_fail(expr) \ + do \ + { \ + if (!(expr)) \ + { \ fprintf(stderr, "In %s: %s failed\n", FUNC, #expr); \ - return; \ - } \ - } \ + return; \ + } \ + } \ while (0) -#define return_val_if_fail(expr, retval) \ - do \ - { \ - if (!(expr)) \ - { \ +#define return_val_if_fail(expr, retval) \ + do \ + { \ + if (!(expr)) \ + { \ fprintf(stderr, "In %s: %s failed\n", FUNC, #expr); \ - return (retval); \ - } \ - } \ + return (retval); \ + } \ + } \ while (0) #else @@ -214,6 +214,27 @@ union pixman_image void pixmanCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer); +#define LOG2_BITMAP_PAD 5 +#define FB_STIP_SHIFT LOG2_BITMAP_PAD +#define FB_STIP_UNIT (1 << FB_STIP_SHIFT) +#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 +#define FbScrLeft(x,n) ((x) << (n)) +#define FbScrRight(x,n) ((x) >> (n)) +#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n))) +#endif + +#define FbStipLeft(x,n) FbScrLeft(x,n) +#define FbStipRight(x,n) FbScrRight(x,n) +#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \ + FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK)) + #if IMAGE_BYTE_ORDER == MSBFirst #define Fetch24(a) ((unsigned long) (a) & 1 ? \ ((READ(a) << 16) | READ((uint16_t *) ((a)+1))) : \ -- 2.7.4