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