1
/***********************************************************
3
Copyright 1987, 1998 The Open Group
5
Permission to use, copy, modify, distribute, and sell this software and its
6
documentation for any purpose is hereby granted without fee, provided that
7
the above copyright notice appear in all copies and that both that
8
copyright notice and this permission notice appear in supporting
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
Except as contained in this notice, the name of The Open Group shall not be
22
used in advertising or otherwise to promote the sale, use or other dealings
23
in this Software without prior written authorization from The Open Group.
26
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
30
Permission to use, copy, modify, and distribute this software and its
31
documentation for any purpose and without fee is hereby granted,
32
provided that the above copyright notice appear in all copies and that
33
both that copyright notice and this permission notice appear in
34
supporting documentation, and that the name of Digital not be
35
used in advertising or publicity pertaining to distribution of the
36
software without specific, written prior permission.
38
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46
******************************************************************/
48
#ifndef REGIONSTRUCT_H
49
#define REGIONSTRUCT_H
51
typedef struct pixman_region16 RegionRec, *RegionPtr;
53
#include "miscstruct.h"
55
/* Return values from RectIn() */
61
#define NullRegion ((RegionPtr)0)
67
typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
69
extern BoxRec miEmptyBox;
70
extern RegDataRec miEmptyData;
71
extern RegDataRec miBrokenData;
73
#define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
75
#define REGION_NAR(reg) ((reg)->data == &miBrokenData)
76
#define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
77
#define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
78
#define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
80
#define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
81
#define REGION_BOX(reg,i) (®ION_BOXPTR(reg)[i])
82
#define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
83
#define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
84
#define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
86
#define REGION_CREATE(_pScreen, _rect, _size) \
87
miRegionCreate(_rect, _size)
89
#define REGION_COPY(_pScreen, dst, src) \
90
miRegionCopy(dst, src)
92
#define REGION_DESTROY(_pScreen, _pReg) \
93
miRegionDestroy(_pReg)
95
#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
96
miIntersect(newReg, reg1, reg2)
98
#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
99
miUnion(newReg, reg1, reg2)
101
#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
102
miSubtract(newReg, reg1, reg2)
104
#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
105
miInverse(newReg, reg1, invRect)
107
#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
108
miTranslateRegion(_pReg, _x, _y)
110
#define RECT_IN_REGION(_pScreen, _pReg, prect) \
111
miRectIn(_pReg, prect)
113
#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
114
miPointInRegion(_pReg, _x, _y, prect)
116
#define REGION_APPEND(_pScreen, dstrgn, rgn) \
117
miRegionAppend(dstrgn, rgn)
119
#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
120
miRegionValidate(badreg, pOverlap)
122
#define BITMAP_TO_REGION(_pScreen, pPix) \
123
(*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
125
#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
126
miRectsToRegion(nrects, prect, ctype)
128
#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
129
miRegionEqual(_pReg1, _pReg2)
131
#define REGION_BREAK(_pScreen, _pReg) \
134
#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
136
if ((_rect) != NULL) \
138
(_pReg)->extents = *(_rect); \
139
(_pReg)->data = (RegDataPtr)NULL; \
143
(_pReg)->extents = miEmptyBox; \
144
if (((_size) > 1) && ((_pReg)->data = \
145
(RegDataPtr)xalloc(REGION_SZOF(_size)))) \
147
(_pReg)->data->size = (_size); \
148
(_pReg)->data->numRects = 0; \
151
(_pReg)->data = &miEmptyData; \
156
#define REGION_UNINIT(_pScreen, _pReg) \
158
if ((_pReg)->data && (_pReg)->data->size) { \
159
xfree((_pReg)->data); \
160
(_pReg)->data = NULL; \
164
#define REGION_RESET(_pScreen, _pReg, _pBox) \
166
(_pReg)->extents = *(_pBox); \
167
REGION_UNINIT(_pScreen, _pReg); \
168
(_pReg)->data = (RegDataPtr)NULL; \
171
#define REGION_NOTEMPTY(_pScreen, _pReg) \
174
#define REGION_BROKEN(_pScreen, _pReg) \
177
#define REGION_EMPTY(_pScreen, _pReg) \
179
REGION_UNINIT(_pScreen, _pReg); \
180
(_pReg)->extents.x2 = (_pReg)->extents.x1; \
181
(_pReg)->extents.y2 = (_pReg)->extents.y1; \
182
(_pReg)->data = &miEmptyData; \
185
#define REGION_EXTENTS(_pScreen, _pReg) \
188
#define REGION_NULL(_pScreen, _pReg) \
190
(_pReg)->extents = miEmptyBox; \
191
(_pReg)->data = &miEmptyData; \
195
#define REGION_NULL(_pScreen, _pReg) \
196
REGION_INIT(_pScreen, _pReg, NullBox, 1)
199
/* moved from mi.h */
201
extern void InitRegions (void);
203
extern RegionPtr miRegionCreate(
207
extern void miRegionInit(
212
extern void miRegionDestroy(
215
extern void miRegionUninit(
218
extern Bool miRegionCopy(
222
extern Bool miIntersect(
223
RegionPtr /*newReg*/,
228
RegionPtr /*newReg*/,
232
extern Bool miRegionAppend(
233
RegionPtr /*dstrgn*/,
236
extern Bool miRegionValidate(
237
RegionPtr /*badreg*/,
238
Bool * /*pOverlap*/);
240
extern RegionPtr miRectsToRegion(
242
xRectanglePtr /*prect*/,
245
extern Bool miSubtract(
250
extern Bool miInverse(
251
RegionPtr /*newReg*/,
256
RegionPtr /*region*/,
259
extern void miTranslateRegion(
264
extern void miRegionReset(
268
extern Bool miRegionBreak(
271
extern Bool miPointInRegion(
277
extern Bool miRegionEqual(
279
RegionPtr /*pReg2*/);
281
extern Bool miRegionNotEmpty(
284
extern void miRegionEmpty(
287
extern BoxPtr miRegionExtents(
290
extern void miPrintRegion(
293
#endif /* REGIONSTRUCT_H */