3 Copyright 1988, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
29 /* Author: Keith Packard, MIT X Consortium */
32 #include "mifpoly.h" /* for ICEIL */
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 == pGC->fgPixel) \
46 group = &spanData->fgGroup; \
47 if (pGC->lineStyle == LineDoubleDash) \
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 = pGC->fgPixel; \
144 if (pixel != oldPixel) { \
145 DoChangeGC (pGC, GCForeground, (XID *) &pixel, FALSE); \
146 ValidateGC (pDrawable, pGC); \
149 #define MILINERESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
150 if (pixel != oldPixel) { \
151 DoChangeGC (pGC, GCForeground, (XID *) &oldPixel, FALSE); \
152 ValidateGC (pDrawable, pGC); \
156 extern void miRoundJoinClip(
157 LineFacePtr
/*pLeft*/,
158 LineFacePtr
/*pRight*/,
159 PolyEdgePtr
/*edge1*/,
160 PolyEdgePtr
/*edge2*/,
167 extern int miRoundCapClip(
168 LineFacePtr
/*face*/,
170 PolyEdgePtr
/*edge*/,
174 extern int miPolyBuildEdge(double x0
, double y0
, double k
, int dx
, int dy
,
175 int xi
, int yi
, int left
, PolyEdgePtr edge
);
176 extern int miPolyBuildPoly(PolyVertexPtr vertices
, PolySlopePtr slopes
,
177 int count
, int xi
, int yi
, PolyEdgePtr left
,
178 PolyEdgePtr right
, int *pnleft
, int *pnright
,