aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r--nx-X11/programs/Xserver/include/misc.h2
-rw-r--r--nx-X11/programs/Xserver/include/miscstruct.h6
-rw-r--r--nx-X11/programs/Xserver/include/regionstr.h399
3 files changed, 183 insertions, 224 deletions
diff --git a/nx-X11/programs/Xserver/include/misc.h b/nx-X11/programs/Xserver/include/misc.h
index e6bc1019d..5f30823fa 100644
--- a/nx-X11/programs/Xserver/include/misc.h
+++ b/nx-X11/programs/Xserver/include/misc.h
@@ -295,7 +295,7 @@ extern int Ones(
unsigned long /*mask*/);
typedef struct _xPoint *DDXPointPtr;
-typedef struct _Box *BoxPtr;
+typedef struct pixman_box16 *BoxPtr;
typedef struct _xEvent *xEventPtr;
typedef struct _xRectangle *xRectanglePtr;
typedef struct _GrabRec *GrabPtr;
diff --git a/nx-X11/programs/Xserver/include/miscstruct.h b/nx-X11/programs/Xserver/include/miscstruct.h
index 7df9240c9..7b1f8047b 100644
--- a/nx-X11/programs/Xserver/include/miscstruct.h
+++ b/nx-X11/programs/Xserver/include/miscstruct.h
@@ -50,15 +50,15 @@ SOFTWARE.
#ifndef MISCSTRUCT_H
#define MISCSTRUCT_H 1
+#include <pixman.h>
+
#include "misc.h"
#include <nx-X11/Xprotostr.h>
#include "gc.h"
typedef xPoint DDXPointRec;
-typedef struct _Box {
- short x1, y1, x2, y2;
-} BoxRec;
+typedef struct pixman_box16 BoxRec;
typedef union _DevUnion {
void * ptr;
diff --git a/nx-X11/programs/Xserver/include/regionstr.h b/nx-X11/programs/Xserver/include/regionstr.h
index b1eb100a5..c61acc003 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,261 +72,218 @@ 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;
-};
+typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
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 RegionCreate(_rect, _size) \
- (*(REG_pScreen)->RegionCreate)(_rect, _size)
-
-#define RegionInit(_pReg, _rect, _size) \
- (*(REG_pScreen)->RegionInit)(_pReg, _rect, _size)
-
-#define RegionCopy(dst, src) \
- (*(REG_pScreen)->RegionCopy)(dst, src)
-
-#define RegionDestroy(_pReg) \
- (*(REG_pScreen)->RegionDestroy)(_pReg)
-
-#define RegionUninit(_pReg) \
- (*(REG_pScreen)->RegionUninit)(_pReg)
-
-#define RegionIntersect(newReg, reg1, reg2) \
- (*(REG_pScreen)->Intersect)(newReg, reg1, reg2)
-
-#define RegionUnion(newReg, reg1, reg2) \
- (*(REG_pScreen)->Union)(newReg, reg1, reg2)
-
-#define RegionSubtract(newReg, reg1, reg2) \
- (*(REG_pScreen)->Subtract)(newReg, reg1, reg2)
-
-#define RegionInverse(newReg, reg1, invRect) \
- (*(REG_pScreen)->Inverse)(newReg, reg1, invRect)
-
-#define RegionReset(_pReg, _pBox) \
- (*(REG_pScreen)->RegionReset)(_pReg, _pBox)
-
-#define RegionTranslate(_pReg, _x, _y) \
- (*(REG_pScreen)->TranslateRegion)(_pReg, _x, _y)
-
-#define RegionContainsRect(_pReg, prect) \
- (*(REG_pScreen)->RectIn)(_pReg, prect)
-
-#define RegionContainsPoint(_pReg, _x, _y, prect) \
- (*(REG_pScreen)->PointInRegion)(_pReg, _x, _y, prect)
-
-#define RegionNotEmpty(_pReg) \
- (*(REG_pScreen)->RegionNotEmpty)(_pReg)
-
-#define RegionEqual(_pReg1, _pReg2) \
- (*(REG_pScreen)->RegionEqual)(_pReg1, _pReg2)
-
-#define RegionBroken(_pReg) \
- (*(REG_pScreen)->RegionBroken)(_pReg)
-
-#define RegionBreak(_pReg) \
- (*(REG_pScreen)->RegionBreak)(_pReg)
-
-#define RegionEmpty(_pReg) \
- (*(REG_pScreen)->RegionEmpty)(_pReg)
-
-#define RegionExtents(_pReg) \
- (*(REG_pScreen)->RegionExtents)(_pReg)
-
-#define RegionAppend(dstrgn, rgn) \
- (*(REG_pScreen)->RegionAppend)(dstrgn, rgn)
-
-#define RegionValidate(badreg, pOverlap) \
- (*(REG_pScreen)->RegionValidate)(badreg, pOverlap)
-
-#define BITMAP_TO_REGION(_pScreen, pPix) \
- (*(REG_pScreen)->BitmapToRegion)(pPix)
-
-#define RegionFromRects(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 RegionCreate(_rect, _size) \
- (REGION_SCREEN(_pScreen), miRegionCreate(_rect, _size))
-
-#define RegionCopy(dst, src) \
- (REGION_SCREEN(_pScreen), miRegionCopy(dst, src))
-
-#define RegionDestroy(_pReg) \
- (REGION_SCREEN(_pScreen), miRegionDestroy(_pReg))
-
-#define RegionIntersect(newReg, reg1, reg2) \
- (REGION_SCREEN(_pScreen), miIntersect(newReg, reg1, reg2))
-
-#define RegionUnion(newReg, reg1, reg2) \
- (REGION_SCREEN(_pScreen), miUnion(newReg, reg1, reg2))
-
-#define RegionSubtract(newReg, reg1, reg2) \
- (REGION_SCREEN(_pScreen), miSubtract(newReg, reg1, reg2))
-
-#define RegionInverse(newReg, reg1, invRect) \
- (REGION_SCREEN(_pScreen), miInverse(newReg, reg1, invRect))
-
-#define RegionTranslate(_pReg, _x, _y) \
- (REGION_SCREEN(_pScreen), miTranslateRegion(_pReg, _x, _y))
-
-#define RegionContainsRect(_pReg, prect) \
- (REGION_SCREEN(_pScreen), miRectIn(_pReg, prect))
-
-#define RegionContainsPoint(_pReg, _x, _y, prect) \
- (REGION_SCREEN(_pScreen), miPointInRegion(_pReg, _x, _y, prect))
-
-#define RegionAppend(dstrgn, rgn) \
- (REGION_SCREEN(_pScreen), miRegionAppend(dstrgn, rgn))
+static inline Bool RegionNil(RegionPtr reg) {
+ return ((reg)->data && !(reg)->data->numRects);
+}
-#define RegionValidate(badreg, pOverlap) \
- (REGION_SCREEN(_pScreen), miRegionValidate(badreg, pOverlap))
+static inline Bool RegionNar(RegionPtr reg) {
+ return ((reg)->data == &miBrokenData);
+}
-#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 RegionFromRects(nrects, prect, ctype) \
- (REGION_SCREEN(_pScreen), miRectsToRegion(nrects, prect, ctype))
+static inline int RegionSize(RegionPtr reg) {
+ return ((reg)->data ? (reg)->data->size : 0);
+}
-#define RegionEqual(_pReg1, _pReg2) \
- (REGION_SCREEN(_pScreen), miRegionEqual(_pReg1, _pReg2))
+static inline BoxPtr RegionRects(RegionPtr reg) {
+ return ((reg)->data ? (BoxPtr)((reg)->data + 1) : &(reg)->extents);
+}
-#define RegionBreak(_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 RegionInit(_pReg, _rect, _size) \
- (REGION_SCREEN(_pScreen), miRegionInit(_pReg, _rect, _size))
+static inline BoxPtr RegionTop(RegionPtr reg) {
+ return RegionBox(reg, (reg)->data->numRects);
+}
-#define RegionUninit(_pReg) \
- (REGION_SCREEN(_pScreen), miRegionUninit(_pReg))
+static inline BoxPtr RegionEnd(RegionPtr reg) {
+ return RegionBox(reg, (reg)->data->numRects - 1);
+}
-#define RegionReset(_pReg, _pBox) \
- (REGION_SCREEN(_pScreen), miRegionReset(_pReg, _pBox))
+static inline size_t RegionSizeof(int n) {
+ return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
+}
-#define RegionNotEmpty(_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 = miEmptyBox;
+ if (((_size) > 1) && ((_pReg)->data =
+ (RegDataPtr)malloc(RegionSizeof(_size))))
+ {
+ (_pReg)->data->size = (_size);
+ (_pReg)->data->numRects = 0;
+ }
+ else
+ (_pReg)->data = &miEmptyData;
+ }
+}
-#define RegionBroken(_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 RegionEmpty(_pReg) \
- (REGION_SCREEN(_pScreen), miRegionEmpty(_pReg))
+static inline void RegionReset(RegionPtr _pReg, BoxPtr _pBox)
+{
+ (_pReg)->extents = *(_pBox);
+ RegionUninit(_pReg);
+ (_pReg)->data = (RegDataPtr)NULL;
+}
-#define RegionExtents(_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 RegionInit(_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 = &miEmptyData;
+}
+static inline BoxPtr RegionExtents(RegionPtr _pReg)
+{
+ return (&(_pReg)->extents);
+}
-#define RegionUninit(_pReg) \
-{ \
- REGION_SCREEN(_pScreen); \
- if ((_pReg)->data && (_pReg)->data->size) { \
- xfree((_pReg)->data); \
- (_pReg)->data = NULL; \
- } \
+static inline void RegionNull(RegionPtr _pReg)
+{
+ (_pReg)->extents = miEmptyBox;
+ (_pReg)->data = &miEmptyData;
}
-#define RegionReset(_pReg, _pBox) \
-{ \
- REGION_SCREEN(_pScreen); \
- (_pReg)->extents = *(_pBox); \
- RegionUninit(_pReg); \
- (_pReg)->data = (RegDataPtr)NULL; \
+static inline Bool
+RegionCopy(RegionPtr dst, RegionPtr src)
+{
+ return pixman_region_copy (dst, src);
}
-#define RegionNotEmpty(_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 RegionBroken(_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 RegionEmpty(_pReg) \
-{ \
- RegionUninit(_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 RegionExtents(_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 RegionNull(_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 RegionNull
-#define RegionNull(_pReg) \
- RegionInit(_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(
BoxPtr /*rect*/,