1 | /* $XFree86: xc/programs/Xserver/mi/mifillarc.h,v 3.6 2001/10/25 12:03:47 alanh Exp $ */
|
---|
2 | /************************************************************
|
---|
3 |
|
---|
4 | Copyright 1989, 1998 The Open Group
|
---|
5 |
|
---|
6 | Permission to use, copy, modify, distribute, and sell this software and its
|
---|
7 | documentation for any purpose is hereby granted without fee, provided that
|
---|
8 | the above copyright notice appear in all copies and that both that
|
---|
9 | copyright notice and this permission notice appear in supporting
|
---|
10 | documentation.
|
---|
11 |
|
---|
12 | The above copyright notice and this permission notice shall be included in
|
---|
13 | all copies or substantial portions of the Software.
|
---|
14 |
|
---|
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
18 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
19 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
21 |
|
---|
22 | Except as contained in this notice, the name of The Open Group shall not be
|
---|
23 | used in advertising or otherwise to promote the sale, use or other dealings
|
---|
24 | in this Software without prior written authorization from The Open Group.
|
---|
25 |
|
---|
26 | ********************************************************/
|
---|
27 |
|
---|
28 | /* $Xorg: mifillarc.h,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
|
---|
29 |
|
---|
30 | #ifndef __MIFILLARC_H__
|
---|
31 | #define __MIFILLARC_H__
|
---|
32 |
|
---|
33 | #define FULLCIRCLE (360 * 64)
|
---|
34 |
|
---|
35 | typedef struct _miFillArc {
|
---|
36 | int xorg, yorg;
|
---|
37 | int y;
|
---|
38 | int dx, dy;
|
---|
39 | int e;
|
---|
40 | int ym, yk, xm, xk;
|
---|
41 | } miFillArcRec;
|
---|
42 |
|
---|
43 | /* could use 64-bit integers */
|
---|
44 | typedef struct _miFillArcD {
|
---|
45 | int xorg, yorg;
|
---|
46 | int y;
|
---|
47 | int dx, dy;
|
---|
48 | double e;
|
---|
49 | double ym, yk, xm, xk;
|
---|
50 | } miFillArcDRec;
|
---|
51 |
|
---|
52 | #define miFillArcEmpty(arc) (!(arc)->angle2 || \
|
---|
53 | !(arc)->width || !(arc)->height || \
|
---|
54 | (((arc)->width == 1) && ((arc)->height & 1)))
|
---|
55 |
|
---|
56 | #define miCanFillArc(arc) (((arc)->width == (arc)->height) || \
|
---|
57 | (((arc)->width <= 800) && ((arc)->height <= 800)))
|
---|
58 |
|
---|
59 | #define MIFILLARCSETUP() \
|
---|
60 | x = 0; \
|
---|
61 | y = info.y; \
|
---|
62 | e = info.e; \
|
---|
63 | xk = info.xk; \
|
---|
64 | xm = info.xm; \
|
---|
65 | yk = info.yk; \
|
---|
66 | ym = info.ym; \
|
---|
67 | dx = info.dx; \
|
---|
68 | dy = info.dy; \
|
---|
69 | xorg = info.xorg; \
|
---|
70 | yorg = info.yorg
|
---|
71 |
|
---|
72 | #define MIFILLARCSTEP(slw) \
|
---|
73 | e += yk; \
|
---|
74 | while (e >= 0) \
|
---|
75 | { \
|
---|
76 | x++; \
|
---|
77 | xk -= xm; \
|
---|
78 | e += xk; \
|
---|
79 | } \
|
---|
80 | y--; \
|
---|
81 | yk -= ym; \
|
---|
82 | slw = (x << 1) + dx; \
|
---|
83 | if ((e == xk) && (slw > 1)) \
|
---|
84 | slw--
|
---|
85 |
|
---|
86 | #define MIFILLCIRCSTEP(slw) MIFILLARCSTEP(slw)
|
---|
87 | #define MIFILLELLSTEP(slw) MIFILLARCSTEP(slw)
|
---|
88 |
|
---|
89 | #define miFillArcLower(slw) (((y + dy) != 0) && ((slw > 1) || (e != xk)))
|
---|
90 |
|
---|
91 | typedef struct _miSliceEdge {
|
---|
92 | int x;
|
---|
93 | int stepx;
|
---|
94 | int deltax;
|
---|
95 | int e;
|
---|
96 | int dy;
|
---|
97 | int dx;
|
---|
98 | } miSliceEdgeRec, *miSliceEdgePtr;
|
---|
99 |
|
---|
100 | typedef struct _miArcSlice {
|
---|
101 | miSliceEdgeRec edge1, edge2;
|
---|
102 | int min_top_y, max_top_y;
|
---|
103 | int min_bot_y, max_bot_y;
|
---|
104 | Bool edge1_top, edge2_top;
|
---|
105 | Bool flip_top, flip_bot;
|
---|
106 | } miArcSliceRec;
|
---|
107 |
|
---|
108 | #define MIARCSLICESTEP(edge) \
|
---|
109 | edge.x -= edge.stepx; \
|
---|
110 | edge.e -= edge.dx; \
|
---|
111 | if (edge.e <= 0) \
|
---|
112 | { \
|
---|
113 | edge.x -= edge.deltax; \
|
---|
114 | edge.e += edge.dy; \
|
---|
115 | }
|
---|
116 |
|
---|
117 | #define miFillSliceUpper(slice) \
|
---|
118 | ((y >= slice.min_top_y) && (y <= slice.max_top_y))
|
---|
119 |
|
---|
120 | #define miFillSliceLower(slice) \
|
---|
121 | ((y >= slice.min_bot_y) && (y <= slice.max_bot_y))
|
---|
122 |
|
---|
123 | #define MIARCSLICEUPPER(xl,xr,slice,slw) \
|
---|
124 | xl = xorg - x; \
|
---|
125 | xr = xl + slw - 1; \
|
---|
126 | if (slice.edge1_top && (slice.edge1.x < xr)) \
|
---|
127 | xr = slice.edge1.x; \
|
---|
128 | if (slice.edge2_top && (slice.edge2.x > xl)) \
|
---|
129 | xl = slice.edge2.x;
|
---|
130 |
|
---|
131 | #define MIARCSLICELOWER(xl,xr,slice,slw) \
|
---|
132 | xl = xorg - x; \
|
---|
133 | xr = xl + slw - 1; \
|
---|
134 | if (!slice.edge1_top && (slice.edge1.x > xl)) \
|
---|
135 | xl = slice.edge1.x; \
|
---|
136 | if (!slice.edge2_top && (slice.edge2.x < xr)) \
|
---|
137 | xr = slice.edge2.x;
|
---|
138 |
|
---|
139 | #define MIWIDEARCSETUP(x,y,dy,slw,e,xk,xm,yk,ym) \
|
---|
140 | x = 0; \
|
---|
141 | y = slw >> 1; \
|
---|
142 | yk = y << 3; \
|
---|
143 | xm = 8; \
|
---|
144 | ym = 8; \
|
---|
145 | if (dy) \
|
---|
146 | { \
|
---|
147 | xk = 0; \
|
---|
148 | if (slw & 1) \
|
---|
149 | e = -1; \
|
---|
150 | else \
|
---|
151 | e = -(y << 2) - 2; \
|
---|
152 | } \
|
---|
153 | else \
|
---|
154 | { \
|
---|
155 | y++; \
|
---|
156 | yk += 4; \
|
---|
157 | xk = -4; \
|
---|
158 | if (slw & 1) \
|
---|
159 | e = -(y << 2) - 3; \
|
---|
160 | else \
|
---|
161 | e = - (y << 3); \
|
---|
162 | }
|
---|
163 |
|
---|
164 | #define MIFILLINARCSTEP(slw) \
|
---|
165 | ine += inyk; \
|
---|
166 | while (ine >= 0) \
|
---|
167 | { \
|
---|
168 | inx++; \
|
---|
169 | inxk -= inxm; \
|
---|
170 | ine += inxk; \
|
---|
171 | } \
|
---|
172 | iny--; \
|
---|
173 | inyk -= inym; \
|
---|
174 | slw = (inx << 1) + dx; \
|
---|
175 | if ((ine == inxk) && (slw > 1)) \
|
---|
176 | slw--
|
---|
177 |
|
---|
178 | #define miFillInArcLower(slw) (((iny + dy) != 0) && \
|
---|
179 | ((slw > 1) || (ine != inxk)))
|
---|
180 |
|
---|
181 | extern int miFreeArcCache(
|
---|
182 | pointer /*data*/,
|
---|
183 | XID /*id*/
|
---|
184 | );
|
---|
185 |
|
---|
186 | extern struct finalSpan *realAllocSpan(
|
---|
187 | void
|
---|
188 | );
|
---|
189 |
|
---|
190 | extern void miFillArcSetup(
|
---|
191 | xArc * /*arc*/,
|
---|
192 | miFillArcRec * /*info*/
|
---|
193 | );
|
---|
194 |
|
---|
195 | extern void miFillArcDSetup(
|
---|
196 | xArc * /*arc*/,
|
---|
197 | miFillArcDRec * /*info*/
|
---|
198 | );
|
---|
199 |
|
---|
200 | extern void miEllipseAngleToSlope(
|
---|
201 | int /*angle*/,
|
---|
202 | int /*width*/,
|
---|
203 | int /*height*/,
|
---|
204 | int * /*dxp*/,
|
---|
205 | int * /*dyp*/,
|
---|
206 | double * /*d_dxp*/,
|
---|
207 | double * /*d_dyp*/
|
---|
208 | );
|
---|
209 |
|
---|
210 | extern void miFillArcSliceSetup(
|
---|
211 | xArc * /*arc*/,
|
---|
212 | miArcSliceRec * /*slice*/,
|
---|
213 | GCPtr /*pGC*/
|
---|
214 | );
|
---|
215 |
|
---|
216 | #endif /* __MIFILLARC_H__ */
|
---|