/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, 2026 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 "SplashErrorCodes.h" |
26 | | #include "SplashTypes.h" |
27 | | #include "poppler_private_export.h" |
28 | | |
29 | | //------------------------------------------------------------------------ |
30 | | // SplashPathPoint |
31 | | //------------------------------------------------------------------------ |
32 | | |
33 | | struct SplashPathPoint |
34 | | { |
35 | | SplashCoord x, y; |
36 | | }; |
37 | | |
38 | | //------------------------------------------------------------------------ |
39 | | // SplashPath.flags |
40 | | //------------------------------------------------------------------------ |
41 | | |
42 | | // first point on each subpath sets this flag |
43 | 370M | #define splashPathFirst 0x01 |
44 | | |
45 | | // last point on each subpath sets this flag |
46 | 1.00G | #define splashPathLast 0x02 |
47 | | |
48 | | // if the subpath is closed, its first and last points must be |
49 | | // identical, and must set this flag |
50 | 157M | #define splashPathClosed 0x04 |
51 | | |
52 | | // curve control points set this flag |
53 | 275M | #define splashPathCurve 0x08 |
54 | | |
55 | | //------------------------------------------------------------------------ |
56 | | // SplashPathHint |
57 | | //------------------------------------------------------------------------ |
58 | | |
59 | | struct SplashPathHint |
60 | | { |
61 | | int ctrl0, ctrl1; |
62 | | int firstPt, lastPt; |
63 | | }; |
64 | | |
65 | | //------------------------------------------------------------------------ |
66 | | // SplashPath |
67 | | //------------------------------------------------------------------------ |
68 | | |
69 | | class POPPLER_PRIVATE_EXPORT SplashPath |
70 | | { |
71 | | public: |
72 | | // Create an empty path. |
73 | | SplashPath(); |
74 | | ~SplashPath(); |
75 | | |
76 | | SplashPath(const SplashPath &) = delete; |
77 | | SplashPath &operator=(const SplashPath &) = delete; |
78 | | SplashPath(SplashPath &&path) noexcept; |
79 | | |
80 | | // Append <path> to <this>. |
81 | | void append(SplashPath *path); |
82 | | |
83 | | // Start a new subpath. |
84 | | SplashError moveTo(SplashCoord x, SplashCoord y); |
85 | | |
86 | | // Add a line segment to the last subpath. |
87 | | SplashError lineTo(SplashCoord x, SplashCoord y); |
88 | | |
89 | | // Add a third-order (cubic) Bezier curve segment to the last |
90 | | // subpath. |
91 | | SplashError curveTo(SplashCoord x1, SplashCoord y1, SplashCoord x2, SplashCoord y2, SplashCoord x3, SplashCoord y3); |
92 | | |
93 | | // Close the last subpath, adding a line segment if necessary. If |
94 | | // <force> is true, this adds a line segment even if the current |
95 | | // point is equal to the first point in the subpath. |
96 | | SplashError close(bool force = false); |
97 | | |
98 | | // Add a stroke adjustment hint. The controlling segments are |
99 | | // <ctrl0> and <ctrl1> (where segments are identified by their first |
100 | | // point), and the points to be adjusted are <firstPt> .. <lastPt>. |
101 | | void addStrokeAdjustHint(int ctrl0, int ctrl1, int firstPt, int lastPt); |
102 | | |
103 | | // Add (<dx>, <dy>) to every point on this path. |
104 | | void offset(SplashCoord dx, SplashCoord dy); |
105 | | |
106 | | // Get the points on the path. |
107 | 10.2M | int getLength() const { return length; } |
108 | | void getPoint(int i, double *x, double *y, unsigned char *f) |
109 | 0 | { |
110 | 0 | *x = pts[i].x; |
111 | 0 | *y = pts[i].y; |
112 | 0 | *f = flags[i]; |
113 | 0 | } |
114 | | |
115 | | // Get the current point. |
116 | | bool getCurPt(SplashCoord *x, SplashCoord *y); |
117 | | |
118 | | // Reserve space for at least n points |
119 | | void reserve(int n); |
120 | | |
121 | | protected: |
122 | | void grow(int nPts); |
123 | 380M | bool noCurrentPoint() const { return curSubpath == length; } |
124 | 80.0M | bool onePointSubpath() const { return curSubpath == length - 1; } |
125 | 0 | bool openSubpath() const { return curSubpath < length - 1; } |
126 | | |
127 | | SplashPathPoint *pts; // array of points |
128 | | unsigned char *flags; // array of flags |
129 | | int length, size; // length/size of the pts and flags arrays |
130 | | int curSubpath; // index of first point in last subpath |
131 | | |
132 | | SplashPathHint *hints; // list of hints |
133 | | int hintsLength, hintsSize; |
134 | | |
135 | | friend class SplashXPath; |
136 | | friend class Splash; |
137 | | }; |
138 | | |
139 | | #endif |