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