1 /* $XConsortium: regionstr.h,v 1.8 94/04/17 20:26:01 dpw Exp $ */
2 /***********************************************************
4 Copyright (c) 1987 X Consortium
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
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 X CONSORTIUM 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 X Consortium 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 X Consortium.
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 #ifndef REGIONSTRUCT_H
50 #define REGIONSTRUCT_H
52 #include "miscstruct.h"
54 /* Return values from RectIn() */
60 #define NullRegion ((RegionPtr)0)
66 typedef struct _RegData {
69 /* BoxRec rects[size]; in memory but not explicitly declared */
70 } RegDataRec, *RegDataPtr;
72 typedef struct _Region {
75 } RegionRec, *RegionPtr;
77 extern BoxRec miEmptyBox;
78 extern RegDataRec miEmptyData;
80 #define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
81 #define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
82 #define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
83 #define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
85 #define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
86 #define REGION_BOX(reg,i) (®ION_BOXPTR(reg)[i])
87 #define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
88 #define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
89 #define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
91 #ifdef NEED_SCREEN_REGIONS
93 #define REGION_CREATE(_pScreen, _rect, _size) \
94 (*(_pScreen)->RegionCreate)(_rect, _size)
96 #define REGION_INIT(_pScreen, _pReg, _rect, _size) \
97 (*(_pScreen)->RegionInit)(_pReg, _rect, _size)
99 #define REGION_COPY(_pScreen, dst, src) \
100 (*(_pScreen)->RegionCopy)(dst, src)
102 #define REGION_DESTROY(_pScreen, _pReg) \
103 (*(_pScreen)->RegionDestroy)(_pReg)
105 #define REGION_UNINIT(_pScreen, _pReg) \
106 (*(_pScreen)->RegionUninit)(_pReg)
108 #define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
109 (*(_pScreen)->Intersect)(newReg, reg1, reg2)
111 #define REGION_UNION(_pScreen, newReg, reg1, reg2) \
112 (*(_pScreen)->Union)(newReg, reg1, reg2)
114 #define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
115 (*(_pScreen)->Subtract)(newReg, reg1, reg2)
117 #define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
118 (*(_pScreen)->Inverse)(newReg, reg1, invRect)
120 #define REGION_RESET(_pScreen, _pReg, _pBox) \
121 (*(_pScreen)->RegionReset)(_pReg, _pBox)
123 #define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
124 (*(_pScreen)->TranslateRegion)(_pReg, _x, _y)
126 #define RECT_IN_REGION(_pScreen, _pReg, prect) \
127 (*(_pScreen)->RectIn)(_pReg, prect)
129 #define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
130 (*(_pScreen)->PointInRegion)(_pReg, _x, _y, prect)
132 #define REGION_NOTEMPTY(_pScreen, _pReg) \
133 (*(_pScreen)->RegionNotEmpty)(_pReg)
135 #define REGION_EMPTY(_pScreen, _pReg) \
136 (*(_pScreen)->RegionEmpty)(_pReg)
138 #define REGION_EXTENTS(_pScreen, _pReg) \
139 (*(_pScreen)->RegionExtents)(_pReg)
141 #define REGION_APPEND(_pScreen, dstrgn, rgn) \
142 (*(_pScreen)->RegionAppend)(dstrgn, rgn)
144 #define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
145 (*(_pScreen)->RegionValidate)(badreg, pOverlap)
147 #define BITMAP_TO_REGION(_pScreen, pPix) \
148 (*(_pScreen)->BitmapToRegion)(pPix)
150 #define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
151 (*(_pScreen)->RectsToRegion)(nrects, prect, ctype)
153 #else /* !NEED_SCREEN_REGIONS */
155 #define REGION_CREATE(_pScreen, _rect, _size) \
156 miRegionCreate(_rect, _size)
158 #define REGION_COPY(_pScreen, dst, src) \
159 miRegionCopy(dst, src)
161 #define REGION_DESTROY(_pScreen, _pReg) \
162 miRegionDestroy(_pReg)
164 #define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
165 miIntersect(newReg, reg1, reg2)
167 #define REGION_UNION(_pScreen, newReg, reg1, reg2) \
168 miUnion(newReg, reg1, reg2)
170 #define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
171 miSubtract(newReg, reg1, reg2)
173 #define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
174 miInverse(newReg, reg1, invRect)
176 #define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
177 miTranslateRegion(_pReg, _x, _y)
179 #define RECT_IN_REGION(_pScreen, _pReg, prect) \
180 miRectIn(_pReg, prect)
182 #define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
183 miPointInRegion(_pReg, _x, _y, prect)
185 #define REGION_APPEND(_pScreen, dstrgn, rgn) \
186 miRegionAppend(dstrgn, rgn)
188 #define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
189 miRegionValidate(badreg, pOverlap)
191 #define BITMAP_TO_REGION(_pScreen, pPix) \
192 (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
194 #define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
195 miRectsToRegion(nrects, prect, ctype)
197 #ifdef DONT_INLINE_REGION_OPS
199 #define REGION_INIT(_pScreen, _pReg, _rect, _size) \
200 miRegionInit(_pReg, _rect, _size)
202 #define REGION_UNINIT(_pScreen, _pReg) \
203 miRegionUninit(_pReg)
205 #define REGION_RESET(_pScreen, _pReg, _pBox) \
206 miRegionReset(_pReg, _pBox)
208 #define REGION_NOTEMPTY(_pScreen, _pReg) \
209 miRegionNotEmpty(_pReg)
211 #define REGION_EMPTY(_pScreen, _pReg) \
214 #define REGION_EXTENTS(_pScreen, _pReg) \
215 miRegionExtents(_pReg)
217 #else /* inline certain simple region ops for performance */
219 #define REGION_INIT(_pScreen, _pReg, _rect, _size) \
223 (_pReg)->extents = *(_rect); \
224 (_pReg)->data = (RegDataPtr)NULL; \
228 (_pReg)->extents = miEmptyBox; \
229 if (((_size) > 1) && ((_pReg)->data = \
230 (RegDataPtr)xalloc(REGION_SZOF(_size)))) \
232 (_pReg)->data->size = (_size); \
233 (_pReg)->data->numRects = 0; \
236 (_pReg)->data = &miEmptyData; \
240 #define REGION_UNINIT(_pScreen, _pReg) \
242 if ((_pReg)->data && (_pReg)->data->size) xfree((_pReg)->data); \
245 #define REGION_RESET(_pScreen, _pReg, _pBox) \
247 (_pReg)->extents = *(_pBox); \
248 REGION_UNINIT(_pScreen, _pReg); \
249 (_pReg)->data = (RegDataPtr)NULL; \
252 #define REGION_NOTEMPTY(_pScreen, _pReg) \
255 #define REGION_EMPTY(_pScreen, _pReg) \
257 REGION_UNINIT(_pScreen, _pReg); \
258 (_pReg)->extents.x2 = (_pReg)->extents.x1; \
259 (_pReg)->extents.y2 = (_pReg)->extents.y1; \
260 (_pReg)->data = &miEmptyData; \
263 #define REGION_EXTENTS(_pScreen, _pReg) \
266 #endif /* DONT_INLINE_REGION_OPS */
268 #endif /* NEED_SCREEN_REGIONS */
270 /* moved from mi.h */
272 extern RegionPtr miRegionCreate(
273 #if NeedFunctionPrototypes
279 extern void miRegionInit(
280 #if NeedFunctionPrototypes
287 extern void miRegionDestroy(
288 #if NeedFunctionPrototypes
293 extern void miRegionUninit(
294 #if NeedFunctionPrototypes
299 extern Bool miRegionCopy(
300 #if NeedFunctionPrototypes
306 extern Bool miIntersect(
307 #if NeedFunctionPrototypes
308 RegionPtr /*newReg*/,
315 #if NeedFunctionPrototypes
316 RegionPtr /*newReg*/,
322 extern Bool miRegionAppend(
323 #if NeedFunctionPrototypes
324 RegionPtr /*dstrgn*/,
329 extern Bool miRegionValidate(
330 #if NeedFunctionPrototypes
331 RegionPtr /*badreg*/,
336 extern RegionPtr miRectsToRegion(
337 #if NeedFunctionPrototypes
339 xRectanglePtr /*prect*/,
344 extern Bool miSubtract(
345 #if NeedFunctionPrototypes
352 extern Bool miInverse(
353 #if NeedFunctionPrototypes
354 RegionPtr /*newReg*/,
361 #if NeedFunctionPrototypes
362 RegionPtr /*region*/,
367 extern void miTranslateRegion(
368 #if NeedFunctionPrototypes
375 extern void miRegionReset(
376 #if NeedFunctionPrototypes
382 extern Bool miPointInRegion(
383 #if NeedFunctionPrototypes
391 extern Bool miRegionNotEmpty(
392 #if NeedFunctionPrototypes
397 extern void miRegionEmpty(
398 #if NeedFunctionPrototypes
403 extern BoxPtr miRegionExtents(
404 #if NeedFunctionPrototypes
409 #endif /* REGIONSTRUCT_H */