[xserver-commit] xserver/fb fb.h,1.38,1.39 fbpict.c,1.17,1.18 fbpict.h,1.12,1.13

Keith Packard xserver-commit@pdx.freedesktop.org
Tue, 04 Nov 2003 21:45:33 -0800


Committed by: keithp

Update of /cvs/xserver/xserver/fb
In directory pdx:/tmp/cvs-serv6826/fb

Modified Files:
	fb.h fbpict.c fbpict.h 
Log Message:
	* Makefile.am:
	* composite/Makefile.am:
	* composite/compalloc.c: (compReportDamage), (compDestroyDamage),
	(compAllocPixmap), (compFreePixmap), (compReallocPixmap):
	* composite/compinit.c: (compCloseScreen), (compScreenUpdate),
	(compBlockHandler), (compScreenInit), (CompositeExtensionInit):
	* composite/compint.h:
	* composite/compwindow.c: (compCheckWindow), (compCheckTree),
	(compSetPixmapVisitWindow), (compSetPixmap),
	(compShouldBeRedirected), (compCheckRedirect),
	(compPositionWindow), (compRealizeWindow), (compUnrealizeWindow),
	(compReparentWindow), (compCopyWindow), (compCreateWindow),
	(compDestroyWindow), (compRedirectBorderClip),
	(compGetWindowVisual), (compWindowFormat),
	(compWindowUpdateAutomatic), (compWindowPaintBackground),
	(compWindowUpdate):
	* configure.ac:
	* dix/window.c: (SetWinSize), (SetBorderSize):
	* fb/fb.h:
	* fb/fbpict.c: (fbIn24), (fbCompositeTrans_0565xnx0565),
	(fbCompositeSrcSrc_nxn), (fbComposite):
	* fb/fbpict.h:
	* include/picturestr.h:
	* include/windowstr.h:
	* mi/Makefile.am:
	* mi/mi.h:
	* mi/miinitext.c:
	* mi/mivaltree.c: (miRegisterRedirectBorderClipProc),
	(miGetRedirectBorderClipProc), (miComputeClips):
	* miext/damage/damage.c: (damageDestroyPixmap):
	* render/mipict.c: (miValidatePicture):
	* render/picture.c: (SetPictureClipRects), (SetPictureClipRegion):
	* xfixes/region.c: (ProcXFixesSetPictureClipRegion):
	Initial import of Composite extension along with
	name change from Apportion.
	Added some accelerated code to fbpict to make this initial
	hack a bit faster.  "real" extension bits to follow.


Index: fb.h
===================================================================
RCS file: /cvs/xserver/xserver/fb/fb.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- fb.h	11 Sep 2003 05:12:50 -0000	1.38
+++ fb.h	5 Nov 2003 05:45:31 -0000	1.39
@@ -637,13 +637,8 @@
 	((WindowPtr) (pWin))->devPrivates[fbWinPrivateIndex].ptr)
 #endif
 
-#ifdef __DARWIN__
 #define __fbPixOriginX(pPix)	((pPix)->drawable.x)
 #define __fbPixOriginY(pPix)	((pPix)->drawable.y)
-#else
-#define __fbPixOriginX(pPix)	0
-#define __fbPixOriginY(pPix)	0
-#endif
 
 #define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
     PixmapPtr   _pPix; \

Index: fbpict.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbpict.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- fbpict.c	11 Sep 2003 05:12:50 -0000	1.17
+++ fbpict.c	5 Nov 2003 05:45:31 -0000	1.18
@@ -102,6 +102,20 @@
     return m|n|o|p;
 }
 
+CARD32
+fbIn24 (CARD32 x, CARD8 y)
+{
+    CARD16  a = y;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    m = FbInU(x,0,a,t);
+    n = FbInU(x,8,a,t);
+    o = FbInU(x,16,a,t);
+    p = (y << 24);
+    return m|n|o|p;
+}
+
 #define fbComposeGetSolid(pict, bits) { \
     FbBits	*__bits__; \
     FbStride	__stride__; \
@@ -120,6 +134,14 @@
 	(bits) = *(CARD16 *) __bits__; \
 	(bits) = cvt0565to8888(bits); \
 	break; \
+    case 8: \
+	(bits) = *(CARD8 *) __bits__; \
+	(bits) = (bits) << 24; \
+	break; \
+    case 1: \
+	(bits) = *(CARD32 *) __bits__; \
+	(bits) = FbLeftStipBits((bits),1) ? 0xff000000 : 0x00000000;\
+	break; \
     default: \
 	return; \
     } \
@@ -136,7 +158,7 @@
 \
     fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
     (stride) = __stride__ * sizeof (FbBits) / sizeof (type); \
-    (line) = ((type *) __bits__) + (stride) * ((y) - __yoff__) + (mul) * ((x) - __xoff__); \
+    (line) = ((type *) __bits__) + (stride) * ((y) + __yoff__) + (mul) * ((x) + __xoff__); \
 }
 
 /*
@@ -871,6 +893,142 @@
 	      0x0);
 }
 
+/*
+ * Apply a constant alpha value in an over computation
+ */
+
+void
+fbCompositeTrans_0565xnx0565(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;
+    FbBits	mask;
+    CARD8	maskAlpha;
+    CARD16	s_16, d_16, r_16;
+    CARD32	s_32, d_32, i_32, r_32;
+    
+    fbComposeGetSolid (pMask, mask);
+    maskAlpha = mask >> 24;
+    
+    if (!maskAlpha)
+	return;
+    if (maskAlpha == 0xff)
+    {
+	fbCompositeSrc_0565x0565 (op, pSrc, pMask, pDst,
+				  xSrc, ySrc, xMask, yMask, xDst, yDst, 
+				  width, height);
+	return;
+    }
+
+    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--)
+	{
+	    s_16 = *src++;
+	    s_32 = cvt0565to8888(s_16);
+	    d_16 = *dst;
+	    d_32 = cvt0565to8888(d_16);
+	    
+	    i_32 = fbIn24 (s_32, maskAlpha);
+	    r_32 = fbOver24 (i_32, d_32);
+	    r_16 = cvt8888to0565(r_32);
+	    *dst++ = r_16;
+	}
+    }
+}
+
+/*
+ * Simple bitblt
+ */
+
+void
+fbCompositeSrcSrc_nxn  (CARD8	op,
+			PicturePtr pSrc,
+			PicturePtr pMask,
+			PicturePtr pDst,
+			INT16      xSrc,
+			INT16      ySrc,
+			INT16      xMask,
+			INT16      yMask,
+			INT16      xDst,
+			INT16      yDst,
+			CARD16     width,
+			CARD16     height)
+{
+    FbBits	*dst;
+    FbBits	*src;
+    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);
+
+    fbBlt (src + (ySrc + srcYoff) * srcStride,
+	   srcStride,
+	   (xSrc + srcXoff) * srcBpp,
+
+	   dst + (yDst + dstYoff) * dstStride,
+	   dstStride,
+	   (xDst + dstXoff) * dstBpp,
+
+	   (width) * dstBpp,
+	   (height),
+
+	   GXcopy,
+	   FB_ALLONES,
+	   dstBpp,
+
+	   reverse,
+	   upsidedown);
+}
+
+/*
+ * Solid fill
+void
+fbCompositeSolidSrc_nxn  (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 mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
 void
@@ -936,7 +1094,6 @@
 		pSrc->pDrawable->width == 1 &&
 		pSrc->pDrawable->height == 1)
 	    {
-		srcRepeat = FALSE;
 		if (PICT_FORMAT_COLOR(pSrc->format)) {
 		    switch (pMask->format) {
 		    case PICT_a8:
@@ -998,6 +1155,22 @@
 			}
 		    }
 		}
+		if (func != fbCompositeGeneral)
+		    srcRepeat = FALSE;
+	    }
+	    else if (maskRepeat &&
+		     pMask->pDrawable->width == 1 &&
+		     pMask->pDrawable->height == 1)
+	    {
+		switch (pSrc->format) {
+		case PICT_r5g6b5:
+		case PICT_b5g6r5:
+		    if (pDst->format == pSrc->format)
+		        func = fbCompositeTrans_0565xnx0565;
+		    break;
+		}
+		if (func != fbCompositeGeneral)
+		    maskRepeat = FALSE;
 	    }
 	}
 	else
@@ -1085,6 +1258,13 @@
 	    }
 	}
 	break;
+    case PictOpSrc:
+	if (pMask == 0)
+	{
+	    if (pSrc->format == pDst->format)
+		func = fbCompositeSrcSrc_nxn;
+	}
+	break;
     }
     n = REGION_NUM_RECTS (&region);
     pbox = REGION_RECTS (&region);

Index: fbpict.h
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbpict.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- fbpict.h	11 Sep 2003 05:12:50 -0000	1.12
+++ fbpict.h	5 Nov 2003 05:45:31 -0000	1.13
@@ -770,6 +770,9 @@
 CARD32
 fbIn (CARD32 x, CARD8 y);
 
+CARD32
+fbIn24 (CARD32 x, CARD8 y);
+
 void
 fbCompositeSolidMask_nx8x8888 (CARD8      op,
 			       PicturePtr pSrc,
@@ -953,6 +956,34 @@
 			    CARD16     height);
 
 void
+fbCompositeTrans_0565xnx0565(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
+fbCompositeSrcSrc_nxn  (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
 fbComposite (CARD8      op,
 	     PicturePtr pSrc,
 	     PicturePtr pMask,