a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncCopyright 1988, 1998 The Open Group
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncdocumentation for any purpose is hereby granted without fee, provided that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncthe above copyright notice appear in all copies and that both that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynccopyright notice and this permission notice appear in supporting
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncdocumentation.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncThe above copyright notice and this permission notice shall be included
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncin all copies or substantial portions of the Software.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncOTHER DEALINGS IN THE SOFTWARE.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncExcept as contained in this notice, the name of The Open Group shall
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncnot be used in advertising or otherwise to promote the sale, use or
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncother dealings in this Software without prior written authorization
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncfrom The Open Group.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync*/
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Author: Keith Packard, MIT X Consortium */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include "mifpoly.h" /* for ICEIL */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Polygon edge description for integer wide-line routines
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct _PolyEdge {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int height; /* number of scanlines to process */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int x; /* starting x coordinate */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int stepx; /* fixed integral dx */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int signdx; /* variable dx sign */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int e; /* initial error term */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int dy;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int dx;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} PolyEdgeRec, *PolyEdgePtr;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - miter limit constant */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * types for general polygon routines
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct _PolyVertex {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync double x, y;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} PolyVertexRec, *PolyVertexPtr;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct _PolySlope {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int dx, dy;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync double k; /* x0 * dy - y0 * dx */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} PolySlopeRec, *PolySlopePtr;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Line face description for caps/joins
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct _LineFace {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync double xa, ya;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int dx, dy;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int x, y;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync double k;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} LineFaceRec, *LineFacePtr;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * macros for polygon fillers
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define MILINESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync oldPixel = pGC->fgPixel; \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync if (pixel != oldPixel) { \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ChangeGCVal gcval; \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync gcval.val = pixel; \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ChangeGC (NullClient, pGC, GCForeground, &gcval); \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ValidateGC (pDrawable, pGC); \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync } \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync}
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define MILINERESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync if (pixel != oldPixel) { \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ChangeGCVal gcval; \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync gcval.val = oldPixel; \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ChangeGC (NullClient, pGC, GCForeground, &gcval); \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ValidateGC (pDrawable, pGC); \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync } \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync}