diff options
author | Soren Sandmann Pedersen <ssp@dhcp83-218.boston.redhat.com> | 2007-04-24 19:02:44 -0400 |
---|---|---|
committer | Soren Sandmann Pedersen <ssp@dhcp83-218.boston.redhat.com> | 2007-04-24 19:02:44 -0400 |
commit | 0a2fe443d25b1ca25349aba3f748df986952e20f (patch) | |
tree | da664101e86d0f5ef451e8634844fec7d31000f0 /fb/fbpict.c | |
parent | 7e16da7b78c422f96387502b9cc29eaa1741543f (diff) |
Use READ/WRITE macros for new functions introduced in previous commits.
Diffstat (limited to 'fb/fbpict.c')
-rw-r--r-- | fb/fbpict.c | 515 |
1 files changed, 257 insertions, 258 deletions
diff --git a/fb/fbpict.c b/fb/fbpict.c index 8ca733604..44bee1bca 100644 --- a/fb/fbpict.c +++ b/fb/fbpict.c @@ -100,7 +100,7 @@ fbIn (CARD32 x, CARD8 y) #define inOver0888(alpha, source, destval, dest) { \ CARD32 dstrb=destval&0xFF00FF; CARD32 dstag=(destval>>8)&0xFF00FF; \ CARD32 drb=((source&0xFF00FF)-dstrb)*alpha; CARD32 dag=(((source>>8)&0xFF00FF)-dstag)*alpha; \ - dest =((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00)); \ + WRITE(dest, ((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00))); \ } /* @@ -111,42 +111,42 @@ fbIn (CARD32 x, CARD8 y) #define inOver0565(alpha, source, destval, dest) { \ CARD16 dstrb = destval & 0xf81f; CARD16 dstg = destval & 0x7e0; \ CARD32 drb = ((source&0xf81f)-dstrb)*alpha; CARD32 dg=((source & 0x7e0)-dstg)*alpha; \ - dest = ((((drb>>5) + dstrb)&0xf81f) | (((dg>>5) + dstg) & 0x7e0)); \ + WRITE(dest, ((((drb>>5) + dstrb)&0xf81f) | (((dg>>5) + dstg) & 0x7e0))); \ } #define inOver2x0565(alpha, source, destval, dest) { \ CARD32 dstrb = destval & 0x07e0f81f; CARD32 dstg = (destval & 0xf81f07e0)>>5; \ CARD32 drb = ((source&0x07e0f81f)-dstrb)*alpha; CARD32 dg=(((source & 0xf81f07e0)>>5)-dstg)*alpha; \ - dest = ((((drb>>5) + dstrb)&0x07e0f81f) | ((((dg>>5) + dstg)<<5) & 0xf81f07e0)); \ + WRITE(dest, ((((drb>>5) + dstrb)&0x07e0f81f) | ((((dg>>5) + dstg)<<5) & 0xf81f07e0))); \ } #if IMAGE_BYTE_ORDER == LSBFirst - #define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \ +#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \ temp=count&3; \ where-=temp; \ workingWhere=(CARD32 *)where; \ - workingVal=*workingWhere++; \ + workingVal=READ(workingWhere++); \ count=4-temp; \ workingVal>>=(8*temp) - #define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y=*z++; } where=(y)&0xff; (y)>>=8; (x)--;} + #define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y = READ(z++); } where=(y)&0xff; (y)>>=8; (x)--;} #define readPackedSource(where) readPacked(where,ws,workingSource,wsrc) #define readPackedDest(where) readPacked(where,wd,workingiDest,widst) - #define writePacked(what) workingoDest>>=8; workingoDest|=(what<<24); ww--; if(!ww) { ww=4; *wodst++=workingoDest; } + #define writePacked(what) workingoDest>>=8; workingoDest|=(what<<24); ww--; if(!ww) { ww=4; WRITE (wodst++, workingoDest); } #else #warning "I havn't tested fbCompositeTrans_0888xnx0888() on big endian yet!" #define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \ temp=count&3; \ where-=temp; \ workingWhere=(CARD32 *)where; \ - workingVal=*workingWhere++; \ + workingVal=READ(workingWhere)++; \ count=4-temp; \ workingVal<<=(8*temp) - #define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y=*z++; } where=(y)>>24; (y)<<=8; (x)--;} + #define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y = READ(z++); } where=(y)>>24; (y)<<=8; (x)--;} #define readPackedSource(where) readPacked(where,ws,workingSource,wsrc) #define readPackedDest(where) readPacked(where,wd,workingiDest,widst) - #define writePacked(what) workingoDest<<=8; workingoDest|=what; ww--; if(!ww) { ww=4; *wodst++=workingoDest; } + #define writePacked(what) workingoDest<<=8; workingoDest|=what; ww--; if(!ww) { ww=4; WRITE(wodst++, workingoDest); } #endif /* @@ -328,65 +328,65 @@ fbCompositeSolidMask_nx8x0888 (CARD8 op, fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3); fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - while (height--) - { - /* fixme: cleanup unused */ - unsigned int wt,wd; - CARD32 workingiDest; - CARD32 *widst; - - edst=dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - + while (height--) + { + /* fixme: cleanup unused */ + unsigned int wt, wd; + CARD32 workingiDest; + CARD32 *widst; + + edst = dst = dstLine; + dstLine += dstStride; + mask = maskLine; + maskLine += maskStride; + w = width; + #ifndef NO_MASKED_PACKED_READ - setupPackedReader(wd,wt,edst,widst,workingiDest); + setupPackedReader(wd,wt,edst,widst,workingiDest); #endif - - while (w--) - { + + while (w--) + { #ifndef NO_MASKED_PACKED_READ - readPackedDest(rd); - readPackedDest(gd); - readPackedDest(bd); + readPackedDest(rd); + readPackedDest(gd); + readPackedDest(bd); #else - rd= *edst++; - gd= *edst++; - bd= *edst++; + rd = READ(edst++); + gd = READ(edst++); + bd = READ(edst++); #endif - m = *mask++; - if (m == 0xff) - { - if (srca == 0xff) - { - *dst++=rs; - *dst++=gs; - *dst++=bs; - } - else - { - *dst++=(srcAlphaCombine24(rs, rd)>>8); - *dst++=(srcAlphaCombine24(gs, gd)>>8); - *dst++=(srcAlphaCombine24(bs, bd)>>8); - } - } - else if (m) - { - int na=(srca*(int)m)>>8; - int nia=255-na; - *dst++=(genericCombine24(rs, rd, na, nia)>>8); - *dst++=(genericCombine24(gs, gd, na, nia)>>8); - *dst++=(genericCombine24(bs, bd, na, nia)>>8); - } - else - { - dst+=3; - } + m = READ(mask++); + if (m == 0xff) + { + if (srca == 0xff) + { + WRITE(dst++, rs); + WRITE(dst++, gs); + WRITE(dst++, bs); } + else + { + WRITE(dst++, (srcAlphaCombine24(rs, rd)>>8)); + WRITE(dst++, (srcAlphaCombine24(gs, gd)>>8)); + WRITE(dst++, (srcAlphaCombine24(bs, bd)>>8)); + } + } + else if (m) + { + int na=(srca*(int)m)>>8; + int nia=255-na; + WRITE(dst++, (genericCombine24(rs, rd, na, nia)>>8)); + WRITE(dst++, (genericCombine24(gs, gd, na, nia)>>8)); + WRITE(dst++, (genericCombine24(bs, bd, na, nia)>>8)); + } + else + { + dst+=3; + } } - + } + fbFinishAccess (pMask->pDrawable); fbFinishAccess (pDst->pDrawable); } @@ -414,8 +414,6 @@ fbCompositeSolidMask_nx8x0565 (CARD8 op, CARD16 w,src16; fbComposeGetSolid(pSrc, src, pDst->format); - - if (src == 0) return; @@ -437,23 +435,23 @@ fbCompositeSolidMask_nx8x0565 (CARD8 op, while (w--) { - m = *mask++; + m = READ(mask++); if (m == 0) dst++; else if (srca5 == (0xff >> 3)) { if (m == 0xff) - *dst++ = src16; + WRITE(dst++, src16); else { - d = *dst; + d = READ(dst); m >>= 3; - inOver0565 (m, src16, d, *dst++); + inOver0565 (m, src16, d, dst++); } } else { - d = *dst; + d = READ(dst); if (m == 0xff) { t = fbOver24 (src, cvt0565to0888 (d)); @@ -463,7 +461,7 @@ fbCompositeSolidMask_nx8x0565 (CARD8 op, t = fbIn (src, m); t = fbOver (t, cvt0565to0888 (d)); } - *dst++ = cvt8888to0565 (t); + WRITE(dst++, cvt8888to0565 (t)); } } } @@ -517,34 +515,34 @@ fbCompositeSolidMask_nx8888x0565 (CARD8 op, while (w--) { - m = *mask++ >> 24; + m = READ(mask++) >> 24; if (m == 0) dst++; else if (srca5 == (0xff >> 3)) { if (m == 0xff) - *dst++ = src16; + WRITE(dst++, src16); else { - d = *dst; + d = READ(dst); m >>= 3; - inOver0565 (m, src16, d, *dst++); + inOver0565 (m, src16, d, dst++); } } else { if (m == 0xff) { - d = *dst; + d = READ(dst); t = fbOver24 (src, cvt0565to0888 (d)); - *dst++ = cvt8888to0565 (t); + WRITE(dst++, cvt8888to0565 (t)); } else { - d = *dst; + d = READ(dst); t = fbIn (src, m); t = fbOver (t, cvt0565to0888 (d)); - *dst++ = cvt8888to0565 (t); + WRITE(dst++, cvt8888to0565 (t)); } } } @@ -1078,9 +1076,9 @@ fbCompositeTrans_0565xnx0565(CARD8 op, if(((int)src&1)==1) { - s_16 = *src++; - d_16 = *dst; - inOver0565(maskAlpha, s_16, d_16, *dst++); + s_16 = READ(src++); + d_16 = READ(dst); + inOver0565(maskAlpha, s_16, d_16, dst++); w--; } isrc=(CARD32 *)src; @@ -1089,9 +1087,9 @@ fbCompositeTrans_0565xnx0565(CARD8 op, idst=(CARD32 *)dst; while (w>1) { - s_32 = *isrc++; - d_32 = *idst; - inOver2x0565(maskAlpha, s_32, d_32, *idst++); + s_32 = READ(isrc++); + d_32 = READ(idst); + inOver2x0565(maskAlpha, s_32, d_32, idst++); w-=2; } dst=(CARD16 *)idst; @@ -1100,30 +1098,30 @@ fbCompositeTrans_0565xnx0565(CARD8 op, { while (w > 1) { - s_32 = *isrc++; + s_32 = READ(isrc++); #if IMAGE_BYTE_ORDER == LSBFirst s_16=s_32&0xffff; #else s_16=s_32>>16; #endif - d_16 = *dst; - inOver0565 (maskAlpha, s_16, d_16, *dst++); + d_16 = READ(dst); + inOver0565 (maskAlpha, s_16, d_16, dst++); #if IMAGE_BYTE_ORDER == LSBFirst s_16=s_32>>16; #else s_16=s_32&0xffff; #endif - d_16 = *dst; - inOver0565(maskAlpha, s_16, d_16, *dst++); + d_16 = READ(dst); + inOver0565(maskAlpha, s_16, d_16, dst++); w-=2; } } src=(CARD16 *)isrc; if(w!=0) { - s_16 = *src; - d_16 = *dst; - inOver0565(maskAlpha, s_16, d_16, *dst); + s_16 = READ(src); + d_16 = READ(dst); + inOver0565(maskAlpha, s_16, d_16, dst); } } @@ -1133,6 +1131,7 @@ fbCompositeTrans_0565xnx0565(CARD8 op, /* macros for "i can't believe it's not fast" packed pixel handling */ #define alphamaskCombine24(a,b) genericCombine24(a,b,maskAlpha,maskiAlpha) + static void fbCompositeTrans_0888xnx0888(CARD8 op, PicturePtr pSrc, @@ -1146,175 +1145,175 @@ fbCompositeTrans_0888xnx0888(CARD8 op, INT16 yDst, CARD16 width, CARD16 height) - { - CARD8 *dstLine, *dst,*idst; - CARD8 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - FbBits mask; - CARD16 maskAlpha,maskiAlpha; - - fbComposeGetSolid (pMask, mask, pDst->format); - maskAlpha = mask >> 24; - maskiAlpha= 255-maskAlpha; - - if (!maskAlpha) - return; - /* - if (maskAlpha == 0xff) - { - fbCompositeSrc_0888x0888 (op, pSrc, pMask, pDst, - xSrc, ySrc, xMask, yMask, xDst, yDst, - width, height); +{ + CARD8 *dstLine, *dst,*idst; + CARD8 *srcLine, *src; + FbStride dstStride, srcStride; + CARD16 w; + FbBits mask; + CARD16 maskAlpha,maskiAlpha; + + fbComposeGetSolid (pMask, mask, pDst->format); + maskAlpha = mask >> 24; + maskiAlpha= 255-maskAlpha; + + if (!maskAlpha) return; - } - */ - - fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 3); - fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3); - - { - unsigned int ws,wt; - CARD32 workingSource; - CARD32 *wsrc, *wdst, *widst; - CARD32 rs, rd, nd; - CARD8 *isrc; - - - /* are xSrc and xDst at the same alignment? if not, we need to be complicated :) */ - /* if(0==0) */ - if( (((xSrc*3)&3)!=((xDst*3)&3)) || ((srcStride&3)!=(dstStride&3))) - { - while (height--) - { - dst = dstLine; - dstLine += dstStride; - isrc = src = srcLine; - srcLine += srcStride; - w = width*3; - - setupPackedReader(ws,wt,isrc,wsrc,workingSource); - - /* get to word aligned */ - switch(!(int)src&3) - { - case 1: - readPackedSource(rs); - /* *dst++=alphamaskCombine24(rs, *dst)>>8; */ - rd=*dst; /* make gcc happy. hope it doens't cost us too much performance*/ - *dst++=alphamaskCombine24(rs, rd)>>8; - w--; if(w==0) break; - case 2: - readPackedSource(rs); - rd=*dst; - *dst++=alphamaskCombine24(rs, rd)>>8; - w--; if(w==0) break; - case 3: - readPackedSource(rs); - rd=*dst; - *dst++=alphamaskCombine24(rs, rd)>>8; - w--; if(w==0) break; - } - wdst=(CARD32 *)dst; - while (w>3) - { - rs=*wsrc++; - /* FIXME: write a special readPackedWord macro, which knows how to - * halfword combine - */ - #if IMAGE_BYTE_ORDER == LSBFirst - rd=*wdst; - readPackedSource(nd); - readPackedSource(rs); - nd|=rs<<8; - readPackedSource(rs); - nd|=rs<<16; - readPackedSource(rs); - nd|=rs<<24; + /* + if (maskAlpha == 0xff) + { + fbCompositeSrc_0888x0888 (op, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height); + return; + } + */ + + fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 3); + fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3); + + { + unsigned int ws,wt; + CARD32 workingSource; + CARD32 *wsrc, *wdst, *widst; + CARD32 rs, rd, nd; + CARD8 *isrc; + + + /* are xSrc and xDst at the same alignment? if not, we need to be complicated :) */ + /* if(0==0) */ + if ((((xSrc * 3) & 3) != ((xDst * 3) & 3)) || + ((srcStride & 3) != (dstStride & 3))) + { + while (height--) + { + dst = dstLine; + dstLine += dstStride; + isrc = src = srcLine; + srcLine += srcStride; + w = width*3; + + setupPackedReader(ws,wt,isrc,wsrc,workingSource); + + /* get to word aligned */ + switch(!(int)src&3) + { + case 1: + readPackedSource(rs); + /* *dst++=alphamaskCombine24(rs, *dst)>>8; */ + rd = READ(dst); /* make gcc happy. hope it doens't cost us too much performance*/ + WRITE(dst++, alphamaskCombine24(rs, rd) >> 8); + w--; if(w==0) break; + case 2: + readPackedSource(rs); + rd = READ(dst); + WRITE(dst++, alphamaskCombine24(rs, rd) >> 8); + w--; if(w==0) break; + case 3: + readPackedSource(rs); + rd = READ(dst); + WRITE(dst++,alphamaskCombine24(rs, rd) >> 8); + w--; if(w==0) break; + } + wdst=(CARD32 *)dst; + while (w>3) + { + rs=READ(wsrc++); + /* FIXME: write a special readPackedWord macro, which knows how to + * halfword combine + */ +#if IMAGE_BYTE_ORDER == LSBFirst + rd=READ(wdst); + readPackedSource(nd); + readPackedSource(rs); + nd|=rs<<8; + readPackedSource(rs); + nd|=rs<<16; + readPackedSource(rs); + nd|=rs<<24; #else - readPackedSource(nd); - nd<<=24; - readPackedSource(rs); - nd|=rs<<16; - readPackedSource(rs); - nd|=rs<<8; - readPackedSource(rs); - nd|=rs; + readPackedSource(nd); + nd<<=24; + readPackedSource(rs); + nd|=rs<<16; + readPackedSource(rs); + nd|=rs<<8; + readPackedSource(rs); + nd|=rs; #endif - inOver0888(maskAlpha, nd, rd, *wdst++); - w-=4; - } - src=(CARD8 *)wdst; - switch(w) - { - case 3: - readPackedSource(rs); - rd=*dst; - *dst++=alphamaskCombine24(rs, rd)>>8; - case 2: - readPackedSource(rs); - rd=*dst; - *dst++=alphamaskCombine24(rs, rd)>>8; - case 1: - readPackedSource(rs); - rd=*dst; - *dst++=alphamaskCombine24(rs, rd)>>8; - } - } - } - else - { - while (height--) - { - idst=dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width*3; - /* get to word aligned */ - switch(!(int)src&3) - { - case 1: - rd=alphamaskCombine24(*src++, *dst)>>8; - *dst++=rd; - w--; if(w==0) break; - case 2: - rd=alphamaskCombine24(*src++, *dst)>>8; - *dst++=rd; - w--; if(w==0) break; - case 3: - rd=alphamaskCombine24(*src++, *dst)>>8; - *dst++=rd; - w--; if(w==0) break; - } - wsrc=(CARD32 *)src; - widst=(CARD32 *)dst; - while(w>3) - { - rs = *wsrc++; - rd = *widst; - inOver0888 (maskAlpha, rs, rd, *widst++); - w-=4; - } - src=(CARD8 *)wsrc; - dst=(CARD8 *)widst; - switch(w) - { - case 3: - rd=alphamaskCombine24(*src++, *dst)>>8; - *dst++=rd; - case 2: - rd=alphamaskCombine24(*src++, *dst)>>8; - *dst++=rd; - case 1: - rd=alphamaskCombine24(*src++, *dst)>>8; - *dst++=rd; - } - } - } - } - } - + inOver0888(maskAlpha, nd, rd, wdst++); + w-=4; + } + src=(CARD8 *)wdst; + switch(w) + { + case 3: + readPackedSource(rs); + rd=READ(dst); + WRITE(dst++,alphamaskCombine24(rs, rd)>>8); + case 2: + readPackedSource(rs); + rd = READ(dst); + WRITE(dst++, alphamaskCombine24(rs, rd)>>8); + case 1: + readPackedSource(rs); + rd = READ(dst); + WRITE(dst++, alphamaskCombine24(rs, rd)>>8); + } + } + } + else + { + while (height--) + { + idst=dst = dstLine; + dstLine += dstStride; + src = srcLine; + srcLine += srcStride; + w = width*3; + /* get to word aligned */ + switch(!(int)src&3) + { + case 1: + rd=alphamaskCombine24(READ(src++), READ(dst))>>8; + WRITE(dst++, rd); + w--; if(w==0) break; + case 2: + rd=alphamaskCombine24(READ(src++), READ(dst))>>8; + WRITE(dst++, rd); + w--; if(w==0) break; + case 3: + rd=alphamaskCombine24(READ(src++), READ(dst))>>8; + WRITE(dst++, rd); + w--; if(w==0) break; + } + wsrc=(CARD32 *)src; + widst=(CARD32 *)dst; + while(w>3) + { + rs = READ(wsrc++); + rd = READ(widst); + inOver0888 (maskAlpha, rs, rd, widst++); + w-=4; + } + src=(CARD8 *)wsrc; + dst=(CARD8 *)widst; + switch(w) + { + case 3: + rd=alphamaskCombine24(READ(src++), READ(dst))>>8; + WRITE(dst++, rd); + case 2: + rd=alphamaskCombine24(READ(src++), READ(dst))>>8; + WRITE(dst++, rd); + case 1: + rd=alphamaskCombine24(READ(src++), READ(dst))>>8; + WRITE(dst++, rd); + } + } + } + } +} /* * Simple bitblt |