aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/include/regionstr.h
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/include/regionstr.h')
-rw-r--r--xorg-server/include/regionstr.h429
1 files changed, 253 insertions, 176 deletions
diff --git a/xorg-server/include/regionstr.h b/xorg-server/include/regionstr.h
index d67873295..92f4ca9f2 100644
--- a/xorg-server/include/regionstr.h
+++ b/xorg-server/include/regionstr.h
@@ -66,228 +66,305 @@ typedef struct pixman_region16 RegionRec, *RegionPtr;
typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
-extern _X_EXPORT BoxRec miEmptyBox;
-extern _X_EXPORT RegDataRec miEmptyData;
-extern _X_EXPORT RegDataRec miBrokenData;
+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 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) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
-
-#define REGION_CREATE(_pScreen, _rect, _size) \
- miRegionCreate(_rect, _size)
-
-#define REGION_COPY(_pScreen, dst, src) \
- miRegionCopy(dst, src)
-
-#define REGION_DESTROY(_pScreen, _pReg) \
- miRegionDestroy(_pReg)
-
-#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
- miIntersect(newReg, reg1, reg2)
-
-#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
- miUnion(newReg, reg1, reg2)
-
-#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
- miSubtract(newReg, reg1, reg2)
-
-#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
- miInverse(newReg, reg1, invRect)
-
-#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
- miTranslateRegion(_pReg, _x, _y)
-
-#define RECT_IN_REGION(_pScreen, _pReg, prect) \
- miRectIn(_pReg, prect)
-
-#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
- miPointInRegion(_pReg, _x, _y, prect)
-
-#define REGION_APPEND(_pScreen, dstrgn, rgn) \
- miRegionAppend(dstrgn, rgn)
-
-#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
- miRegionValidate(badreg, pOverlap)
-
-#define BITMAP_TO_REGION(_pScreen, pPix) \
- (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
-
-#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
- miRectsToRegion(nrects, prect, ctype)
-
-#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
- miRegionEqual(_pReg1, _pReg2)
-
-#define REGION_BREAK(_pScreen, _pReg) \
- miRegionBreak(_pReg)
-
-#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
-{ \
- if ((_rect) != NULL) \
- { \
- (_pReg)->extents = *(_rect); \
- (_pReg)->data = (RegDataPtr)NULL; \
- } \
- else \
- { \
- (_pReg)->extents = miEmptyBox; \
- if (((_size) > 1) && ((_pReg)->data = \
- (RegDataPtr)malloc(REGION_SZOF(_size)))) \
- { \
- (_pReg)->data->size = (_size); \
- (_pReg)->data->numRects = 0; \
- } \
- else \
- (_pReg)->data = &miEmptyData; \
- } \
- }
-
-
-#define REGION_UNINIT(_pScreen, _pReg) \
-{ \
- if ((_pReg)->data && (_pReg)->data->size) { \
- free((_pReg)->data); \
- (_pReg)->data = NULL; \
- } \
+
+static inline Bool RegionNar(RegionPtr reg) {
+ return ((reg)->data == &RegionBrokenData);
}
-#define REGION_RESET(_pScreen, _pReg, _pBox) \
-{ \
- (_pReg)->extents = *(_pBox); \
- REGION_UNINIT(_pScreen, _pReg); \
- (_pReg)->data = (RegDataPtr)NULL; \
+static inline int RegionNumRects(RegionPtr reg) {
+ return ((reg)->data ? (reg)->data->numRects : 1);
}
-#define REGION_NOTEMPTY(_pScreen, _pReg) \
- !REGION_NIL(_pReg)
+static inline int RegionSize(RegionPtr reg) {
+ return ((reg)->data ? (reg)->data->size : 0);
+}
-#define REGION_BROKEN(_pScreen, _pReg) \
- REGION_NAR(_pReg)
+static inline BoxPtr RegionRects(RegionPtr reg) {
+ return ((reg)->data ? (BoxPtr)((reg)->data + 1) : &(reg)->extents);
+}
-#define REGION_EMPTY(_pScreen, _pReg) \
-{ \
- REGION_UNINIT(_pScreen, _pReg); \
- (_pReg)->extents.x2 = (_pReg)->extents.x1; \
- (_pReg)->extents.y2 = (_pReg)->extents.y1; \
- (_pReg)->data = &miEmptyData; \
+static inline BoxPtr RegionBoxptr(RegionPtr reg) {
+ return ((BoxPtr)((reg)->data + 1));
}
-#define REGION_EXTENTS(_pScreen, _pReg) \
- (&(_pReg)->extents)
+static inline BoxPtr RegionBox(RegionPtr reg, int i) {
+ return (&RegionBoxptr(reg)[i]);
+}
-#define REGION_NULL(_pScreen, _pReg) \
-{ \
- (_pReg)->extents = miEmptyBox; \
- (_pReg)->data = &miEmptyData; \
+static inline BoxPtr RegionTop(RegionPtr reg) {
+ return RegionBox(reg, (reg)->data->numRects);
}
-#ifndef REGION_NULL
-#define REGION_NULL(_pScreen, _pReg) \
- REGION_INIT(_pScreen, _pReg, NullBox, 1)
-#endif
+static inline BoxPtr RegionEnd(RegionPtr reg) {
+ return RegionBox(reg, (reg)->data->numRects - 1);
+}
-/* moved from mi.h */
+static inline size_t RegionSizeof(int n) {
+ return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
+}
-extern _X_EXPORT void InitRegions (void);
+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 RegionPtr miRegionCreate(
- BoxPtr /*rect*/,
- int /*size*/);
+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);
+}
-extern _X_EXPORT void miRegionInit(
- RegionPtr /*pReg*/,
+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*/,
int /*size*/);
-extern _X_EXPORT void miRegionDestroy(
+extern _X_EXPORT void RegionDestroy(
RegionPtr /*pReg*/);
-extern _X_EXPORT void miRegionUninit(
- RegionPtr /*pReg*/);
-
-extern _X_EXPORT Bool miRegionCopy(
- RegionPtr /*dst*/,
- RegionPtr /*src*/);
+static inline Bool
+RegionCopy(RegionPtr dst, RegionPtr src)
+{
+ return pixman_region_copy (dst, src);
+}
-extern _X_EXPORT Bool miIntersect(
- 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 miUnion(
- 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 miRegionAppend(
+extern _X_EXPORT Bool RegionAppend(
RegionPtr /*dstrgn*/,
RegionPtr /*rgn*/);
-extern _X_EXPORT Bool miRegionValidate(
+extern _X_EXPORT Bool RegionValidate(
RegionPtr /*badreg*/,
Bool * /*pOverlap*/);
-extern _X_EXPORT RegionPtr miRectsToRegion(
+extern _X_EXPORT RegionPtr RegionFromRects(
int /*nrects*/,
xRectanglePtr /*prect*/,
int /*ctype*/);
-extern _X_EXPORT Bool miSubtract(
- 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 miInverse(
- 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 miRectIn(
- RegionPtr /*region*/,
- BoxPtr /*prect*/);
+static inline int
+RegionContainsRect(RegionPtr region, BoxPtr prect)
+{
+ return pixman_region_contains_rectangle (region, prect);
+}
-extern _X_EXPORT void miTranslateRegion(
- RegionPtr /*pReg*/,
- int /*x*/,
- int /*y*/);
+/* TranslateRegion(pReg, x, y)
+ translates in place
+*/
-extern _X_EXPORT void miRegionReset(
- RegionPtr /*pReg*/,
- BoxPtr /*pBox*/);
+static inline void
+RegionTranslate(RegionPtr pReg, int x, int y)
+{
+ pixman_region_translate (pReg, x, y);
+}
-extern _X_EXPORT Bool miRegionBreak(
+extern _X_EXPORT Bool RegionBreak(
RegionPtr /*pReg*/);
-extern _X_EXPORT Bool miPointInRegion(
- RegionPtr /*pReg*/,
- int /*x*/,
- int /*y*/,
- BoxPtr /*box*/);
-
-extern _X_EXPORT Bool miRegionEqual(
- RegionPtr /*pReg1*/,
- RegionPtr /*pReg2*/);
+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 miRegionNotEmpty(
- RegionPtr /*pReg*/);
+static inline Bool
+RegionEqual(RegionPtr reg1, RegionPtr reg2)
+{
+ return pixman_region_equal (reg1, reg2);
+}
-extern _X_EXPORT void miRegionEmpty(
- RegionPtr /*pReg*/);
+extern _X_EXPORT Bool RegionRectAlloc(
+ RegionPtr /*pRgn*/,
+ int /*n*/
+);
-extern _X_EXPORT BoxPtr miRegionExtents(
- RegionPtr /*pReg*/);
+#ifdef DEBUG
+extern _X_EXPORT Bool RegionIsValid(
+ RegionPtr /*prgn*/
+);
+#endif
-extern _X_EXPORT void miPrintRegion(
+extern _X_EXPORT void RegionPrint(
RegionPtr /*pReg*/);
+extern _X_EXPORT int RegionClipSpans(
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ DDXPointPtr /*pptNew*/,
+ int * /*pwidthNew*/,
+ int /*fSorted*/
+);
+
+#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 BITMAP_TO_REGION 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 */