diff options
-rw-r--r-- | Xext/panoramiX.c | 2 | ||||
-rw-r--r-- | dix/region.c | 133 | ||||
-rw-r--r-- | include/regionstr.h | 333 | ||||
-rw-r--r-- | include/scrnintstr.h | 4 |
4 files changed, 196 insertions, 276 deletions
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index 670cf504a..c6254387e 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -386,7 +386,7 @@ static void XineramaInitData(ScreenPtr pScreen) { int i, w, h; - RegionNull(&PanoramiXScreenRegion) + RegionNull(&PanoramiXScreenRegion); for (i = 0; i < PanoramiXNumScreens; i++) { BoxRec TheBox; RegionRec ScreenRegion; diff --git a/dix/region.c b/dix/region.c index 2e8dde557..911fe1614 100644 --- a/dix/region.c +++ b/dix/region.c @@ -275,12 +275,6 @@ RegionPrint(RegionPtr rgn) ErrorF("[mi] \n"); } -Bool -RegionEqual(RegionPtr reg1, RegionPtr reg2) -{ - return pixman_region_equal (reg1, reg2); -} - #ifdef DEBUG Bool RegionIsValid(RegionPtr reg) @@ -376,12 +370,6 @@ RegionRectAlloc(RegionPtr pRgn, int n) return TRUE; } -Bool -RegionCopy(RegionPtr dst, RegionPtr src) -{ - return pixman_region_copy (dst, src); -} - /*====================================================================== * Generic Region Operator *====================================================================*/ @@ -800,8 +788,8 @@ RegionOp( *----------------------------------------------------------------------- * RegionSetExtents -- * Reset the extents of a region to what they should be. Called by - * RegionSubtract and RegionIntersect as they can't figure it out along the - * way or do so easily, as RegionUnion can. + * Subtract and Intersect as they can't figure it out along the + * way or do so easily, as Union can. * * Results: * None. @@ -869,15 +857,6 @@ RegionSetExtents (RegionPtr pReg) *----------------------------------------------------------------------- */ /*ARGSUSED*/ -Bool -RegionIntersect( - RegionPtr newReg, /* destination Region */ - RegionPtr reg1, - RegionPtr reg2 /* source regions */ - ) -{ - return pixman_region_intersect (newReg, reg1, reg2); -} #define MERGERECT(r) \ { \ @@ -973,16 +952,6 @@ RegionUnionO ( return TRUE; } -Bool -RegionUnion( - RegionPtr newReg, /* destination Region */ - RegionPtr reg1, - RegionPtr reg2 /* source regions */ - ) -{ - return pixman_region_union (newReg, reg1, reg2); -} - /*====================================================================== * Batch Rectangle Union *====================================================================*/ @@ -1182,7 +1151,7 @@ QuickSortRects( * or a coalescing into 1 box (ala Menus). * * Step 3. Merge the separate regions down to a single region by calling - * RegionUnion. Maximize the work each RegionUnion call does by using + * Union. Maximize the work each Union call does by using * a binary merge. * *----------------------------------------------------------------------- @@ -1456,102 +1425,6 @@ RegionFromRects(int nrects, xRectangle *prect, int ctype) return pRgn; } -/*====================================================================== - * Region Subtraction - *====================================================================*/ - - -/*- - *----------------------------------------------------------------------- - * RegionSubtractO -- - * Overlapping band subtraction. x1 is the left-most point not yet - * checked. - * - * Results: - * TRUE if successful. - * - * Side Effects: - * pReg may have rectangles added to it. - * - *----------------------------------------------------------------------- - */ -/*ARGSUSED*/ - -/*- - *----------------------------------------------------------------------- - * RegionSubtract -- - * Subtract regS from regM and leave the result in regD. - * S stands for subtrahend, M for minuend and D for difference. - * - * Results: - * TRUE if successful. - * - * Side Effects: - * regD is overwritten. - * - *----------------------------------------------------------------------- - */ -Bool -RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS) -{ - return pixman_region_subtract (regD, regM, regS); -} - -/*====================================================================== - * Region Inversion - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * 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... - * - * Results: - * TRUE. - * - * Side Effects: - * newReg is overwritten. - * - *----------------------------------------------------------------------- - */ -Bool -RegionInverse( - RegionPtr newReg, /* Destination region */ - RegionPtr reg1, /* Region to invert */ - BoxPtr invRect /* Bounding box for inversion */ - ) -{ - return pixman_region_inverse (newReg, reg1, invRect); -} -int -RegionContainsRect(RegionPtr region, BoxPtr prect) -{ - return pixman_region_contains_rectangle (region, prect); -} - -/* TranslateRegion(pReg, x, y) - translates in place -*/ - -void -RegionTranslate(RegionPtr pReg, int x, int y) -{ - pixman_region_translate (pReg, x, y); -} - -Bool -RegionContainsPoint( - RegionPtr pReg, - int x, - int y, - BoxPtr box /* "return" value */ - ) -{ - return pixman_region_contains_point (pReg, x, y, box); -} - #define ExchangeSpans(a, b) \ { \ DDXPointRec tpt; \ diff --git a/include/regionstr.h b/include/regionstr.h index c6dd16231..8bc902aca 100644 --- a/include/regionstr.h +++ b/include/regionstr.h @@ -69,131 +69,112 @@ typedef struct pixman_region16_data RegDataRec, *RegDataPtr; extern _X_EXPORT BoxRec RegionEmptyBox; extern _X_EXPORT RegDataRec RegionEmptyData; extern _X_EXPORT RegDataRec RegionBrokenData; +static inline Bool RegionNil(RegionPtr reg) { + return ((reg)->data && !(reg)->data->numRects); +} -#define RegionNil(reg) ((reg)->data && !(reg)->data->numRects) /* not a region */ -#define RegionNar(reg) ((reg)->data == &RegionBrokenData) -#define RegionNumRects(reg) ((reg)->data ? (reg)->data->numRects : 1) -#define RegionSize(reg) ((reg)->data ? (reg)->data->size : 0) -#define RegionRects(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \ - : &(reg)->extents) -#define RegionBoxptr(reg) ((BoxPtr)((reg)->data + 1)) -#define RegionBox(reg,i) (&RegionBoxptr(reg)[i]) -#define RegionTop(reg) RegionBox(reg, (reg)->data->numRects) -#define RegionEnd(reg) RegionBox(reg, (reg)->data->numRects - 1) -#define RegionSizeof(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec))) - -#define RegionCreate(_rect, _size) \ - RegionCreate(_rect, _size) - -#define RegionCopy(dst, src) \ - RegionCopy(dst, src) - -#define RegionDestroy(_pReg) \ - RegionDestroy(_pReg) - -#define RegionIntersect(newReg, reg1, reg2) \ - RegionIntersect(newReg, reg1, reg2) - -#define RegionUnion(newReg, reg1, reg2) \ - RegionUnion(newReg, reg1, reg2) - -#define RegionSubtract(newReg, reg1, reg2) \ - RegionSubtract(newReg, reg1, reg2) - -#define RegionInverse(newReg, reg1, invRect) \ - RegionInverse(newReg, reg1, invRect) - -#define RegionTranslate(_pReg, _x, _y) \ - RegionTranslate(_pReg, _x, _y) - -#define RegionContainsRect(_pReg, prect) \ - RegionContainsRect(_pReg, prect) - -#define RegionContainsPoint(_pReg, _x, _y, prect) \ - RegionContainsPoint(_pReg, _x, _y, prect) - -#define RegionAppend(dstrgn, rgn) \ - RegionAppend(dstrgn, rgn) - -#define RegionValidate(badreg, pOverlap) \ - RegionValidate(badreg, pOverlap) - -#define BitmapToRegion(_pScreen, pPix) \ - (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */ - -#define RegionFromRects(nrects, prect, ctype) \ - RegionFromRects(nrects, prect, ctype) - -#define RegionEqual(_pReg1, _pReg2) \ - RegionEqual(_pReg1, _pReg2) - -#define RegionBreak(_pReg) \ - RegionBreak(_pReg) - -#define RegionInit(_pReg, _rect, _size) \ -{ \ - if ((_rect) != NULL) \ - { \ - (_pReg)->extents = *(_rect); \ - (_pReg)->data = (RegDataPtr)NULL; \ - } \ - else \ - { \ - (_pReg)->extents = RegionEmptyBox; \ - if (((_size) > 1) && ((_pReg)->data = \ - (RegDataPtr)malloc(RegionSizeof(_size)))) \ - { \ - (_pReg)->data->size = (_size); \ - (_pReg)->data->numRects = 0; \ - } \ - else \ - (_pReg)->data = &RegionEmptyData; \ - } \ - } - - -#define RegionUninit(_pReg) \ -{ \ - if ((_pReg)->data && (_pReg)->data->size) { \ - free((_pReg)->data); \ - (_pReg)->data = NULL; \ - } \ + +static inline Bool RegionNar(RegionPtr reg) { + return ((reg)->data == &RegionBrokenData); +} + +static inline int RegionNumRects(RegionPtr reg) { + return ((reg)->data ? (reg)->data->numRects : 1); +} + +static inline int RegionSize(RegionPtr reg) { + return ((reg)->data ? (reg)->data->size : 0); } -#define RegionReset(_pReg, _pBox) \ -{ \ - (_pReg)->extents = *(_pBox); \ - RegionUninit(_pReg); \ - (_pReg)->data = (RegDataPtr)NULL; \ +static inline BoxPtr RegionRects(RegionPtr reg) { + return ((reg)->data ? (BoxPtr)((reg)->data + 1) : &(reg)->extents); } -#define RegionNotEmpty(_pReg) \ - !RegionNil(_pReg) +static inline BoxPtr RegionBoxptr(RegionPtr reg) { + return ((BoxPtr)((reg)->data + 1)); +} -#define RegionBroken(_pReg) \ - RegionNar(_pReg) +static inline BoxPtr RegionBox(RegionPtr reg, int i) { + return (&RegionBoxptr(reg)[i]); +} -#define RegionEmpty(_pReg) \ -{ \ - RegionUninit(_pReg); \ - (_pReg)->extents.x2 = (_pReg)->extents.x1; \ - (_pReg)->extents.y2 = (_pReg)->extents.y1; \ - (_pReg)->data = &RegionEmptyData; \ +static inline BoxPtr RegionTop(RegionPtr reg) { + return RegionBox(reg, (reg)->data->numRects); } -#define RegionExtents(_pReg) \ - (&(_pReg)->extents) +static inline BoxPtr RegionEnd(RegionPtr reg) { + return RegionBox(reg, (reg)->data->numRects - 1); +} -#define RegionNull(_pReg) \ -{ \ - (_pReg)->extents = RegionEmptyBox; \ - (_pReg)->data = &RegionEmptyData; \ +static inline size_t RegionSizeof(int n) { + return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec))); } -/* moved from mi.h */ +static inline void RegionInit(RegionPtr _pReg, BoxPtr _rect, int _size) +{ + if ((_rect) != NULL) + { + (_pReg)->extents = *(_rect); + (_pReg)->data = (RegDataPtr)NULL; + } + else + { + (_pReg)->extents = RegionEmptyBox; + if (((_size) > 1) && ((_pReg)->data = + (RegDataPtr)malloc(RegionSizeof(_size)))) + { + (_pReg)->data->size = (_size); + (_pReg)->data->numRects = 0; + } + else + (_pReg)->data = &RegionEmptyData; + } +} -extern _X_EXPORT void InitRegions (void); +static inline void RegionUninit(RegionPtr _pReg) +{ + if ((_pReg)->data && (_pReg)->data->size) { + free((_pReg)->data); + (_pReg)->data = NULL; + } +} + +static inline void RegionReset(RegionPtr _pReg, BoxPtr _pBox) +{ + (_pReg)->extents = *(_pBox); + RegionUninit(_pReg); + (_pReg)->data = (RegDataPtr)NULL; +} + +static inline Bool RegionNotEmpty(RegionPtr _pReg) { + return !RegionNil(_pReg); +} + +static inline Bool RegionBroken(RegionPtr _pReg) { + return RegionNar(_pReg); +} + +static inline void RegionEmpty(RegionPtr _pReg) +{ + RegionUninit(_pReg); + (_pReg)->extents.x2 = (_pReg)->extents.x1; + (_pReg)->extents.y2 = (_pReg)->extents.y1; + (_pReg)->data = &RegionEmptyData; +} + +static inline BoxPtr RegionExtents(RegionPtr _pReg) +{ + return (&(_pReg)->extents); +} + +static inline void RegionNull(RegionPtr _pReg) +{ + (_pReg)->extents = RegionEmptyBox; + (_pReg)->data = &RegionEmptyData; +} + +extern _X_EXPORT void InitRegions(void); extern _X_EXPORT RegionPtr RegionCreate( BoxPtr /*rect*/, @@ -202,19 +183,31 @@ extern _X_EXPORT RegionPtr RegionCreate( extern _X_EXPORT void RegionDestroy( RegionPtr /*pReg*/); -extern _X_EXPORT Bool RegionCopy( - RegionPtr /*dst*/, - RegionPtr /*src*/); +static inline Bool +RegionCopy(RegionPtr dst, RegionPtr src) +{ + return pixman_region_copy (dst, src); +} -extern _X_EXPORT Bool RegionIntersect( - RegionPtr /*newReg*/, - RegionPtr /*reg1*/, - RegionPtr /*reg2*/); +static inline Bool +RegionIntersect( + RegionPtr newReg, /* destination Region */ + RegionPtr reg1, + RegionPtr reg2 /* source regions */ + ) +{ + return pixman_region_intersect (newReg, reg1, reg2); +} -extern _X_EXPORT Bool RegionUnion( - RegionPtr /*newReg*/, - RegionPtr /*reg1*/, - RegionPtr /*reg2*/); +static inline Bool +RegionUnion( + RegionPtr newReg, /* destination Region */ + RegionPtr reg1, + RegionPtr reg2 /* source regions */ + ) +{ + return pixman_region_union (newReg, reg1, reg2); +} extern _X_EXPORT Bool RegionAppend( RegionPtr /*dstrgn*/, @@ -229,37 +222,87 @@ extern _X_EXPORT RegionPtr RegionFromRects( xRectanglePtr /*prect*/, int /*ctype*/); -extern _X_EXPORT Bool RegionSubtract( - RegionPtr /*regD*/, - RegionPtr /*regM*/, - RegionPtr /*regS*/); +/*- + *----------------------------------------------------------------------- + * Subtract -- + * Subtract regS from regM and leave the result in regD. + * S stands for subtrahend, M for minuend and D for difference. + * + * Results: + * TRUE if successful. + * + * Side Effects: + * regD is overwritten. + * + *----------------------------------------------------------------------- + */ +static inline Bool +RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS) +{ + return pixman_region_subtract (regD, regM, regS); +} + +/*- + *----------------------------------------------------------------------- + * Inverse -- + * 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... + * + * Results: + * TRUE. + * + * Side Effects: + * newReg is overwritten. + * + *----------------------------------------------------------------------- + */ -extern _X_EXPORT Bool RegionInverse( - RegionPtr /*newReg*/, - RegionPtr /*reg1*/, - BoxPtr /*invRect*/); +static inline Bool +RegionInverse( + RegionPtr newReg, /* Destination region */ + RegionPtr reg1, /* Region to invert */ + BoxPtr invRect /* Bounding box for inversion */ + ) +{ + return pixman_region_inverse (newReg, reg1, invRect); +} -extern _X_EXPORT int RegionContainsRect( - RegionPtr /*region*/, - BoxPtr /*prect*/); +static inline int +RegionContainsRect(RegionPtr region, BoxPtr prect) +{ + return pixman_region_contains_rectangle (region, prect); +} -extern _X_EXPORT void RegionTranslate( - RegionPtr /*pReg*/, - int /*x*/, - int /*y*/); +/* TranslateRegion(pReg, x, y) + translates in place +*/ + +static inline void +RegionTranslate(RegionPtr pReg, int x, int y) +{ + pixman_region_translate (pReg, x, y); +} extern _X_EXPORT Bool RegionBreak( RegionPtr /*pReg*/); -extern _X_EXPORT Bool RegionContainsPoint( - RegionPtr /*pReg*/, - int /*x*/, - int /*y*/, - BoxPtr /*box*/); +static inline Bool +RegionContainsPoint( + RegionPtr pReg, + int x, + int y, + BoxPtr box /* "return" value */ + ) +{ + return pixman_region_contains_point (pReg, x, y, box); +} -extern _X_EXPORT Bool RegionEqual( - RegionPtr /*pReg1*/, - RegionPtr /*pReg2*/); +static inline Bool +RegionEqual(RegionPtr reg1, RegionPtr reg2) +{ + return pixman_region_equal (reg1, reg2); +} extern _X_EXPORT Bool RegionRectAlloc( RegionPtr /*pRgn*/, diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 361c48434..e36b15f5e 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -603,6 +603,10 @@ typedef struct _Screen { DeviceCursorCleanupProcPtr DeviceCursorCleanup; } ScreenRec; +static inline RegionPtr BitmapToRegion(ScreenPtr _pScreen, PixmapPtr pPix) { + return (*(_pScreen)->BitmapToRegion)(pPix); /* no mi version?! */ +} + typedef struct _ScreenInfo { int imageByteOrder; int bitmapScanlineUnit; |