aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/include/regionstr.h
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/include/regionstr.h')
-rw-r--r--nx-X11/programs/Xserver/include/regionstr.h486
1 files changed, 242 insertions, 244 deletions
diff --git a/nx-X11/programs/Xserver/include/regionstr.h b/nx-X11/programs/Xserver/include/regionstr.h
index cf41170a6..ace8031e0 100644
--- a/nx-X11/programs/Xserver/include/regionstr.h
+++ b/nx-X11/programs/Xserver/include/regionstr.h
@@ -51,7 +51,9 @@ SOFTWARE.
#ifndef REGIONSTRUCT_H
#define REGIONSTRUCT_H
-typedef struct _Region RegionRec, *RegionPtr;
+#include <pixman.h>
+
+typedef struct pixman_region16 RegionRec, *RegionPtr;
#include <stddef.h>
#include <limits.h>
@@ -70,347 +72,343 @@ typedef struct _Region RegionRec, *RegionPtr;
* clip region
*/
-typedef struct _RegData {
- long size;
- long numRects;
-/* BoxRec rects[size]; in memory but not explicitly declared */
-} RegDataRec, *RegDataPtr;
-
-struct _Region {
- BoxRec extents;
- RegDataPtr data;
-};
-
-extern BoxRec miEmptyBox;
-extern RegDataRec miEmptyData;
-extern RegDataRec miBrokenData;
-
-#define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
-/* not a region */
-#define REGION_NAR(reg) ((reg)->data == &miBrokenData)
-#define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
-#define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
-#define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
- : &(reg)->extents)
-#define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
-#define REGION_BOX(reg,i) (&REGION_BOXPTR(reg)[i])
-#define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
-#define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
-#define REGION_SZOF(n) (n < ((INT_MAX - sizeof(RegDataRec)) / sizeof(BoxRec)) ? sizeof(RegDataRec) + ((n) * sizeof(BoxRec)) : 0)
-
-/* Keith recommends weaning the region code of pScreen argument */
-#define REG_pScreen screenInfo.screens[0]
-
-#ifdef NEED_SCREEN_REGIONS
-
-#define REGION_CREATE(_pScreen, _rect, _size) \
- (*(REG_pScreen)->RegionCreate)(_rect, _size)
-
-#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
- (*(REG_pScreen)->RegionInit)(_pReg, _rect, _size)
-
-#define REGION_COPY(_pScreen, dst, src) \
- (*(REG_pScreen)->RegionCopy)(dst, src)
-
-#define REGION_DESTROY(_pScreen, _pReg) \
- (*(REG_pScreen)->RegionDestroy)(_pReg)
-
-#define REGION_UNINIT(_pScreen, _pReg) \
- (*(REG_pScreen)->RegionUninit)(_pReg)
-
-#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
- (*(REG_pScreen)->Intersect)(newReg, reg1, reg2)
-
-#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
- (*(REG_pScreen)->Union)(newReg, reg1, reg2)
-
-#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
- (*(REG_pScreen)->Subtract)(newReg, reg1, reg2)
-
-#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
- (*(REG_pScreen)->Inverse)(newReg, reg1, invRect)
-
-#define REGION_RESET(_pScreen, _pReg, _pBox) \
- (*(REG_pScreen)->RegionReset)(_pReg, _pBox)
-
-#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
- (*(REG_pScreen)->TranslateRegion)(_pReg, _x, _y)
-
-#define RECT_IN_REGION(_pScreen, _pReg, prect) \
- (*(REG_pScreen)->RectIn)(_pReg, prect)
-
-#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
- (*(REG_pScreen)->PointInRegion)(_pReg, _x, _y, prect)
-
-#define REGION_NOTEMPTY(_pScreen, _pReg) \
- (*(REG_pScreen)->RegionNotEmpty)(_pReg)
-
-#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
- (*(REG_pScreen)->RegionEqual)(_pReg1, _pReg2)
-
-#define REGION_BROKEN(_pScreen, _pReg) \
- (*(REG_pScreen)->RegionBroken)(_pReg)
-
-#define REGION_BREAK(_pScreen, _pReg) \
- (*(REG_pScreen)->RegionBreak)(_pReg)
-
-#define REGION_EMPTY(_pScreen, _pReg) \
- (*(REG_pScreen)->RegionEmpty)(_pReg)
-
-#define REGION_EXTENTS(_pScreen, _pReg) \
- (*(REG_pScreen)->RegionExtents)(_pReg)
-
-#define REGION_APPEND(_pScreen, dstrgn, rgn) \
- (*(REG_pScreen)->RegionAppend)(dstrgn, rgn)
-
-#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
- (*(REG_pScreen)->RegionValidate)(badreg, pOverlap)
-
-#define BITMAP_TO_REGION(_pScreen, pPix) \
- (*(REG_pScreen)->BitmapToRegion)(pPix)
-
-#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
- (*(REG_pScreen)->RectsToRegion)(nrects, prect, ctype)
-
-#else /* !NEED_SCREEN_REGIONS */
-
-/* Reference _pScreen macro argument and check its type */
-#define REGION_SCREEN(_pScreen) (void)((REG_pScreen)->myNum)
-
-#define REGION_CREATE(_pScreen, _rect, _size) \
- (REGION_SCREEN(_pScreen), miRegionCreate(_rect, _size))
-
-#define REGION_COPY(_pScreen, dst, src) \
- (REGION_SCREEN(_pScreen), miRegionCopy(dst, src))
-
-#define REGION_DESTROY(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), miRegionDestroy(_pReg))
+typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
-#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
- (REGION_SCREEN(_pScreen), miIntersect(newReg, reg1, reg2))
+extern BoxRec RegionEmptyBox;
+extern RegDataRec RegionEmptyData;
+extern RegDataRec RegionBrokenData;
-#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
- (REGION_SCREEN(_pScreen), miUnion(newReg, reg1, reg2))
-
-#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
- (REGION_SCREEN(_pScreen), miSubtract(newReg, reg1, reg2))
-
-#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
- (REGION_SCREEN(_pScreen), miInverse(newReg, reg1, invRect))
-
-#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
- (REGION_SCREEN(_pScreen), miTranslateRegion(_pReg, _x, _y))
-
-#define RECT_IN_REGION(_pScreen, _pReg, prect) \
- (REGION_SCREEN(_pScreen), miRectIn(_pReg, prect))
-
-#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
- (REGION_SCREEN(_pScreen), miPointInRegion(_pReg, _x, _y, prect))
-
-#define REGION_APPEND(_pScreen, dstrgn, rgn) \
- (REGION_SCREEN(_pScreen), miRegionAppend(dstrgn, rgn))
+static inline Bool RegionNil(RegionPtr reg) {
+ return ((reg)->data && !(reg)->data->numRects);
+}
-#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
- (REGION_SCREEN(_pScreen), miRegionValidate(badreg, pOverlap))
+static inline Bool RegionNar(RegionPtr reg) {
+ return ((reg)->data == &RegionBrokenData);
+}
-#define BITMAP_TO_REGION(_pScreen, pPix) \
- (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
+static inline int RegionNumRects(RegionPtr reg) {
+ return ((reg)->data ? (reg)->data->numRects : 1);
+}
-#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
- (REGION_SCREEN(_pScreen), miRectsToRegion(nrects, prect, ctype))
+static inline int RegionSize(RegionPtr reg) {
+ return ((reg)->data ? (reg)->data->size : 0);
+}
-#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
- (REGION_SCREEN(_pScreen), miRegionEqual(_pReg1, _pReg2))
+static inline BoxPtr RegionRects(RegionPtr reg) {
+ return ((reg)->data ? (BoxPtr)((reg)->data + 1) : &(reg)->extents);
+}
-#define REGION_BREAK(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), miRegionBreak(_pReg))
+static inline BoxPtr RegionBoxptr(RegionPtr reg) {
+ return ((BoxPtr)((reg)->data + 1));
+}
-#ifdef DONT_INLINE_REGION_OPS
+static inline BoxPtr RegionBox(RegionPtr reg, int i) {
+ return (&RegionBoxptr(reg)[i]);
+}
-#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
- (REGION_SCREEN(_pScreen), miRegionInit(_pReg, _rect, _size))
+static inline BoxPtr RegionTop(RegionPtr reg) {
+ return RegionBox(reg, (reg)->data->numRects);
+}
-#define REGION_UNINIT(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), miRegionUninit(_pReg))
+static inline BoxPtr RegionEnd(RegionPtr reg) {
+ return RegionBox(reg, (reg)->data->numRects - 1);
+}
-#define REGION_RESET(_pScreen, _pReg, _pBox) \
- (REGION_SCREEN(_pScreen), miRegionReset(_pReg, _pBox))
+static inline size_t RegionSizeof(int n) {
+ return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
+}
-#define REGION_NOTEMPTY(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), miRegionNotEmpty(_pReg))
+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;
+ }
+}
-#define REGION_BROKEN(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), miRegionBroken(_pReg))
+static inline void RegionUninit(RegionPtr _pReg)
+{
+ if ((_pReg)->data && (_pReg)->data->size) {
+ free((_pReg)->data);
+ (_pReg)->data = NULL;
+ }
+}
-#define REGION_EMPTY(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), miRegionEmpty(_pReg))
+static inline void RegionReset(RegionPtr _pReg, BoxPtr _pBox)
+{
+ (_pReg)->extents = *(_pBox);
+ RegionUninit(_pReg);
+ (_pReg)->data = (RegDataPtr)NULL;
+}
-#define REGION_EXTENTS(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), miRegionExtents(_pReg))
+static inline Bool RegionNotEmpty(RegionPtr _pReg) {
+ return !RegionNil(_pReg);
+}
-#else /* inline certain simple region ops for performance */
+static inline Bool RegionBroken(RegionPtr _pReg) {
+ return RegionNar(_pReg);
+}
-#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
-{ \
- REGION_SCREEN(_pScreen); \
- if (_rect) \
- { \
- (_pReg)->extents = *(_rect); \
- (_pReg)->data = (RegDataPtr)NULL; \
- } \
- else \
- { \
- size_t rgnSize; \
- (_pReg)->extents = miEmptyBox; \
- if (((_size) > 1) && ((rgnSize = REGION_SZOF(_size)) > 0) && \
- ((_pReg)->data = (RegDataPtr)xalloc(rgnSize))) \
- { \
- (_pReg)->data->size = (_size); \
- (_pReg)->data->numRects = 0; \
- } \
- else \
- (_pReg)->data = &miEmptyData; \
- } \
- }
+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);
+}
-#define REGION_UNINIT(_pScreen, _pReg) \
-{ \
- REGION_SCREEN(_pScreen); \
- if ((_pReg)->data && (_pReg)->data->size) { \
- xfree((_pReg)->data); \
- (_pReg)->data = NULL; \
- } \
+static inline void RegionNull(RegionPtr _pReg)
+{
+ (_pReg)->extents = RegionEmptyBox;
+ (_pReg)->data = &RegionEmptyData;
}
-#define REGION_RESET(_pScreen, _pReg, _pBox) \
-{ \
- REGION_SCREEN(_pScreen); \
- (_pReg)->extents = *(_pBox); \
- REGION_UNINIT(_pScreen, _pReg); \
- (_pReg)->data = (RegDataPtr)NULL; \
+static inline Bool
+RegionCopy(RegionPtr dst, RegionPtr src)
+{
+ return pixman_region_copy (dst, src);
}
-#define REGION_NOTEMPTY(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), !REGION_NIL(_pReg))
+static inline Bool
+RegionIntersect(
+ RegionPtr newReg, /* destination Region */
+ RegionPtr reg1,
+ RegionPtr reg2 /* source regions */
+ )
+{
+ return pixman_region_intersect (newReg, reg1, reg2);
+}
-#define REGION_BROKEN(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), REGION_NAR(_pReg))
+static inline Bool
+RegionUnion(
+ RegionPtr newReg, /* destination Region */
+ RegionPtr reg1,
+ RegionPtr reg2 /* source regions */
+ )
+{
+ return pixman_region_union (newReg, reg1, reg2);
+}
-#define REGION_EMPTY(_pScreen, _pReg) \
-{ \
- REGION_UNINIT(_pScreen, _pReg); \
- (_pReg)->extents.x2 = (_pReg)->extents.x1; \
- (_pReg)->extents.y2 = (_pReg)->extents.y1; \
- (_pReg)->data = &miEmptyData; \
+/*
+ *-----------------------------------------------------------------------
+ * 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);
}
-#define REGION_EXTENTS(_pScreen, _pReg) \
- (REGION_SCREEN(_pScreen), &(_pReg)->extents)
+/*
+ *-----------------------------------------------------------------------
+ * 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.
+ *
+ *-----------------------------------------------------------------------
+ */
+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);
+}
-#define REGION_NULL(_pScreen, _pReg) \
-{ \
- REGION_SCREEN(_pScreen); \
- (_pReg)->extents = miEmptyBox; \
- (_pReg)->data = &miEmptyData; \
+static inline int
+RegionContainsRect(RegionPtr region, BoxPtr prect)
+{
+ return pixman_region_contains_rectangle (region, prect);
}
-#endif /* DONT_INLINE_REGION_OPS */
+/* TranslateRegion(pReg, x, y)
+ * translates in place
+ */
-#endif /* NEED_SCREEN_REGIONS */
+static inline void
+RegionTranslate(RegionPtr pReg, int x, int y)
+{
+ pixman_region_translate (pReg, x, y);
+}
-#ifndef REGION_NULL
-#define REGION_NULL(_pScreen, _pReg) \
- REGION_INIT(_pScreen, _pReg, NullBox, 1)
-#endif
+static inline Bool
+RegionContainsPoint(
+ RegionPtr pReg,
+ int x,
+ int y,
+ BoxPtr box /* "return" value */
+ )
+{
+ return pixman_region_contains_point (pReg, x, y, box);
+}
-/* moved from mi.h */
+static inline Bool
+RegionEqual(RegionPtr reg1, RegionPtr reg2)
+{
+ return pixman_region_equal (reg1, reg2);
+}
-extern RegionPtr miRegionCreate(
+extern RegionPtr RegionCreate(
BoxPtr /*rect*/,
int /*size*/);
-extern void miRegionInit(
+extern void RegionInit(
RegionPtr /*pReg*/,
BoxPtr /*rect*/,
int /*size*/);
-extern void miRegionDestroy(
+extern void RegionDestroy(
RegionPtr /*pReg*/);
-extern void miRegionUninit(
+extern void RegionUninit(
RegionPtr /*pReg*/);
-extern Bool miRegionCopy(
+extern Bool RegionCopy(
RegionPtr /*dst*/,
RegionPtr /*src*/);
-extern Bool miIntersect(
+extern Bool RegionIntersect(
RegionPtr /*newReg*/,
RegionPtr /*reg1*/,
RegionPtr /*reg2*/);
-extern Bool miUnion(
+extern Bool RegionUnion(
RegionPtr /*newReg*/,
RegionPtr /*reg1*/,
RegionPtr /*reg2*/);
-extern Bool miRegionAppend(
+extern Bool RegionAppend(
RegionPtr /*dstrgn*/,
RegionPtr /*rgn*/);
-extern Bool miRegionValidate(
+extern Bool RegionValidate(
RegionPtr /*badreg*/,
Bool * /*pOverlap*/);
-extern RegionPtr miRectsToRegion(
+extern RegionPtr RegionFromRects(
int /*nrects*/,
xRectanglePtr /*prect*/,
int /*ctype*/);
-extern Bool miSubtract(
+extern Bool RegionSubtract(
RegionPtr /*regD*/,
RegionPtr /*regM*/,
RegionPtr /*regS*/);
-extern Bool miInverse(
+extern Bool RegionInverse(
RegionPtr /*newReg*/,
RegionPtr /*reg1*/,
BoxPtr /*invRect*/);
-extern int miRectIn(
+extern int RegionContainsRect(
RegionPtr /*region*/,
BoxPtr /*prect*/);
-extern void miTranslateRegion(
+extern void RegionTranslate(
RegionPtr /*pReg*/,
int /*x*/,
int /*y*/);
-extern void miRegionReset(
+extern void RegionReset(
RegionPtr /*pReg*/,
BoxPtr /*pBox*/);
-extern Bool miRegionBreak(
+extern Bool RegionBreak(
RegionPtr /*pReg*/);
-extern Bool miPointInRegion(
+extern Bool RegionContainsPoint(
RegionPtr /*pReg*/,
int /*x*/,
int /*y*/,
BoxPtr /*box*/);
-extern Bool miRegionEqual(
+extern Bool RegionEqual(
RegionPtr /*pReg1*/,
RegionPtr /*pReg2*/);
-extern Bool miRegionNotEmpty(
+extern Bool RegionNotEmpty(
RegionPtr /*pReg*/);
-extern void miRegionEmpty(
+extern void RegionEmpty(
RegionPtr /*pReg*/);
-extern BoxPtr miRegionExtents(
+extern BoxPtr RegionExtents(
RegionPtr /*pReg*/);
+#define INCLUDE_LEGACY_REGION_DEFINES
+#ifdef INCLUDE_LEGACY_REGION_DEFINES
+
+#define REGION_NIL RegionNil
+#define REGION_NAR RegionNar
+#define REGION_NUM_RECTS RegionNumRects
+#define REGION_SIZE RegionSize
+#define REGION_RECTS RegionRects
+#define REGION_BOXPTR RegionBoxptr
+#define REGION_BOX RegionBox
+#define REGION_TOP RegionTop
+#define REGION_END RegionEnd
+#define REGION_SZOF RegionSizeof
+#define BitmapToRegion BitmapToRegion
+#define REGION_CREATE(pScreen, r, s) RegionCreate(r,s)
+#define REGION_COPY(pScreen, d, r) RegionCopy(d, r)
+#define REGION_DESTROY(pScreen, r) RegionDestroy(r)
+#define REGION_INTERSECT(pScreen, res, r1, r2) RegionIntersect(res, r1, r2)
+#define REGION_UNION(pScreen, res, r1, r2) RegionUnion(res, r1, r2)
+#define REGION_SUBTRACT(pScreen, res, r1, r2) RegionSubtract(res, r1, r2)
+#define REGION_INVERSE(pScreen, n, r, b) RegionInverse(n, r, b)
+#define REGION_TRANSLATE(pScreen, r, x, y) RegionTranslate(r, x, y)
+#define RECT_IN_REGION(pScreen, r, b) RegionContainsRect(r, b)
+#define POINT_IN_REGION(pScreen, r, x, y, b) RegionContainsPoint(r, x, y, b)
+#define REGION_EQUAL(pScreen, r1, r2) RegionEqual(r1, r2)
+#define REGION_APPEND(pScreen, d, r) RegionAppend(d, r)
+#define REGION_VALIDATE(pScreen, r, o) RegionValidate(r, o)
+#define RECTS_TO_REGION(pScreen, n, r, c) RegionFromRects(n, r, c)
+#define REGION_BREAK(pScreen, r) RegionBreak(r)
+#define REGION_INIT(pScreen, r, b, s) RegionInit(r, b, s)
+#define REGION_UNINIT(pScreen, r) RegionUninit(r)
+#define REGION_RESET(pScreen, r, b) RegionReset(r, b)
+#define REGION_NOTEMPTY(pScreen, r) RegionNotEmpty(r)
+#define REGION_BROKEN(pScreen, r) RegionBroken(r)
+#define REGION_EMPTY(pScreen, r) RegionEmpty(r)
+#define REGION_EXTENTS(pScreen, r) RegionExtents(r)
+#define REGION_NULL(pScreen, r) RegionNull(r)
+
+#endif /* INCLUDE_LEGACY_REGION_DEFINES */
#endif /* REGIONSTRUCT_H */