jpayne@69
|
1 /************************************************************************
|
jpayne@69
|
2
|
jpayne@69
|
3 Copyright 1987, 1998 The Open Group
|
jpayne@69
|
4
|
jpayne@69
|
5 Permission to use, copy, modify, distribute, and sell this software and its
|
jpayne@69
|
6 documentation for any purpose is hereby granted without fee, provided that
|
jpayne@69
|
7 the above copyright notice appear in all copies and that both that
|
jpayne@69
|
8 copyright notice and this permission notice appear in supporting
|
jpayne@69
|
9 documentation.
|
jpayne@69
|
10
|
jpayne@69
|
11 The above copyright notice and this permission notice shall be included in
|
jpayne@69
|
12 all copies or substantial portions of the Software.
|
jpayne@69
|
13
|
jpayne@69
|
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
jpayne@69
|
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
jpayne@69
|
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
jpayne@69
|
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
jpayne@69
|
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
jpayne@69
|
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
jpayne@69
|
20
|
jpayne@69
|
21 Except as contained in this notice, the name of The Open Group shall not be
|
jpayne@69
|
22 used in advertising or otherwise to promote the sale, use or other dealings
|
jpayne@69
|
23 in this Software without prior written authorization from The Open Group.
|
jpayne@69
|
24
|
jpayne@69
|
25
|
jpayne@69
|
26 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
jpayne@69
|
27
|
jpayne@69
|
28 All Rights Reserved
|
jpayne@69
|
29
|
jpayne@69
|
30 Permission to use, copy, modify, and distribute this software and its
|
jpayne@69
|
31 documentation for any purpose and without fee is hereby granted,
|
jpayne@69
|
32 provided that the above copyright notice appear in all copies and that
|
jpayne@69
|
33 both that copyright notice and this permission notice appear in
|
jpayne@69
|
34 supporting documentation, and that the name of Digital not be
|
jpayne@69
|
35 used in advertising or publicity pertaining to distribution of the
|
jpayne@69
|
36 software without specific, written prior permission.
|
jpayne@69
|
37
|
jpayne@69
|
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
jpayne@69
|
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
jpayne@69
|
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
jpayne@69
|
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
jpayne@69
|
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
jpayne@69
|
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
jpayne@69
|
44 SOFTWARE.
|
jpayne@69
|
45
|
jpayne@69
|
46 ************************************************************************/
|
jpayne@69
|
47
|
jpayne@69
|
48 #ifndef _X11_XREGION_H_
|
jpayne@69
|
49 #define _X11_XREGION_H_
|
jpayne@69
|
50
|
jpayne@69
|
51 typedef struct {
|
jpayne@69
|
52 short x1, x2, y1, y2;
|
jpayne@69
|
53 } Box, BOX, BoxRec, *BoxPtr;
|
jpayne@69
|
54
|
jpayne@69
|
55 typedef struct {
|
jpayne@69
|
56 short x, y, width, height;
|
jpayne@69
|
57 }RECTANGLE, RectangleRec, *RectanglePtr;
|
jpayne@69
|
58
|
jpayne@69
|
59 #define TRUE 1
|
jpayne@69
|
60 #define FALSE 0
|
jpayne@69
|
61 #define MAXSHORT 32767
|
jpayne@69
|
62 #define MINSHORT -MAXSHORT
|
jpayne@69
|
63 #ifndef MAX
|
jpayne@69
|
64 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
jpayne@69
|
65 #endif
|
jpayne@69
|
66 #ifndef MIN
|
jpayne@69
|
67 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
jpayne@69
|
68 #endif
|
jpayne@69
|
69
|
jpayne@69
|
70
|
jpayne@69
|
71 /*
|
jpayne@69
|
72 * clip region
|
jpayne@69
|
73 */
|
jpayne@69
|
74
|
jpayne@69
|
75 typedef struct _XRegion {
|
jpayne@69
|
76 long size;
|
jpayne@69
|
77 long numRects;
|
jpayne@69
|
78 BOX *rects;
|
jpayne@69
|
79 BOX extents;
|
jpayne@69
|
80 } REGION;
|
jpayne@69
|
81
|
jpayne@69
|
82 /* Xutil.h contains the declaration:
|
jpayne@69
|
83 * typedef struct _XRegion *Region;
|
jpayne@69
|
84 */
|
jpayne@69
|
85
|
jpayne@69
|
86 /* 1 if two BOXs overlap.
|
jpayne@69
|
87 * 0 if two BOXs do not overlap.
|
jpayne@69
|
88 * Remember, x2 and y2 are not in the region
|
jpayne@69
|
89 */
|
jpayne@69
|
90 #define EXTENTCHECK(r1, r2) \
|
jpayne@69
|
91 ((r1)->x2 > (r2)->x1 && \
|
jpayne@69
|
92 (r1)->x1 < (r2)->x2 && \
|
jpayne@69
|
93 (r1)->y2 > (r2)->y1 && \
|
jpayne@69
|
94 (r1)->y1 < (r2)->y2)
|
jpayne@69
|
95
|
jpayne@69
|
96 /*
|
jpayne@69
|
97 * update region extents
|
jpayne@69
|
98 */
|
jpayne@69
|
99 #define EXTENTS(r,idRect){\
|
jpayne@69
|
100 if((r)->x1 < (idRect)->extents.x1)\
|
jpayne@69
|
101 (idRect)->extents.x1 = (r)->x1;\
|
jpayne@69
|
102 if((r)->y1 < (idRect)->extents.y1)\
|
jpayne@69
|
103 (idRect)->extents.y1 = (r)->y1;\
|
jpayne@69
|
104 if((r)->x2 > (idRect)->extents.x2)\
|
jpayne@69
|
105 (idRect)->extents.x2 = (r)->x2;\
|
jpayne@69
|
106 if((r)->y2 > (idRect)->extents.y2)\
|
jpayne@69
|
107 (idRect)->extents.y2 = (r)->y2;\
|
jpayne@69
|
108 }
|
jpayne@69
|
109
|
jpayne@69
|
110 /*
|
jpayne@69
|
111 * Check to see if there is enough memory in the present region.
|
jpayne@69
|
112 */
|
jpayne@69
|
113 #define MEMCHECK(reg, rect, firstrect){\
|
jpayne@69
|
114 if ((reg)->numRects >= ((reg)->size - 1)){\
|
jpayne@69
|
115 BoxPtr tmpRect = Xrealloc ((firstrect), \
|
jpayne@69
|
116 (2 * (sizeof(BOX)) * ((reg)->size))); \
|
jpayne@69
|
117 if (tmpRect == NULL) \
|
jpayne@69
|
118 return(0);\
|
jpayne@69
|
119 (firstrect) = tmpRect; \
|
jpayne@69
|
120 (reg)->size *= 2;\
|
jpayne@69
|
121 (rect) = &(firstrect)[(reg)->numRects];\
|
jpayne@69
|
122 }\
|
jpayne@69
|
123 }
|
jpayne@69
|
124
|
jpayne@69
|
125 /* this routine checks to see if the previous rectangle is the same
|
jpayne@69
|
126 * or subsumes the new rectangle to add.
|
jpayne@69
|
127 */
|
jpayne@69
|
128
|
jpayne@69
|
129 #define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
|
jpayne@69
|
130 (!(((Reg)->numRects > 0)&&\
|
jpayne@69
|
131 ((R-1)->y1 == (Ry1)) &&\
|
jpayne@69
|
132 ((R-1)->y2 == (Ry2)) &&\
|
jpayne@69
|
133 ((R-1)->x1 <= (Rx1)) &&\
|
jpayne@69
|
134 ((R-1)->x2 >= (Rx2))))
|
jpayne@69
|
135
|
jpayne@69
|
136 /* add a rectangle to the given Region */
|
jpayne@69
|
137 #define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
|
jpayne@69
|
138 if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
|
jpayne@69
|
139 CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
|
jpayne@69
|
140 (r)->x1 = (rx1);\
|
jpayne@69
|
141 (r)->y1 = (ry1);\
|
jpayne@69
|
142 (r)->x2 = (rx2);\
|
jpayne@69
|
143 (r)->y2 = (ry2);\
|
jpayne@69
|
144 EXTENTS((r), (reg));\
|
jpayne@69
|
145 (reg)->numRects++;\
|
jpayne@69
|
146 (r)++;\
|
jpayne@69
|
147 }\
|
jpayne@69
|
148 }
|
jpayne@69
|
149
|
jpayne@69
|
150
|
jpayne@69
|
151
|
jpayne@69
|
152 /* add a rectangle to the given Region */
|
jpayne@69
|
153 #define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
|
jpayne@69
|
154 if ((rx1 < rx2) && (ry1 < ry2) &&\
|
jpayne@69
|
155 CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
|
jpayne@69
|
156 (r)->x1 = (rx1);\
|
jpayne@69
|
157 (r)->y1 = (ry1);\
|
jpayne@69
|
158 (r)->x2 = (rx2);\
|
jpayne@69
|
159 (r)->y2 = (ry2);\
|
jpayne@69
|
160 (reg)->numRects++;\
|
jpayne@69
|
161 (r)++;\
|
jpayne@69
|
162 }\
|
jpayne@69
|
163 }
|
jpayne@69
|
164
|
jpayne@69
|
165 #define EMPTY_REGION(pReg) pReg->numRects = 0
|
jpayne@69
|
166
|
jpayne@69
|
167 #define REGION_NOT_EMPTY(pReg) pReg->numRects
|
jpayne@69
|
168
|
jpayne@69
|
169 #define INBOX(r, x, y) \
|
jpayne@69
|
170 ( ( ((r).x2 > x)) && \
|
jpayne@69
|
171 ( ((r).x1 <= x)) && \
|
jpayne@69
|
172 ( ((r).y2 > y)) && \
|
jpayne@69
|
173 ( ((r).y1 <= y)) )
|
jpayne@69
|
174
|
jpayne@69
|
175 /*
|
jpayne@69
|
176 * number of points to buffer before sending them off
|
jpayne@69
|
177 * to scanlines() : Must be an even number
|
jpayne@69
|
178 */
|
jpayne@69
|
179 #define NUMPTSTOBUFFER 200
|
jpayne@69
|
180
|
jpayne@69
|
181 /*
|
jpayne@69
|
182 * used to allocate buffers for points and link
|
jpayne@69
|
183 * the buffers together
|
jpayne@69
|
184 */
|
jpayne@69
|
185 typedef struct _POINTBLOCK {
|
jpayne@69
|
186 XPoint pts[NUMPTSTOBUFFER];
|
jpayne@69
|
187 struct _POINTBLOCK *next;
|
jpayne@69
|
188 } POINTBLOCK;
|
jpayne@69
|
189
|
jpayne@69
|
190 #endif /* _X11_XREGION_H_ */
|