~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to lib/include/region.h

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2008-08-15 21:21:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080815212140-05fhxj8wroosysmj
Tags: 2008.08.08-109361-1ubuntu1
* Merge from Debian unstable (LP: #258393), remaining Ubuntu change:
  - add ubuntu_toolchain_FTBFS.dpatch patch, fix FTBFS
* Update ubuntu_toolchain_FTBFS.dpatch patch for the new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* **********************************************************
 
2
 * Copyright (C) 2002 VMware, Inc.
 
3
 * All Rights Reserved
 
4
 * **********************************************************/
 
5
 
 
6
/* $Xorg: regionstr.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
 
7
/***********************************************************
 
8
 
 
9
Copyright 1987, 1998  The Open Group
 
10
 
 
11
Permission to use, copy, modify, distribute, and sell this software and its
 
12
documentation for any purpose is hereby granted without fee, provided that
 
13
the above copyright notice appear in all copies and that both that
 
14
copyright notice and this permission notice appear in supporting
 
15
documentation.
 
16
 
 
17
The above copyright notice and this permission notice shall be included in
 
18
all copies or substantial portions of the Software.
 
19
 
 
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
21
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
22
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
23
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
24
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
25
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
26
 
 
27
Except as contained in this notice, the name of The Open Group shall not be
 
28
used in advertising or otherwise to promote the sale, use or other dealings
 
29
in this Software without prior written authorization from The Open Group.
 
30
 
 
31
 
 
32
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
33
 
 
34
                        All Rights Reserved
 
35
 
 
36
Permission to use, copy, modify, and distribute this software and its
 
37
documentation for any purpose and without fee is hereby granted,
 
38
provided that the above copyright notice appear in all copies and that
 
39
both that copyright notice and this permission notice appear in
 
40
supporting documentation, and that the name of Digital not be
 
41
used in advertising or publicity pertaining to distribution of the
 
42
software without specific, written prior permission.
 
43
 
 
44
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
45
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
46
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
47
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
48
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
49
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
50
SOFTWARE.
 
51
 
 
52
******************************************************************/
 
53
/* $XFree86: xc/programs/Xserver/include/regionstr.h,v 1.7 2001/12/14 19:59:56 dawes Exp $ */
 
54
 
 
55
/*
 
56
 * region.h --
 
57
 *
 
58
 *      Interface definition for miRegion operations. Originally from X11
 
59
 *      source distribution. This version includes modifications made for the
 
60
 *      VNC Reflector package.
 
61
 *
 
62
 * ChangeLog:
 
63
 *
 
64
 *      07/21/2003 rrdharan     - added miRegionArea function prototype
 
65
 *                              - added REGION_AREA wrapper macro
 
66
 *                              - added this header, removed whitespace
 
67
 *      08/02/2005 akan         - fixed conflicting definition of MINSHORT
 
68
 *                                and MAXSHORT with winnt.h
 
69
 *      04/03/2007 shelleygong  - use int instead of short for data
 
70
 *                                inside the region
 
71
 */
 
72
 
 
73
#ifndef __REGION_H__
 
74
#define __REGION_H__
 
75
 
 
76
#include "vmware.h"
 
77
 
 
78
#ifdef _WIN32
 
79
/*
 
80
 * lib/region has terrible short/long confusion problems.  For MSFT,
 
81
 * disable the warning.  See PR142264.
 
82
 */
 
83
#pragma warning( disable: 4242 )
 
84
#endif
 
85
 
 
86
/* Return values from RectIn() */
 
87
#define rgnOUT 0
 
88
#define rgnIN  1
 
89
#define rgnPART 2
 
90
 
 
91
#define NullBox ((BoxPtr)0)
 
92
#define NullRegion ((RegionPtr)0)
 
93
 
 
94
#define R_MAXSHORT 32767
 
95
#define R_MINSHORT (-R_MAXSHORT)
 
96
 
 
97
#define R_MAXINT 0x7FFFFFFF
 
98
#define R_MININT 0x8FFFFFFF
 
99
 
 
100
#define CT_YXBANDED 18
 
101
 
 
102
#define xalloc(n)        malloc(n)
 
103
#define xrealloc(ptr, n) realloc((ptr), (n))
 
104
#define xfree(ptr)       free(ptr)
 
105
 
 
106
typedef enum {
 
107
   UpdateRect,
 
108
   ROPFillRect,
 
109
   Present3dRect,
 
110
   MaxRect
 
111
} RectInfoType;
 
112
 
 
113
typedef struct RectInfo {
 
114
   RectInfoType type;
 
115
   union {
 
116
      struct {
 
117
         uint32 rop;
 
118
         uint32 color;
 
119
      } ROPFill;
 
120
      struct {
 
121
         uint32 sid;
 
122
         uint32 srcx, srcy;
 
123
      } Present3d;
 
124
      /* add more here, then update miRectInfosEqual and miPrintRegion. */
 
125
   };
 
126
} RectInfo, *RectInfoPtr;
 
127
 
 
128
#define RECTINFO_ISVALID(info) \
 
129
   ((info).type >= UpdateRect && (info).type < MaxRect)
 
130
 
 
131
/*
 
132
 * X data types
 
133
 */
 
134
 
 
135
typedef struct _Box {
 
136
   int x1, y1, x2, y2;
 
137
   RectInfo info;
 
138
} BoxRec, *BoxPtr;
 
139
 
 
140
typedef struct _xPoint {
 
141
    int x, y;
 
142
} xPoint, *xPointPtr;
 
143
 
 
144
typedef xPoint DDXPointRec, *DDXPointPtr;
 
145
 
 
146
typedef struct _xRectangle {
 
147
    int x, y;
 
148
    unsigned short width, height;
 
149
    RectInfo info;
 
150
} xRectangle, *xRectanglePtr;
 
151
 
 
152
/*
 
153
 *   clip region
 
154
 */
 
155
 
 
156
typedef struct _RegData {
 
157
    int         size;
 
158
    int         numRects;
 
159
/*  BoxRec      rects[size];   in memory but not explicitly declared */
 
160
} RegDataRec, *RegDataPtr;
 
161
 
 
162
typedef struct _Region {
 
163
    BoxRec      extents;
 
164
    RegDataPtr  data;
 
165
} RegionRec, *RegionPtr;
 
166
 
 
167
extern BoxRec miEmptyBox;
 
168
extern RegDataRec miEmptyData;
 
169
extern RegDataRec miBrokenData;
 
170
 
 
171
#define REGION_EXTENTS(reg) (&(reg)->extents)
 
172
#define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
 
173
#define REGION_NAR(reg) ((reg)->data == &miBrokenData)
 
174
#define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
 
175
#define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
 
176
#define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
 
177
                                       : &(reg)->extents)
 
178
#define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
 
179
#define REGION_BOX(reg,i) (&REGION_BOXPTR(reg)[i])
 
180
#define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
 
181
#define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
 
182
#define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
 
183
 
 
184
#define REGION_VALIDINDEX(reg, i) (i >= 0 && i < REGION_NUM_RECTS((reg)))
 
185
 
 
186
#define RECT_SETBOX(r, rx, ry, rw, rh) do { \
 
187
  (r)->x1 = (rx); \
 
188
  (r)->x2 = (rx) + (rw); \
 
189
  (r)->y1 = (ry); \
 
190
  (r)->y2 = (ry) + (rh); \
 
191
  (r)->info.type = UpdateRect; \
 
192
} while (FALSE)
 
193
 
 
194
#define RECT_SETRECT(r, rx1, ry1, rx2, ry2) do { \
 
195
  RECT_SETBOX((r), (rx1), (ry1), ((rx2) - (rx1)), ((ry2) - (ry1))); \
 
196
} while (FALSE)
 
197
 
 
198
/*
 
199
 * This will only work if the intersection is not empty.
 
200
 */
 
201
#define RECT_INTERSECT(r, r1, r2) \
 
202
{ \
 
203
   (r)->x1 = MAX((r1)->x1, (r2)->x1); \
 
204
   (r)->x2 = MIN((r1)->x2, (r2)->x2); \
 
205
   (r)->y1 = MAX((r1)->y1, (r2)->y1); \
 
206
   (r)->y2 = MIN((r1)->y2, (r2)->y2); \
 
207
}
 
208
 
 
209
/*
 
210
 *  True iff the two boxes overlap.
 
211
 */
 
212
#define RECT_EXTENTCHECK(r1, r2) \
 
213
   (!( ((r1)->x2 <= (r2)->x1)  || \
 
214
       ((r1)->x1 >= (r2)->x2)  || \
 
215
       ((r1)->y2 <= (r2)->y1)  || \
 
216
       ((r1)->y1 >= (r2)->y2) ) )
 
217
 
 
218
/*
 
219
 * True iff both the BoxRecs are identical.
 
220
 */
 
221
#define RECT_IDENTICAL(r1, r2) \
 
222
   (( ((r1)->x1 == (r2)->x1)  && \
 
223
      ((r1)->x2 == (r2)->x2)  && \
 
224
      ((r1)->y1 == (r2)->y1)  && \
 
225
      ((r1)->y2 == (r2)->y2) ) )
 
226
 
 
227
 
 
228
extern RegionPtr miRegionCreate(BoxPtr rect, int size);
 
229
extern void miRegionInit(RegionPtr pReg, BoxPtr rect, int size);
 
230
extern void miRegionDestroy(RegionPtr pReg);
 
231
extern void miRegionUninit(RegionPtr pReg);
 
232
extern Bool miRegionCopy(RegionPtr dst, RegionPtr src);
 
233
extern Bool miIntersect(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2);
 
234
extern Bool miUnion(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2);
 
235
extern Bool miRegionAppend(RegionPtr dstrgn, RegionPtr rgn);
 
236
extern Bool miRegionValidate(RegionPtr badreg, Bool *pOverlap);
 
237
extern RegionPtr miRectsToRegion(int nrects, xRectanglePtr prect, int ctype);
 
238
extern RegionPtr miRectsToRegionbyBoundary(int nrects, xRectanglePtr prect, int ctype,
 
239
                                           int minValue, int maxValue);
 
240
extern Bool miSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS);
 
241
extern Bool miInverse(RegionPtr newReg, RegionPtr reg1, BoxPtr invRect);
 
242
extern int miRectIn(RegionPtr region, BoxPtr prect);
 
243
extern void miTranslateRegion(RegionPtr pReg, int x, int y);
 
244
extern void miTranslateRegionByBoundary(RegionPtr pReg, int x, int y,
 
245
                                        int minValue, int maxValue);
 
246
extern void miRegionReset(RegionPtr pReg, BoxPtr pBox);
 
247
extern Bool miRegionBreak(RegionPtr pReg);
 
248
extern Bool miPointInRegion(RegionPtr pReg, int x, int y, BoxPtr box);
 
249
extern Bool miRegionNotEmpty(RegionPtr pReg);
 
250
extern void miRegionEmpty(RegionPtr pReg);
 
251
extern Bool miRegionsEqual(RegionPtr reg1, RegionPtr reg2);
 
252
extern BoxPtr miRegionExtents(RegionPtr pReg);
 
253
extern int miRegionArea(RegionPtr pReg);
 
254
extern void miRegionPack(RegionPtr pReg, int threshold);
 
255
 
 
256
extern Bool miApplyRect(RegionPtr newReg, RegionPtr reg, BoxPtr rect,
 
257
                        Bool (*op) (RegionPtr, RegionPtr, RegionPtr));
 
258
extern int miPrintRegion(RegionPtr rgn);
 
259
 
 
260
typedef Bool (*miRegionMatchFunc)(BoxPtr box, uintptr_t userData);
 
261
extern Bool miRegionMatch(RegionPtr newReg, RegionPtr reg,
 
262
                          miRegionMatchFunc match, uintptr_t userData);
 
263
 
 
264
// Extension to REGION_NIL that also checks for a 0 x 0 bounding rect.
 
265
extern Bool miIsRegionVoid(RegionPtr pReg);
 
266
 
 
267
#endif /* __REGION_H__ */