/src/xpdf-4.04/splash/SplashXPath.h
Line | Count | Source (jump to first uncovered line) |
1 | | //======================================================================== |
2 | | // |
3 | | // SplashXPath.h |
4 | | // |
5 | | // Copyright 2003-2013 Glyph & Cog, LLC |
6 | | // |
7 | | //======================================================================== |
8 | | |
9 | | #ifndef SPLASHXPATH_H |
10 | | #define SPLASHXPATH_H |
11 | | |
12 | | #include <aconf.h> |
13 | | |
14 | | #ifdef USE_GCC_PRAGMAS |
15 | | #pragma interface |
16 | | #endif |
17 | | |
18 | | #include "SplashTypes.h" |
19 | | |
20 | | class SplashPath; |
21 | | struct SplashXPathPoint; |
22 | | struct SplashPathHint; |
23 | | |
24 | | //------------------------------------------------------------------------ |
25 | | |
26 | 0 | #define splashMaxCurveSplits (1 << 10) |
27 | | |
28 | | //------------------------------------------------------------------------ |
29 | | // SplashXPathSeg |
30 | | //------------------------------------------------------------------------ |
31 | | |
32 | | struct SplashXPathSeg { |
33 | | SplashCoord x0, y0; // first endpoint (y0 <= y1) |
34 | | SplashCoord x1, y1; // second endpoint |
35 | | SplashCoord dxdy; // slope: delta-x / delta-y |
36 | | SplashCoord dydx; // slope: delta-y / delta-x |
37 | | int count; // EO/NZWN counter increment |
38 | | |
39 | | //----- used by SplashXPathScanner |
40 | | int iy; |
41 | | SplashCoord sx0, sx1, mx; |
42 | | SplashXPathSeg *prev, *next; |
43 | | |
44 | | #if HAVE_STD_SORT |
45 | | |
46 | | static bool cmpMX(const SplashXPathSeg &s0, |
47 | 0 | const SplashXPathSeg &s1) { |
48 | 0 | if (s0.iy != s1.iy) { |
49 | 0 | return s0.iy < s1.iy; |
50 | 0 | } |
51 | 0 | return s0.mx < s1.mx; |
52 | 0 | } |
53 | | |
54 | | static bool cmpY(const SplashXPathSeg &seg0, |
55 | 0 | const SplashXPathSeg &seg1) { |
56 | 0 | return seg0.y0 < seg1.y0; |
57 | 0 | } |
58 | | |
59 | | #else |
60 | | |
61 | | static int cmpMX(const void *p0, const void *p1) { |
62 | | SplashXPathSeg *s0 = (SplashXPathSeg *)p0; |
63 | | SplashXPathSeg *s1 = (SplashXPathSeg *)p1; |
64 | | SplashCoord cmp; |
65 | | |
66 | | if (s0->iy != s1->iy) { |
67 | | return s0->iy - s1->iy; |
68 | | } |
69 | | cmp = s0->mx - s1->mx; |
70 | | return (cmp < 0) ? -1 : (cmp > 0) ? 1 : 0; |
71 | | } |
72 | | |
73 | | static int cmpY(const void *seg0, const void *seg1) { |
74 | | SplashCoord cmp; |
75 | | |
76 | | cmp = ((SplashXPathSeg *)seg0)->y0 |
77 | | - ((SplashXPathSeg *)seg1)->y0; |
78 | | return (cmp > 0) ? 1 : (cmp < 0) ? -1 : 0; |
79 | | } |
80 | | |
81 | | #endif |
82 | | }; |
83 | | |
84 | | //------------------------------------------------------------------------ |
85 | | // SplashXPath |
86 | | //------------------------------------------------------------------------ |
87 | | |
88 | | class SplashXPath { |
89 | | public: |
90 | | |
91 | | // Expands (converts to segments) and flattens (converts curves to |
92 | | // lines) <path>. Transforms all points from user space to device |
93 | | // space, via <matrix>. If <closeSubpaths> is true, closes all open |
94 | | // subpaths. |
95 | | SplashXPath(SplashPath *path, SplashCoord *matrix, |
96 | | SplashCoord flatness, GBool closeSubpaths, |
97 | | GBool simplify, SplashStrokeAdjustMode strokeAdjMode); |
98 | | |
99 | | // Copy an expanded path. |
100 | 0 | SplashXPath *copy() { return new SplashXPath(this); } |
101 | | |
102 | | ~SplashXPath(); |
103 | | |
104 | 0 | int getXMin() { return xMin; } |
105 | 0 | int getXMax() { return xMax; } |
106 | 0 | int getYMin() { return yMin; } |
107 | 0 | int getYMax() { return yMax; } |
108 | | |
109 | | private: |
110 | | |
111 | | static void clampCoords(SplashCoord *x, SplashCoord *y); |
112 | | SplashXPath(SplashXPath *xPath); |
113 | | void transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi, |
114 | | SplashCoord *xo, SplashCoord *yo); |
115 | | GBool strokeAdjust(SplashXPathPoint *pts, |
116 | | SplashPathHint *hints, int nHints, |
117 | | SplashStrokeAdjustMode strokeAdjMode); |
118 | | void grow(int nSegs); |
119 | | void addCurve(SplashCoord x0, SplashCoord y0, |
120 | | SplashCoord x1, SplashCoord y1, |
121 | | SplashCoord x2, SplashCoord y2, |
122 | | SplashCoord x3, SplashCoord y3, |
123 | | SplashCoord flatness, |
124 | | GBool first, GBool last, GBool end0, GBool end1); |
125 | | void mergeSegments(int first); |
126 | | void addSegment(SplashCoord x0, SplashCoord y0, |
127 | | SplashCoord x1, SplashCoord y1); |
128 | | void finishSegments(); |
129 | | |
130 | | SplashXPathSeg *segs; |
131 | | int length, size; // length and size of segs array |
132 | | int xMin, xMax; |
133 | | int yMin, yMax; |
134 | | |
135 | | GBool isRect; |
136 | | SplashCoord rectX0, rectY0, rectX1, rectY1; |
137 | | |
138 | | friend class SplashXPathScanner; |
139 | | friend class SplashClip; |
140 | | friend class Splash; |
141 | | }; |
142 | | |
143 | | #endif |