VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.14.0/regionstr.h@ 75410

Last change on this file since 75410 was 45134, checked in by vboxsync, 12 years ago

Additions/X11: build vboxvideo_drv.so for X.Org Server 1.14.

  • Property svn:eol-style set to native
File size: 10.4 KB
Line 
1/***********************************************************
2
3Copyright 1987, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
26
27 All Rights Reserved
28
29Permission to use, copy, modify, and distribute this software and its
30documentation for any purpose and without fee is hereby granted,
31provided that the above copyright notice appear in all copies and that
32both that copyright notice and this permission notice appear in
33supporting documentation, and that the name of Digital not be
34used in advertising or publicity pertaining to distribution of the
35software without specific, written prior permission.
36
37DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43SOFTWARE.
44
45******************************************************************/
46
47#ifndef REGIONSTRUCT_H
48#define REGIONSTRUCT_H
49
50typedef struct pixman_region16 RegionRec, *RegionPtr;
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
66typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
67
68extern _X_EXPORT BoxRec RegionEmptyBox;
69extern _X_EXPORT RegDataRec RegionEmptyData;
70extern _X_EXPORT RegDataRec RegionBrokenData;
71static inline Bool
72RegionNil(RegionPtr reg)
73{
74 return ((reg)->data && !(reg)->data->numRects);
75}
76
77/* not a region */
78
79static inline Bool
80RegionNar(RegionPtr reg)
81{
82 return ((reg)->data == &RegionBrokenData);
83}
84
85static inline int
86RegionNumRects(RegionPtr reg)
87{
88 return ((reg)->data ? (reg)->data->numRects : 1);
89}
90
91static inline int
92RegionSize(RegionPtr reg)
93{
94 return ((reg)->data ? (reg)->data->size : 0);
95}
96
97static inline BoxPtr
98RegionRects(RegionPtr reg)
99{
100 return ((reg)->data ? (BoxPtr) ((reg)->data + 1) : &(reg)->extents);
101}
102
103static inline BoxPtr
104RegionBoxptr(RegionPtr reg)
105{
106 return ((BoxPtr) ((reg)->data + 1));
107}
108
109static inline BoxPtr
110RegionBox(RegionPtr reg, int i)
111{
112 return (&RegionBoxptr(reg)[i]);
113}
114
115static inline BoxPtr
116RegionTop(RegionPtr reg)
117{
118 return RegionBox(reg, (reg)->data->numRects);
119}
120
121static inline BoxPtr
122RegionEnd(RegionPtr reg)
123{
124 return RegionBox(reg, (reg)->data->numRects - 1);
125}
126
127static inline size_t
128RegionSizeof(int n)
129{
130 return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
131}
132
133static inline void
134RegionInit(RegionPtr _pReg, BoxPtr _rect, int _size)
135{
136 if ((_rect) != NULL) {
137 (_pReg)->extents = *(_rect);
138 (_pReg)->data = (RegDataPtr) NULL;
139 }
140 else {
141 (_pReg)->extents = RegionEmptyBox;
142 if (((_size) > 1) && ((_pReg)->data =
143 (RegDataPtr) malloc(RegionSizeof(_size)))) {
144 (_pReg)->data->size = (_size);
145 (_pReg)->data->numRects = 0;
146 }
147 else
148 (_pReg)->data = &RegionEmptyData;
149 }
150}
151
152static inline Bool
153RegionInitBoxes(RegionPtr pReg, BoxPtr boxes, int nBoxes)
154{
155 return pixman_region_init_rects(pReg, boxes, nBoxes);
156}
157
158static inline void
159RegionUninit(RegionPtr _pReg)
160{
161 if ((_pReg)->data && (_pReg)->data->size) {
162 free((_pReg)->data);
163 (_pReg)->data = NULL;
164 }
165}
166
167static inline void
168RegionReset(RegionPtr _pReg, BoxPtr _pBox)
169{
170 (_pReg)->extents = *(_pBox);
171 RegionUninit(_pReg);
172 (_pReg)->data = (RegDataPtr) NULL;
173}
174
175static inline Bool
176RegionNotEmpty(RegionPtr _pReg)
177{
178 return !RegionNil(_pReg);
179}
180
181static inline Bool
182RegionBroken(RegionPtr _pReg)
183{
184 return RegionNar(_pReg);
185}
186
187static inline void
188RegionEmpty(RegionPtr _pReg)
189{
190 RegionUninit(_pReg);
191 (_pReg)->extents.x2 = (_pReg)->extents.x1;
192 (_pReg)->extents.y2 = (_pReg)->extents.y1;
193 (_pReg)->data = &RegionEmptyData;
194}
195
196static inline BoxPtr
197RegionExtents(RegionPtr _pReg)
198{
199 return (&(_pReg)->extents);
200}
201
202static inline void
203RegionNull(RegionPtr _pReg)
204{
205 (_pReg)->extents = RegionEmptyBox;
206 (_pReg)->data = &RegionEmptyData;
207}
208
209extern _X_EXPORT void InitRegions(void);
210
211extern _X_EXPORT RegionPtr RegionCreate(BoxPtr /*rect */ ,
212 int /*size */ );
213
214extern _X_EXPORT void RegionDestroy(RegionPtr /*pReg */ );
215
216static inline Bool
217RegionCopy(RegionPtr dst, RegionPtr src)
218{
219 return pixman_region_copy(dst, src);
220}
221
222static inline Bool
223RegionIntersect(RegionPtr newReg, /* destination Region */
224 RegionPtr reg1, RegionPtr reg2 /* source regions */
225 )
226{
227 return pixman_region_intersect(newReg, reg1, reg2);
228}
229
230static inline Bool
231RegionUnion(RegionPtr newReg, /* destination Region */
232 RegionPtr reg1, RegionPtr reg2 /* source regions */
233 )
234{
235 return pixman_region_union(newReg, reg1, reg2);
236}
237
238extern _X_EXPORT Bool RegionAppend(RegionPtr /*dstrgn */ ,
239 RegionPtr /*rgn */ );
240
241extern _X_EXPORT Bool RegionValidate(RegionPtr /*badreg */ ,
242 Bool * /*pOverlap */ );
243
244extern _X_EXPORT RegionPtr RegionFromRects(int /*nrects */ ,
245 xRectanglePtr /*prect */ ,
246 int /*ctype */ );
247
248/*-
249 *-----------------------------------------------------------------------
250 * Subtract --
251 * Subtract regS from regM and leave the result in regD.
252 * S stands for subtrahend, M for minuend and D for difference.
253 *
254 * Results:
255 * TRUE if successful.
256 *
257 * Side Effects:
258 * regD is overwritten.
259 *
260 *-----------------------------------------------------------------------
261 */
262static inline Bool
263RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
264{
265 return pixman_region_subtract(regD, regM, regS);
266}
267
268/*-
269 *-----------------------------------------------------------------------
270 * Inverse --
271 * Take a region and a box and return a region that is everything
272 * in the box but not in the region. The careful reader will note
273 * that this is the same as subtracting the region from the box...
274 *
275 * Results:
276 * TRUE.
277 *
278 * Side Effects:
279 * newReg is overwritten.
280 *
281 *-----------------------------------------------------------------------
282 */
283
284static inline Bool
285RegionInverse(RegionPtr newReg, /* Destination region */
286 RegionPtr reg1, /* Region to invert */
287 BoxPtr invRect /* Bounding box for inversion */
288 )
289{
290 return pixman_region_inverse(newReg, reg1, invRect);
291}
292
293static inline int
294RegionContainsRect(RegionPtr region, BoxPtr prect)
295{
296 return pixman_region_contains_rectangle(region, prect);
297}
298
299/* TranslateRegion(pReg, x, y)
300 translates in place
301*/
302
303static inline void
304RegionTranslate(RegionPtr pReg, int x, int y)
305{
306 pixman_region_translate(pReg, x, y);
307}
308
309extern _X_EXPORT Bool RegionBreak(RegionPtr /*pReg */ );
310
311static inline Bool
312RegionContainsPoint(RegionPtr pReg, int x, int y, BoxPtr box /* "return" value */
313 )
314{
315 return pixman_region_contains_point(pReg, x, y, box);
316}
317
318static inline Bool
319RegionEqual(RegionPtr reg1, RegionPtr reg2)
320{
321 return pixman_region_equal(reg1, reg2);
322}
323
324extern _X_EXPORT Bool RegionRectAlloc(RegionPtr /*pRgn */ ,
325 int /*n */
326 );
327
328#ifdef DEBUG
329extern _X_EXPORT Bool RegionIsValid(RegionPtr /*prgn */
330 );
331#endif
332
333extern _X_EXPORT void RegionPrint(RegionPtr /*pReg */ );
334
335#define INCLUDE_LEGACY_REGION_DEFINES
336#ifdef INCLUDE_LEGACY_REGION_DEFINES
337
338#define REGION_NIL RegionNil
339#define REGION_NAR RegionNar
340#define REGION_NUM_RECTS RegionNumRects
341#define REGION_SIZE RegionSize
342#define REGION_RECTS RegionRects
343#define REGION_BOXPTR RegionBoxptr
344#define REGION_BOX RegionBox
345#define REGION_TOP RegionTop
346#define REGION_END RegionEnd
347#define REGION_SZOF RegionSizeof
348#define BITMAP_TO_REGION BitmapToRegion
349#define REGION_CREATE(pScreen, r, s) RegionCreate(r,s)
350#define REGION_COPY(pScreen, d, r) RegionCopy(d, r)
351#define REGION_DESTROY(pScreen, r) RegionDestroy(r)
352#define REGION_INTERSECT(pScreen, res, r1, r2) RegionIntersect(res, r1, r2)
353#define REGION_UNION(pScreen, res, r1, r2) RegionUnion(res, r1, r2)
354#define REGION_SUBTRACT(pScreen, res, r1, r2) RegionSubtract(res, r1, r2)
355#define REGION_INVERSE(pScreen, n, r, b) RegionInverse(n, r, b)
356#define REGION_TRANSLATE(pScreen, r, x, y) RegionTranslate(r, x, y)
357#define RECT_IN_REGION(pScreen, r, b) RegionContainsRect(r, b)
358#define POINT_IN_REGION(pScreen, r, x, y, b) RegionContainsPoint(r, x, y, b)
359#define REGION_EQUAL(pScreen, r1, r2) RegionEqual(r1, r2)
360#define REGION_APPEND(pScreen, d, r) RegionAppend(d, r)
361#define REGION_VALIDATE(pScreen, r, o) RegionValidate(r, o)
362#define RECTS_TO_REGION(pScreen, n, r, c) RegionFromRects(n, r, c)
363#define REGION_BREAK(pScreen, r) RegionBreak(r)
364#define REGION_INIT(pScreen, r, b, s) RegionInit(r, b, s)
365#define REGION_UNINIT(pScreen, r) RegionUninit(r)
366#define REGION_RESET(pScreen, r, b) RegionReset(r, b)
367#define REGION_NOTEMPTY(pScreen, r) RegionNotEmpty(r)
368#define REGION_BROKEN(pScreen, r) RegionBroken(r)
369#define REGION_EMPTY(pScreen, r) RegionEmpty(r)
370#define REGION_EXTENTS(pScreen, r) RegionExtents(r)
371#define REGION_NULL(pScreen, r) RegionNull(r)
372
373#endif /* INCLUDE_LEGACY_REGION_DEFINES */
374#endif /* REGIONSTRUCT_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette