1 | /* $Xorg: miwideline.h,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
|
---|
2 | /*
|
---|
3 |
|
---|
4 | Copyright 1988, 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
|
---|
13 | in all copies or substantial portions of the Software.
|
---|
14 |
|
---|
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
16 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
---|
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
---|
18 | IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
19 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
20 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
21 | OTHER DEALINGS IN THE SOFTWARE.
|
---|
22 |
|
---|
23 | Except as contained in this notice, the name of The Open Group shall
|
---|
24 | not be used in advertising or otherwise to promote the sale, use or
|
---|
25 | other dealings in this Software without prior written authorization
|
---|
26 | from The Open Group.
|
---|
27 |
|
---|
28 | */
|
---|
29 | /* $XFree86: xc/programs/Xserver/mi/miwideline.h,v 1.11 2001/10/25 12:03:47 alanh Exp $ */
|
---|
30 |
|
---|
31 | /* Author: Keith Packard, MIT X Consortium */
|
---|
32 |
|
---|
33 | #include "mispans.h"
|
---|
34 | #include "mifpoly.h" /* for ICEIL */
|
---|
35 |
|
---|
36 | /*
|
---|
37 | * interface data to span-merging polygon filler
|
---|
38 | */
|
---|
39 |
|
---|
40 | typedef struct _SpanData {
|
---|
41 | SpanGroup fgGroup, bgGroup;
|
---|
42 | } SpanDataRec, *SpanDataPtr;
|
---|
43 |
|
---|
44 | #define AppendSpanGroup(pGC, pixel, spanPtr, spanData) { \
|
---|
45 | SpanGroup *group, *othergroup = NULL; \
|
---|
46 | if (pixel == pGC->fgPixel) \
|
---|
47 | { \
|
---|
48 | group = &spanData->fgGroup; \
|
---|
49 | if (pGC->lineStyle == LineDoubleDash) \
|
---|
50 | othergroup = &spanData->bgGroup; \
|
---|
51 | } \
|
---|
52 | else \
|
---|
53 | { \
|
---|
54 | group = &spanData->bgGroup; \
|
---|
55 | othergroup = &spanData->fgGroup; \
|
---|
56 | } \
|
---|
57 | miAppendSpans (group, othergroup, spanPtr); \
|
---|
58 | }
|
---|
59 |
|
---|
60 | /*
|
---|
61 | * Polygon edge description for integer wide-line routines
|
---|
62 | */
|
---|
63 |
|
---|
64 | typedef struct _PolyEdge {
|
---|
65 | int height; /* number of scanlines to process */
|
---|
66 | int x; /* starting x coordinate */
|
---|
67 | int stepx; /* fixed integral dx */
|
---|
68 | int signdx; /* variable dx sign */
|
---|
69 | int e; /* initial error term */
|
---|
70 | int dy;
|
---|
71 | int dx;
|
---|
72 | } PolyEdgeRec, *PolyEdgePtr;
|
---|
73 |
|
---|
74 | #define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - miter limit constant */
|
---|
75 |
|
---|
76 | /*
|
---|
77 | * types for general polygon routines
|
---|
78 | */
|
---|
79 |
|
---|
80 | typedef struct _PolyVertex {
|
---|
81 | double x, y;
|
---|
82 | } PolyVertexRec, *PolyVertexPtr;
|
---|
83 |
|
---|
84 | typedef struct _PolySlope {
|
---|
85 | int dx, dy;
|
---|
86 | double k; /* x0 * dy - y0 * dx */
|
---|
87 | } PolySlopeRec, *PolySlopePtr;
|
---|
88 |
|
---|
89 | /*
|
---|
90 | * Line face description for caps/joins
|
---|
91 | */
|
---|
92 |
|
---|
93 | typedef struct _LineFace {
|
---|
94 | double xa, ya;
|
---|
95 | int dx, dy;
|
---|
96 | int x, y;
|
---|
97 | double k;
|
---|
98 | } LineFaceRec, *LineFacePtr;
|
---|
99 |
|
---|
100 | /*
|
---|
101 | * macros for polygon fillers
|
---|
102 | */
|
---|
103 |
|
---|
104 | #define MIPOLYRELOADLEFT if (!left_height && left_count) { \
|
---|
105 | left_height = left->height; \
|
---|
106 | left_x = left->x; \
|
---|
107 | left_stepx = left->stepx; \
|
---|
108 | left_signdx = left->signdx; \
|
---|
109 | left_e = left->e; \
|
---|
110 | left_dy = left->dy; \
|
---|
111 | left_dx = left->dx; \
|
---|
112 | --left_count; \
|
---|
113 | ++left; \
|
---|
114 | }
|
---|
115 |
|
---|
116 | #define MIPOLYRELOADRIGHT if (!right_height && right_count) { \
|
---|
117 | right_height = right->height; \
|
---|
118 | right_x = right->x; \
|
---|
119 | right_stepx = right->stepx; \
|
---|
120 | right_signdx = right->signdx; \
|
---|
121 | right_e = right->e; \
|
---|
122 | right_dy = right->dy; \
|
---|
123 | right_dx = right->dx; \
|
---|
124 | --right_count; \
|
---|
125 | ++right; \
|
---|
126 | }
|
---|
127 |
|
---|
128 | #define MIPOLYSTEPLEFT left_x += left_stepx; \
|
---|
129 | left_e += left_dx; \
|
---|
130 | if (left_e > 0) \
|
---|
131 | { \
|
---|
132 | left_x += left_signdx; \
|
---|
133 | left_e -= left_dy; \
|
---|
134 | }
|
---|
135 |
|
---|
136 | #define MIPOLYSTEPRIGHT right_x += right_stepx; \
|
---|
137 | right_e += right_dx; \
|
---|
138 | if (right_e > 0) \
|
---|
139 | { \
|
---|
140 | right_x += right_signdx; \
|
---|
141 | right_e -= right_dy; \
|
---|
142 | }
|
---|
143 |
|
---|
144 | #define MILINESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
|
---|
145 | oldPixel = pGC->fgPixel; \
|
---|
146 | if (pixel != oldPixel) { \
|
---|
147 | DoChangeGC (pGC, GCForeground, (XID *) &pixel, FALSE); \
|
---|
148 | ValidateGC (pDrawable, pGC); \
|
---|
149 | } \
|
---|
150 | }
|
---|
151 | #define MILINERESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
|
---|
152 | if (pixel != oldPixel) { \
|
---|
153 | DoChangeGC (pGC, GCForeground, (XID *) &oldPixel, FALSE); \
|
---|
154 | ValidateGC (pDrawable, pGC); \
|
---|
155 | } \
|
---|
156 | }
|
---|
157 |
|
---|
158 | extern void miFillPolyHelper(
|
---|
159 | DrawablePtr /*pDrawable*/,
|
---|
160 | GCPtr /*pGC*/,
|
---|
161 | unsigned long /*pixel*/,
|
---|
162 | SpanDataPtr /*spanData*/,
|
---|
163 | int /*y*/,
|
---|
164 | int /*overall_height*/,
|
---|
165 | PolyEdgePtr /*left*/,
|
---|
166 | PolyEdgePtr /*right*/,
|
---|
167 | int /*left_count*/,
|
---|
168 | int /*right_count*/
|
---|
169 | );
|
---|
170 | extern int miRoundJoinFace(
|
---|
171 | LineFacePtr /*face*/,
|
---|
172 | PolyEdgePtr /*edge*/,
|
---|
173 | Bool * /*leftEdge*/
|
---|
174 | );
|
---|
175 |
|
---|
176 | extern void miRoundJoinClip(
|
---|
177 | LineFacePtr /*pLeft*/,
|
---|
178 | LineFacePtr /*pRight*/,
|
---|
179 | PolyEdgePtr /*edge1*/,
|
---|
180 | PolyEdgePtr /*edge2*/,
|
---|
181 | int * /*y1*/,
|
---|
182 | int * /*y2*/,
|
---|
183 | Bool * /*left1*/,
|
---|
184 | Bool * /*left2*/
|
---|
185 | );
|
---|
186 |
|
---|
187 | extern int miRoundCapClip(
|
---|
188 | LineFacePtr /*face*/,
|
---|
189 | Bool /*isInt*/,
|
---|
190 | PolyEdgePtr /*edge*/,
|
---|
191 | Bool * /*leftEdge*/
|
---|
192 | );
|
---|
193 |
|
---|
194 | extern void miLineProjectingCap(
|
---|
195 | DrawablePtr /*pDrawable*/,
|
---|
196 | GCPtr /*pGC*/,
|
---|
197 | unsigned long /*pixel*/,
|
---|
198 | SpanDataPtr /*spanData*/,
|
---|
199 | LineFacePtr /*face*/,
|
---|
200 | Bool /*isLeft*/,
|
---|
201 | double /*xorg*/,
|
---|
202 | double /*yorg*/,
|
---|
203 | Bool /*isInt*/
|
---|
204 | );
|
---|
205 |
|
---|
206 | extern SpanDataPtr miSetupSpanData(
|
---|
207 | GCPtr /*pGC*/,
|
---|
208 | SpanDataPtr /*spanData*/,
|
---|
209 | int /*npt*/
|
---|
210 | );
|
---|
211 |
|
---|
212 | extern void miCleanupSpanData(
|
---|
213 | DrawablePtr /*pDrawable*/,
|
---|
214 | GCPtr /*pGC*/,
|
---|
215 | SpanDataPtr /*spanData*/
|
---|
216 | );
|
---|
217 |
|
---|
218 | extern int miPolyBuildEdge(double x0, double y0, double k, int dx, int dy,
|
---|
219 | int xi, int yi, int left, PolyEdgePtr edge);
|
---|
220 | extern int miPolyBuildPoly(PolyVertexPtr vertices, PolySlopePtr slopes,
|
---|
221 | int count, int xi, int yi, PolyEdgePtr left,
|
---|
222 | PolyEdgePtr right, int *pnleft, int *pnright,
|
---|
223 | int *h);
|
---|
224 |
|
---|