1
/* $XdotOrg: xserver/xorg/include/regionstr.h,v 1.8 2006/03/28 00:18:31 ajax Exp $ */
2
/* $Xorg: regionstr.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
3
/***********************************************************
5
Copyright 1987, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
28
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
32
Permission to use, copy, modify, and distribute this software and its
33
documentation for any purpose and without fee is hereby granted,
34
provided that the above copyright notice appear in all copies and that
35
both that copyright notice and this permission notice appear in
36
supporting documentation, and that the name of Digital not be
37
used in advertising or publicity pertaining to distribution of the
38
software without specific, written prior permission.
40
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
48
******************************************************************/
49
/* $XFree86: xc/programs/Xserver/include/regionstr.h,v 1.12tsi Exp $ */
51
#ifndef REGIONSTRUCT_H
52
#define REGIONSTRUCT_H
54
typedef struct _Region RegionRec, *RegionPtr;
56
#include "miscstruct.h"
58
/* Return values from RectIn() */
64
#define NullRegion ((RegionPtr)0)
70
typedef struct _RegData {
73
/* BoxRec rects[size]; in memory but not explicitly declared */
74
} RegDataRec, *RegDataPtr;
81
extern BoxRec miEmptyBox;
82
extern RegDataRec miEmptyData;
83
extern RegDataRec miBrokenData;
85
#define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
87
#define REGION_NAR(reg) ((reg)->data == &miBrokenData)
88
#define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
89
#define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
90
#define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
92
#define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
93
#define REGION_BOX(reg,i) (®ION_BOXPTR(reg)[i])
94
#define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
95
#define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
96
#define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
98
#define REGION_CREATE(_pScreen, _rect, _size) \
99
miRegionCreate(_rect, _size)
101
#define REGION_COPY(_pScreen, dst, src) \
102
miRegionCopy(dst, src)
104
#define REGION_DESTROY(_pScreen, _pReg) \
105
miRegionDestroy(_pReg)
107
#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
108
miIntersect(newReg, reg1, reg2)
110
#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
111
miUnion(newReg, reg1, reg2)
113
#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
114
miSubtract(newReg, reg1, reg2)
116
#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
117
miInverse(newReg, reg1, invRect)
119
#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
120
miTranslateRegion(_pReg, _x, _y)
122
#define RECT_IN_REGION(_pScreen, _pReg, prect) \
123
miRectIn(_pReg, prect)
125
#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
126
miPointInRegion(_pReg, _x, _y, prect)
128
#define REGION_APPEND(_pScreen, dstrgn, rgn) \
129
miRegionAppend(dstrgn, rgn)
131
#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
132
miRegionValidate(badreg, pOverlap)
134
#define BITMAP_TO_REGION(_pScreen, pPix) \
135
(*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
137
#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
138
miRectsToRegion(nrects, prect, ctype)
140
#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
141
miRegionEqual(_pReg1, _pReg2)
143
#define REGION_BREAK(_pScreen, _pReg) \
146
#ifdef DONT_INLINE_REGION_OPS
148
#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
149
miRegionInit(_pReg, _rect, _size)
151
#define REGION_UNINIT(_pScreen, _pReg) \
152
miRegionUninit(_pReg)
154
#define REGION_RESET(_pScreen, _pReg, _pBox) \
155
miRegionReset(_pReg, _pBox)
157
#define REGION_NOTEMPTY(_pScreen, _pReg) \
158
miRegionNotEmpty(_pReg)
160
#define REGION_BROKEN(_pScreen, _pReg) \
161
miRegionBroken(_pReg)
163
#define REGION_EMPTY(_pScreen, _pReg) \
166
#define REGION_EXTENTS(_pScreen, _pReg) \
167
miRegionExtents(_pReg)
169
#else /* inline certain simple region ops for performance */
171
#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
175
(_pReg)->extents = *(_rect); \
176
(_pReg)->data = (RegDataPtr)NULL; \
180
(_pReg)->extents = miEmptyBox; \
181
if (((_size) > 1) && ((_pReg)->data = \
182
(RegDataPtr)xalloc(REGION_SZOF(_size)))) \
184
(_pReg)->data->size = (_size); \
185
(_pReg)->data->numRects = 0; \
188
(_pReg)->data = &miEmptyData; \
193
#define REGION_UNINIT(_pScreen, _pReg) \
195
if ((_pReg)->data && (_pReg)->data->size) { \
196
xfree((_pReg)->data); \
197
(_pReg)->data = NULL; \
201
#define REGION_RESET(_pScreen, _pReg, _pBox) \
203
(_pReg)->extents = *(_pBox); \
204
REGION_UNINIT(_pScreen, _pReg); \
205
(_pReg)->data = (RegDataPtr)NULL; \
208
#define REGION_NOTEMPTY(_pScreen, _pReg) \
211
#define REGION_BROKEN(_pScreen, _pReg) \
214
#define REGION_EMPTY(_pScreen, _pReg) \
216
REGION_UNINIT(_pScreen, _pReg); \
217
(_pReg)->extents.x2 = (_pReg)->extents.x1; \
218
(_pReg)->extents.y2 = (_pReg)->extents.y1; \
219
(_pReg)->data = &miEmptyData; \
222
#define REGION_EXTENTS(_pScreen, _pReg) \
225
#define REGION_NULL(_pScreen, _pReg) \
227
(_pReg)->extents = miEmptyBox; \
228
(_pReg)->data = &miEmptyData; \
231
#endif /* DONT_INLINE_REGION_OPS */
234
#define REGION_NULL(_pScreen, _pReg) \
235
REGION_INIT(_pScreen, _pReg, NullBox, 1)
238
/* moved from mi.h */
240
extern RegionPtr miRegionCreate(
244
extern void miRegionInit(
249
extern void miRegionDestroy(
252
extern void miRegionUninit(
255
extern Bool miRegionCopy(
259
extern Bool miIntersect(
260
RegionPtr /*newReg*/,
265
RegionPtr /*newReg*/,
269
extern Bool miRegionAppend(
270
RegionPtr /*dstrgn*/,
273
extern Bool miRegionValidate(
274
RegionPtr /*badreg*/,
275
Bool * /*pOverlap*/);
277
extern RegionPtr miRectsToRegion(
279
xRectanglePtr /*prect*/,
282
extern Bool miSubtract(
287
extern Bool miInverse(
288
RegionPtr /*newReg*/,
293
RegionPtr /*region*/,
296
extern void miTranslateRegion(
301
extern void miRegionReset(
305
extern Bool miRegionBreak(
308
extern Bool miPointInRegion(
314
extern Bool miRegionEqual(
316
RegionPtr /*pReg2*/);
318
extern Bool miRegionNotEmpty(
321
extern void miRegionEmpty(
324
extern BoxPtr miRegionExtents(
327
#endif /* REGIONSTRUCT_H */