diff options
author | Jamey Sharp <jamey@minilop.net> | 2010-05-22 21:13:48 -0700 |
---|---|---|
committer | Jamey Sharp <jamey@minilop.net> | 2010-06-03 14:03:23 -0700 |
commit | a7c7ebe4b3a0df1a4d1ffe3c690cfb21470f103d (patch) | |
tree | 3678eb5f068114c7fa41f48b1adcef81f2b273af /Xext | |
parent | a0456da339fa9b3c3e6fead060338ee7348d6460 (diff) |
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)
Diffstat (limited to 'Xext')
-rw-r--r-- | Xext/panoramiX.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index 78728a9f7..14e06e160 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); @@ -392,6 +389,7 @@ static void XineramaInitData(ScreenPtr pScreen) REGION_NULL(pScreen, &PanoramiXScreenRegion) for (i = 0; i < PanoramiXNumScreens; i++) { BoxRec TheBox; + RegionRec ScreenRegion; pScreen = screenInfo.screens[i]; @@ -400,9 +398,10 @@ static void XineramaInitData(ScreenPtr pScreen) TheBox.y1 = pScreen->y; TheBox.y2 = TheBox.y1 + pScreen->height; - REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1); + REGION_INIT(pScreen, &ScreenRegion, &TheBox, 1); REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion, - &XineramaScreenRegions[i]); + &ScreenRegion); + REGION_UNINIT(pScreen, &ScreenRegion); } PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width; @@ -422,12 +421,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 +1135,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 +1159,24 @@ XineramaGetImageData( depth = (format == XYPixmap) ? 1 : pDraw->depth; for(i = 0; i < PanoramiXNumScreens; i++) { + BoxRec TheBox; + ScreenPtr pScreen; 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) { - (*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 +1184,6 @@ XineramaGetImageData( } else if (inOut == rgnOUT) continue; - REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion, - &XineramaScreenRegions[i]); - nbox = REGION_NUM_RECTS(&GrabRegion); if(nbox) { @@ -1206,7 +1209,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 */ |