1 /* $TOG: miwideline.h /main/12 1998/02/09 14:49:26 kaleb $ */
4 Copyright 1988, 1998 The Open Group
8 The above copyright notice and this permission notice shall be included
9 in all copies or substantial portions of the Software.
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
15 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
17 OTHER DEALINGS IN THE SOFTWARE.
19 Except as contained in this notice, the name of The Open Group shall
20 not be used in advertising or otherwise to promote the sale, use or
21 other dealings in this Software without prior written authorization
25 /* $XFree86: xc/programs/Xserver/mi/miwideline.h,v 1.7 1998/10/04 09:39:35 dawes Exp $ */
27 /* Author: Keith Packard, MIT X Consortium */
30 #define MI_WIDELINE_H 1
35 * interface data to span-merging polygon filler
38 typedef struct _SpanData {
39 SpanGroup fgGroup, bgGroup;
40 } SpanDataRec, *SpanDataPtr;
42 #define AppendSpanGroup(pGC, pixel, spanPtr, spanData) { \
43 SpanGroup *group, *othergroup = NULL; \
44 if (pixel->pixel == GDK_GC_FBDATA(pGC)->values.foreground.pixel) \
46 group = &spanData->fgGroup; \
47 if (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_DOUBLE_DASH) \
48 othergroup = &spanData->bgGroup; \
52 group = &spanData->bgGroup; \
53 othergroup = &spanData->fgGroup; \
55 miAppendSpans (group, othergroup, spanPtr); \
59 * Polygon edge description for integer wide-line routines
62 typedef struct _PolyEdge {
63 int height; /* number of scanlines to process */
64 int x; /* starting x coordinate */
65 int stepx; /* fixed integral dx */
66 int signdx; /* variable dx sign */
67 int e; /* initial error term */
70 } PolyEdgeRec, *PolyEdgePtr;
72 #define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - miter limit constant */
75 * types for general polygon routines
78 typedef struct _PolyVertex {
80 } PolyVertexRec, *PolyVertexPtr;
82 typedef struct _PolySlope {
84 double k; /* x0 * dy - y0 * dx */
85 } PolySlopeRec, *PolySlopePtr;
88 * Line face description for caps/joins
91 typedef struct _LineFace {
96 } LineFaceRec, *LineFacePtr;
99 * macros for polygon fillers
102 #define MIPOLYRELOADLEFT if (!left_height && left_count) { \
103 left_height = left->height; \
105 left_stepx = left->stepx; \
106 left_signdx = left->signdx; \
108 left_dy = left->dy; \
109 left_dx = left->dx; \
114 #define MIPOLYRELOADRIGHT if (!right_height && right_count) { \
115 right_height = right->height; \
116 right_x = right->x; \
117 right_stepx = right->stepx; \
118 right_signdx = right->signdx; \
119 right_e = right->e; \
120 right_dy = right->dy; \
121 right_dx = right->dx; \
126 #define MIPOLYSTEPLEFT left_x += left_stepx; \
130 left_x += left_signdx; \
134 #define MIPOLYSTEPRIGHT right_x += right_stepx; \
135 right_e += right_dx; \
138 right_x += right_signdx; \
139 right_e -= right_dy; \
142 #define MILINESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
143 oldPixel = GDK_GC_FBDATA(pGC)->values.foreground; \
144 if (pixel->pixel != oldPixel.pixel) { \
145 gdk_gc_set_foreground(pGC, pixel); \
148 #define MILINERESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
149 if (pixel->pixel != oldPixel.pixel) { \
150 gdk_gc_set_foreground(pGC, &oldPixel); \
156 #define ICEIL(x) ((int)ceil(x))
160 static __inline int ICEIL(x)
164 return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp+1;
167 #define ICEIL(x) ((((x) == (_cTmp = (x))) || ((x) < 0.0)) ? _cTmp : _cTmp+1)
168 #define ICEILTEMPDECL static int _cTmp;
173 extern void miFillPolyHelper(
174 #if NeedFunctionPrototypes
175 GdkDrawable* /*pDrawable*/,
177 GdkColor * /*pixel*/,
178 SpanDataPtr /*spanData*/,
180 int /*overall_height*/,
181 PolyEdgePtr /*left*/,
182 PolyEdgePtr /*right*/,
187 extern int miRoundJoinFace(
188 #if NeedFunctionPrototypes
189 LineFacePtr /*face*/,
190 PolyEdgePtr /*edge*/,
191 gboolean * /*leftEdge*/
195 extern void miRoundJoinClip(
196 #if NeedFunctionPrototypes
197 LineFacePtr /*pLeft*/,
198 LineFacePtr /*pRight*/,
199 PolyEdgePtr /*edge1*/,
200 PolyEdgePtr /*edge2*/,
203 gboolean * /*left1*/,
208 extern int miRoundCapClip(
209 #if NeedFunctionPrototypes
210 LineFacePtr /*face*/,
212 PolyEdgePtr /*edge*/,
213 gboolean * /*leftEdge*/
217 extern void miLineProjectingCap(
218 #if NeedFunctionPrototypes
219 GdkDrawable* /*pDrawable*/,
221 GdkColor * /*pixel*/,
222 SpanDataPtr /*spanData*/,
223 LineFacePtr /*face*/,
231 extern SpanDataPtr miSetupSpanData(
232 #if NeedFunctionPrototypes
234 SpanDataPtr /*spanData*/,
239 extern void miCleanupSpanData(
240 #if NeedFunctionPrototypes
241 GdkDrawable* /*pDrawable*/,
243 SpanDataPtr /*spanData*/
247 extern int miPolyBuildEdge(double x0, double y0, double k, int dx, int dy,
248 int xi, int yi, int left, PolyEdgePtr edge);
249 extern int miPolyBuildPoly(PolyVertexPtr vertices, PolySlopePtr slopes,
250 int count, int xi, int yi, PolyEdgePtr left,
251 PolyEdgePtr right, int *pnleft, int *pnright,