[PATCH] miTrapezoids(): Simplify.

Bernardo Innocenti bernie at codewiz.org
Wed Jul 11 15:09:23 PDT 2007


It striked me that miTrapezoids() called itself recursively.
The current form is probably the result of successive changes.

Lightly tested and even more lightly understood, so apply at
your own risk.
---
 render/mitrap.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/render/mitrap.c b/render/mitrap.c
index c618806..0eb32de 100644
--- a/render/mitrap.c
+++ b/render/mitrap.c
@@ -148,19 +148,25 @@ miTrapezoids (CARD8	    op,
 	for (; ntrap; ntrap--, traps++)
 	    (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0);
     } 
-    else if (maskFormat)
+    else
     {
 	PicturePtr	pPicture;
 	BoxRec		bounds;
 	INT16		xDst, yDst;
 	INT16		xRel, yRel;
-	
+
 	xDst = traps[0].left.p1.x >> 16;
 	yDst = traps[0].left.p1.y >> 16;
 
 	miTrapezoidBounds (ntrap, traps, &bounds);
 	if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
 	    return;
+
+	if (pDst->polyEdge == PolyEdgeSharp)
+	    maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+	else
+	    maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+
 	pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
 					 bounds.x2 - bounds.x1,
 					 bounds.y2 - bounds.y1);
@@ -177,13 +183,4 @@ miTrapezoids (CARD8	    op,
 			  bounds.y2 - bounds.y1);
 	FreePicture (pPicture, 0);
     }
-    else
-    {
-	if (pDst->polyEdge == PolyEdgeSharp)
-	    maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
-	else
-	    maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
-	for (; ntrap; ntrap--, traps++)
-	    miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
-    }
 }
-- 
1.5.2.2




More information about the xorg mailing list