]> Pileus Git - ~andy/gtk/blob - gdk/linux-fb/miwideline.h
Don't mangle sequences of consecutive \n or \r.
[~andy/gtk] / gdk / linux-fb / miwideline.h
1 /* $TOG: miwideline.h /main/12 1998/02/09 14:49:26 kaleb $ */
2 /*
3
4 Copyright 1988, 1998  The Open Group
5
6 All Rights Reserved.
7
8 The above copyright notice and this permission notice shall be included
9 in all copies or substantial portions of the Software.
10
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
15 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
17 OTHER DEALINGS IN THE SOFTWARE.
18
19 Except as contained in this notice, the name of The Open Group shall
20 not be used in advertising or otherwise to promote the sale, use or
21 other dealings in this Software without prior written authorization
22 from The Open Group.
23
24 */
25 /* $XFree86: xc/programs/Xserver/mi/miwideline.h,v 1.7 1998/10/04 09:39:35 dawes Exp $ */
26
27 /* Author:  Keith Packard, MIT X Consortium */
28
29 #ifndef MI_WIDELINE_H
30 #define MI_WIDELINE_H 1
31
32 #include "mispans.h"
33
34 /* 
35  * interface data to span-merging polygon filler
36  */
37
38 typedef struct _SpanData {
39     SpanGroup   fgGroup, bgGroup;
40 } SpanDataRec, *SpanDataPtr;
41
42 #define AppendSpanGroup(pGC, pixel, spanPtr, spanData) { \
43         SpanGroup   *group, *othergroup = NULL; \
44         if (pixel->pixel == GDK_GC_FBDATA(pGC)->values.foreground.pixel) \
45         { \
46             group = &spanData->fgGroup; \
47             if (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_DOUBLE_DASH) \
48                 othergroup = &spanData->bgGroup; \
49         } \
50         else \
51         { \
52             group = &spanData->bgGroup; \
53             othergroup = &spanData->fgGroup; \
54         } \
55         miAppendSpans (group, othergroup, spanPtr); \
56 }
57
58 /*
59  * Polygon edge description for integer wide-line routines
60  */
61
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 */
68     int     dy;
69     int     dx;
70 } PolyEdgeRec, *PolyEdgePtr;
71
72 #define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - miter limit constant */
73
74 /*
75  * types for general polygon routines
76  */
77
78 typedef struct _PolyVertex {
79     double  x, y;
80 } PolyVertexRec, *PolyVertexPtr;
81
82 typedef struct _PolySlope {
83     int     dx, dy;
84     double  k;      /* x0 * dy - y0 * dx */
85 } PolySlopeRec, *PolySlopePtr;
86
87 /*
88  * Line face description for caps/joins
89  */
90
91 typedef struct _LineFace {
92     double  xa, ya;
93     int     dx, dy;
94     int     x, y;
95     double  k;
96 } LineFaceRec, *LineFacePtr;
97
98 /*
99  * macros for polygon fillers
100  */
101
102 #define MIPOLYRELOADLEFT    if (!left_height && left_count) { \
103                                 left_height = left->height; \
104                                 left_x = left->x; \
105                                 left_stepx = left->stepx; \
106                                 left_signdx = left->signdx; \
107                                 left_e = left->e; \
108                                 left_dy = left->dy; \
109                                 left_dx = left->dx; \
110                                 --left_count; \
111                                 ++left; \
112                             }
113
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; \
122                                 --right_count; \
123                                 ++right; \
124                         }
125
126 #define MIPOLYSTEPLEFT  left_x += left_stepx; \
127                         left_e += left_dx; \
128                         if (left_e > 0) \
129                         { \
130                             left_x += left_signdx; \
131                             left_e -= left_dy; \
132                         }
133
134 #define MIPOLYSTEPRIGHT right_x += right_stepx; \
135                         right_e += right_dx; \
136                         if (right_e > 0) \
137                         { \
138                             right_x += right_signdx; \
139                             right_e -= right_dy; \
140                         }
141
142 #define MILINESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
143     oldPixel = GDK_GC_FBDATA(pGC)->values.foreground; \
144     if (pixel->pixel != oldPixel.pixel) { \
145         gdk_gc_set_foreground(pGC, pixel); \
146     } \
147 }
148 #define MILINERESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
149     if (pixel->pixel != oldPixel.pixel) { \
150         gdk_gc_set_foreground(pGC, &oldPixel); \
151     } \
152 }
153
154 #ifndef ICEIL
155 #ifdef NOINLINEICEIL
156 #define ICEIL(x) ((int)ceil(x))
157 #else
158 #ifdef __GNUC__
159 #define ICEIL ICIEL
160 static __inline int ICEIL(x)
161     double x;
162 {
163     int _cTmp = x;
164     return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp+1;
165 }
166 #else
167 #define ICEIL(x) ((((x) == (_cTmp = (x))) || ((x) < 0.0)) ? _cTmp : _cTmp+1)
168 #define ICEILTEMPDECL static int _cTmp;
169 #endif
170 #endif
171 #endif
172
173 extern void miFillPolyHelper(
174 #if NeedFunctionPrototypes
175     GdkDrawable* /*pDrawable*/,
176     GdkGC* /*pGC*/,
177     GdkColor * /*pixel*/,
178     SpanDataPtr /*spanData*/,
179     int /*y*/,
180     int /*overall_height*/,
181     PolyEdgePtr /*left*/,
182     PolyEdgePtr /*right*/,
183     int /*left_count*/,
184     int /*right_count*/
185 #endif
186 );
187 extern int miRoundJoinFace(
188 #if NeedFunctionPrototypes
189     LineFacePtr /*face*/,
190     PolyEdgePtr /*edge*/,
191     gboolean * /*leftEdge*/
192 #endif
193 );
194
195 extern void miRoundJoinClip(
196 #if NeedFunctionPrototypes
197     LineFacePtr /*pLeft*/,
198     LineFacePtr /*pRight*/,
199     PolyEdgePtr /*edge1*/,
200     PolyEdgePtr /*edge2*/,
201     int * /*y1*/,
202     int * /*y2*/,
203     gboolean * /*left1*/,
204     gboolean * /*left2*/
205 #endif
206 );
207
208 extern int miRoundCapClip(
209 #if NeedFunctionPrototypes
210     LineFacePtr /*face*/,
211     gboolean /*isInt*/,
212     PolyEdgePtr /*edge*/,
213     gboolean * /*leftEdge*/
214 #endif
215 );
216
217 extern void miLineProjectingCap(
218 #if NeedFunctionPrototypes
219     GdkDrawable* /*pDrawable*/,
220     GdkGC* /*pGC*/,
221     GdkColor * /*pixel*/,
222     SpanDataPtr /*spanData*/,
223     LineFacePtr /*face*/,
224     gboolean /*isLeft*/,
225     double /*xorg*/,
226     double /*yorg*/,
227     gboolean /*isInt*/
228 #endif
229 );
230
231 extern SpanDataPtr miSetupSpanData(
232 #if NeedFunctionPrototypes
233     GdkGC* /*pGC*/,
234     SpanDataPtr /*spanData*/,
235     int /*npt*/
236 #endif
237 );
238
239 extern void miCleanupSpanData(
240 #if NeedFunctionPrototypes
241     GdkDrawable* /*pDrawable*/,
242     GdkGC* /*pGC*/,
243     SpanDataPtr /*spanData*/
244 #endif
245 );
246
247 extern int miPolyBuildEdge(double x0, double y0, double k, int dx, int dy,
248                                 int xi, int yi, int left, PolyEdgePtr edge);
249 extern int miPolyBuildPoly(PolyVertexPtr vertices, PolySlopePtr slopes,
250                                 int count, int xi, int yi, PolyEdgePtr left,
251                                 PolyEdgePtr right, int *pnleft, int *pnright,
252                                 int *h);
253
254 #endif