Rename region macros to eliminate screen argument

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>
This commit is contained in:
Keith Packard 2010-05-21 15:05:48 -07:00
commit 2dc138922b
130 changed files with 1817 additions and 1865 deletions

View file

@ -363,8 +363,8 @@ AllocateArea(
if(granularity <= 1) granularity = 0;
boxp = REGION_RECTS(offman->FreeBoxes);
num = REGION_NUM_RECTS(offman->FreeBoxes);
boxp = RegionRects(offman->FreeBoxes);
num = RegionNumRects(offman->FreeBoxes);
/* look through the free boxes */
for(i = 0; i < num; i++, boxp++) {
@ -407,9 +407,9 @@ AllocateArea(
/* bye, bye */
(*link->area.RemoveAreaCallback)(&link->area);
REGION_INIT(pScreen, &NewReg, &(link->area.box), 1);
REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
REGION_UNINIT(pScreen, &NewReg);
RegionInit(&NewReg, &(link->area.box), 1);
RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
RegionUninit(&NewReg);
area = &(link->area);
break;
@ -427,9 +427,9 @@ AllocateArea(
area->RemoveAreaCallback = removeCB;
area->devPrivate.ptr = privData;
REGION_INIT(pScreen, &NewReg, &(area->box), 1);
REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
REGION_UNINIT(pScreen, &NewReg);
RegionInit(&NewReg, &(area->box), 1);
RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
RegionUninit(&NewReg);
}
return area;
@ -477,9 +477,9 @@ localFreeOffscreenArea(FBAreaPtr area)
}
/* put the area back into the pool */
REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1);
REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
REGION_UNINIT(pScreen, &FreedRegion);
RegionInit(&FreedRegion, &(pLink->area.box), 1);
RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
RegionUninit(&FreedRegion);
if(pLinkPrev)
pLinkPrev->next = pLink->next;
@ -536,12 +536,12 @@ localResizeOffscreenArea(
(resize->box.x2 == OrigArea.x2))
return TRUE;
REGION_INIT(pScreen, &FreedReg, &OrigArea, 1);
REGION_INIT(pScreen, &NewReg, &(resize->box), 1);
REGION_SUBTRACT(pScreen, &FreedReg, &FreedReg, &NewReg);
REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
REGION_UNINIT(pScreen, &FreedReg);
REGION_UNINIT(pScreen, &NewReg);
RegionInit(&FreedReg, &OrigArea, 1);
RegionInit(&NewReg, &(resize->box), 1);
RegionSubtract(&FreedReg, &FreedReg, &NewReg);
RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
RegionUninit(&FreedReg);
RegionUninit(&NewReg);
SendCallFreeBoxCallbacks(offman);
@ -551,8 +551,8 @@ localResizeOffscreenArea(
/* otherwise we remove the old region */
REGION_INIT(pScreen, &FreedReg, &OrigArea, 1);
REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
RegionInit(&FreedReg, &OrigArea, 1);
RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
/* remove the old link */
if(pLinkPrev)
@ -589,8 +589,8 @@ localResizeOffscreenArea(
offman->NumUsedAreas--;
} else {
/* reinstate the old region */
REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
REGION_UNINIT(pScreen, &FreedReg);
RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
RegionUninit(&FreedReg);
pLink->next = offman->UsedAreas;
offman->UsedAreas = pLink;
@ -598,7 +598,7 @@ localResizeOffscreenArea(
}
REGION_UNINIT(pScreen, &FreedReg);
RegionUninit(&FreedReg);
SendCallFreeBoxCallbacks(offman);
@ -636,47 +636,47 @@ localQueryLargestOffscreenArea(
if(offman->NumUsedAreas) {
FBLinkPtr pLink;
RegionRec tmpRegion;
newRegion = REGION_CREATE(pScreen, NULL, 1);
REGION_COPY(pScreen, newRegion, offman->InitialBoxes);
newRegion = RegionCreate(NULL, 1);
RegionCopy(newRegion, offman->InitialBoxes);
pLink = offman->UsedAreas;
while(pLink) {
if(!pLink->area.RemoveAreaCallback) {
REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
REGION_SUBTRACT(pScreen, newRegion, newRegion, &tmpRegion);
REGION_UNINIT(pScreen, &tmpRegion);
RegionInit(&tmpRegion, &(pLink->area.box), 1);
RegionSubtract(newRegion, newRegion, &tmpRegion);
RegionUninit(&tmpRegion);
}
pLink = pLink->next;
}
nbox = REGION_NUM_RECTS(newRegion);
pbox = REGION_RECTS(newRegion);
nbox = RegionNumRects(newRegion);
pbox = RegionRects(newRegion);
break;
}
case 1:
if(offman->NumUsedAreas) {
FBLinkPtr pLink;
RegionRec tmpRegion;
newRegion = REGION_CREATE(pScreen, NULL, 1);
REGION_COPY(pScreen, newRegion, offman->FreeBoxes);
newRegion = RegionCreate(NULL, 1);
RegionCopy(newRegion, offman->FreeBoxes);
pLink = offman->UsedAreas;
while(pLink) {
if(pLink->area.RemoveAreaCallback) {
REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
REGION_APPEND(pScreen, newRegion, &tmpRegion);
REGION_UNINIT(pScreen, &tmpRegion);
RegionInit(&tmpRegion, &(pLink->area.box), 1);
RegionAppend(newRegion, &tmpRegion);
RegionUninit(&tmpRegion);
}
pLink = pLink->next;
}
nbox = REGION_NUM_RECTS(newRegion);
pbox = REGION_RECTS(newRegion);
nbox = RegionNumRects(newRegion);
pbox = RegionRects(newRegion);
break;
}
default:
nbox = REGION_NUM_RECTS(offman->FreeBoxes);
pbox = REGION_RECTS(offman->FreeBoxes);
nbox = RegionNumRects(offman->FreeBoxes);
pbox = RegionRects(offman->FreeBoxes);
break;
}
@ -719,7 +719,7 @@ localQueryLargestOffscreenArea(
}
if(newRegion)
REGION_DESTROY(pScreen, newRegion);
RegionDestroy(newRegion);
return TRUE;
}
@ -741,9 +741,9 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
if(pLink->area.RemoveAreaCallback) {
(*pLink->area.RemoveAreaCallback)(&pLink->area);
REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1);
REGION_APPEND(pScreen, offman->FreeBoxes, &FreedRegion);
REGION_UNINIT(pScreen, &FreedRegion);
RegionInit(&FreedRegion, &(pLink->area.box), 1);
RegionAppend(offman->FreeBoxes, &FreedRegion);
RegionUninit(&FreedRegion);
if(pPrev)
pPrev->next = pLink->next;
@ -761,7 +761,7 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
}
if(anyUsed) {
REGION_VALIDATE(pScreen, offman->FreeBoxes, &anyUsed);
RegionValidate(offman->FreeBoxes, &anyUsed);
SendCallFreeBoxCallbacks(offman);
}
@ -924,7 +924,7 @@ localAllocateOffscreenLinear(
return NULL;
/* No linear available, so try and pinch some from the XY areas */
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
extents = RegionExtents(offman->InitialBoxes);
pitch = extents->x2 - extents->x1;
if (gran > 1) {
@ -1055,7 +1055,7 @@ localResizeOffscreenLinear(FBLinearPtr resize, int length)
BoxPtr extents;
int pitch, w, h;
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
extents = RegionExtents(offman->InitialBoxes);
pitch = extents->x2 - extents->x1;
if(length < pitch) { /* special case */
@ -1121,7 +1121,7 @@ localQueryLargestOffscreenLinear(
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
xf86FBScreenKey);
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
extents = RegionExtents(offman->InitialBoxes);
if((extents->x2 - extents->x1) == w)
*size = w * h;
return TRUE;
@ -1171,8 +1171,8 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen)
free(tmp2);
}
REGION_DESTROY(pScreen, offman->InitialBoxes);
REGION_DESTROY(pScreen, offman->FreeBoxes);
RegionDestroy(offman->InitialBoxes);
RegionDestroy(offman->FreeBoxes);
free(offman->FreeBoxesUpdateCallback);
free(offman->devPrivates);
@ -1206,15 +1206,15 @@ xf86InitFBManager(
if (FullBox->y2 < FullBox->y1) return FALSE;
if (FullBox->x2 < FullBox->x1) return FALSE;
REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1);
REGION_INIT(pScreen, &FullRegion, FullBox, 1);
RegionInit(&ScreenRegion, &ScreenBox, 1);
RegionInit(&FullRegion, FullBox, 1);
REGION_SUBTRACT(pScreen, &FullRegion, &FullRegion, &ScreenRegion);
RegionSubtract(&FullRegion, &FullRegion, &ScreenRegion);
ret = xf86InitFBManagerRegion(pScreen, &FullRegion);
REGION_UNINIT(pScreen, &ScreenRegion);
REGION_UNINIT(pScreen, &FullRegion);
RegionUninit(&ScreenRegion);
RegionUninit(&FullRegion);
return ret;
}
@ -1249,17 +1249,17 @@ xf86InitFBManagerArea(
}
/* Factor out virtual resolution */
pRegion = RECTS_TO_REGION(pScreen, nRect, Rect, 0);
pRegion = RegionFromRects(nRect, Rect, 0);
if (pRegion) {
if (!REGION_NAR(pRegion)) {
if (!RegionNar(pRegion)) {
Rect[2].x = Rect[2].y = 0;
Rect[2].width = pScrn->virtualX;
Rect[2].height = pScrn->virtualY;
pScreenRegion = RECTS_TO_REGION(pScreen, 1, &Rect[2], 0);
pScreenRegion = RegionFromRects(1, &Rect[2], 0);
if (pScreenRegion) {
if (!REGION_NAR(pScreenRegion)) {
REGION_SUBTRACT(pScreen, pRegion, pRegion, pScreenRegion);
if (!RegionNar(pScreenRegion)) {
RegionSubtract(pRegion, pRegion, pScreenRegion);
ret = xf86InitFBManagerRegion(pScreen, pRegion);
@ -1301,11 +1301,11 @@ xf86InitFBManagerArea(
}
}
REGION_DESTROY(pScreen, pScreenRegion);
RegionDestroy(pScreenRegion);
}
}
REGION_DESTROY(pScreen, pRegion);
RegionDestroy(pRegion);
}
return ret;
@ -1318,7 +1318,7 @@ xf86InitFBManagerRegion(
){
FBManagerPtr offman;
if(REGION_NIL(FullRegion))
if(RegionNil(FullRegion))
return FALSE;
if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
@ -1332,11 +1332,11 @@ xf86InitFBManagerRegion(
offman->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86FBCloseScreen;
offman->InitialBoxes = REGION_CREATE(pScreen, NULL, 1);
offman->FreeBoxes = REGION_CREATE(pScreen, NULL, 1);
offman->InitialBoxes = RegionCreate(NULL, 1);
offman->FreeBoxes = RegionCreate(NULL, 1);
REGION_COPY(pScreen, offman->InitialBoxes, FullRegion);
REGION_COPY(pScreen, offman->FreeBoxes, FullRegion);
RegionCopy(offman->InitialBoxes, FullRegion);
RegionCopy(offman->FreeBoxes, FullRegion);
offman->pScreen = pScreen;
offman->UsedAreas = NULL;
@ -1415,7 +1415,7 @@ xf86AllocateLinearOffscreenArea (
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
xf86FBScreenKey);
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
extents = RegionExtents(offman->InitialBoxes);
w = extents->x2 - extents->x1;
if (gran > 1) {