1 | /***********************************************************
|
---|
2 |
|
---|
3 | Copyright 1987, 1998 The Open Group
|
---|
4 |
|
---|
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
|
---|
9 | documentation.
|
---|
10 |
|
---|
11 | The above copyright notice and this permission notice shall be included in
|
---|
12 | all copies or substantial portions of the Software.
|
---|
13 |
|
---|
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.
|
---|
20 |
|
---|
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.
|
---|
24 |
|
---|
25 |
|
---|
26 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
---|
27 |
|
---|
28 | All Rights Reserved
|
---|
29 |
|
---|
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.
|
---|
37 |
|
---|
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
|
---|
44 | SOFTWARE.
|
---|
45 |
|
---|
46 | ******************************************************************/
|
---|
47 |
|
---|
48 | #ifndef REGIONSTRUCT_H
|
---|
49 | #define REGIONSTRUCT_H
|
---|
50 |
|
---|
51 | typedef struct _Region RegionRec, *RegionPtr;
|
---|
52 |
|
---|
53 | #include "miscstruct.h"
|
---|
54 |
|
---|
55 | /* Return values from RectIn() */
|
---|
56 |
|
---|
57 | #define rgnOUT 0
|
---|
58 | #define rgnIN 1
|
---|
59 | #define rgnPART 2
|
---|
60 |
|
---|
61 | #define NullRegion ((RegionPtr)0)
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * clip region
|
---|
65 | */
|
---|
66 |
|
---|
67 | typedef struct _RegData {
|
---|
68 | long size;
|
---|
69 | long numRects;
|
---|
70 | /* BoxRec rects[size]; in memory but not explicitly declared */
|
---|
71 | } RegDataRec, *RegDataPtr;
|
---|
72 |
|
---|
73 | struct _Region {
|
---|
74 | BoxRec extents;
|
---|
75 | RegDataPtr data;
|
---|
76 | };
|
---|
77 |
|
---|
78 | extern BoxRec miEmptyBox;
|
---|
79 | extern RegDataRec miEmptyData;
|
---|
80 | extern RegDataRec miBrokenData;
|
---|
81 |
|
---|
82 | #define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
|
---|
83 | /* not a region */
|
---|
84 | #define REGION_NAR(reg) ((reg)->data == &miBrokenData)
|
---|
85 | #define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
|
---|
86 | #define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
|
---|
87 | #define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
|
---|
88 | : &(reg)->extents)
|
---|
89 | #define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
|
---|
90 | #define REGION_BOX(reg,i) (®ION_BOXPTR(reg)[i])
|
---|
91 | #define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
|
---|
92 | #define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
|
---|
93 | #define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
|
---|
94 |
|
---|
95 | #define REGION_CREATE(_pScreen, _rect, _size) \
|
---|
96 | miRegionCreate(_rect, _size)
|
---|
97 |
|
---|
98 | #define REGION_COPY(_pScreen, dst, src) \
|
---|
99 | miRegionCopy(dst, src)
|
---|
100 |
|
---|
101 | #define REGION_DESTROY(_pScreen, _pReg) \
|
---|
102 | miRegionDestroy(_pReg)
|
---|
103 |
|
---|
104 | #define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
|
---|
105 | miIntersect(newReg, reg1, reg2)
|
---|
106 |
|
---|
107 | #define REGION_UNION(_pScreen, newReg, reg1, reg2) \
|
---|
108 | miUnion(newReg, reg1, reg2)
|
---|
109 |
|
---|
110 | #define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
|
---|
111 | miSubtract(newReg, reg1, reg2)
|
---|
112 |
|
---|
113 | #define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
|
---|
114 | miInverse(newReg, reg1, invRect)
|
---|
115 |
|
---|
116 | #define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
|
---|
117 | miTranslateRegion(_pReg, _x, _y)
|
---|
118 |
|
---|
119 | #define RECT_IN_REGION(_pScreen, _pReg, prect) \
|
---|
120 | miRectIn(_pReg, prect)
|
---|
121 |
|
---|
122 | #define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
|
---|
123 | miPointInRegion(_pReg, _x, _y, prect)
|
---|
124 |
|
---|
125 | #define REGION_APPEND(_pScreen, dstrgn, rgn) \
|
---|
126 | miRegionAppend(dstrgn, rgn)
|
---|
127 |
|
---|
128 | #define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
|
---|
129 | miRegionValidate(badreg, pOverlap)
|
---|
130 |
|
---|
131 | #define BITMAP_TO_REGION(_pScreen, pPix) \
|
---|
132 | (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
|
---|
133 |
|
---|
134 | #define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
|
---|
135 | miRectsToRegion(nrects, prect, ctype)
|
---|
136 |
|
---|
137 | #define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
|
---|
138 | miRegionEqual(_pReg1, _pReg2)
|
---|
139 |
|
---|
140 | #define REGION_BREAK(_pScreen, _pReg) \
|
---|
141 | miRegionBreak(_pReg)
|
---|
142 |
|
---|
143 | #ifdef DONT_INLINE_REGION_OPS
|
---|
144 |
|
---|
145 | #define REGION_INIT(_pScreen, _pReg, _rect, _size) \
|
---|
146 | miRegionInit(_pReg, _rect, _size)
|
---|
147 |
|
---|
148 | #define REGION_UNINIT(_pScreen, _pReg) \
|
---|
149 | miRegionUninit(_pReg)
|
---|
150 |
|
---|
151 | #define REGION_RESET(_pScreen, _pReg, _pBox) \
|
---|
152 | miRegionReset(_pReg, _pBox)
|
---|
153 |
|
---|
154 | #define REGION_NOTEMPTY(_pScreen, _pReg) \
|
---|
155 | miRegionNotEmpty(_pReg)
|
---|
156 |
|
---|
157 | #define REGION_BROKEN(_pScreen, _pReg) \
|
---|
158 | miRegionBroken(_pReg)
|
---|
159 |
|
---|
160 | #define REGION_EMPTY(_pScreen, _pReg) \
|
---|
161 | miRegionEmpty(_pReg)
|
---|
162 |
|
---|
163 | #define REGION_EXTENTS(_pScreen, _pReg) \
|
---|
164 | miRegionExtents(_pReg)
|
---|
165 |
|
---|
166 | #else /* inline certain simple region ops for performance */
|
---|
167 |
|
---|
168 | #define REGION_INIT(_pScreen, _pReg, _rect, _size) \
|
---|
169 | { \
|
---|
170 | if (_rect) \
|
---|
171 | { \
|
---|
172 | (_pReg)->extents = *(_rect); \
|
---|
173 | (_pReg)->data = (RegDataPtr)NULL; \
|
---|
174 | } \
|
---|
175 | else \
|
---|
176 | { \
|
---|
177 | (_pReg)->extents = miEmptyBox; \
|
---|
178 | if (((_size) > 1) && ((_pReg)->data = \
|
---|
179 | (RegDataPtr)xalloc(REGION_SZOF(_size)))) \
|
---|
180 | { \
|
---|
181 | (_pReg)->data->size = (_size); \
|
---|
182 | (_pReg)->data->numRects = 0; \
|
---|
183 | } \
|
---|
184 | else \
|
---|
185 | (_pReg)->data = &miEmptyData; \
|
---|
186 | } \
|
---|
187 | }
|
---|
188 |
|
---|
189 |
|
---|
190 | #define REGION_UNINIT(_pScreen, _pReg) \
|
---|
191 | { \
|
---|
192 | if ((_pReg)->data && (_pReg)->data->size) { \
|
---|
193 | xfree((_pReg)->data); \
|
---|
194 | (_pReg)->data = NULL; \
|
---|
195 | } \
|
---|
196 | }
|
---|
197 |
|
---|
198 | #define REGION_RESET(_pScreen, _pReg, _pBox) \
|
---|
199 | { \
|
---|
200 | (_pReg)->extents = *(_pBox); \
|
---|
201 | REGION_UNINIT(_pScreen, _pReg); \
|
---|
202 | (_pReg)->data = (RegDataPtr)NULL; \
|
---|
203 | }
|
---|
204 |
|
---|
205 | #define REGION_NOTEMPTY(_pScreen, _pReg) \
|
---|
206 | !REGION_NIL(_pReg)
|
---|
207 |
|
---|
208 | #define REGION_BROKEN(_pScreen, _pReg) \
|
---|
209 | REGION_NAR(_pReg)
|
---|
210 |
|
---|
211 | #define REGION_EMPTY(_pScreen, _pReg) \
|
---|
212 | { \
|
---|
213 | REGION_UNINIT(_pScreen, _pReg); \
|
---|
214 | (_pReg)->extents.x2 = (_pReg)->extents.x1; \
|
---|
215 | (_pReg)->extents.y2 = (_pReg)->extents.y1; \
|
---|
216 | (_pReg)->data = &miEmptyData; \
|
---|
217 | }
|
---|
218 |
|
---|
219 | #define REGION_EXTENTS(_pScreen, _pReg) \
|
---|
220 | (&(_pReg)->extents)
|
---|
221 |
|
---|
222 | #define REGION_NULL(_pScreen, _pReg) \
|
---|
223 | { \
|
---|
224 | (_pReg)->extents = miEmptyBox; \
|
---|
225 | (_pReg)->data = &miEmptyData; \
|
---|
226 | }
|
---|
227 |
|
---|
228 | #endif /* DONT_INLINE_REGION_OPS */
|
---|
229 |
|
---|
230 | #ifndef REGION_NULL
|
---|
231 | #define REGION_NULL(_pScreen, _pReg) \
|
---|
232 | REGION_INIT(_pScreen, _pReg, NullBox, 1)
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | /* moved from mi.h */
|
---|
236 |
|
---|
237 | extern RegionPtr miRegionCreate(
|
---|
238 | BoxPtr /*rect*/,
|
---|
239 | int /*size*/);
|
---|
240 |
|
---|
241 | extern void miRegionInit(
|
---|
242 | RegionPtr /*pReg*/,
|
---|
243 | BoxPtr /*rect*/,
|
---|
244 | int /*size*/);
|
---|
245 |
|
---|
246 | extern void miRegionDestroy(
|
---|
247 | RegionPtr /*pReg*/);
|
---|
248 |
|
---|
249 | extern void miRegionUninit(
|
---|
250 | RegionPtr /*pReg*/);
|
---|
251 |
|
---|
252 | extern Bool miRegionCopy(
|
---|
253 | RegionPtr /*dst*/,
|
---|
254 | RegionPtr /*src*/);
|
---|
255 |
|
---|
256 | extern Bool miIntersect(
|
---|
257 | RegionPtr /*newReg*/,
|
---|
258 | RegionPtr /*reg1*/,
|
---|
259 | RegionPtr /*reg2*/);
|
---|
260 |
|
---|
261 | extern Bool miUnion(
|
---|
262 | RegionPtr /*newReg*/,
|
---|
263 | RegionPtr /*reg1*/,
|
---|
264 | RegionPtr /*reg2*/);
|
---|
265 |
|
---|
266 | extern Bool miRegionAppend(
|
---|
267 | RegionPtr /*dstrgn*/,
|
---|
268 | RegionPtr /*rgn*/);
|
---|
269 |
|
---|
270 | extern Bool miRegionValidate(
|
---|
271 | RegionPtr /*badreg*/,
|
---|
272 | Bool * /*pOverlap*/);
|
---|
273 |
|
---|
274 | extern RegionPtr miRectsToRegion(
|
---|
275 | int /*nrects*/,
|
---|
276 | xRectanglePtr /*prect*/,
|
---|
277 | int /*ctype*/);
|
---|
278 |
|
---|
279 | extern Bool miSubtract(
|
---|
280 | RegionPtr /*regD*/,
|
---|
281 | RegionPtr /*regM*/,
|
---|
282 | RegionPtr /*regS*/);
|
---|
283 |
|
---|
284 | extern Bool miInverse(
|
---|
285 | RegionPtr /*newReg*/,
|
---|
286 | RegionPtr /*reg1*/,
|
---|
287 | BoxPtr /*invRect*/);
|
---|
288 |
|
---|
289 | extern int miRectIn(
|
---|
290 | RegionPtr /*region*/,
|
---|
291 | BoxPtr /*prect*/);
|
---|
292 |
|
---|
293 | extern void miTranslateRegion(
|
---|
294 | RegionPtr /*pReg*/,
|
---|
295 | int /*x*/,
|
---|
296 | int /*y*/);
|
---|
297 |
|
---|
298 | extern void miRegionReset(
|
---|
299 | RegionPtr /*pReg*/,
|
---|
300 | BoxPtr /*pBox*/);
|
---|
301 |
|
---|
302 | extern Bool miRegionBreak(
|
---|
303 | RegionPtr /*pReg*/);
|
---|
304 |
|
---|
305 | extern Bool miPointInRegion(
|
---|
306 | RegionPtr /*pReg*/,
|
---|
307 | int /*x*/,
|
---|
308 | int /*y*/,
|
---|
309 | BoxPtr /*box*/);
|
---|
310 |
|
---|
311 | extern Bool miRegionEqual(
|
---|
312 | RegionPtr /*pReg1*/,
|
---|
313 | RegionPtr /*pReg2*/);
|
---|
314 |
|
---|
315 | extern Bool miRegionNotEmpty(
|
---|
316 | RegionPtr /*pReg*/);
|
---|
317 |
|
---|
318 | extern void miRegionEmpty(
|
---|
319 | RegionPtr /*pReg*/);
|
---|
320 |
|
---|
321 | extern BoxPtr miRegionExtents(
|
---|
322 | RegionPtr /*pReg*/);
|
---|
323 |
|
---|
324 | #endif /* REGIONSTRUCT_H */
|
---|