[PATCH 6/7] Delete XineramaScreenRegions cache.

Jamey Sharp jamey at minilop.net
Sun May 23 16:22:12 PDT 2010


Every screen region consists of a single rectangle, so initializing a
stack-allocated region for each screen on-demand does no heap allocation
and is fast.

This eliminates a MAXSCREENS-sized array.

The REGION_UNINIT calls are no-ops since no boxes are actually allocated
for a single-rectangle region, but it seemed wiser to include them.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
---
This conflicts with Keith's change-region-api branch.

 Xext/panoramiX.c   |   41 ++++++++++++++++++-----------------------
 hw/dmx/doc/dmx.xml |    3 +--
 2 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 78728a9..b9215c1 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -119,8 +119,6 @@ typedef struct {
   CloseScreenProcPtr	CloseScreen;
 } PanoramiXScreenRec, *PanoramiXScreenPtr;
 
-static RegionRec XineramaScreenRegions[MAXSCREENS];
-
 static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr);
 static void XineramaChangeGC(GCPtr, unsigned long);
 static void XineramaCopyGC(GCPtr, unsigned long, GCPtr);
@@ -153,7 +151,6 @@ XineramaCloseScreen (int i, ScreenPtr pScreen)
     pScreen->CloseScreen = pScreenPriv->CloseScreen;
     pScreen->CreateGC = pScreenPriv->CreateGC;
 
-    REGION_UNINIT(pScreen, &XineramaScreenRegions[pScreen->myNum]);
     if (pScreen->myNum == 0)
 	REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
 
@@ -391,18 +388,16 @@ static void XineramaInitData(ScreenPtr pScreen)
 
     REGION_NULL(pScreen, &PanoramiXScreenRegion)
     for (i = 0; i < PanoramiXNumScreens; i++) {
-	BoxRec TheBox;
+	RegionRec ScreenRegion;
 
         pScreen = screenInfo.screens[i];
 
-	TheBox.x1 = pScreen->x;
-	TheBox.x2 = TheBox.x1 + pScreen->width;
-	TheBox.y1 = pScreen->y;
-	TheBox.y2 = TheBox.y1 + pScreen->height;
-
-	REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1);
+	pixman_region_init_rect(&ScreenRegion,
+				pScreen->x, pScreen->y,
+				pScreen->width, pScreen->height);
 	REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion,
-		     &XineramaScreenRegions[i]);
+		     &ScreenRegion);
+	REGION_UNINIT(pScreen, &ScreenRegion);
     }
 
     PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width;
@@ -422,12 +417,7 @@ static void XineramaInitData(ScreenPtr pScreen)
 
 void XineramaReinitData(ScreenPtr pScreen)
 {
-    int i;
-
     REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
-    for (i = 0; i < PanoramiXNumScreens; i++)
-	REGION_UNINIT(pScreen, &XineramaScreenRegions[i]);
-
     XineramaInitData(pScreen);
 }
 
@@ -1141,7 +1131,7 @@ XineramaGetImageData(
     int pitch,
     Bool isRoot
 ){
-    RegionRec SrcRegion, GrabRegion;
+    RegionRec SrcRegion, ScreenRegion, GrabRegion;
     BoxRec SrcBox, *pbox;
     int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth;
     DrawablePtr pDraw = pDrawables[0];
@@ -1165,12 +1155,20 @@ XineramaGetImageData(
     depth = (format == XYPixmap) ? 1 : pDraw->depth;
 
     for(i = 0; i < PanoramiXNumScreens; i++) {
+	ScreenPtr pScreen;
 	pDraw = pDrawables[i];
+	pScreen = pDraw->pScreen;
 
-	inOut = RECT_IN_REGION(pScreen,&XineramaScreenRegions[i],&SrcBox);
+	pixman_region_init_rect(&ScreenRegion,
+				pScreen->x, pScreen->y,
+				pScreen->width, pScreen->height);
+	inOut = RECT_IN_REGION(pScreen, &ScreenRegion, &SrcBox);
+	if(inOut == rgnPART)
+	    REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion, &ScreenRegion);
+	REGION_UNINIT(pScreen, &ScreenRegion);
 
 	if(inOut == rgnIN) {	   
-	    (*pDraw->pScreen->GetImage)(pDraw, 
+	    (*pScreen->GetImage)(pDraw,
 			SrcBox.x1 - pDraw->x - screenInfo.screens[i]->x,
 			SrcBox.y1 - pDraw->y - screenInfo.screens[i]->y,
 			width, height, format, planemask, data);
@@ -1178,9 +1176,6 @@ XineramaGetImageData(
 	} else if (inOut == rgnOUT)
 	    continue;
 
-	REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion, 
-					&XineramaScreenRegions[i]);
-
 	nbox = REGION_NUM_RECTS(&GrabRegion);
 
 	if(nbox) {
@@ -1206,7 +1201,7 @@ XineramaGetImageData(
 		x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x;
 		y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y;
 
-		(*pDraw->pScreen->GetImage)(pDraw, x, y, w, h, 
+		(*pScreen->GetImage)(pDraw, x, y, w, h,
 					format, planemask, ScratchMem);
 		
 		/* copy the memory over */
diff --git a/hw/dmx/doc/dmx.xml b/hw/dmx/doc/dmx.xml
index d0c83bb..c6dc0cc 100644
--- a/hw/dmx/doc/dmx.xml
+++ b/hw/dmx/doc/dmx.xml
@@ -1507,8 +1507,7 @@ PanoramiX prefix.
     Xinerama windows, pixmaps and colormaps.
     </para>
 
-    <para>A region (XineramaScreenRegions&lsqb;i&rsqb;) is initialized for each
-    physical screen, and single region (PanoramiXScreenRegion) is
+    <para>A region (PanoramiXScreenRegion) is
     initialized to be the union of the screen regions.
     The relative positioning information for the
     physical screens is taken from the ScreenRec x and y members, which
-- 
1.7.0



More information about the xorg-devel mailing list