[xserver-commit] xserver/hw/kdrive/src kaapict.c,1.2,1.3 kdrive.h,1.46,1.47

Eric Anholt xserver-commit@pdx.freedesktop.org
Tue, 30 Dec 2003 00:23:58 -0800


Committed by: anholt

Update of /cvs/xserver/xserver/hw/kdrive/src
In directory pdx:/home/anholt/xserver/hw/kdrive/src

Modified Files:
	kaapict.c kdrive.h 
Log Message:
- Add new Composite hook for kdrive drivers, which only ensures that
  the pixmaps are offscreen and don't have alpha maps.  It is the
  last case checked before going to software fallback
- Use the new Composite hook in the ati driver to implement
  acceleration of most Composites that get done in an xcompmgr
  environment on r100 series cards.  It is only available when using
  the DRM.  There are still some corruption issues, but the DRI is
  still non-default and I need to get this into version control.


Index: kaapict.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kaapict.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- kaapict.c	29 Dec 2003 06:24:01 -0000	1.2
+++ kaapict.c	30 Dec 2003 08:23:56 -0000	1.3
@@ -320,8 +320,8 @@
 		ySrc += pSrc->pDrawable->y;
 
 		if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
-					       xSrc, ySrc, xMask, yMask, xDst, yDst,
-					       width, height))
+					       xSrc, ySrc, xMask, yMask, xDst,
+					       yDst, width, height))
 		    return;
 		
 		
@@ -396,6 +396,87 @@
 	    return;
 	}
     }
+    if (pScreenPriv->enabled && pKaaScr->info->PrepareComposite &&
+	!pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap)
+    {
+	/* Catch-all Composite case */
+	RegionRec region;
+	BoxPtr pbox;
+	int nbox;
+	int src_off_x, src_off_y, mask_off_x, mask_off_y, dst_off_x, dst_off_y;
+	PixmapPtr pSrcPix, pMaskPix = NULL, pDstPix;
+
+	xDst += pDst->pDrawable->x;
+	yDst += pDst->pDrawable->y;
+
+	if (pMask) {
+	    xMask += pMask->pDrawable->x;
+	    yMask += pMask->pDrawable->y;
+	}
+
+	xSrc += pSrc->pDrawable->x;
+	ySrc += pSrc->pDrawable->y;
+
+	if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
+				       xSrc, ySrc, xMask, yMask, xDst, yDst,
+				       width, height))
+		return;
+
+
+	/* Migrate pixmaps to same place as destination */
+	if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)
+		kaaPixmapUseScreen ((PixmapPtr) pSrc->pDrawable);
+	if (pMask && pMask->pDrawable->type == DRAWABLE_PIXMAP)
+		kaaPixmapUseScreen ((PixmapPtr) pMask->pDrawable);
+	if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
+		kaaPixmapUseScreen ((PixmapPtr) pDst->pDrawable);
+
+	pSrcPix = kaaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x,
+				    	 &src_off_y);
+	pDstPix = kaaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x,
+				    	 &dst_off_y);
+	if (!pSrcPix || !pDstPix)
+		goto software2;
+	if (pMask) {
+	    pMaskPix = kaaGetOffscreenPixmap (pMask->pDrawable, &mask_off_x,
+				    	     &mask_off_y);
+	    if (!pMaskPix)
+		goto software2;
+	}
+
+    	if (!(*pKaaScr->info->PrepareComposite) (op, pSrc, pMask, pDst, pSrcPix,
+						 pMaskPix, pDstPix))
+    	{
+		goto software;
+	}
+    	
+    	nbox = REGION_NUM_RECTS(&region);
+    	pbox = REGION_RECTS(&region);
+
+    	xMask -= xDst;
+    	yMask -= yDst;
+
+    	xSrc -= xDst;
+    	ySrc -= yDst;
+	
+    	while (nbox--)
+    	{
+		(*pKaaScr->info->Composite) (pbox->x1 + xSrc + src_off_x,
+					     pbox->y1 + ySrc + src_off_y,
+					     pbox->x1 + mask_off_x,
+					     pbox->y1 + mask_off_y,
+					     pbox->x1 + dst_off_x,
+					     pbox->y1 + dst_off_y,
+					     pbox->x2 - pbox->x1,
+					     pbox->y2 - pbox->y1);
+		pbox++;
+    	}
+    	
+    	(*pKaaScr->info->DoneBlend) ();
+    	KdMarkSync(pDst->pDrawable->pScreen);
+
+    	return;
+    }
 
 software:
     if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)

Index: kdrive.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kdrive.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- kdrive.h	29 Dec 2003 06:24:01 -0000	1.46
+++ kdrive.h	30 Dec 2003 08:23:56 -0000	1.47
@@ -345,6 +345,23 @@
 			  int	width,
 			  int	height);
     void	(*DoneBlend) (void);
+
+    Bool        (*PrepareComposite) (int		op,
+				     PicturePtr		pSrcPicture,
+				     PicturePtr		pMaskPicture,
+				     PicturePtr		pDstPicture,
+				     PixmapPtr		pSrc,
+				     PixmapPtr		pMask,
+				     PixmapPtr		pDst);
+    void        (*Composite) (int	srcX,
+			     int	srcY,
+			     int	maskX,
+			     int	maskY,
+			     int	dstX,
+			     int	dstY,
+			     int	width,
+			     int	height);
+    void	(*DoneComposite) (void);
 } KaaScreenInfoRec, *KaaScreenInfoPtr;
 
 #define KAA_OFFSCREEN_PIXMAPS (1 << 0)