1/* 2 3Copyright 1988, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included 12in all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20OTHER DEALINGS IN THE SOFTWARE. 21 22Except as contained in this notice, the name of The Open Group shall 23not be used in advertising or otherwise to promote the sale, use or 24other dealings in this Software without prior written authorization 25from The Open Group. 26 27*/ 28 29/* Author: Keith Packard, MIT X Consortium */ 30 31#include "mispans.h" 32#include "mifpoly.h" /* for ICEIL */ 33 34/* 35 * Polygon edge description for integer wide-line routines 36 */ 37 38typedef struct _PolyEdge { 39 int height; /* number of scanlines to process */ 40 int x; /* starting x coordinate */ 41 int stepx; /* fixed integral dx */ 42 int signdx; /* variable dx sign */ 43 int e; /* initial error term */ 44 int dy; 45 int dx; 46} PolyEdgeRec, *PolyEdgePtr; 47 48#define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - miter limit constant */ 49 50/* 51 * types for general polygon routines 52 */ 53 54typedef struct _PolyVertex { 55 double x, y; 56} PolyVertexRec, *PolyVertexPtr; 57 58typedef struct _PolySlope { 59 int dx, dy; 60 double k; /* x0 * dy - y0 * dx */ 61} PolySlopeRec, *PolySlopePtr; 62 63/* 64 * Line face description for caps/joins 65 */ 66 67typedef struct _LineFace { 68 double xa, ya; 69 int dx, dy; 70 int x, y; 71 double k; 72} LineFaceRec, *LineFacePtr; 73 74/* 75 * macros for polygon fillers 76 */ 77 78#define MILINESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \ 79 oldPixel = pGC->fgPixel; \ 80 if (pixel != oldPixel) { \ 81 ChangeGCVal gcval; \ 82 gcval.val = pixel; \ 83 ChangeGC (NullClient, pGC, GCForeground, &gcval); \ 84 ValidateGC (pDrawable, pGC); \ 85 } \ 86} 87#define MILINERESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \ 88 if (pixel != oldPixel) { \ 89 ChangeGCVal gcval; \ 90 gcval.val = oldPixel; \ 91 ChangeGC (NullClient, pGC, GCForeground, &gcval); \ 92 ValidateGC (pDrawable, pGC); \ 93 } \ 94} 95 96extern _X_EXPORT void miRoundJoinClip( 97 LineFacePtr /*pLeft*/, 98 LineFacePtr /*pRight*/, 99 PolyEdgePtr /*edge1*/, 100 PolyEdgePtr /*edge2*/, 101 int * /*y1*/, 102 int * /*y2*/, 103 Bool * /*left1*/, 104 Bool * /*left2*/ 105); 106 107extern _X_EXPORT int miRoundCapClip( 108 LineFacePtr /*face*/, 109 Bool /*isInt*/, 110 PolyEdgePtr /*edge*/, 111 Bool * /*leftEdge*/ 112); 113 114extern _X_EXPORT int miPolyBuildEdge(double x0, double y0, double k, int dx, int dy, 115 int xi, int yi, int left, PolyEdgePtr edge); 116extern _X_EXPORT int miPolyBuildPoly(PolyVertexPtr vertices, PolySlopePtr slopes, 117 int count, int xi, int yi, PolyEdgePtr left, 118 PolyEdgePtr right, int *pnleft, int *pnright, 119 int *h); 120 121