Delete XineramaScreenRegions cache.
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@minilop.net> Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com> Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com> (i686 GNU/Linux)
This commit is contained in:
		
							parent
							
								
									a0456da339
								
							
						
					
					
						commit
						a7c7ebe4b3
					
				|  | @ -119,8 +119,6 @@ typedef struct { | ||||||
|   CloseScreenProcPtr	CloseScreen; |   CloseScreenProcPtr	CloseScreen; | ||||||
| } PanoramiXScreenRec, *PanoramiXScreenPtr; | } PanoramiXScreenRec, *PanoramiXScreenPtr; | ||||||
| 
 | 
 | ||||||
| static RegionRec XineramaScreenRegions[MAXSCREENS]; |  | ||||||
| 
 |  | ||||||
| static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr); | static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr); | ||||||
| static void XineramaChangeGC(GCPtr, unsigned long); | static void XineramaChangeGC(GCPtr, unsigned long); | ||||||
| static void XineramaCopyGC(GCPtr, unsigned long, GCPtr); | static void XineramaCopyGC(GCPtr, unsigned long, GCPtr); | ||||||
|  | @ -153,7 +151,6 @@ XineramaCloseScreen (int i, ScreenPtr pScreen) | ||||||
|     pScreen->CloseScreen = pScreenPriv->CloseScreen; |     pScreen->CloseScreen = pScreenPriv->CloseScreen; | ||||||
|     pScreen->CreateGC = pScreenPriv->CreateGC; |     pScreen->CreateGC = pScreenPriv->CreateGC; | ||||||
| 
 | 
 | ||||||
|     REGION_UNINIT(pScreen, &XineramaScreenRegions[pScreen->myNum]); |  | ||||||
|     if (pScreen->myNum == 0) |     if (pScreen->myNum == 0) | ||||||
| 	REGION_UNINIT(pScreen, &PanoramiXScreenRegion); | 	REGION_UNINIT(pScreen, &PanoramiXScreenRegion); | ||||||
| 
 | 
 | ||||||
|  | @ -392,6 +389,7 @@ static void XineramaInitData(ScreenPtr pScreen) | ||||||
|     REGION_NULL(pScreen, &PanoramiXScreenRegion) |     REGION_NULL(pScreen, &PanoramiXScreenRegion) | ||||||
|     for (i = 0; i < PanoramiXNumScreens; i++) { |     for (i = 0; i < PanoramiXNumScreens; i++) { | ||||||
| 	BoxRec TheBox; | 	BoxRec TheBox; | ||||||
|  | 	RegionRec ScreenRegion; | ||||||
| 
 | 
 | ||||||
|         pScreen = screenInfo.screens[i]; |         pScreen = screenInfo.screens[i]; | ||||||
| 
 | 
 | ||||||
|  | @ -400,9 +398,10 @@ static void XineramaInitData(ScreenPtr pScreen) | ||||||
| 	TheBox.y1 = pScreen->y; | 	TheBox.y1 = pScreen->y; | ||||||
| 	TheBox.y2 = TheBox.y1 + pScreen->height; | 	TheBox.y2 = TheBox.y1 + pScreen->height; | ||||||
| 
 | 
 | ||||||
| 	REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1); | 	REGION_INIT(pScreen, &ScreenRegion, &TheBox, 1); | ||||||
| 	REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion, | 	REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion, | ||||||
| 		     &XineramaScreenRegions[i]); | 		     &ScreenRegion); | ||||||
|  | 	REGION_UNINIT(pScreen, &ScreenRegion); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width; |     PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width; | ||||||
|  | @ -422,12 +421,7 @@ static void XineramaInitData(ScreenPtr pScreen) | ||||||
| 
 | 
 | ||||||
| void XineramaReinitData(ScreenPtr pScreen) | void XineramaReinitData(ScreenPtr pScreen) | ||||||
| { | { | ||||||
|     int i; |  | ||||||
| 
 |  | ||||||
|     REGION_UNINIT(pScreen, &PanoramiXScreenRegion); |     REGION_UNINIT(pScreen, &PanoramiXScreenRegion); | ||||||
|     for (i = 0; i < PanoramiXNumScreens; i++) |  | ||||||
| 	REGION_UNINIT(pScreen, &XineramaScreenRegions[i]); |  | ||||||
| 
 |  | ||||||
|     XineramaInitData(pScreen); |     XineramaInitData(pScreen); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -1141,7 +1135,7 @@ XineramaGetImageData( | ||||||
|     int pitch, |     int pitch, | ||||||
|     Bool isRoot |     Bool isRoot | ||||||
| ){ | ){ | ||||||
|     RegionRec SrcRegion, GrabRegion; |     RegionRec SrcRegion, ScreenRegion, GrabRegion; | ||||||
|     BoxRec SrcBox, *pbox; |     BoxRec SrcBox, *pbox; | ||||||
|     int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth; |     int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth; | ||||||
|     DrawablePtr pDraw = pDrawables[0]; |     DrawablePtr pDraw = pDrawables[0]; | ||||||
|  | @ -1165,12 +1159,24 @@ XineramaGetImageData( | ||||||
|     depth = (format == XYPixmap) ? 1 : pDraw->depth; |     depth = (format == XYPixmap) ? 1 : pDraw->depth; | ||||||
| 
 | 
 | ||||||
|     for(i = 0; i < PanoramiXNumScreens; i++) { |     for(i = 0; i < PanoramiXNumScreens; i++) { | ||||||
|  | 	BoxRec TheBox; | ||||||
|  | 	ScreenPtr pScreen; | ||||||
| 	pDraw = pDrawables[i]; | 	pDraw = pDrawables[i]; | ||||||
|  | 	pScreen = pDraw->pScreen; | ||||||
| 
 | 
 | ||||||
| 	inOut = RECT_IN_REGION(pScreen,&XineramaScreenRegions[i],&SrcBox); | 	TheBox.x1 = pScreen->x; | ||||||
|  | 	TheBox.x2 = TheBox.x1 + pScreen->width; | ||||||
|  | 	TheBox.y1 = pScreen->y; | ||||||
|  | 	TheBox.y2 = TheBox.y1 + pScreen->height; | ||||||
|  | 
 | ||||||
|  | 	REGION_INIT(pScreen, &ScreenRegion, &TheBox, 1); | ||||||
|  | 	inOut = RECT_IN_REGION(pScreen, &ScreenRegion, &SrcBox); | ||||||
|  | 	if(inOut == rgnPART) | ||||||
|  | 	    REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion, &ScreenRegion); | ||||||
|  | 	REGION_UNINIT(pScreen, &ScreenRegion); | ||||||
| 
 | 
 | ||||||
| 	if(inOut == rgnIN) {	    | 	if(inOut == rgnIN) {	    | ||||||
| 	    (*pDraw->pScreen->GetImage)(pDraw,  | 	    (*pScreen->GetImage)(pDraw, | ||||||
| 			SrcBox.x1 - pDraw->x - screenInfo.screens[i]->x, | 			SrcBox.x1 - pDraw->x - screenInfo.screens[i]->x, | ||||||
| 			SrcBox.y1 - pDraw->y - screenInfo.screens[i]->y, | 			SrcBox.y1 - pDraw->y - screenInfo.screens[i]->y, | ||||||
| 			width, height, format, planemask, data); | 			width, height, format, planemask, data); | ||||||
|  | @ -1178,9 +1184,6 @@ XineramaGetImageData( | ||||||
| 	} else if (inOut == rgnOUT) | 	} else if (inOut == rgnOUT) | ||||||
| 	    continue; | 	    continue; | ||||||
| 
 | 
 | ||||||
| 	REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion,  |  | ||||||
| 					&XineramaScreenRegions[i]); |  | ||||||
| 
 |  | ||||||
| 	nbox = REGION_NUM_RECTS(&GrabRegion); | 	nbox = REGION_NUM_RECTS(&GrabRegion); | ||||||
| 
 | 
 | ||||||
| 	if(nbox) { | 	if(nbox) { | ||||||
|  | @ -1206,7 +1209,7 @@ XineramaGetImageData( | ||||||
| 		x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x; | 		x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x; | ||||||
| 		y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y; | 		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); | 					format, planemask, ScratchMem); | ||||||
| 		 | 		 | ||||||
| 		/* copy the memory over */ | 		/* copy the memory over */ | ||||||
|  |  | ||||||
|  | @ -1507,8 +1507,7 @@ PanoramiX prefix. | ||||||
|     Xinerama windows, pixmaps and colormaps. |     Xinerama windows, pixmaps and colormaps. | ||||||
|     </para> |     </para> | ||||||
| 
 | 
 | ||||||
|     <para>A region (XineramaScreenRegions[i]) is initialized for each |     <para>A region (PanoramiXScreenRegion) is | ||||||
|     physical screen, and single region (PanoramiXScreenRegion) is |  | ||||||
|     initialized to be the union of the screen regions. |     initialized to be the union of the screen regions. | ||||||
|     The relative positioning information for the |     The relative positioning information for the | ||||||
|     physical screens is taken from the ScreenRec x and y members, which |     physical screens is taken from the ScreenRec x and y members, which | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue