Skip to content

Commit

Permalink
Rename region macros to eliminate screen argument
Browse files Browse the repository at this point in the history
This is a combination of a huge mechanical patch and a few small
fixups required to finish the job. They were reviewed separately, but
because the server does not build without both pieces, I've merged
them together at this time.

The mechanical changes were performed by running the included
'fix-region' script over the whole tree:

$ git ls-files | grep -v '^fix-' | xargs ./fix-region

And then, the white space errors in the resulting patch were fixed
using the provided fix-patch-whitespace script.

$ sh ./fix-patch-whitespace

Thanks to Jamey Sharp for the mighty fine sed-generating sed script.

The hand-done changes involve removing functions from dix/region.c
that duplicate inline functions in include/regionstr.h, along with
their declarations in regionstr.h, mi.h and mispans.h.

Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Jun 6, 2010
1 parent d17e726 commit 2dc1389
Show file tree
Hide file tree
Showing 130 changed files with 1,817 additions and 1,865 deletions.
36 changes: 18 additions & 18 deletions Xext/panoramiX.c
Expand Up @@ -152,7 +152,7 @@ XineramaCloseScreen (int i, ScreenPtr pScreen)
pScreen->CreateGC = pScreenPriv->CreateGC;

if (pScreen->myNum == 0)
REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
RegionUninit(&PanoramiXScreenRegion);

free((pointer) pScreenPriv);

Expand Down Expand Up @@ -386,7 +386,7 @@ static void XineramaInitData(ScreenPtr pScreen)
{
int i, w, h;

REGION_NULL(pScreen, &PanoramiXScreenRegion)
RegionNull(&PanoramiXScreenRegion)
for (i = 0; i < PanoramiXNumScreens; i++) {
BoxRec TheBox;
RegionRec ScreenRegion;
Expand All @@ -398,10 +398,10 @@ static void XineramaInitData(ScreenPtr pScreen)
TheBox.y1 = pScreen->y;
TheBox.y2 = TheBox.y1 + pScreen->height;

REGION_INIT(pScreen, &ScreenRegion, &TheBox, 1);
REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion,
RegionInit(&ScreenRegion, &TheBox, 1);
RegionUnion(&PanoramiXScreenRegion, &PanoramiXScreenRegion,
&ScreenRegion);
REGION_UNINIT(pScreen, &ScreenRegion);
RegionUninit(&ScreenRegion);
}

PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width;
Expand All @@ -421,7 +421,7 @@ static void XineramaInitData(ScreenPtr pScreen)

void XineramaReinitData(ScreenPtr pScreen)
{
REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
RegionUninit(&PanoramiXScreenRegion);
XineramaInitData(pScreen);
}

Expand Down Expand Up @@ -1153,8 +1153,8 @@ XineramaGetImageData(
SrcBox.x2 = SrcBox.x1 + width;
SrcBox.y2 = SrcBox.y1 + height;

REGION_INIT(pScreen, &SrcRegion, &SrcBox, 1);
REGION_NULL(pScreen, &GrabRegion);
RegionInit(&SrcRegion, &SrcBox, 1);
RegionNull(&GrabRegion);

depth = (format == XYPixmap) ? 1 : pDraw->depth;

Expand All @@ -1169,11 +1169,11 @@ XineramaGetImageData(
TheBox.y1 = pScreen->y;
TheBox.y2 = TheBox.y1 + pScreen->height;

REGION_INIT(pScreen, &ScreenRegion, &TheBox, 1);
inOut = RECT_IN_REGION(pScreen, &ScreenRegion, &SrcBox);
RegionInit(&ScreenRegion, &TheBox, 1);
inOut = RegionContainsRect(&ScreenRegion, &SrcBox);
if(inOut == rgnPART)
REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion, &ScreenRegion);
REGION_UNINIT(pScreen, &ScreenRegion);
RegionIntersect(&GrabRegion, &SrcRegion, &ScreenRegion);
RegionUninit(&ScreenRegion);

if(inOut == rgnIN) {
(*pScreen->GetImage)(pDraw,
Expand All @@ -1184,10 +1184,10 @@ XineramaGetImageData(
} else if (inOut == rgnOUT)
continue;

nbox = REGION_NUM_RECTS(&GrabRegion);
nbox = RegionNumRects(&GrabRegion);

if(nbox) {
pbox = REGION_RECTS(&GrabRegion);
pbox = RegionRects(&GrabRegion);

while(nbox--) {
w = pbox->x2 - pbox->x1;
Expand Down Expand Up @@ -1264,8 +1264,8 @@ XineramaGetImageData(
pbox++;
}

REGION_SUBTRACT(pScreen, &SrcRegion, &SrcRegion, &GrabRegion);
if(!REGION_NOTEMPTY(pScreen, &SrcRegion))
RegionSubtract(&SrcRegion, &SrcRegion, &GrabRegion);
if(!RegionNotEmpty(&SrcRegion))
break;
}

Expand All @@ -1274,6 +1274,6 @@ XineramaGetImageData(
if(ScratchMem)
free(ScratchMem);

REGION_UNINIT(pScreen, &SrcRegion);
REGION_UNINIT(pScreen, &GrabRegion);
RegionUninit(&SrcRegion);
RegionUninit(&GrabRegion);
}
24 changes: 12 additions & 12 deletions Xext/panoramiXprocs.c
Expand Up @@ -620,7 +620,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
* borderSize
*/
&& (!wBoundingShape(pWin) ||
POINT_IN_REGION(pWin->drawable.pScreen,
RegionContainsPoint(
wBoundingShape(pWin),
x - pWin->drawable.x,
y - pWin->drawable.y, &box))
Expand Down Expand Up @@ -1087,7 +1087,7 @@ int PanoramiXCopyArea(ClientPtr client)
RegionRec totalReg;
int rc;

REGION_NULL(unusedScreen, &totalReg);
RegionNull(&totalReg);
FOR_NSCREENS_BACKWARD(j) {
RegionPtr pRgn;
stuff->dstDrawable = dst->info[j].id;
Expand Down Expand Up @@ -1124,11 +1124,11 @@ int PanoramiXCopyArea(ClientPtr client)
stuff->dstX, stuff->dstY);
if(pGC->graphicsExposures && pRgn) {
if(srcIsRoot) {
REGION_TRANSLATE(unusedScreen, pRgn,
RegionTranslate(pRgn,
screenInfo.screens[j]->x, screenInfo.screens[j]->y);
}
REGION_APPEND(unusedScreen, &totalReg, pRgn);
REGION_DESTROY(unusedScreen, pRgn);
RegionAppend(&totalReg, pRgn);
RegionDestroy(pRgn);
}

if(dstShared)
Expand All @@ -1138,10 +1138,10 @@ int PanoramiXCopyArea(ClientPtr client)
if(pGC->graphicsExposures) {
ScreenPtr pScreen = pDst->pScreen;
Bool overlap;
REGION_VALIDATE(unusedScreen, &totalReg, &overlap);
RegionValidate(&totalReg, &overlap);
(*pScreen->SendGraphicsExpose)(
client, &totalReg, stuff->dstDrawable, X_CopyArea, 0);
REGION_UNINIT(unusedScreen, &totalReg);
RegionUninit(&totalReg);
}
}

Expand Down Expand Up @@ -1193,7 +1193,7 @@ int PanoramiXCopyPlane(ClientPtr client)
srcx = stuff->srcX; srcy = stuff->srcY;
dstx = stuff->dstX; dsty = stuff->dstY;

REGION_NULL(unusedScreen, &totalReg);
RegionNull(&totalReg);
FOR_NSCREENS_BACKWARD(j) {
RegionPtr pRgn;
stuff->dstDrawable = dst->info[j].id;
Expand Down Expand Up @@ -1233,8 +1233,8 @@ int PanoramiXCopyPlane(ClientPtr client)
stuff->width, stuff->height,
stuff->dstX, stuff->dstY, stuff->bitPlane);
if(pGC->graphicsExposures && pRgn) {
REGION_APPEND(unusedScreen, &totalReg, pRgn);
REGION_DESTROY(unusedScreen, pRgn);
RegionAppend(&totalReg, pRgn);
RegionDestroy(pRgn);
}

if(dstShared)
Expand All @@ -1244,10 +1244,10 @@ int PanoramiXCopyPlane(ClientPtr client)
if(pGC->graphicsExposures) {
ScreenPtr pScreen = pdstDraw->pScreen;
Bool overlap;
REGION_VALIDATE(unusedScreen, &totalReg, &overlap);
RegionValidate(&totalReg, &overlap);
(*pScreen->SendGraphicsExpose)(
client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0);
REGION_UNINIT(unusedScreen, &totalReg);
RegionUninit(&totalReg);
}

return Success;
Expand Down
48 changes: 24 additions & 24 deletions Xext/shape.c
Expand Up @@ -153,11 +153,11 @@ RegionOperate (
ScreenPtr pScreen = pWin->drawable.pScreen;

if (srcRgn && (xoff || yoff))
REGION_TRANSLATE(pScreen, srcRgn, xoff, yoff);
RegionTranslate(srcRgn, xoff, yoff);
if (!pWin->parent)
{
if (srcRgn)
REGION_DESTROY(pScreen, srcRgn);
RegionDestroy(srcRgn);
return Success;
}

Expand All @@ -168,7 +168,7 @@ RegionOperate (
*/
if (srcRgn == NULL) {
if (*destRgnp != NULL) {
REGION_DESTROY (pScreen, *destRgnp);
RegionDestroy(*destRgnp);
*destRgnp = 0;
/* go on to remove shape and generate ShapeNotify */
}
Expand All @@ -187,17 +187,17 @@ RegionOperate (
else switch (op) {
case ShapeSet:
if (*destRgnp)
REGION_DESTROY(pScreen, *destRgnp);
RegionDestroy(*destRgnp);
*destRgnp = srcRgn;
srcRgn = 0;
break;
case ShapeUnion:
if (*destRgnp)
REGION_UNION(pScreen, *destRgnp, *destRgnp, srcRgn);
RegionUnion(*destRgnp, *destRgnp, srcRgn);
break;
case ShapeIntersect:
if (*destRgnp)
REGION_INTERSECT(pScreen, *destRgnp, *destRgnp, srcRgn);
RegionIntersect(*destRgnp, *destRgnp, srcRgn);
else {
*destRgnp = srcRgn;
srcRgn = 0;
Expand All @@ -206,20 +206,20 @@ RegionOperate (
case ShapeSubtract:
if (!*destRgnp)
*destRgnp = (*create)(pWin);
REGION_SUBTRACT(pScreen, *destRgnp, *destRgnp, srcRgn);
RegionSubtract(*destRgnp, *destRgnp, srcRgn);
break;
case ShapeInvert:
if (!*destRgnp)
*destRgnp = REGION_CREATE(pScreen, (BoxPtr) 0, 0);
*destRgnp = RegionCreate((BoxPtr) 0, 0);
else
REGION_SUBTRACT(pScreen, *destRgnp, srcRgn, *destRgnp);
RegionSubtract(*destRgnp, srcRgn, *destRgnp);
break;
default:
client->errorValue = op;
return BadValue;
}
if (srcRgn)
REGION_DESTROY(pScreen, srcRgn);
RegionDestroy(srcRgn);
(*pScreen->SetShape) (pWin, kind);
SendShapeNotify (pWin, kind);
return Success;
Expand All @@ -234,7 +234,7 @@ CreateBoundingShape (WindowPtr pWin)
extents.y1 = -wBorderWidth (pWin);
extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
extents.y2 = pWin->drawable.height + wBorderWidth (pWin);
return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
return RegionCreate(&extents, 1);
}

RegionPtr
Expand All @@ -246,7 +246,7 @@ CreateClipShape (WindowPtr pWin)
extents.y1 = 0;
extents.x2 = pWin->drawable.width;
extents.y2 = pWin->drawable.height;
return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
return RegionCreate(&extents, 1);
}

static int
Expand Down Expand Up @@ -323,7 +323,7 @@ ProcShapeRectangles (ClientPtr client)
ctype = VerifyRectOrder(nrects, prects, (int)stuff->ordering);
if (ctype < 0)
return BadMatch;
srcRgn = RECTS_TO_REGION(pScreen, nrects, prects, ctype);
srcRgn = RegionFromRects(nrects, prects, ctype);

if (!pWin->optional)
MakeWindowOptional (pWin);
Expand Down Expand Up @@ -419,7 +419,7 @@ ProcShapeMask (ClientPtr client)
if (pPixmap->drawable.pScreen != pScreen ||
pPixmap->drawable.depth != 1)
return BadMatch;
srcRgn = BITMAP_TO_REGION(pScreen, pPixmap);
srcRgn = BitmapToRegion(pScreen, pPixmap);
if (!srcRgn)
return BadAlloc;
}
Expand Down Expand Up @@ -547,8 +547,8 @@ ProcShapeCombine (ClientPtr client)
}

if (srcRgn) {
tmp = REGION_CREATE(pScreen, (BoxPtr) 0, 0);
REGION_COPY(pScreen, tmp, srcRgn);
tmp = RegionCreate((BoxPtr) 0, 0);
RegionCopy(tmp, srcRgn);
srcRgn = tmp;
} else
srcRgn = (*createSrc) (pSrcWin);
Expand Down Expand Up @@ -641,7 +641,7 @@ ProcShapeOffset (ClientPtr client)
pScreen = pWin->drawable.pScreen;
if (srcRgn)
{
REGION_TRANSLATE(pScreen, srcRgn, stuff->xOff, stuff->yOff);
RegionTranslate(srcRgn, stuff->xOff, stuff->yOff);
(*pScreen->SetShape) (pWin, stuff->destKind);
}
SendShapeNotify (pWin, (int)stuff->destKind);
Expand Down Expand Up @@ -697,7 +697,7 @@ ProcShapeQueryExtents (ClientPtr client)
rep.clipShaped = (wClipShape(pWin) != 0);
if ((region = wBoundingShape(pWin))) {
/* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
pExtents = RegionExtents(region);
extents = *pExtents;
} else {
extents.x1 = -wBorderWidth (pWin);
Expand All @@ -711,7 +711,7 @@ ProcShapeQueryExtents (ClientPtr client)
rep.heightBoundingShape = extents.y2 - extents.y1;
if ((region = wClipShape(pWin))) {
/* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
pExtents = RegionExtents(region);
extents = *pExtents;
} else {
extents.x1 = 0;
Expand Down Expand Up @@ -899,7 +899,7 @@ SendShapeNotify (WindowPtr pWin, int which)
case ShapeBounding:
region = wBoundingShape(pWin);
if (region) {
extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
extents = *RegionExtents(region);
shaped = xTrue;
} else {
extents.x1 = -wBorderWidth (pWin);
Expand All @@ -912,7 +912,7 @@ SendShapeNotify (WindowPtr pWin, int which)
case ShapeClip:
region = wClipShape(pWin);
if (region) {
extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
extents = *RegionExtents(region);
shaped = xTrue;
} else {
extents.x1 = 0;
Expand All @@ -925,7 +925,7 @@ SendShapeNotify (WindowPtr pWin, int which)
case ShapeInput:
region = wInputShape(pWin);
if (region) {
extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
extents = *RegionExtents(region);
shaped = xTrue;
} else {
extents.x1 = -wBorderWidth (pWin);
Expand Down Expand Up @@ -1050,8 +1050,8 @@ ProcShapeGetRectangles (ClientPtr client)
}
} else {
BoxPtr box;
nrects = REGION_NUM_RECTS(region);
box = REGION_RECTS(region);
nrects = RegionNumRects(region);
box = RegionRects(region);
rects = malloc(nrects * sizeof (xRectangle));
if (!rects && nrects)
return BadAlloc;
Expand Down
14 changes: 7 additions & 7 deletions Xext/xace.c
Expand Up @@ -255,12 +255,12 @@ XaceCensorImage(
imageBox.y1 = y;
imageBox.x2 = x + w;
imageBox.y2 = y + h;
REGION_INIT(pScreen, &imageRegion, &imageBox, 1);
REGION_NULL(pScreen, &censorRegion);
RegionInit(&imageRegion, &imageBox, 1);
RegionNull(&censorRegion);

/* censorRegion = imageRegion - visibleRegion */
REGION_SUBTRACT(pScreen, &censorRegion, &imageRegion, pVisibleRegion);
nRects = REGION_NUM_RECTS(&censorRegion);
RegionSubtract(&censorRegion, &imageRegion, pVisibleRegion);
nRects = RegionNumRects(&censorRegion);
if (nRects > 0)
{ /* we have something to censor */
GCPtr pScratchGC = NULL;
Expand All @@ -280,7 +280,7 @@ XaceCensorImage(
failed = TRUE;
goto failSafe;
}
for (pBox = REGION_RECTS(&censorRegion), i = 0;
for (pBox = RegionRects(&censorRegion), i = 0;
i < nRects;
i++, pBox++)
{
Expand Down Expand Up @@ -330,8 +330,8 @@ XaceCensorImage(
if (pScratchGC) FreeScratchGC(pScratchGC);
if (pPix) FreeScratchPixmapHeader(pPix);
}
REGION_UNINIT(pScreen, &imageRegion);
REGION_UNINIT(pScreen, &censorRegion);
RegionUninit(&imageRegion);
RegionUninit(&censorRegion);
} /* XaceCensorImage */

/*
Expand Down

0 comments on commit 2dc1389

Please sign in to comment.