1 /* $XConsortium: miwideline.h,v 1.11 94/04/17 20:28:02 dpw Exp $ */
4 Copyright (c) 1988 X Consortium
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of the X Consortium shall
26 not be used in advertising or otherwise to promote the sale, use or
27 other dealings in this Software without prior written authorization
28 from the X Consortium.
32 /* Author: Keith Packard, MIT X Consortium */
37 * interface data to span-merging polygon filler
40 typedef struct _SpanData {
41 SpanGroup fgGroup, bgGroup;
42 } SpanDataRec, *SpanDataPtr;
44 #define AppendSpanGroup(pGC, pixel, spanPtr, spanData) { \
45 SpanGroup *group, *othergroup = NULL; \
46 if (pixel == pGC->fgPixel) \
48 group = &spanData->fgGroup; \
49 if (pGC->lineStyle == LineDoubleDash) \
50 othergroup = &spanData->bgGroup; \
54 group = &spanData->bgGroup; \
55 othergroup = &spanData->fgGroup; \
57 miAppendSpans (group, othergroup, spanPtr); \
61 * Polygon edge description for integer wide-line routines
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 */
72 } PolyEdgeRec, *PolyEdgePtr;
74 #define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - miter limit constant */
77 * types for general polygon routines
80 typedef struct _PolyVertex {
82 } PolyVertexRec, *PolyVertexPtr;
84 typedef struct _PolySlope {
86 double k; /* x0 * dy - y0 * dx */
87 } PolySlopeRec, *PolySlopePtr;
90 * Line face description for caps/joins
93 typedef struct _LineFace {
98 } LineFaceRec, *LineFacePtr;
101 * macros for polygon fillers
104 #define MIPOLYRELOADLEFT if (!left_height && left_count) { \
105 left_height = left->height; \
107 left_stepx = left->stepx; \
108 left_signdx = left->signdx; \
110 left_dy = left->dy; \
111 left_dx = left->dx; \
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; \
128 #define MIPOLYSTEPLEFT left_x += left_stepx; \
132 left_x += left_signdx; \
136 #define MIPOLYSTEPRIGHT right_x += right_stepx; \
137 right_e += right_dx; \
140 right_x += right_signdx; \
141 right_e -= right_dy; \
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); \
151 #define MILINERESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
152 if (pixel != oldPixel) { \
153 DoChangeGC (pGC, GCForeground, (XID *) &oldPixel, FALSE); \
154 ValidateGC (pDrawable, pGC); \
159 #define ICEIL(x) ((int)ceil(x))
162 static __inline int ICEIL(x)
166 return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp+1;
169 #define ICEIL(x) ((((x) == (_cTmp = (x))) || ((x) < 0.0)) ? _cTmp : _cTmp+1)
170 #define ICEILTEMPDECL static int _cTmp;
174 extern void miFillPolyHelper(
175 #if NeedFunctionPrototypes
176 DrawablePtr /*pDrawable*/,
178 unsigned long /*pixel*/,
179 SpanDataPtr /*spanData*/,
181 int /*overall_height*/,
182 PolyEdgePtr /*left*/,
183 PolyEdgePtr /*right*/,
188 extern int miRoundJoinFace(
189 #if NeedFunctionPrototypes
190 LineFacePtr /*face*/,
191 PolyEdgePtr /*edge*/,
196 extern void miRoundJoinClip(
197 #if NeedFunctionPrototypes
198 LineFacePtr /*pLeft*/,
199 LineFacePtr /*pRight*/,
200 PolyEdgePtr /*edge1*/,
201 PolyEdgePtr /*edge2*/,
209 extern int miRoundCapClip(
210 #if NeedFunctionPrototypes
211 LineFacePtr /*face*/,
213 PolyEdgePtr /*edge*/,
218 extern void miLineProjectingCap(
219 #if NeedFunctionPrototypes
220 DrawablePtr /*pDrawable*/,
222 unsigned long /*pixel*/,
223 SpanDataPtr /*spanData*/,
224 LineFacePtr /*face*/,
232 extern SpanDataPtr miSetupSpanData(
233 #if NeedFunctionPrototypes
235 SpanDataPtr /*spanData*/,
240 extern void miCleanupSpanData(
241 #if NeedFunctionPrototypes
242 DrawablePtr /*pDrawable*/,
244 SpanDataPtr /*spanData*/