Skip to content

Commit

Permalink
Delete XineramaScreenRegions cache.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Tiago Vignatti <[email protected]>
Tested-by: Tiago Vignatti <[email protected]> (i686 GNU/Linux)
  • Loading branch information
jameysharp committed Jun 3, 2010
1 parent a0456da commit a7c7ebe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
37 changes: 20 additions & 17 deletions Xext/panoramiX.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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];

Expand All @@ -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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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];
Expand All @@ -1165,22 +1159,31 @@ 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);
break;
} else if (inOut == rgnOUT)
continue;

REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion,
&XineramaScreenRegions[i]);

nbox = REGION_NUM_RECTS(&GrabRegion);

if(nbox) {
Expand All @@ -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 */
Expand Down
3 changes: 1 addition & 2 deletions hw/dmx/doc/dmx.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7c7ebe

Please sign in to comment.