diff options
Diffstat (limited to 'mi/miregion.c')
-rw-r--r-- | mi/miregion.c | 184 |
1 files changed, 92 insertions, 92 deletions
diff --git a/mi/miregion.c b/mi/miregion.c index 59aaa85b8..a56160190 100644 --- a/mi/miregion.c +++ b/mi/miregion.c @@ -101,7 +101,7 @@ Equipment Corporation. #define assert(expr) #endif -#define good(reg) assert(miValidRegion(reg)) +#define good(reg) assert(RegionIsValid(reg)) /* * The functions in this file implement the Region abstraction used extensively @@ -144,7 +144,7 @@ Equipment Corporation. * * Adam de Boor wrote most of the original region code. Joel McCormack * substantially modified or rewrote most of the core arithmetic routines, - * and added miRegionValidate in order to support several speed improvements + * and added RegionValidate in order to support several speed improvements * to miValidateTree. Bob Scheifler changed the representation to be more * compact when empty or a single rectangle, and did a bunch of gratuitous * reformatting. @@ -176,11 +176,11 @@ Equipment Corporation. #define RECTALLOC_BAIL(pReg,n,bail) \ if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \ - if (!miRectAlloc(pReg, n)) { goto bail; } + if (!RegionRectAlloc(pReg, n)) { goto bail; } #define RECTALLOC(pReg,n) \ if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \ - if (!miRectAlloc(pReg, n)) { return FALSE; } + if (!RegionRectAlloc(pReg, n)) { return FALSE; } #define ADDRECT(pNextRect,nx1,ny1,nx2,ny2) \ { \ @@ -195,7 +195,7 @@ if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \ { \ if (!(pReg)->data || ((pReg)->data->numRects == (pReg)->data->size))\ { \ - if (!miRectAlloc(pReg, 1)) \ + if (!RegionRectAlloc(pReg, 1)) \ return FALSE; \ pNextRect = REGION_TOP(pReg); \ } \ @@ -218,16 +218,16 @@ if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \ } -BoxRec miEmptyBox = {0, 0, 0, 0}; -RegDataRec miEmptyData = {0, 0}; +BoxRec RegionEmptyBox = {0, 0, 0, 0}; +RegDataRec RegionEmptyData = {0, 0}; -RegDataRec miBrokenData = {0, 0}; -static RegionRec miBrokenRegion = { { 0, 0, 0, 0 }, &miBrokenData }; +RegDataRec RegionBrokenData = {0, 0}; +static RegionRec RegionBrokenRegion = { { 0, 0, 0, 0 }, &RegionBrokenData }; void InitRegions (void) { - pixman_region_set_static_pointers (&miEmptyBox, &miEmptyData, &miBrokenData); + pixman_region_set_static_pointers (&RegionEmptyBox, &RegionEmptyData, &RegionBrokenData); } /***************************************************************** @@ -237,29 +237,29 @@ InitRegions (void) *****************************************************************/ RegionPtr -miRegionCreate(BoxPtr rect, int size) +RegionCreate(BoxPtr rect, int size) { RegionPtr pReg; pReg = (RegionPtr)malloc(sizeof(RegionRec)); if (!pReg) - return &miBrokenRegion; + return &RegionBrokenRegion; - miRegionInit (pReg, rect, size); + RegionInit (pReg, rect, size); return(pReg); } void -miRegionDestroy(RegionPtr pReg) +RegionDestroy(RegionPtr pReg) { pixman_region_fini (pReg); - if (pReg != &miBrokenRegion) + if (pReg != &RegionBrokenRegion) free(pReg); } void -miPrintRegion(RegionPtr rgn) +RegionPrint(RegionPtr rgn) { int num, size; int i; @@ -278,14 +278,14 @@ miPrintRegion(RegionPtr rgn) } Bool -miRegionEqual(RegionPtr reg1, RegionPtr reg2) +RegionEqual(RegionPtr reg1, RegionPtr reg2) { return pixman_region_equal (reg1, reg2); } #ifdef DEBUG Bool -miValidRegion(RegionPtr reg) +RegionIsValid(RegionPtr reg) { int i, numRects; @@ -296,7 +296,7 @@ miValidRegion(RegionPtr reg) if (!numRects) return ((reg->extents.x1 == reg->extents.x2) && (reg->extents.y1 == reg->extents.y2) && - (reg->data->size || (reg->data == &miEmptyData))); + (reg->data->size || (reg->data == &RegionEmptyData))); else if (numRects == 1) return (!reg->data); else @@ -336,7 +336,7 @@ miValidRegion(RegionPtr reg) *****************************************************************/ void -miRegionInit(RegionPtr pReg, BoxPtr rect, int size) +RegionInit(RegionPtr pReg, BoxPtr rect, int size) { if (rect) pixman_region_init_with_extents (pReg, rect); @@ -345,22 +345,22 @@ miRegionInit(RegionPtr pReg, BoxPtr rect, int size) } void -miRegionUninit(RegionPtr pReg) +RegionUninit(RegionPtr pReg) { pixman_region_fini (pReg); } Bool -miRegionBreak (RegionPtr pReg) +RegionBreak (RegionPtr pReg) { xfreeData (pReg); - pReg->extents = miEmptyBox; - pReg->data = &miBrokenData; + pReg->extents = RegionEmptyBox; + pReg->data = &RegionBrokenData; return FALSE; } Bool -miRectAlloc(RegionPtr pRgn, int n) +RegionRectAlloc(RegionPtr pRgn, int n) { RegDataPtr data; @@ -369,7 +369,7 @@ miRectAlloc(RegionPtr pRgn, int n) n++; pRgn->data = xallocData(n); if (!pRgn->data) - return miRegionBreak (pRgn); + return RegionBreak (pRgn); pRgn->data->numRects = 1; *REGION_BOXPTR(pRgn) = pRgn->extents; } @@ -377,7 +377,7 @@ miRectAlloc(RegionPtr pRgn, int n) { pRgn->data = xallocData(n); if (!pRgn->data) - return miRegionBreak (pRgn); + return RegionBreak (pRgn); pRgn->data->numRects = 0; } else @@ -391,7 +391,7 @@ miRectAlloc(RegionPtr pRgn, int n) n += pRgn->data->numRects; data = (RegDataPtr)realloc(pRgn->data, REGION_SZOF(n)); if (!data) - return miRegionBreak (pRgn); + return RegionBreak (pRgn); pRgn->data = data; } pRgn->data->size = n; @@ -399,7 +399,7 @@ miRectAlloc(RegionPtr pRgn, int n) } Bool -miRegionCopy(RegionPtr dst, RegionPtr src) +RegionCopy(RegionPtr dst, RegionPtr src) { return pixman_region_copy (dst, src); } @@ -410,10 +410,10 @@ miRegionCopy(RegionPtr dst, RegionPtr src) /*- *----------------------------------------------------------------------- - * miCoalesce -- + * RegionCoalesce -- * Attempt to merge the boxes in the current band with those in the * previous one. We are guaranteed that the current band extends to - * the end of the rects array. Used only by miRegionOp. + * the end of the rects array. Used only by RegionOp. * * Results: * The new index for the previous band. @@ -427,7 +427,7 @@ miRegionCopy(RegionPtr dst, RegionPtr src) *----------------------------------------------------------------------- */ _X_INLINE static int -miCoalesce ( +RegionCoalesce ( RegionPtr pReg, /* Region to coalesce */ int prevStart, /* Index of start of previous band */ int curStart) /* Index of start of current band */ @@ -484,18 +484,18 @@ miCoalesce ( } -/* Quicky macro to avoid trivial reject procedure calls to miCoalesce */ +/* Quicky macro to avoid trivial reject procedure calls to RegionCoalesce */ #define Coalesce(newReg, prevBand, curBand) \ if (curBand - prevBand == newReg->data->numRects - curBand) { \ - prevBand = miCoalesce(newReg, prevBand, curBand); \ + prevBand = RegionCoalesce(newReg, prevBand, curBand); \ } else { \ prevBand = curBand; \ } /*- *----------------------------------------------------------------------- - * miAppendNonO -- + * RegionAppendNonO -- * Handle a non-overlapping band for the union and subtract operations. * Just adds the (top/bottom-clipped) rectangles into the region. * Doesn't have to check for subsumption or anything. @@ -511,7 +511,7 @@ miCoalesce ( */ _X_INLINE static Bool -miAppendNonO ( +RegionAppendNonO ( RegionPtr pReg, BoxPtr r, BoxPtr rEnd, @@ -561,9 +561,9 @@ miAppendNonO ( /*- *----------------------------------------------------------------------- - * miRegionOp -- - * Apply an operation to two regions. Called by miUnion, miInverse, - * miSubtract, miIntersect.... Both regions MUST have at least one + * RegionOp -- + * Apply an operation to two regions. Called by RegionUnion, RegionInverse, + * RegionSubtract, RegionIntersect.... Both regions MUST have at least one * rectangle, and cannot be the same object. * * Results: @@ -599,7 +599,7 @@ typedef Bool (*OverlapProcPtr)( Bool *pOverlap); static Bool -miRegionOp( +RegionOp( RegionPtr newReg, /* Place to store result */ RegionPtr reg1, /* First region in operation */ RegionPtr reg2, /* 2d region in operation */ @@ -635,7 +635,7 @@ miRegionOp( * Break any region computed from a broken region */ if (REGION_NAR (reg1) || REGION_NAR(reg2)) - return miRegionBreak (newReg); + return RegionBreak (newReg); /* * Initialization: @@ -659,18 +659,18 @@ miRegionOp( ((newReg == reg2) && (numRects > 1))) { oldData = newReg->data; - newReg->data = &miEmptyData; + newReg->data = &RegionEmptyData; } /* guess at new size */ if (numRects > newSize) newSize = numRects; newSize <<= 1; if (!newReg->data) - newReg->data = &miEmptyData; + newReg->data = &RegionEmptyData; else if (newReg->data->size) newReg->data->numRects = 0; if (newSize > newReg->data->size) - if (!miRectAlloc(newReg, newSize)) + if (!RegionRectAlloc(newReg, newSize)) return FALSE; /* @@ -691,7 +691,7 @@ miRegionOp( /* * prevBand serves to mark the start of the previous band so rectangles - * can be coalesced into larger rectangles. qv. miCoalesce, above. + * can be coalesced into larger rectangles. qv. RegionCoalesce, above. * In the beginning, there is no previous band, so prevBand == curBand * (curBand is set later on, of course, but the first band will always * start at index 0). prevBand and curBand must be indices because of @@ -728,7 +728,7 @@ miRegionOp( bot = min(r1->y2, r2y1); if (top != bot) { curBand = newReg->data->numRects; - miAppendNonO(newReg, r1, r1BandEnd, top, bot); + RegionAppendNonO(newReg, r1, r1BandEnd, top, bot); Coalesce(newReg, prevBand, curBand); } } @@ -739,7 +739,7 @@ miRegionOp( bot = min(r2->y2, r1y1); if (top != bot) { curBand = newReg->data->numRects; - miAppendNonO(newReg, r2, r2BandEnd, top, bot); + RegionAppendNonO(newReg, r2, r2BandEnd, top, bot); Coalesce(newReg, prevBand, curBand); } } @@ -781,7 +781,7 @@ miRegionOp( /* Do first nonOverlap1Func call, which may be able to coalesce */ FindBand(r1, r1BandEnd, r1End, r1y1); curBand = newReg->data->numRects; - miAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2); + RegionAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2); Coalesce(newReg, prevBand, curBand); /* Just append the rest of the boxes */ AppendRegions(newReg, r1BandEnd, r1End); @@ -790,7 +790,7 @@ miRegionOp( /* Do first nonOverlap2Func call, which may be able to coalesce */ FindBand(r2, r2BandEnd, r2End, r2y1); curBand = newReg->data->numRects; - miAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2); + RegionAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2); Coalesce(newReg, prevBand, curBand); /* Append rest of boxes */ AppendRegions(newReg, r2BandEnd, r2End); @@ -802,7 +802,7 @@ miRegionOp( if (!(numRects = newReg->data->numRects)) { xfreeData(newReg); - newReg->data = &miEmptyData; + newReg->data = &RegionEmptyData; } else if (numRects == 1) { @@ -820,10 +820,10 @@ miRegionOp( /*- *----------------------------------------------------------------------- - * miSetExtents -- + * RegionSetExtents -- * Reset the extents of a region to what they should be. Called by - * miSubtract and miIntersect as they can't figure it out along the - * way or do so easily, as miUnion can. + * RegionSubtract and RegionIntersect as they can't figure it out along the + * way or do so easily, as RegionUnion can. * * Results: * None. @@ -834,7 +834,7 @@ miRegionOp( *----------------------------------------------------------------------- */ static void -miSetExtents (RegionPtr pReg) +RegionSetExtents (RegionPtr pReg) { BoxPtr pBox, pBoxEnd; @@ -879,8 +879,8 @@ miSetExtents (RegionPtr pReg) *====================================================================*/ /*- *----------------------------------------------------------------------- - * miIntersectO -- - * Handle an overlapping band for miIntersect. + * RegionIntersectO -- + * Handle an overlapping band for RegionIntersect. * * Results: * TRUE if successful. @@ -892,7 +892,7 @@ miSetExtents (RegionPtr pReg) */ /*ARGSUSED*/ Bool -miIntersect( +RegionIntersect( RegionPtr newReg, /* destination Region */ RegionPtr reg1, RegionPtr reg2 /* source regions */ @@ -922,7 +922,7 @@ miIntersect( /*- *----------------------------------------------------------------------- - * miUnionO -- + * RegionUnionO -- * Handle an overlapping band for the union operation. Picks the * left-most rectangle each time and merges it into the region. * @@ -936,7 +936,7 @@ miIntersect( *----------------------------------------------------------------------- */ static Bool -miUnionO ( +RegionUnionO ( RegionPtr pReg, BoxPtr r1, BoxPtr r1End, @@ -996,7 +996,7 @@ miUnionO ( } Bool -miUnion( +RegionUnion( RegionPtr newReg, /* destination Region */ RegionPtr reg1, RegionPtr reg2 /* source regions */ @@ -1011,13 +1011,13 @@ miUnion( /*- *----------------------------------------------------------------------- - * miRegionAppend -- + * RegionAppend -- * * "Append" the rgn rectangles onto the end of dstrgn, maintaining * knowledge of YX-banding when it's easy. Otherwise, dstrgn just * becomes a non-y-x-banded random collection of rectangles, and not * yet a true region. After a sequence of appends, the caller must - * call miRegionValidate to ensure that a valid region is constructed. + * call RegionValidate to ensure that a valid region is constructed. * * Results: * TRUE if successful. @@ -1027,16 +1027,16 @@ miUnion( * */ Bool -miRegionAppend(RegionPtr dstrgn, RegionPtr rgn) +RegionAppend(RegionPtr dstrgn, RegionPtr rgn) { int numRects, dnumRects, size; BoxPtr new, old; Bool prepend; if (REGION_NAR(rgn)) - return miRegionBreak (dstrgn); + return RegionBreak (dstrgn); - if (!rgn->data && (dstrgn->data == &miEmptyData)) + if (!rgn->data && (dstrgn->data == &RegionEmptyData)) { dstrgn->extents = rgn->extents; dstrgn->data = NULL; @@ -1180,7 +1180,7 @@ QuickSortRects( /*- *----------------------------------------------------------------------- - * miRegionValidate -- + * RegionValidate -- * * Take a ``region'' which is a non-y-x-banded random collection of * rectangles, and compute a nice region which is the union of all the @@ -1204,14 +1204,14 @@ QuickSortRects( * or a coalescing into 1 box (ala Menus). * * Step 3. Merge the separate regions down to a single region by calling - * miUnion. Maximize the work each miUnion call does by using + * RegionUnion. Maximize the work each RegionUnion call does by using * a binary merge. * *----------------------------------------------------------------------- */ Bool -miRegionValidate(RegionPtr badreg, Bool *pOverlap) +RegionValidate(RegionPtr badreg, Bool *pOverlap) { /* Descriptor for regions under construction in Step 2. */ typedef struct { @@ -1271,7 +1271,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap) /* Note that step 2 code will never overflow the ri[0].reg rects array */ ri = (RegionInfo *) malloc(4 * sizeof(RegionInfo)); if (!ri) - return miRegionBreak (badreg); + return RegionBreak (badreg); sizeRI = 4; numRI = 1; ri[0].prevBand = 0; @@ -1344,7 +1344,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap) rit->curBand = 0; rit->reg.extents = *box; rit->reg.data = NULL; - if (!miRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */ + if (!RegionRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */ goto bail; NextRect: ; } /* for i */ @@ -1374,7 +1374,7 @@ NextRect: ; { reg = &ri[j].reg; hreg = &ri[j+half].reg; - if (!miRegionOp(reg, reg, hreg, miUnionO, TRUE, TRUE, pOverlap)) + if (!RegionOp(reg, reg, hreg, RegionUnionO, TRUE, TRUE, pOverlap)) ret = FALSE; if (hreg->extents.x1 < reg->extents.x1) reg->extents.x1 = hreg->extents.x1; @@ -1396,11 +1396,11 @@ bail: for (i = 0; i < numRI; i++) xfreeData(&ri[i].reg); free(ri); - return miRegionBreak (badreg); + return RegionBreak (badreg); } RegionPtr -miRectsToRegion(int nrects, xRectangle *prect, int ctype) +RegionFromRects(int nrects, xRectangle *prect, int ctype) { RegionPtr pRgn; @@ -1409,7 +1409,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) int i; int x1, y1, x2, y2; - pRgn = miRegionCreate(NullBox, 0); + pRgn = RegionCreate(NullBox, 0); if (REGION_NAR (pRgn)) return pRgn; if (!nrects) @@ -1435,7 +1435,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) pData = xallocData(nrects); if (!pData) { - miRegionBreak (pRgn); + RegionBreak (pRgn); return pRgn; } pBox = (BoxPtr) (pData + 1); @@ -1465,10 +1465,10 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) { Bool overlap; /* result ignored */ pRgn->extents.x1 = pRgn->extents.x2 = 0; - miRegionValidate(pRgn, &overlap); + RegionValidate(pRgn, &overlap); } else - miSetExtents(pRgn); + RegionSetExtents(pRgn); good(pRgn); } else @@ -1485,7 +1485,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) /*- *----------------------------------------------------------------------- - * miSubtractO -- + * RegionSubtractO -- * Overlapping band subtraction. x1 is the left-most point not yet * checked. * @@ -1501,7 +1501,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) /*- *----------------------------------------------------------------------- - * miSubtract -- + * RegionSubtract -- * Subtract regS from regM and leave the result in regD. * S stands for subtrahend, M for minuend and D for difference. * @@ -1514,7 +1514,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) *----------------------------------------------------------------------- */ Bool -miSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS) +RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS) { return pixman_region_subtract (regD, regM, regS); } @@ -1525,7 +1525,7 @@ miSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS) /*- *----------------------------------------------------------------------- - * miInverse -- + * RegionInverse -- * Take a region and a box and return a region that is everything * in the box but not in the region. The careful reader will note * that this is the same as subtracting the region from the box... @@ -1539,7 +1539,7 @@ miSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS) *----------------------------------------------------------------------- */ Bool -miInverse( +RegionInverse( RegionPtr newReg, /* Destination region */ RegionPtr reg1, /* Region to invert */ BoxPtr invRect /* Bounding box for inversion */ @@ -1548,7 +1548,7 @@ miInverse( return pixman_region_inverse (newReg, reg1, invRect); } int -miRectIn(RegionPtr region, BoxPtr prect) +RegionContainsRect(RegionPtr region, BoxPtr prect) { return pixman_region_contains_rectangle (region, prect); } @@ -1558,19 +1558,19 @@ miRectIn(RegionPtr region, BoxPtr prect) */ void -miTranslateRegion(RegionPtr pReg, int x, int y) +RegionTranslate(RegionPtr pReg, int x, int y) { pixman_region_translate (pReg, x, y); } void -miRegionReset(RegionPtr pReg, BoxPtr pBox) +RegionReset(RegionPtr pReg, BoxPtr pBox) { pixman_region_reset (pReg, pBox); } Bool -miPointInRegion( +RegionContainsPoint( RegionPtr pReg, int x, int y, @@ -1581,30 +1581,30 @@ miPointInRegion( } Bool -miRegionNotEmpty(RegionPtr pReg) +RegionNotEmpty(RegionPtr pReg) { return pixman_region_not_empty (pReg); } Bool -miRegionBroken(RegionPtr pReg) +RegionBroken(RegionPtr pReg) { good(pReg); return (REGION_NAR(pReg)); } void -miRegionEmpty(RegionPtr pReg) +RegionEmpty(RegionPtr pReg) { good(pReg); xfreeData(pReg); pReg->extents.x2 = pReg->extents.x1; pReg->extents.y2 = pReg->extents.y1; - pReg->data = &miEmptyData; + pReg->data = &RegionEmptyData; } BoxPtr -miRegionExtents(RegionPtr pReg) +RegionExtents(RegionPtr pReg) { good(pReg); return(&pReg->extents); @@ -1729,7 +1729,7 @@ static void QuickSortSpans( */ int -miClipSpans( +RegionClipSpans( RegionPtr prgnDst, DDXPointPtr ppt, int *pwidth, |