[xserver-commit] xserver/fb fbpict.c,1.28,1.29 fbpict.h,1.15,1.16
Keith Packard
xserver-commit@pdx.freedesktop.org
Thu, 15 Jan 2004 01:09:31 -0800
Committed by: keithp
Update of /cvs/xserver/xserver/fb
In directory pdx:/tmp/cvs-serv18362/fb
Modified Files:
fbpict.c fbpict.h
Log Message:
2004-01-15 Keith Packard <keithp@keithp.com>
* fb/fbpict.c: (fbCompositeSolidMask_nx8x0888),
(fbCompositeSolidMask_nx8x0565),
(fbCompositeSolidMask_nx8888x0565),
(fbCompositeSolidMask_nx8888x0565C), (fbCompositeSrc_8888x0565),
(fbCompositeTrans_0565xnx0565), (fbCompositeTrans_0888xnx0888),
(fbCompositeSrcSrc_nxn), (fbComposite), (fbPictureInit):
* fb/fbpict.h:
Fix up the fast-path compositing operators; those are useful
for sources without alpha, but can't be used for sources with
alpha. Also, replaced fbCompositeSrcSrc_nxn with call to
fbBlt as this function must handle 1, 4, 8, 16, 24, 32 bpp
objects. Would be nice to optimize fbBlt for common cases
involving 8, 16, 24 and 32bpp.
Index: fbpict.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbpict.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- fbpict.c 28 Dec 2003 12:58:00 -0000 1.28
+++ fbpict.c 15 Jan 2004 09:09:29 -0000 1.29
@@ -37,7 +37,7 @@
#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \
(((s) >> 5) & 0x07e0) | \
(((s) >> 8) & 0xf800))
-#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
+#define cvt0565to0888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
@@ -132,7 +132,7 @@
break; \
case 16: \
(bits) = *(CARD16 *) __bits__; \
- (bits) = cvt0565to8888(bits); \
+ (bits) = cvt0565to0888(bits); \
break; \
case 8: \
(bits) = *(CARD8 *) __bits__; \
@@ -163,25 +163,32 @@
#define genericCombine24(a,b,c,d) (((a)*(c)+(b)*(d)))
-#define fastcombine32(alpha, source, destval, destptr) { \
+/*
+ * This macro does src IN mask OVER dst when src and dst are 0888.
+ * If src has alpha, this will not work
+ */
+#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; \
- *destptr++=((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00)); \
+ dest =((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00)); \
}
-/* Note: this macro expects 5 bits of alpha, not 8!
- * (single op can actually be changed to take 6 bits, but double op can't)
+/*
+ * This macro does src IN mask OVER dst when src and dst are 0565 and
+ * mask is a 5-bit alpha value. Again, if src has alpha, this will not
+ * work.
*/
-#define fastCombine0565(alpha, source, destval, destptr) { \
+
+#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; \
- destptr= ((((drb>>5) + dstrb)&0xf81f) | (((dg>>5) + dstg) & 0x7e0)); \
+ dest = ((((drb>>5) + dstrb)&0xf81f) | (((dg>>5) + dstg) & 0x7e0)); \
}
-#define fastCombine2x0565(alpha, source, destval, destptr) { \
+#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; \
- destptr= ((((drb>>5) + dstrb)&0x07e0f81f) | ((((dg>>5) + dstg)<<5) & 0xf81f07e0)); \
+ dest = ((((drb>>5) + dstrb)&0x07e0f81f) | ((((dg>>5) + dstg)<<5) & 0xf81f07e0)); \
}
#if IMAGE_BYTE_ORDER == LSBFirst
@@ -364,7 +371,6 @@
{
CARD32 src, srca, srcia;
CARD8 *dstLine, *dst, *edst;
- CARD32 d;
CARD8 *maskLine, *mask, m;
FbStride dstStride, maskStride;
CARD16 w;
@@ -458,57 +464,146 @@
CARD16 width,
CARD16 height)
{
- CARD32 src, srca,na, rsrca;
+ CARD32 src, srca8, srca5;
CARD16 *dstLine, *dst;
CARD16 d;
+ CARD32 t;
CARD8 *maskLine, *mask, m;
FbStride dstStride, maskStride;
CARD16 w,src16;
fbComposeGetSolid(pSrc, src);
- src16 = cvt8888to0565(src);
-
- rsrca = src >> 24;
- srca=rsrca>>3;
+
if (src == 0)
- return;
+ return;
+
+ srca8 = (src >> 24);
+ srca5 = (srca8 >> 3);
+
+ src16 = cvt8888to0565(src);
fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-
- while (height--)
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
{
- dst = dstLine;
- dstLine += dstStride;
- mask = maskLine;
- maskLine += maskStride;
- w = width;
+ m = *mask++;
+ if (m == 0)
+ dst++;
+ else if (srca5 == (0xff >> 3))
+ {
+ if (m == 0xff)
+ *dst++ = src16;
+ else
+ {
+ d = *dst;
+ m >>= 3;
+ inOver0565 (m, src16, d, *dst++);
+ }
+ }
+ else
+ {
+ d = *dst;
+ if (m == 0xff)
+ {
+ t = fbOver24 (src, cvt0565to0888 (d));
+ }
+ else
+ {
+ t = fbIn (src, m);
+ t = fbOver (t, cvt0565to0888 (d));
+ }
+ *dst++ = cvt8888to0565 (t);
+ }
+ }
+ }
+}
- while (w--)
+void
+fbCompositeSolidMask_nx8888x0565 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca8, srca5;
+ CARD16 *dstLine, *dst;
+ CARD16 d;
+ CARD32 *maskLine, *mask;
+ CARD32 t;
+ CARD8 m;
+ FbStride dstStride, maskStride;
+ CARD16 w, src16;
+
+ fbComposeGetSolid(pSrc, src);
+
+ if (src == 0)
+ return;
+
+ srca8 = src >> 24;
+ srca5 = srca8 >> 3;
+ src16 = cvt8888to0565(src);
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ m = *mask++ >> 24;
+ if (m == 0)
+ dst++;
+ else if (srca5 == (0xff >> 3))
+ {
+ if (m == 0xff)
+ *dst++ = src16;
+ else
{
- m = *mask++;
- if (m == 0xff)
- {
- if (srca == 0xff)
- {
- *dst=src16;
- }
- else
- {
- d = *dst;
- fastCombine0565(srca, src16, d, *dst++);
- }
- }
- else if (m)
- {
- na=(rsrca*(int)m)>>11;
- d = *dst;
- fastCombine0565(na, src16, d, *dst++);
- }
- else
- dst++;
+ d = *dst;
+ m >>= 3;
+ inOver0565 (m, src16, d, *dst++);
}
+ }
+ else
+ {
+ if (m == 0xff)
+ {
+ d = *dst;
+ t = fbOver24 (src, cvt0565to0888 (d));
+ *dst++ = cvt8888to0565 (t);
+ }
+ else
+ {
+ d = *dst;
+ t = fbIn (src, m);
+ t = fbOver (t, cvt0565to0888 (d));
+ *dst++ = cvt8888to0565 (t);
+ }
+ }
}
+ }
}
void
@@ -565,14 +660,14 @@
else
{
d = *dst;
- d = fbOver24 (src, cvt0565to8888(d));
+ d = fbOver24 (src, cvt0565to0888(d));
*dst = cvt8888to0565(d);
}
}
else if (ma)
{
d = *dst;
- d = cvt0565to8888(d);
+ d = cvt0565to0888(d);
FbInOverC (src, srca, ma, d, 0, m);
FbInOverC (src, srca, ma, d, 8, n);
FbInOverC (src, srca, ma, d, 16, o);
@@ -722,7 +817,7 @@
else
{
d = *dst;
- d = fbOver24 (s, cvt0565to8888(d));
+ d = fbOver24 (s, cvt0565to0888(d));
}
*dst = cvt8888to0565(d);
}
@@ -732,42 +827,6 @@
}
void
-fbCompositeSrc_0565x0565 (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height)
-{
- CARD16 *dstLine, *dst;
- CARD16 *srcLine, *src;
- FbStride dstStride, srcStride;
- CARD16 w;
-
- fbComposeGetStart (pSrc, xSrc, ySrc, CARD16, srcStride, srcLine, 1);
-
- fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-
- while (height--)
- {
- dst = dstLine;
- dstLine += dstStride;
- src = srcLine;
- srcLine += srcStride;
- w = width;
-
- while (w--)
- *dst++ = *src++;
- }
-}
-
-void
fbCompositeSrcAdd_8000x8000 (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
@@ -1005,8 +1064,8 @@
CARD16 w;
FbBits mask;
CARD8 maskAlpha;
- CARD16 s_16, d_16, r_16;
- CARD32 s_32, d_32, i_32, r_32;
+ CARD16 s_16, d_16;
+ CARD32 s_32, d_32;
fbComposeGetSolid (pMask, mask);
maskAlpha = mask >> 27;
@@ -1015,9 +1074,9 @@
return;
if (maskAlpha == 0xff)
{
- fbCompositeSrc_0565x0565 (op, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask, xDst, yDst,
- width, height);
+ fbCompositeSrcSrc_nxn (PictOpSrc, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height);
return;
}
@@ -1037,7 +1096,7 @@
{
s_16 = *src++;
d_16 = *dst;
- fastCombine0565(maskAlpha, s_16, d_16, *dst++);
+ inOver0565(maskAlpha, s_16, d_16, *dst++);
w--;
}
isrc=(CARD32 *)src;
@@ -1048,38 +1107,39 @@
{
s_32 = *isrc++;
d_32 = *idst;
- fastCombine2x0565(maskAlpha,s_32,d_32,*idst++);
+ inOver2x0565(maskAlpha,s_32,d_32,*idst++);
w-=2;
}
dst=(CARD16 *)idst;
}
else
{
- if(w>1)
- {
+ while (w > 1)
+ {
+ s_32 = *isrc++;
#if IMAGE_BYTE_ORDER == LSBFirst
s_16=s_32&0xffff;
#else
s_16=s_32>>16;
#endif
d_16 = *dst;
- fastCombine0565(maskAlpha, s_16, d_16, *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;
- fastCombine0565(maskAlpha, s_16, d_16, *dst++);
- w-=2;
- }
+ d_16 = *dst;
+ inOver0565(maskAlpha, s_16, d_16, *dst++);
+ w-=2;
+ }
}
src=(CARD16 *)isrc;
if(w!=0)
{
s_16 = *src;
d_16 = *dst;
- fastCombine0565(maskAlpha, s_16, d_16, *dst);
+ inOver0565(maskAlpha, s_16, d_16, *dst);
}
}
}
@@ -1129,7 +1189,7 @@
fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
{
- unsigned int ws,wt,ww;
+ unsigned int ws,wt;
CARD32 workingSource;
CARD32 *wsrc, *wdst, *widst;
CARD32 rs, rd, nd;
@@ -1195,7 +1255,7 @@
readPackedSource(rs);
nd|=rs;
#endif
- fastcombine32(maskAlpha, nd, rd, wdst)
+ inOver0888(maskAlpha, nd, rd, *wdst++)
w-=4;
}
dst=(CARD8 *)wdst;
@@ -1248,7 +1308,7 @@
{
rs = *wsrc++;
rd = *widst;
- fastcombine32(maskAlpha, rs, rd, widst);
+ inOver0888(maskAlpha, rs, rd, *widst++);
w-=4;
}
src=(CARD8 *)wsrc;
@@ -1290,86 +1350,34 @@
{
FbBits *dst;
FbBits *src;
- CARD8 *isrc;
- CARD8 *idst;
- int dstStride, srcStride;
- int srcXoff, srcYoff;
- int dstXoff, dstYoff;
- int srcBpp;
- int dstBpp;
- /* these need to be signed now! */
- int iwidth=width;
- int iheight=height;
- int bytesPerPixel;
- int initialWidth=width;
- int initialX=xDst;
+ FbStride dstStride, srcStride;
+ int srcXoff, srcYoff;
+ int dstXoff, dstYoff;
+ int srcBpp;
+ int dstBpp;
+ Bool reverse = FALSE;
+ Bool upsidedown = FALSE;
+
+ fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
+ fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
- /* FIXME: this is possibly the second worst piece of code I've ever written.
- * (the worst being the previous imlementation of this)
- * -- jj
- */
-
- Bool srcRepeat=pSrc->repeat;
- CARD32 srcHeight=pSrc->pDrawable->height;
- CARD32 srcWidth=pSrc->pDrawable->width;
+ fbBlt (src + (ySrc + srcYoff) * srcStride,
+ srcStride,
+ (xSrc + srcXoff) * srcBpp,
- fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
- fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
-
- src+=(srcXoff+(srcYoff*srcStride));
- dst+=(dstXoff+(dstYoff*dstStride));
-
- isrc=(CARD8 *)src;
- idst=(CARD8 *)dst;
+ dst + (yDst + dstYoff) * dstStride,
+ dstStride,
+ (xDst + dstXoff) * dstBpp,
- bytesPerPixel=(srcBpp>>3);
- srcStride*=sizeof(FbBits);
- dstStride*=sizeof(FbBits);
+ (width) * dstBpp,
+ (height),
- if(srcRepeat)
- {
- xSrc%=srcWidth;
- ySrc%=srcHeight;
- }
-
- while(iheight>0)
- {
- int wheight=iheight;
- if(wheight>(srcHeight-ySrc))
- wheight=(srcHeight-ySrc);
- iwidth=initialWidth;
- xDst=initialX;
- while(iwidth>0)
- {
- int wwidth=iwidth;
- int j;
- if(wwidth>(srcWidth-xSrc))
- wwidth=(srcWidth-xSrc);
+ GXcopy,
+ FB_ALLONES,
+ dstBpp,
- for(j=0;j<wheight;j++)
- memcpy( idst + (yDst + j) * dstStride + ((xDst * bytesPerPixel)),
- isrc + (ySrc + j) * srcStride + ((xSrc * bytesPerPixel)),
- (wwidth*bytesPerPixel));
- /* reset the xSrc pointer. D'oh. */
- xSrc=0;
- if(!srcRepeat)
- iwidth=0;
- else
- {
- xDst+=wwidth;
- iwidth-=wwidth;
- }
- }
- ySrc=0;
- /* reset the ySrc pointer. D'oh. */
- if(!srcRepeat)
- iheight=0;
- else
- {
- yDst+=wheight;
- iheight-=wheight;
- }
- }
+ reverse,
+ upsidedown);
}
/*
@@ -1489,6 +1497,14 @@
break;
}
}
+ else
+ {
+ switch (pDst->format) {
+ case PICT_r5g6b5:
+ func = fbCompositeSolidMask_nx8888x0565;
+ break;
+ }
+ }
break;
case PICT_a8b8g8r8:
if (pMask->componentAlpha) {
@@ -1502,6 +1518,14 @@
break;
}
}
+ else
+ {
+ switch (pDst->format) {
+ case PICT_r5g6b5:
+ func = fbCompositeSolidMask_nx8888x0565;
+ break;
+ }
+ }
break;
case PICT_a1:
switch (pDst->format) {
@@ -1543,7 +1567,14 @@
}
else
{
- switch (pSrc->format) {
+ /*
+ * Formats without alpha bits are just Copy with Over
+ */
+ if (pSrc->format == pDst->format && !PICT_FORMAT_A(pSrc->format))
+ {
+ func = fbCompositeSrcSrc_nxn;
+ }
+ else switch (pSrc->format) {
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
switch (pDst->format) {
@@ -1574,20 +1605,6 @@
break;
}
break;
- case PICT_r5g6b5:
- switch (pDst->format) {
- case PICT_r5g6b5:
- func = fbCompositeSrc_0565x0565;
- break;
- }
- break;
- case PICT_b5g6r5:
- switch (pDst->format) {
- case PICT_b5g6r5:
- func = fbCompositeSrc_0565x0565;
- break;
- }
- break;
}
}
break;
@@ -1636,14 +1653,6 @@
}
n = REGION_NUM_RECTS (®ion);
pbox = REGION_RECTS (®ion);
- /* FIXME: this is bascially a "white list" of composites that work
- * with repeat until they are all implented. Once that's done, we
- * remove the checks below entirely
- */
- if(func==fbCompositeSrcSrc_nxn)
- {
- srcRepeat=maskRepeat=FALSE;
- }
while (n--)
{
h = pbox->y2 - pbox->y1;
@@ -1720,6 +1729,7 @@
ps->CompositeRects = miCompositeRects;
ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
+
#endif /* RENDER */
return TRUE;
Index: fbpict.h
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbpict.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- fbpict.h 18 Dec 2003 17:30:43 -0000 1.15
+++ fbpict.h 15 Jan 2004 09:09:29 -0000 1.16
@@ -830,6 +830,20 @@
CARD16 height);
void
+fbCompositeSolidMask_nx8888x0565 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
fbCompositeSolidMask_nx8888x0565C (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,