diff options
author | Adam Jackson <ajax@nwnk.net> | 2005-05-08 23:34:15 +0000 |
---|---|---|
committer | Adam Jackson <ajax@nwnk.net> | 2005-05-08 23:34:15 +0000 |
commit | 2de24db63eb65974ac547facf2a99aa4709d54b3 (patch) | |
tree | 9e1c2d5ea337b9c7fa01a8cd3cfc8a3dcc233205 /fb/fbpict.h | |
parent | 2c9b1e337b2e82e10909f62e8cd8c2c7a402fdd8 (diff) |
Render performance improvements. (Lars Knoll, Zack Rusin)
Diffstat (limited to 'fb/fbpict.h')
-rw-r--r-- | fb/fbpict.h | 790 |
1 files changed, 126 insertions, 664 deletions
diff --git a/fb/fbpict.h b/fb/fbpict.h index 3b88bfa37..ed59b0ed7 100644 --- a/fb/fbpict.h +++ b/fb/fbpict.h @@ -59,18 +59,10 @@ (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i)) -typedef void (*CompositeFunc) (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); +#define Alpha(x) ((x) >> 24) +#define Red(x) (((x) >> 16) & 0xff) +#define Green(x) (((x) >> 8) & 0xff) +#define Blue(x) ((x) & 0xff) #define fbComposeGetSolid(pict, bits, fmt) { \ FbBits *__bits__; \ @@ -143,675 +135,145 @@ typedef void (*CompositeFunc) (CARD8 op, (*((a)+2) = (CARD8) ((v) >> 16)))) #endif - -typedef struct _FbCompositeOperand FbCompositeOperand; - -typedef CARD32 (*FbCompositeFetch)(FbCompositeOperand *op); -typedef void (*FbCompositeStore) (FbCompositeOperand *op, CARD32 value); - -typedef void (*FbCompositeStep) (FbCompositeOperand *op); -typedef void (*FbCompositeSet) (FbCompositeOperand *op, int x, int y); - -struct _FbCompositeOperand { - union { - struct { - FbBits *top_line; - int left_offset; - - int start_offset; - FbBits *line; - CARD32 offset; - FbStride stride; - int bpp; - } drawable; - struct { - int alpha_dx; - int alpha_dy; - } external; - struct { - int top_y; - int left_x; - int start_x; - int x; - int y; - PictTransformPtr transform; - int filter; - } transform; - } u; - FbCompositeFetch fetch; - FbCompositeFetch fetcha; - FbCompositeStore store; - FbCompositeStep over; - FbCompositeStep down; - FbCompositeSet set; - miIndexedPtr indexed; - RegionPtr clip; -}; - -typedef void (*FbCombineFunc) (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - /* - * indexed by op - */ -extern FbCombineFunc fbCombineFunc[]; - -typedef struct _FbAccessMap { - CARD32 format; - FbCompositeFetch fetch; - FbCompositeFetch fetcha; - FbCompositeStore store; -} FbAccessMap; + The methods below use some tricks to be able to do two color + components at the same time. +*/ /* - * search on format - */ -extern FbAccessMap fbAccessMap[]; - -/* fbcompose.c */ - -typedef struct _fbCompSrc { - CARD32 value; - CARD32 alpha; -} FbCompSrc; + x_c = (x_c * a) / 255 +*/ +#define FbByteMul(x, a) do { \ + CARD32 t = (x & 0xff00ff) *a; \ + t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; \ + t &= 0xff00ff; \ + \ + x = ((x >> 8) & 0xff00ff) * a; \ + x = (x + ((x >> 8) & 0xff00ff) + 0x800080); \ + x &= 0xff00ff00; \ + x += t; \ + } while (0) /* - * All compositing operators * - */ - -CARD32 -fbCombineMaskU (FbCompositeOperand *src, - FbCompositeOperand *msk); - -FbCompSrc -fbCombineMaskC (FbCompositeOperand *src, - FbCompositeOperand *msk); - -CARD32 -fbCombineMaskValueC (FbCompositeOperand *src, - FbCompositeOperand *msk); - -CARD32 -fbCombineMaskAlphaU (FbCompositeOperand *src, - FbCompositeOperand *msk); - -CARD32 -fbCombineMaskAlphaC (FbCompositeOperand *src, - FbCompositeOperand *msk); - - -#if 0 -CARD32 -FbCombineMask (FbCompositeOperand *src, - FbCompositeOperand *msk); -#endif - -void -fbCombineClear (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineSrcU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineSrcC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDst (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineOverU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineOverC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineOverReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineOverReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineInU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineInC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineInReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineInReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineOutU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineOutC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineOutReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineOutReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineAtopU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - - -void -fbCombineAtopC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineAtopReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineAtopReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineXorU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineXorC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - - -void -fbCombineAddU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineAddC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineSaturateU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineSaturateC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -CARD8 -fbCombineDisjointOutPart (CARD8 a, CARD8 b); - -CARD8 -fbCombineDisjointInPart (CARD8 a, CARD8 b); - -void -fbCombineDisjointGeneralU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst, - CARD8 combine); - -void -fbCombineDisjointGeneralC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst, - CARD8 combine); - -void -fbCombineDisjointOverU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointOverC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -#define fbCombineDisjointOverReverseU fbCombineSaturateU -#define fbCombineDisjointOverReverseC fbCombineSaturateC - -void -fbCombineDisjointInU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointInC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointInReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointInReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointOutU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointOutC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); -void -fbCombineDisjointOutReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointOutReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointAtopU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointAtopC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointAtopReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointAtopReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointXorU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointXorC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -CARD8 -fbCombineConjointOutPart (CARD8 a, CARD8 b); - -CARD8 -fbCombineConjointInPart (CARD8 a, CARD8 b); - - -void -fbCombineConjointGeneralU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst, - CARD8 combine); - -void -fbCombineConjointGeneralC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst, - CARD8 combine); - -void -fbCombineConjointOverU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointOverC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); -void -fbCombineConjointOverReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointOverReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointInU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointInC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointInReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - - -void -fbCombineConjointInReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointOutU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointOutC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointOutReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointOutReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointAtopU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointAtopC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointAtopReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); -void -fbCombineConjointAtopReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointXorU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineConjointXorC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); + x_c = (x_c * a + y_c * b) / 255 +*/ +#define FbByteAddMul(x, a, y, b) do { \ + CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; \ + t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; \ + t &= 0xff00ff; \ + \ + x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; \ + x = (x + ((x >> 8) & 0xff00ff) + 0x800080); \ + x &= 0xff00ff00; \ + x += t; \ +} while (0) /* - * All fetch functions - */ - -CARD32 -fbFetch_a8r8g8b8 (FbCompositeOperand *op); - -CARD32 -fbFetch_x8r8g8b8 (FbCompositeOperand *op); - -CARD32 -fbFetch_a8b8g8r8 (FbCompositeOperand *op); - -CARD32 -fbFetch_x8b8g8r8 (FbCompositeOperand *op); - -CARD32 -fbFetch_r8g8b8 (FbCompositeOperand *op); - -CARD32 -fbFetch_b8g8r8 (FbCompositeOperand *op); - -CARD32 -fbFetch_r5g6b5 (FbCompositeOperand *op); - -CARD32 -fbFetch_b5g6r5 (FbCompositeOperand *op); - -CARD32 -fbFetch_a1r5g5b5 (FbCompositeOperand *op); - -CARD32 -fbFetch_x1r5g5b5 (FbCompositeOperand *op); - -CARD32 -fbFetch_a1b5g5r5 (FbCompositeOperand *op); - -CARD32 -fbFetch_x1b5g5r5 (FbCompositeOperand *op); - -CARD32 -fbFetch_a4r4g4b4 (FbCompositeOperand *op); - -CARD32 -fbFetch_x4r4g4b4 (FbCompositeOperand *op); - -CARD32 -fbFetch_a4b4g4r4 (FbCompositeOperand *op); - -CARD32 -fbFetch_x4b4g4r4 (FbCompositeOperand *op); - -CARD32 -fbFetch_a8 (FbCompositeOperand *op); - -CARD32 -fbFetcha_a8 (FbCompositeOperand *op); - -CARD32 -fbFetch_r3g3b2 (FbCompositeOperand *op); - -CARD32 -fbFetch_b2g3r3 (FbCompositeOperand *op); - -CARD32 -fbFetch_a2r2g2b2 (FbCompositeOperand *op); - -CARD32 -fbFetch_a2b2g2r2 (FbCompositeOperand *op); - -CARD32 -fbFetch_c8 (FbCompositeOperand *op); - -CARD32 -fbFetch_a4 (FbCompositeOperand *op); - -CARD32 -fbFetcha_a4 (FbCompositeOperand *op); - -CARD32 -fbFetch_r1g2b1 (FbCompositeOperand *op); - -CARD32 -fbFetch_b1g2r1 (FbCompositeOperand *op); - -CARD32 -fbFetch_a1r1g1b1 (FbCompositeOperand *op); - -CARD32 -fbFetch_a1b1g1r1 (FbCompositeOperand *op); - -CARD32 -fbFetch_c4 (FbCompositeOperand *op); - -CARD32 -fbFetch_a1 (FbCompositeOperand *op); - -CARD32 -fbFetcha_a1 (FbCompositeOperand *op); - -CARD32 -fbFetch_g1 (FbCompositeOperand *op); - -void -fbStore_a8r8g8b8 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_x8r8g8b8 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_a8b8g8r8 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_x8b8g8r8 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_r8g8b8 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_b8g8r8 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_r5g6b5 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_b5g6r5 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_a1r5g5b5 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_x1r5g5b5 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_a1b5g5r5 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_x1b5g5r5 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_a4r4g4b4 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_x4r4g4b4 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_a4b4g4r4 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_x4b4g4r4 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_a8 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_r3g3b2 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_b2g3r3 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_a2r2g2b2 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_c8 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_g8 (FbCompositeOperand *op, CARD32 value); - - -void -fbStore_a4 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_r1g2b1 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_b1g2r1 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_a1r1g1b1 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_a1b1g1r1 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_c4 (FbCompositeOperand *op, CARD32 value); - -void -fbStore_g4 (FbCompositeOperand *op, CARD32 value); + x_c = (x_c * a + y_c *b) / 256 +*/ +#define FbByteAddMul_256(x, a, y, b) do { \ + CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; \ + t >>= 8; \ + t &= 0xff00ff; \ + \ + x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; \ + x &= 0xff00ff00; \ + x += t; \ +} while (0) +/* + x_c = (x_c * a_c) / 255 +*/ +#define FbByteMulC(x, a) do { \ + CARD32 t; \ + CARD32 r = (x & 0xff) * (a & 0xff); \ + r |= (x & 0xff0000) * ((a >> 16) & 0xff); \ + r = (r + ((r >> 8) & 0xff00ff) + 0x800080) >> 8; \ + r &= 0xff00ff; \ + \ + x >>= 8; \ + t = (x & 0xff) * ((a >> 8) & 0xff); \ + t |= (x & 0xff0000) * (a >> 24); \ + t = (t + ((t >> 8) & 0xff00ff) + 0x800080); \ + x = r | (t & 0xff00ff00); \ + \ + } while (0) -void -fbStore_a1 (FbCompositeOperand *op, CARD32 value); +/* + x_c = (x_c * a_c + y_c * b) / 255 +*/ +#define FbByteAddMulC(x, a, y, b) do { \ + CARD32 t; \ + CARD32 r = (x & 0xff) * (a & 0xff); \ + r |= (x & 0xff0000) * ((a >> 16) & 0xff); \ + r += (y & 0xff00ff) * b; \ + r = (r + ((r >> 8) & 0xff00ff) + 0x800080) >> 8; \ + r &= 0xff00ff; \ + \ + x >>= 8; \ + t = (x & 0xff) * ((a >> 8) & 0xff); \ + t |= (x & 0xff0000) * (a >> 24); \ + t += ((y >> 8) & 0xff00ff) * b; \ + t = (t + ((t >> 8) & 0xff00ff) + 0x800080); \ + x = r | (t & 0xff00ff00); \ + \ + } while (0) -void -fbStore_g1 (FbCompositeOperand *op, CARD32 value); +/* + x_c = min(x_c + y_c, 255) +*/ +#define FbByteAdd(x, y) do { \ + CARD32 t; \ + CARD32 r = (x & 0xff00ff) + (y & 0xff00ff); \ + r |= 0 - ((r >> 8) & 0xff00ff); \ + r &= 0xff00ff; \ + \ + t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff); \ + t |= 0 - ((t >> 8) & 0xff00ff); \ + r |= (t & 0xff00ff) << 8; \ + x = r; \ +} while (0) + +#define div_255(x) (((x) + ((x) >> 8) + 0x80) >> 8) + +#if defined(__i386__) && defined(__GNUC__) +#define FASTCALL __attribute__((regparm(3))) +#else +#define FASTCALL +#endif -CARD32 -fbFetch_external (FbCompositeOperand *op); +#if defined(__GNUC__) +#define INLINE __inline__ +#else +#define INLINE +#endif -CARD32 -fbFetch_transform (FbCompositeOperand *op); +typedef struct _FbComposeData { + CARD8 op; + PicturePtr src; + PicturePtr mask; + PicturePtr dest; + INT16 xSrc; + INT16 ySrc; + INT16 xMask; + INT16 yMask; + INT16 xDest; + INT16 yDest; + CARD16 width; + CARD16 height; +} FbComposeData; -CARD32 -fbFetcha_transform (FbCompositeOperand *op); -CARD32 -fbFetcha_external (FbCompositeOperand *op); +/* fbaddtrap.c */ void -fbStore_external (FbCompositeOperand *op, CARD32 value); +fbAddTraps (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, + int ntrap, + xTrap *traps); -Bool -fbBuildOneCompositeOperand (PicturePtr pPict, - FbCompositeOperand *op, - INT16 x, - INT16 y); +/* fbcompose.c */ -Bool -fbBuildCompositeOperand (PicturePtr pPict, - FbCompositeOperand *op, - INT16 x, - INT16 y, - Bool transform, - Bool alpha); void fbCompositeGeneral (CARD8 op, PicturePtr pSrc, |