/src/poppler/splash/SplashPath.h
Line | Count | Source |
1 | | //======================================================================== |
2 | | // |
3 | | // SplashPath.h |
4 | | // |
5 | | //======================================================================== |
6 | | |
7 | | //======================================================================== |
8 | | // |
9 | | // Modified under the Poppler project - http://poppler.freedesktop.org |
10 | | // |
11 | | // All changes made under the Poppler project to this file are licensed |
12 | | // under GPL version 2 or later |
13 | | // |
14 | | // Copyright (C) 2018, 2019, 2021 Albert Astals Cid <aacid@kde.org> |
15 | | // Copyright (C) 2018 Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de> |
16 | | // |
17 | | // To see a description of the changes please see the Changelog file that |
18 | | // came with your tarball or type make ChangeLog if you are building from git |
19 | | // |
20 | | //======================================================================== |
21 | | |
22 | | #ifndef SPLASHPATH_H |
23 | | #define SPLASHPATH_H |
24 | | |
25 | | #include "SplashTypes.h" |
26 | | #include "poppler_private_export.h" |
27 | | |
28 | | //------------------------------------------------------------------------ |
29 | | // SplashPathPoint |
30 | | //------------------------------------------------------------------------ |
31 | | |
32 | | struct SplashPathPoint |
33 | | { |
34 | | SplashCoord x, y; |
35 | | }; |
36 | | |
37 | | //------------------------------------------------------------------------ |
38 | | // SplashPath.flags |
39 | | //------------------------------------------------------------------------ |
40 | | |
41 | | // first point on each subpath sets this flag |
42 | 413M | #define splashPathFirst 0x01 |
43 | | |
44 | | // last point on each subpath sets this flag |
45 | 1.15G | #define splashPathLast 0x02 |
46 | | |
47 | | // if the subpath is closed, its first and last points must be |
48 | | // identical, and must set this flag |
49 | 186M | #define splashPathClosed 0x04 |
50 | | |
51 | | // curve control points set this flag |
52 | 305M | #define splashPathCurve 0x08 |
53 | | |
54 | | //------------------------------------------------------------------------ |
55 | | // SplashPathHint |
56 | | //------------------------------------------------------------------------ |
57 | | |
58 | | struct SplashPathHint |
59 | | { |
60 | | int ctrl0, ctrl1; |
61 | | int firstPt, lastPt; |
62 | | }; |
63 | | |
64 | | //------------------------------------------------------------------------ |
65 | | // SplashPath |
66 | | //------------------------------------------------------------------------ |
67 | | |
68 | | class POPPLER_PRIVATE_EXPORT SplashPath |
69 | | { |
70 | | public: |
71 | | // Create an empty path. |
72 | | SplashPath(); |
73 | | ~SplashPath(); |
74 | | |
75 | | SplashPath(const SplashPath &) = delete; |
76 | | SplashPath &operator=(const SplashPath &) = delete; |
77 | | SplashPath(SplashPath &&path) noexcept; |
78 | | |
79 | | // Append <path> to <this>. |
80 | | void append(SplashPath *path); |
81 | | |
82 | | // Start a new subpath. |
83 | | SplashError moveTo(SplashCoord x, SplashCoord y); |
84 | | |
85 | | // Add a line segment to the last subpath. |
86 | | SplashError lineTo(SplashCoord x, SplashCoord y); |
87 | | |
88 | | // Add a third-order (cubic) Bezier curve segment to the last |
89 | | // subpath. |
90 | | SplashError curveTo(SplashCoord x1, SplashCoord y1, SplashCoord x2, SplashCoord y2, SplashCoord x3, SplashCoord y3); |
91 | | |
92 | | // Close the last subpath, adding a line segment if necessary. If |
93 | | // <force> is true, this adds a line segment even if the current |
94 | | // point is equal to the first point in the subpath. |
95 | | SplashError close(bool force = false); |
96 | | |
97 | | // Add a stroke adjustment hint. The controlling segments are |
98 | | // <ctrl0> and <ctrl1> (where segments are identified by their first |
99 | | // point), and the points to be adjusted are <firstPt> .. <lastPt>. |
100 | | void addStrokeAdjustHint(int ctrl0, int ctrl1, int firstPt, int lastPt); |
101 | | |
102 | | // Add (<dx>, <dy>) to every point on this path. |
103 | | void offset(SplashCoord dx, SplashCoord dy); |
104 | | |
105 | | // Get the points on the path. |
106 | 11.5M | int getLength() { return length; } |
107 | | void getPoint(int i, double *x, double *y, unsigned char *f) |
108 | 0 | { |
109 | 0 | *x = pts[i].x; |
110 | 0 | *y = pts[i].y; |
111 | 0 | *f = flags[i]; |
112 | 0 | } |
113 | | |
114 | | // Get the current point. |
115 | | bool getCurPt(SplashCoord *x, SplashCoord *y); |
116 | | |
117 | | // Reserve space for at least n points |
118 | | void reserve(int n); |
119 | | |
120 | | protected: |
121 | | void grow(int nPts); |
122 | 449M | bool noCurrentPoint() { return curSubpath == length; } |
123 | 93.6M | bool onePointSubpath() { return curSubpath == length - 1; } |
124 | 0 | bool openSubpath() { return curSubpath < length - 1; } |
125 | | |
126 | | SplashPathPoint *pts; // array of points |
127 | | unsigned char *flags; // array of flags |
128 | | int length, size; // length/size of the pts and flags arrays |
129 | | int curSubpath; // index of first point in last subpath |
130 | | |
131 | | SplashPathHint *hints; // list of hints |
132 | | int hintsLength, hintsSize; |
133 | | |
134 | | friend class SplashXPath; |
135 | | friend class Splash; |
136 | | }; |
137 | | |
138 | | #endif |