Blob Blame History Raw
From fb2d582e65b386e52bbba8c7f1c7777617db87f4 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Wed, 15 Oct 2008 00:02:13 +0200
Subject: [PATCH] exa: fix unneeded calls to drivers

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 522224b..6e754b2 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -401,6 +401,10 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable,
     RegionPtr srcregion = NULL, dstregion = NULL;
     xRectangle *rects;
 
+    /* avoid doing copy operations if no boxes */
+    if (nbox == 0)
+	return;
+
     pSrcPixmap = exaGetDrawablePixmap (pSrcDrawable);
     pDstPixmap = exaGetDrawablePixmap (pDstDrawable);
 
@@ -1229,36 +1233,51 @@ exaFillRegionTiled (DrawablePtr	pDrawable,
 	 */
 	if (alu != GXcopy)
 	    ret = TRUE;
-	else if ((*pExaScr->info->PrepareCopy) (pPixmap, pPixmap, 1, 1, alu,
-						planemask)) {
-	    for (i = 0; i < nbox; i++)
-	    {
+	else {
+	    Bool more_copy = FALSE;
+
+	    for (i = 0; i < nbox; i++) {
 		int dstX = pBox[i].x1 + tileWidth;
 		int dstY = pBox[i].y1 + tileHeight;
-		int width = min(pBox[i].x2 - dstX, tileWidth);
-		int height = min(pBox[i].y2 - pBox[i].y1, tileHeight);
-
-		while (dstX < pBox[i].x2) {
-		    (*pExaScr->info->Copy) (pPixmap, pBox[i].x1, pBox[i].y1,
-					    dstX, pBox[i].y1, width, height);
-		    dstX += width;
-		    width = min(pBox[i].x2 - dstX, width * 2);
-		}
 
-		width = pBox[i].x2 - pBox[i].x1;
-		height = min(pBox[i].y2 - dstY, tileHeight);
+		if ((dstX < pBox[i].x2) || (dstY < pBox[i].y2))
+		    more_copy = TRUE;
+	    }
+
+	    if (more_copy == FALSE)
+		ret = TRUE;
 
-		while (dstY < pBox[i].y2) {
-		    (*pExaScr->info->Copy) (pPixmap, pBox[i].x1, pBox[i].y1,
-					    pBox[i].x1, dstY, width, height);
-		    dstY += height;
-		    height = min(pBox[i].y2 - dstY, height * 2);
+	    if (more_copy && (*pExaScr->info->PrepareCopy) (pPixmap, pPixmap,
+							    1, 1, alu, planemask)) {
+		for (i = 0; i < nbox; i++)
+		{
+		    int dstX = pBox[i].x1 + tileWidth;
+		    int dstY = pBox[i].y1 + tileHeight;
+		    int width = min(pBox[i].x2 - dstX, tileWidth);
+		    int height = min(pBox[i].y2 - pBox[i].y1, tileHeight);
+
+		    while (dstX < pBox[i].x2) {
+			(*pExaScr->info->Copy) (pPixmap, pBox[i].x1, pBox[i].y1,
+						dstX, pBox[i].y1, width, height);
+			dstX += width;
+			width = min(pBox[i].x2 - dstX, width * 2);
+		    }
+
+		    width = pBox[i].x2 - pBox[i].x1;
+		    height = min(pBox[i].y2 - dstY, tileHeight);
+
+		    while (dstY < pBox[i].y2) {
+			(*pExaScr->info->Copy) (pPixmap, pBox[i].x1, pBox[i].y1,
+						pBox[i].x1, dstY, width, height);
+			dstY += height;
+			height = min(pBox[i].y2 - dstY, height * 2);
+		    }
 		}
-	    }
 
-	    (*pExaScr->info->DoneCopy) (pPixmap);
+		(*pExaScr->info->DoneCopy) (pPixmap);
 
-	    ret = TRUE;
+		ret = TRUE;
+	    }
 	}
 
 	exaMarkSync(pDrawable->pScreen);