xserver/hw/kdrive/src kaa.c, 1.33, 1.34 kaa.h, 1.5, 1.6 kaapict.c, 1.11, 1.12 kdrive.h, 1.56, 1.57

Eric Anholt xserver-commit at pdx.freedesktop.org
Mon Aug 30 15:16:49 PDT 2004


Committed by: anholt

Update of /cvs/xserver/xserver/hw/kdrive/src
In directory gabe:/tmp/cvs-serv10244/hw/kdrive/src

Modified Files:
	kaa.c kaa.h kaapict.c kdrive.h 
Log Message:
Add a set of three hooks for accelerating trapezoids, and use it for
the RasterizeTrapezoid screen function.  These hooks will be called for
imprecise, non-sharp trapezoids with A8 destinations.

Note that the current main consumer of trapezoids, cairo, is requesting
precise, sharp trapezoids by not changing the default Picture
attributes, but gets non-sharp effects in software because fb bases its
choice of sharp/non-sharp on the mask format being A8 vs A1, and cairo
asks for A8.  Follow fb's (poor?) example by ignoring the sharp setting
and basing the choice off of the mask being A8.


Index: kaa.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kaa.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- kaa.c	30 Aug 2004 16:43:10 -0000	1.33
+++ kaa.c	30 Aug 2004 22:16:46 -0000	1.34
@@ -1029,8 +1029,10 @@
     pScreen->PaintWindowBackground = kaaPaintWindow;
     pScreen->PaintWindowBorder = kaaPaintWindow;
 #ifdef RENDER
-    if (ps)
+    if (ps) {
 	ps->Composite = kaaComposite;
+	ps->RasterizeTrapezoid = kaaRasterizeTrapezoid;
+    }
 #endif
 
     /*

Index: kaa.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kaa.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- kaa.h	3 Jul 2004 09:16:30 -0000	1.5
+++ kaa.h	30 Aug 2004 22:16:46 -0000	1.6
@@ -98,4 +98,10 @@
 	     CARD16	width,
 	     CARD16	height);
 
+void
+kaaRasterizeTrapezoid(PicturePtr pPict,
+		      xTrapezoid *trap,
+		      int xoff,
+		      int yoff);
+
 #endif /* _KAA_H_ */

Index: kaapict.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kaapict.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- kaapict.c	3 Jul 2004 09:16:30 -0000	1.11
+++ kaapict.c	30 Aug 2004 22:16:46 -0000	1.12
@@ -62,6 +62,9 @@
     case PICT_a8:
 	snprintf(format, 20, "A8      ");
 	break;
+    case PICT_a1:
+	snprintf(format, 20, "A1      ");
+	break;
     default:
 	snprintf(format, 20, "0x%x", (int)pict->format);
 	break;
@@ -83,7 +86,6 @@
 			  PicturePtr pDst)
 {
     char sop[20];
-
     char srcdesc[40], maskdesc[40], dstdesc[40];
 
     switch(op)
@@ -109,6 +111,19 @@
 	   "                    dst  %s, \n", 
 	   sop, srcdesc, maskdesc, dstdesc);
 }
+
+static void
+kaaPrintTrapezoidFallback(PicturePtr pDst)
+{
+    char dstdesc[40];
+
+    kaaCompositeFallbackPictDesc(pDst, dstdesc, 40);
+
+    ErrorF("Trapezoid fallback: dst  %s, %c/%s\n", 
+	   dstdesc,
+	   (pDst->polyMode == PolyModePrecise) ? 'p' : 'i',
+	   (pDst->polyEdge == PolyEdgeSharp) ? "a" : "aa");
+}
 #endif
 
 static Bool
@@ -605,3 +620,71 @@
 		      xMask, yMask, xDst, yDst, width, height);
 }
 #endif
+
+static xFixed
+miLineFixedX (xLineFixed *l, xFixed y, Bool ceil)
+{
+    xFixed	    dx = l->p2.x - l->p1.x;
+    xFixed_32_32    ex = (xFixed_32_32) (y - l->p1.y) * dx;
+    xFixed	    dy = l->p2.y - l->p1.y;
+    if (ceil)
+	ex += (dy - 1);
+    return l->p1.x + (xFixed) (ex / dy);
+}
+
+/* Need to decide just how much to trim, to maintain translation independence
+ * when converted to floating point.
+ */
+#define XFIXED_TO_FLOAT(x) (((float)((x) & 0xffffff00)) / 65536.0)
+
+void kaaRasterizeTrapezoid(PicturePtr pDst,
+			   xTrapezoid *trap,
+			   int xoff,
+			   int yoff)
+{
+    KdScreenPriv (pDst->pDrawable->pScreen);
+    KaaScreenPriv (pDst->pDrawable->pScreen);
+    KaaTrapezoid ktrap;
+    PixmapPtr pPix;
+    xFixed x1, x2;
+
+    if (!pScreenPriv->enabled ||
+	!pKaaScr->info->PrepareTrapezoids ||
+	pDst->pDrawable->type != DRAWABLE_PIXMAP ||
+	pDst->polyMode == PolyModePrecise ||
+        pDst->alphaMap || pDst->format != PICT_a8)
+    {
+	KdCheckRasterizeTrapezoid (pDst, trap, xoff, yoff);
+#if KAA_DEBUG_FALLBACKS
+	kaaPrintTrapezoidFallback (pDst);
+#endif
+	return;
+    }
+    pPix = (PixmapPtr)pDst->pDrawable;
+
+    kaaPixmapUseScreen (pPix);
+
+    if (!kaaPixmapIsOffscreen (pPix) ||
+	!(*pKaaScr->info->PrepareTrapezoids) (pDst, pPix))
+    {
+#if KAA_DEBUG_FALLBACKS
+	kaaPrintTrapezoidFallback (pDst);
+#endif
+	KdCheckRasterizeTrapezoid (pDst, trap, xoff, yoff);
+	return;
+    }
+
+    ktrap.ty = XFIXED_TO_FLOAT(trap->top) + yoff;
+    x1 = miLineFixedX (&trap->left, trap->top, FALSE);
+    x2 = miLineFixedX (&trap->right, trap->top, TRUE);
+    ktrap.tl = XFIXED_TO_FLOAT(x1) + xoff;
+    ktrap.tr = XFIXED_TO_FLOAT(x2) + xoff;
+    ktrap.by = XFIXED_TO_FLOAT(trap->bottom) + yoff;
+    x1 = miLineFixedX (&trap->left, trap->bottom, FALSE);
+    x2 = miLineFixedX (&trap->right, trap->bottom, TRUE);
+    ktrap.bl = XFIXED_TO_FLOAT(x1) + xoff;
+    ktrap.br = XFIXED_TO_FLOAT(x2) + xoff;
+
+    (*pKaaScr->info->Trapezoids) (&ktrap, 1);
+    (*pKaaScr->info->DoneTrapezoids) ();
+}

Index: kdrive.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kdrive.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- kdrive.h	8 Jul 2004 06:57:58 -0000	1.56
+++ kdrive.h	30 Aug 2004 22:16:46 -0000	1.57
@@ -310,6 +310,11 @@
     int	    matrix[2][3];
 } KdMouseMatrix;
 
+typedef struct _KaaTrapezoid {
+    float tl, tr, ty;
+    float bl, br, by;
+} KaaTrapezoid;
+
 typedef struct _KaaScreenInfo {
     Bool	(*PrepareSolid) (PixmapPtr	pPixmap,
 				 int		alu,
@@ -370,6 +375,12 @@
 			     int	height);
     void	(*DoneComposite) (void);
 
+    Bool	(*PrepareTrapezoids) (PicturePtr pDstPicture,
+				      PixmapPtr pDst);
+    void	(*Trapezoids) (KaaTrapezoid	 *traps,
+			       int		 ntraps);
+    void	(*DoneTrapezoids) (void);
+
     Bool        (*UploadToScreen) (PixmapPtr		pDst,
 				   char			*src,
 				   int			src_pitch);



More information about the xserver-commit mailing list