xserver/render picture.c,1.40,1.41

Lars Knoll <xserver-commit-u7BhqnqprCWvj1b/[email protected]> Wed, 15 Jun 2005 05:14:00 -0700 (PDT)
Newsgroups gmane.comp.freedesktop.xserver.cvs
Message-ID <[email protected]>
Committed by: lars

Update of /cvs/xserver/xserver/render
In directory gabe:/tmp/cvs-serv17324/render

Modified Files:
	picture.c 
Log Message:
Fix projective transformations in fbcompose.c
Bugfix for convolution filters


Index: picture.c
===================================================================
RCS file: /cvs/xserver/xserver/render/picture.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- picture.c	2 Mar 2005 15:30:04 -0000	1.40
+++ picture.c	15 Jun 2005 12:13:57 -0000	1.41
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
@@ -220,7 +220,7 @@
 		type = PICT_TYPE_ARGB;
 	    }
 	    else if (pVisual->offsetRed == 0 &&
-		     pVisual->offsetGreen == r && 
+		     pVisual->offsetGreen == r &&
 		     pVisual->offsetBlue == r + g)
 	    {
 		type = PICT_TYPE_ABGR;
@@ -270,7 +270,7 @@
 				      PICT_x1b5g5r5, pDepth->depth);
 	    }
 	    /* depth 16 formats */
-	    if (pDepth->depth >= 16) 
+	    if (pDepth->depth >= 16)
 	    {
 		nformats = addFormat (formats, nformats,
 				      PICT_a1r5g5b5, pDepth->depth);
@@ -306,7 +306,7 @@
 	    break;
 	}
     }
-    
+
 
     pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
     if (!pFormats)
@@ -321,40 +321,40 @@
 	switch (PICT_FORMAT_TYPE(format)) {
 	case PICT_TYPE_ARGB:
 	    pFormats[f].type = PictTypeDirect;
-	    
+
 	    pFormats[f].direct.alphaMask = Mask(PICT_FORMAT_A(format));
 	    if (pFormats[f].direct.alphaMask)
 		pFormats[f].direct.alpha = (PICT_FORMAT_R(format) +
 					    PICT_FORMAT_G(format) +
 					    PICT_FORMAT_B(format));
-	    
+
 	    pFormats[f].direct.redMask = Mask(PICT_FORMAT_R(format));
-	    pFormats[f].direct.red = (PICT_FORMAT_G(format) + 
+	    pFormats[f].direct.red = (PICT_FORMAT_G(format) +
 				      PICT_FORMAT_B(format));
-	    
+
 	    pFormats[f].direct.greenMask = Mask(PICT_FORMAT_G(format));
 	    pFormats[f].direct.green = PICT_FORMAT_B(format);
-	    
+
 	    pFormats[f].direct.blueMask = Mask(PICT_FORMAT_B(format));
 	    pFormats[f].direct.blue = 0;
 	    break;
 
 	case PICT_TYPE_ABGR:
 	    pFormats[f].type = PictTypeDirect;
-	    
+
 	    pFormats[f].direct.alphaMask = Mask(PICT_FORMAT_A(format));
 	    if (pFormats[f].direct.alphaMask)
 		pFormats[f].direct.alpha = (PICT_FORMAT_B(format) +
 					    PICT_FORMAT_G(format) +
 					    PICT_FORMAT_R(format));
-	    
+
 	    pFormats[f].direct.blueMask = Mask(PICT_FORMAT_B(format));
-	    pFormats[f].direct.blue = (PICT_FORMAT_G(format) + 
+	    pFormats[f].direct.blue = (PICT_FORMAT_G(format) +
 				       PICT_FORMAT_R(format));
-	    
+
 	    pFormats[f].direct.greenMask = Mask(PICT_FORMAT_G(format));
 	    pFormats[f].direct.green = PICT_FORMAT_R(format);
-	    
+
 	    pFormats[f].direct.redMask = Mask(PICT_FORMAT_R(format));
 	    pFormats[f].direct.red = 0;
 	    break;
@@ -367,7 +367,7 @@
 
 	    /* remaining fields already set to zero */
 	    break;
-	    
+
 	case PICT_TYPE_COLOR:
 	case PICT_TYPE_GRAY:
 	    pFormats[f].type = PictTypeIndexed;
@@ -459,7 +459,7 @@
 	return FALSE;
     ps->subpixel = subpixel;
     return TRUE;
-    
+
 }
 
 int
@@ -471,7 +471,7 @@
 	return SubPixelUnknown;
     return ps->subpixel;
 }
-    
+
 PictFormatPtr
 PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual)
 {
@@ -509,11 +509,11 @@
 	    }
 	    else
 	    {
-		if ((unsigned long) format->direct.redMask << format->direct.red == 
+		if ((unsigned long) format->direct.redMask << format->direct.red ==
 		    pVisual->redMask &&
-		    (unsigned long) format->direct.greenMask << format->direct.green == 
+		    (unsigned long) format->direct.greenMask << format->direct.green ==
 		    pVisual->greenMask &&
-		    (unsigned long) format->direct.blueMask << format->direct.blue == 
+		    (unsigned long) format->direct.blueMask << format->direct.blue ==
 		    pVisual->blueMask)
 		{
 		    return format;
@@ -568,7 +568,7 @@
     PictureScreenPtr	ps;
     int			n;
     CARD32		type, a, r, g, b;
-    
+
     if (PictureGeneration != serverGeneration)
     {
 	PictureType = CreateNewResourceType (FreePicture);
@@ -593,7 +593,7 @@
     }
     if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0))
 	return FALSE;
-    
+
     if (!formats)
     {
 	formats = PictureCreateDefaultFormats (pScreen, &nformats);
@@ -651,11 +651,11 @@
     ps->totalPictureSize = sizeof (PictureRec);
     ps->PicturePrivateSizes = 0;
     ps->PicturePrivateLen = 0;
-    
+
     ps->formats = formats;
     ps->fallback = formats;
     ps->nformats = nformats;
-    
+
     ps->filters = 0;
     ps->nfilters = 0;
     ps->filterAliases = 0;
@@ -780,7 +780,7 @@
     }
 
     SetPictureToDefaults (pPicture);
-    
+
     if (vmask)
 	*error = ChangePicture (pPicture, vmask, vlist, 0, client);
     else
@@ -811,7 +811,7 @@
     BITS32		index2;
     int			error = 0;
     BITS32		maskQ;
-    
+
     pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
     maskQ = vmask;
     while (vmask && !error)
@@ -837,7 +837,7 @@
 	case CPAlphaMap:
 	    {
 		PicturePtr  pAlpha;
-		
+
 		if (vlist)
 		{
 		    Picture	pid = NEXT_VAL(Picture);
@@ -847,8 +847,8 @@
 		    else
 		    {
 			pAlpha = (PicturePtr) SecurityLookupIDByType(client,
-								     pid, 
-								     PictureType, 
+								     pid,
+								     PictureType,
 								     SecurityWriteAccess|SecurityReadAccess);
 			if (!pAlpha)
 			{
@@ -906,7 +906,7 @@
 		    {
 			clipType = CT_PIXMAP;
 			pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
-								    pid, 
+								    pid,
 								    RT_PIXMAP,
 								    SecurityReadAccess);
 			if (!pPixmap)
@@ -1038,7 +1038,7 @@
 				 nRect, rects, CT_UNSORTED);
     if (!clientClip)
 	return BadAlloc;
-    result =(*ps->ChangePictureClip) (pPicture, CT_REGION, 
+    result =(*ps->ChangePictureClip) (pPicture, CT_REGION,
 				      (pointer) clientClip, 0);
     if (result == Success)
     {
@@ -1065,7 +1065,7 @@
     if (pRegion)
     {
 	type = CT_REGION;
-	clientClip = REGION_CREATE (pScreen, 
+	clientClip = REGION_CREATE (pScreen,
 				    REGION_EXTENTS(pScreen, pRegion),
 				    REGION_NUM_RECTS(pRegion));
 	if (!clientClip)
@@ -1082,7 +1082,7 @@
 	clientClip = 0;
     }
 
-    result =(*ps->ChangePictureClip) (pPicture, type, 
+    result =(*ps->ChangePictureClip) (pPicture, type,
 				      (pointer) clientClip, 0);
     if (result == Success)
     {
@@ -1109,7 +1109,7 @@
 
     if (transform && memcmp (transform, &identity, sizeof (PictTransform)) == 0)
 	transform = 0;
-    
+
     if (transform)
     {
 	if (!pPicture->transform)
@@ -1164,7 +1164,7 @@
     {
 	ScreenPtr	    pScreen = pPicture->pDrawable->pScreen;
 	PictureScreenPtr    ps = GetPictureScreen(pScreen);
-	
+
 	if (pPicture->alphaMap)
 	    FreePicture ((pointer) pPicture->alphaMap, (XID) 0);
 	(*ps->DestroyPicture) (pPicture);
@@ -1218,7 +1218,7 @@
 		  CARD16	height)
 {
     PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
-    
+
     ValidatePicture (pSrc);
     if (pMask)
 	ValidatePicture (pMask);
@@ -1249,7 +1249,7 @@
 		 GlyphPtr	*glyphs)
 {
     PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
-    
+
     ValidatePicture (pSrc);
     ValidatePicture (pDst);
     (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, glyphs);
@@ -1263,7 +1263,7 @@
 		xRectangle      *rects)
 {
     PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
-    
+
     ValidatePicture (pDst);
     (*ps->CompositeRects) (op, pDst, color, nRect, rects);
 }
@@ -1279,7 +1279,7 @@
 		     xTrapezoid	    *traps)
 {
     PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
-    
+
     ValidatePicture (pSrc);
     ValidatePicture (pDst);
     (*ps->Trapezoids) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, traps);
@@ -1296,7 +1296,7 @@
 		    xTriangle	    *triangles)
 {
     PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
-    
+
     ValidatePicture (pSrc);
     ValidatePicture (pDst);
     (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntriangles, triangles);
@@ -1313,7 +1313,7 @@
 		   xPointFixed	    *points)
 {
     PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
-    
+
     ValidatePicture (pSrc);
     ValidatePicture (pDst);
     (*ps->TriStrip) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points);
@@ -1330,7 +1330,7 @@
 		 xPointFixed	*points)
 {
     PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
-    
+
     ValidatePicture (pSrc);
     ValidatePicture (pDst);
     (*ps->TriFan) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points);
@@ -1344,7 +1344,7 @@
 	  xTrap		*traps)
 {
     PictureScreenPtr	ps = GetPictureScreen(pPicture->pDrawable->pScreen);
-    
+
     ValidatePicture (pPicture);
     (*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps);
 }
@@ -1353,6 +1353,35 @@
 #define MIN_FIXED_48_16	    (-((xFixed_48_16) 1 << 31))
 
 Bool
+PictureTransformPoint3d (PictTransformPtr transform,
+                         PictVectorPtr	vector)
+{
+    PictVector	    result;
+    int		    i, j;
+    xFixed_32_32    partial;
+    xFixed_48_16    v;
+
+    for (j = 0; j < 3; j++)
+    {
+	v = 0;
+	for (i = 0; i < 3; i++)
+	{
+	    partial = ((xFixed_48_16) transform->matrix[j][i] *
+		       (xFixed_48_16) vector->vector[i]);
+	    v += partial >> 16;
+	}
+	if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
+	    return FALSE;
+	result.vector[j] = (xFixed) v;
+    }
+    if (!result.vector[2])
+	return FALSE;
+    *vector = result;
+    return TRUE;
+}
+
+
+Bool
 PictureTransformPoint (PictTransformPtr transform,
 		       PictVectorPtr	vector)
 {
@@ -1366,7 +1395,7 @@
 	v = 0;
 	for (i = 0; i < 3; i++)
 	{
-	    partial = ((xFixed_48_16) transform->matrix[j][i] * 
+	    partial = ((xFixed_48_16) transform->matrix[j][i] *
 		       (xFixed_48_16) vector->vector[i]);
 	    v += partial >> 16;
 	}