[PATCH] Accumulate graphics exposures incrementally in PanoramiXCopyArea.

Jamey Sharp jamey at minilop.net
Fri Apr 23 19:52:56 PDT 2010


This fuses two loops, eliminating an intermediate MAXSCREENS-sized
array.

Aside from being more efficient, I believe this is equivalent to the
previous implementation, assuming that
- each per-screen GC has the graphicsExposures flag set the same way,
  and
- the REGION_* macros continue to ignore their screen argument.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
---

What's up with the REGION_* macros anyway? AFAICT they've never cared
about their screen argument for as long as we have history in git.

 Xext/panoramiXprocs.c |   35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 3baa8f9..3da1dac 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -1092,10 +1092,12 @@ int PanoramiXCopyArea(ClientPtr client)
     } else {
 	DrawablePtr pDst = NULL, pSrc = NULL;
 	GCPtr pGC = NULL;
-	RegionPtr pRgn[MAXSCREENS];
+	RegionRec totalReg;
 	int rc;
 
+	REGION_NULL(unusedScreen, &totalReg);
 	FOR_NSCREENS_BACKWARD(j) {
+	    RegionPtr pRgn;
 	    stuff->dstDrawable = dst->info[j].id;
 	    stuff->srcDrawable = src->info[j].id;
 	    stuff->gc          = gc->info[j].id;
@@ -1124,37 +1126,30 @@ int PanoramiXCopyArea(ClientPtr client)
  	    } else
 		pSrc = pDst;
 
-	    pRgn[j] = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, 
+	    pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
 				stuff->srcX, stuff->srcY,
 				stuff->width, stuff->height, 
 				stuff->dstX, stuff->dstY);
+	    if(pGC->graphicsExposures && pRgn) {
+	       if(srcIsRoot) {
+		   REGION_TRANSLATE(unusedScreen, pRgn,
+			    panoramiXdataPtr[j].x, panoramiXdataPtr[j].y);
+	       }
+	       REGION_APPEND(unusedScreen, &totalReg, pRgn);
+	       REGION_DESTROY(unusedScreen, pRgn);
+	    }
 
-	    if(dstShared) {
-		while(j--) pRgn[j] = NULL;
+	    if(dstShared)
 		break;
-	    }
 	}
 
 	if(pGC->graphicsExposures) {
 	    ScreenPtr pScreen = pDst->pScreen;
-	    RegionRec totalReg;
 	    Bool overlap;
-
-	    REGION_NULL(pScreen, &totalReg);
-	    FOR_NSCREENS_BACKWARD(j) {
-		if(pRgn[j]) {
-		   if(srcIsRoot) {
-		       REGION_TRANSLATE(pScreen, pRgn[j], 
-				panoramiXdataPtr[j].x, panoramiXdataPtr[j].y);
-		   }
-		   REGION_APPEND(pScreen, &totalReg, pRgn[j]);
-		   REGION_DESTROY(pScreen, pRgn[j]);
-		}
-	    }
-	    REGION_VALIDATE(pScreen, &totalReg, &overlap);
+	    REGION_VALIDATE(unusedScreen, &totalReg, &overlap);
 	    (*pScreen->SendGraphicsExpose)(
 		client, &totalReg, stuff->dstDrawable, X_CopyArea, 0);
-	    REGION_UNINIT(pScreen, &totalReg);
+	    REGION_UNINIT(unusedScreen, &totalReg);
 	}
 	
 	result = client->noClientException;
-- 
1.7.0



More information about the xorg-devel mailing list