From dd17d3e6f491dc83708951a208c9954865cce3a6 Mon Sep 17 00:00:00 2001
From: Bernardo Innocenti <bernie@codewiz.org>
Date: Wed, 11 Jul 2007 18:08:08 -0400
Subject: [PATCH] miTrapezoids(): Simplify.
Organization: One Laptop Per Child

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

