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