/src/xpdf-4.04/splash/SplashPath.h
Line | Count | Source (jump to first uncovered line) |
1 | | //======================================================================== |
2 | | // |
3 | | // SplashPath.h |
4 | | // |
5 | | // Copyright 2003-2013 Glyph & Cog, LLC |
6 | | // |
7 | | //======================================================================== |
8 | | |
9 | | #ifndef SPLASHPATH_H |
10 | | #define SPLASHPATH_H |
11 | | |
12 | | #include <aconf.h> |
13 | | |
14 | | #ifdef USE_GCC_PRAGMAS |
15 | | #pragma interface |
16 | | #endif |
17 | | |
18 | | #include "SplashTypes.h" |
19 | | |
20 | | //------------------------------------------------------------------------ |
21 | | // SplashPathPoint |
22 | | //------------------------------------------------------------------------ |
23 | | |
24 | | struct SplashPathPoint { |
25 | | SplashCoord x, y; |
26 | | }; |
27 | | |
28 | | //------------------------------------------------------------------------ |
29 | | // SplashPath.flags |
30 | | //------------------------------------------------------------------------ |
31 | | |
32 | | // first point on each subpath sets this flag |
33 | 0 | #define splashPathFirst 0x01 |
34 | | |
35 | | // last point on each subpath sets this flag |
36 | 0 | #define splashPathLast 0x02 |
37 | | |
38 | | // if the subpath is closed, its first and last points must be |
39 | | // identical, and must set this flag |
40 | 0 | #define splashPathClosed 0x04 |
41 | | |
42 | | // curve control points set this flag |
43 | 0 | #define splashPathCurve 0x08 |
44 | | |
45 | | //------------------------------------------------------------------------ |
46 | | // SplashPathHint |
47 | | //------------------------------------------------------------------------ |
48 | | |
49 | | struct SplashPathHint { |
50 | | int ctrl0, ctrl1; |
51 | | int firstPt, lastPt; |
52 | | GBool projectingCap; |
53 | | }; |
54 | | |
55 | | //------------------------------------------------------------------------ |
56 | | // SplashPath |
57 | | //------------------------------------------------------------------------ |
58 | | |
59 | | class SplashPath { |
60 | | public: |
61 | | |
62 | | // Create an empty path. |
63 | | SplashPath(); |
64 | | |
65 | | // Copy a path. |
66 | 0 | SplashPath *copy() { return new SplashPath(this); } |
67 | | |
68 | | ~SplashPath(); |
69 | | |
70 | | // Append <path> to <this>. |
71 | | void append(SplashPath *path); |
72 | | |
73 | | // Start a new subpath. |
74 | | SplashError moveTo(SplashCoord x, SplashCoord y); |
75 | | |
76 | | // Add a line segment to the last subpath. |
77 | | SplashError lineTo(SplashCoord x, SplashCoord y); |
78 | | |
79 | | // Add a third-order (cubic) Bezier curve segment to the last |
80 | | // subpath. |
81 | | SplashError curveTo(SplashCoord x1, SplashCoord y1, |
82 | | SplashCoord x2, SplashCoord y2, |
83 | | SplashCoord x3, SplashCoord y3); |
84 | | |
85 | | // Close the last subpath, adding a line segment if necessary. If |
86 | | // <force> is true, this adds a line segment even if the current |
87 | | // point is equal to the first point in the subpath. |
88 | | SplashError close(GBool force = gFalse); |
89 | | |
90 | | // Add a stroke adjustment hint. The controlling segments are |
91 | | // <ctrl0> and <ctrl1> (where segments are identified by their first |
92 | | // point), and the points to be adjusted are <firstPt> .. <lastPt>. |
93 | | // <projectingCap> is true if the points are part of a projecting |
94 | | // line cap. |
95 | | void addStrokeAdjustHint(int ctrl0, int ctrl1, int firstPt, int lastPt, |
96 | | GBool projectingCap = gFalse); |
97 | | |
98 | | // Add (<dx>, <dy>) to every point on this path. |
99 | | void offset(SplashCoord dx, SplashCoord dy); |
100 | | |
101 | | // Get the points on the path. |
102 | 0 | int getLength() { return length; } |
103 | | void getPoint(int i, SplashCoord *x, SplashCoord *y, Guchar *f) |
104 | 0 | { *x = pts[i].x; *y = pts[i].y; *f = flags[i]; } |
105 | | |
106 | | // Get the current point. |
107 | | GBool getCurPt(SplashCoord *x, SplashCoord *y); |
108 | | |
109 | | // Returns true if the path contains one or more zero length |
110 | | // subpaths. |
111 | | GBool containsZeroLengthSubpaths(); |
112 | | |
113 | | private: |
114 | | |
115 | | SplashPath(SplashPath *path); |
116 | | void grow(int nPts); |
117 | 0 | GBool noCurrentPoint() { return curSubpath == length; } |
118 | 0 | GBool onePointSubpath() { return curSubpath == length - 1; } |
119 | 0 | GBool openSubpath() { return curSubpath < length - 1; } |
120 | | |
121 | | SplashPathPoint *pts; // array of points |
122 | | Guchar *flags; // array of flags |
123 | | int length, size; // length/size of the pts and flags arrays |
124 | | int curSubpath; // index of first point in last subpath |
125 | | |
126 | | SplashPathHint *hints; // list of hints |
127 | | int hintsLength, hintsSize; |
128 | | |
129 | | friend class SplashXPath; |
130 | | friend class Splash; |
131 | | }; |
132 | | |
133 | | #endif |