]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/include/regionstr.h
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / programs / Xserver / include / regionstr.h
1 /* $XConsortium: regionstr.h,v 1.8 94/04/17 20:26:01 dpw Exp $ */
2 /***********************************************************
3
4 Copyright (c) 1987  X Consortium
5
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:
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 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.
22
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.
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 #ifndef REGIONSTRUCT_H
50 #define REGIONSTRUCT_H
51
52 #include "miscstruct.h"
53
54 /* Return values from RectIn() */
55
56 #define rgnOUT 0
57 #define rgnIN  1
58 #define rgnPART 2
59
60 #define NullRegion ((RegionPtr)0)
61
62 /* 
63  *   clip region
64  */
65
66 typedef struct _RegData {
67     long        size;
68     long        numRects;
69 /*  BoxRec      rects[size];   in memory but not explicitly declared */
70 } RegDataRec, *RegDataPtr;
71
72 typedef struct _Region {
73     BoxRec      extents;
74     RegDataPtr  data;
75 } RegionRec, *RegionPtr;
76
77 extern BoxRec miEmptyBox;
78 extern RegDataRec miEmptyData;
79
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) \
84                                        : &(reg)->extents)
85 #define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
86 #define REGION_BOX(reg,i) (&REGION_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)))
90
91 #ifdef NEED_SCREEN_REGIONS
92
93 #define REGION_CREATE(_pScreen, _rect, _size) \
94     (*(_pScreen)->RegionCreate)(_rect, _size)
95
96 #define REGION_INIT(_pScreen, _pReg, _rect, _size) \
97     (*(_pScreen)->RegionInit)(_pReg, _rect, _size)
98
99 #define REGION_COPY(_pScreen, dst, src) \
100     (*(_pScreen)->RegionCopy)(dst, src)
101
102 #define REGION_DESTROY(_pScreen, _pReg) \
103     (*(_pScreen)->RegionDestroy)(_pReg)
104
105 #define REGION_UNINIT(_pScreen, _pReg) \
106     (*(_pScreen)->RegionUninit)(_pReg)
107
108 #define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
109     (*(_pScreen)->Intersect)(newReg, reg1, reg2)
110
111 #define REGION_UNION(_pScreen, newReg, reg1, reg2) \
112     (*(_pScreen)->Union)(newReg, reg1, reg2)
113
114 #define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
115     (*(_pScreen)->Subtract)(newReg, reg1, reg2)
116
117 #define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
118     (*(_pScreen)->Inverse)(newReg, reg1, invRect)
119
120 #define REGION_RESET(_pScreen, _pReg, _pBox) \
121     (*(_pScreen)->RegionReset)(_pReg, _pBox)
122
123 #define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
124     (*(_pScreen)->TranslateRegion)(_pReg, _x, _y)
125
126 #define RECT_IN_REGION(_pScreen, _pReg, prect) \
127     (*(_pScreen)->RectIn)(_pReg, prect)
128
129 #define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
130     (*(_pScreen)->PointInRegion)(_pReg, _x, _y, prect)
131
132 #define REGION_NOTEMPTY(_pScreen, _pReg) \
133     (*(_pScreen)->RegionNotEmpty)(_pReg)
134
135 #define REGION_EMPTY(_pScreen, _pReg) \
136     (*(_pScreen)->RegionEmpty)(_pReg)
137
138 #define REGION_EXTENTS(_pScreen, _pReg) \
139     (*(_pScreen)->RegionExtents)(_pReg)
140
141 #define REGION_APPEND(_pScreen, dstrgn, rgn) \
142     (*(_pScreen)->RegionAppend)(dstrgn, rgn)
143
144 #define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
145     (*(_pScreen)->RegionValidate)(badreg, pOverlap)
146
147 #define BITMAP_TO_REGION(_pScreen, pPix) \
148     (*(_pScreen)->BitmapToRegion)(pPix)
149
150 #define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
151     (*(_pScreen)->RectsToRegion)(nrects, prect, ctype)
152
153 #else /* !NEED_SCREEN_REGIONS */
154
155 #define REGION_CREATE(_pScreen, _rect, _size) \
156     miRegionCreate(_rect, _size)
157
158 #define REGION_COPY(_pScreen, dst, src) \
159     miRegionCopy(dst, src)
160
161 #define REGION_DESTROY(_pScreen, _pReg) \
162     miRegionDestroy(_pReg)
163
164 #define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
165     miIntersect(newReg, reg1, reg2)
166
167 #define REGION_UNION(_pScreen, newReg, reg1, reg2) \
168     miUnion(newReg, reg1, reg2)
169
170 #define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
171     miSubtract(newReg, reg1, reg2)
172
173 #define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
174     miInverse(newReg, reg1, invRect)
175
176 #define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
177     miTranslateRegion(_pReg, _x, _y)
178
179 #define RECT_IN_REGION(_pScreen, _pReg, prect) \
180     miRectIn(_pReg, prect)
181
182 #define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
183     miPointInRegion(_pReg, _x, _y, prect)
184
185 #define REGION_APPEND(_pScreen, dstrgn, rgn) \
186     miRegionAppend(dstrgn, rgn)
187
188 #define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
189     miRegionValidate(badreg, pOverlap)
190
191 #define BITMAP_TO_REGION(_pScreen, pPix) \
192     (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
193
194 #define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
195     miRectsToRegion(nrects, prect, ctype)
196
197 #ifdef DONT_INLINE_REGION_OPS
198
199 #define REGION_INIT(_pScreen, _pReg, _rect, _size) \
200     miRegionInit(_pReg, _rect, _size)
201
202 #define REGION_UNINIT(_pScreen, _pReg) \
203     miRegionUninit(_pReg)
204
205 #define REGION_RESET(_pScreen, _pReg, _pBox) \
206     miRegionReset(_pReg, _pBox)
207
208 #define REGION_NOTEMPTY(_pScreen, _pReg) \
209     miRegionNotEmpty(_pReg)
210
211 #define REGION_EMPTY(_pScreen, _pReg) \
212     miRegionEmpty(_pReg)
213
214 #define REGION_EXTENTS(_pScreen, _pReg) \
215     miRegionExtents(_pReg)
216
217 #else /* inline certain simple region ops for performance */
218
219 #define REGION_INIT(_pScreen, _pReg, _rect, _size) \
220 { \
221     if (_rect) \
222     { \
223         (_pReg)->extents = *(_rect); \
224         (_pReg)->data = (RegDataPtr)NULL; \
225     } \
226     else \
227     { \
228         (_pReg)->extents = miEmptyBox; \
229         if (((_size) > 1) && ((_pReg)->data = \
230                              (RegDataPtr)xalloc(REGION_SZOF(_size)))) \
231         { \
232             (_pReg)->data->size = (_size); \
233             (_pReg)->data->numRects = 0; \
234         } \
235         else \
236             (_pReg)->data = &miEmptyData; \
237     } \
238 }
239
240 #define REGION_UNINIT(_pScreen, _pReg) \
241 { \
242     if ((_pReg)->data && (_pReg)->data->size) xfree((_pReg)->data); \
243 }
244
245 #define REGION_RESET(_pScreen, _pReg, _pBox) \
246 { \
247     (_pReg)->extents = *(_pBox); \
248     REGION_UNINIT(_pScreen, _pReg); \
249     (_pReg)->data = (RegDataPtr)NULL; \
250 }
251
252 #define REGION_NOTEMPTY(_pScreen, _pReg) \
253     !REGION_NIL(_pReg)
254
255 #define REGION_EMPTY(_pScreen, _pReg) \
256 { \
257     REGION_UNINIT(_pScreen, _pReg); \
258     (_pReg)->extents.x2 = (_pReg)->extents.x1; \
259     (_pReg)->extents.y2 = (_pReg)->extents.y1; \
260     (_pReg)->data = &miEmptyData; \
261 }
262
263 #define REGION_EXTENTS(_pScreen, _pReg) \
264     &(_pReg)->extents
265
266 #endif /* DONT_INLINE_REGION_OPS */
267
268 #endif /* NEED_SCREEN_REGIONS */
269
270 /* moved from mi.h */
271
272 extern RegionPtr miRegionCreate(
273 #if NeedFunctionPrototypes
274     BoxPtr /*rect*/,
275     int /*size*/
276 #endif
277 );
278
279 extern void miRegionInit(
280 #if NeedFunctionPrototypes
281     RegionPtr /*pReg*/,
282     BoxPtr /*rect*/,
283     int /*size*/
284 #endif
285 );
286
287 extern void miRegionDestroy(
288 #if NeedFunctionPrototypes
289     RegionPtr /*pReg*/
290 #endif
291 );
292
293 extern void miRegionUninit(
294 #if NeedFunctionPrototypes
295     RegionPtr /*pReg*/
296 #endif
297 );
298
299 extern Bool miRegionCopy(
300 #if NeedFunctionPrototypes
301     RegionPtr /*dst*/,
302     RegionPtr /*src*/
303 #endif
304 );
305
306 extern Bool miIntersect(
307 #if NeedFunctionPrototypes
308     RegionPtr /*newReg*/,
309     RegionPtr /*reg1*/,
310     RegionPtr /*reg2*/
311 #endif
312 );
313
314 extern Bool miUnion(
315 #if NeedFunctionPrototypes
316     RegionPtr /*newReg*/,
317     RegionPtr /*reg1*/,
318     RegionPtr /*reg2*/
319 #endif
320 );
321
322 extern Bool miRegionAppend(
323 #if NeedFunctionPrototypes
324     RegionPtr /*dstrgn*/,
325     RegionPtr /*rgn*/
326 #endif
327 );
328
329 extern Bool miRegionValidate(
330 #if NeedFunctionPrototypes
331     RegionPtr /*badreg*/,
332     Bool * /*pOverlap*/
333 #endif
334 );
335
336 extern RegionPtr miRectsToRegion(
337 #if NeedFunctionPrototypes
338     int /*nrects*/,
339     xRectanglePtr /*prect*/,
340     int /*ctype*/
341 #endif
342 );
343
344 extern Bool miSubtract(
345 #if NeedFunctionPrototypes
346     RegionPtr /*regD*/,
347     RegionPtr /*regM*/,
348     RegionPtr /*regS*/
349 #endif
350 );
351
352 extern Bool miInverse(
353 #if NeedFunctionPrototypes
354     RegionPtr /*newReg*/,
355     RegionPtr /*reg1*/,
356     BoxPtr /*invRect*/
357 #endif
358 );
359
360 extern int miRectIn(
361 #if NeedFunctionPrototypes
362     RegionPtr /*region*/,
363     BoxPtr /*prect*/
364 #endif
365 );
366
367 extern void miTranslateRegion(
368 #if NeedFunctionPrototypes
369     RegionPtr /*pReg*/,
370     int /*x*/,
371     int /*y*/
372 #endif
373 );
374
375 extern void miRegionReset(
376 #if NeedFunctionPrototypes
377     RegionPtr /*pReg*/,
378     BoxPtr /*pBox*/
379 #endif
380 );
381
382 extern Bool miPointInRegion(
383 #if NeedFunctionPrototypes
384     RegionPtr /*pReg*/,
385     int /*x*/,
386     int /*y*/,
387     BoxPtr /*box*/
388 #endif
389 );
390
391 extern Bool miRegionNotEmpty(
392 #if NeedFunctionPrototypes
393     RegionPtr /*pReg*/
394 #endif
395 );
396
397 extern void miRegionEmpty(
398 #if NeedFunctionPrototypes
399     RegionPtr /*pReg*/
400 #endif
401 );
402
403 extern BoxPtr miRegionExtents(
404 #if NeedFunctionPrototypes
405     RegionPtr /*pReg*/
406 #endif
407 );
408
409 #endif /* REGIONSTRUCT_H */