beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / splash / SplashPath.h
blob81273c613e57bc432d78d0ea26e69585ee521fbc
1 //========================================================================
2 //
3 // SplashPath.h
4 //
5 //========================================================================
7 #ifndef SPLASHPATH_H
8 #define SPLASHPATH_H
10 #ifdef USE_GCC_PRAGMAS
11 #pragma interface
12 #endif
14 #include "SplashTypes.h"
16 //------------------------------------------------------------------------
17 // SplashPathPoint
18 //------------------------------------------------------------------------
20 struct SplashPathPoint {
21 SplashCoord x, y;
24 //------------------------------------------------------------------------
25 // SplashPath.flags
26 //------------------------------------------------------------------------
28 // first point on each subpath sets this flag
29 #define splashPathFirst 0x01
31 // last point on each subpath sets this flag
32 #define splashPathLast 0x02
34 // if the subpath is closed, its first and last points must be
35 // identical, and must set this flag
36 #define splashPathClosed 0x04
38 // curve control points set this flag
39 #define splashPathCurve 0x08
41 //------------------------------------------------------------------------
42 // SplashPathHint
43 //------------------------------------------------------------------------
45 struct SplashPathHint {
46 int ctrl0, ctrl1;
47 int firstPt, lastPt;
50 //------------------------------------------------------------------------
51 // SplashPath
52 //------------------------------------------------------------------------
54 class SplashPath {
55 public:
57 // Create an empty path.
58 SplashPath();
60 // Copy a path.
61 SplashPath *copy() { return new SplashPath(this); }
63 ~SplashPath();
65 // Append <path> to <this>.
66 void append(SplashPath *path);
68 // Start a new subpath.
69 SplashError moveTo(SplashCoord x, SplashCoord y);
71 // Add a line segment to the last subpath.
72 SplashError lineTo(SplashCoord x, SplashCoord y);
74 // Add a third-order (cubic) Bezier curve segment to the last
75 // subpath.
76 SplashError curveTo(SplashCoord x1, SplashCoord y1,
77 SplashCoord x2, SplashCoord y2,
78 SplashCoord x3, SplashCoord y3);
80 // Close the last subpath, adding a line segment if necessary. If
81 // <force> is true, this adds a line segment even if the current
82 // point is equal to the first point in the subpath.
83 SplashError close(GBool force = gFalse);
85 // Add a stroke adjustment hint. The controlling segments are
86 // <ctrl0> and <ctrl1> (where segments are identified by their first
87 // point), and the points to be adjusted are <firstPt> .. <lastPt>.
88 void addStrokeAdjustHint(int ctrl0, int ctrl1, int firstPt, int lastPt);
90 // Add (<dx>, <dy>) to every point on this path.
91 void offset(SplashCoord dx, SplashCoord dy);
93 // Get the points on the path.
94 int getLength() { return length; }
95 void getPoint(int i, double *x, double *y, Guchar *f)
96 { *x = pts[i].x; *y = pts[i].y; *f = flags[i]; }
98 // Get the current point.
99 GBool getCurPt(SplashCoord *x, SplashCoord *y);
101 protected:
103 SplashPath(SplashPath *path);
104 void grow(int nPts);
105 GBool noCurrentPoint() { return curSubpath == length; }
106 GBool onePointSubpath() { return curSubpath == length - 1; }
107 GBool openSubpath() { return curSubpath < length - 1; }
109 SplashPathPoint *pts; // array of points
110 Guchar *flags; // array of flags
111 int length, size; // length/size of the pts and flags arrays
112 int curSubpath; // index of first point in last subpath
114 SplashPathHint *hints; // list of hints
115 int hintsLength, hintsSize;
117 friend class SplashXPath;
118 friend class Splash;
119 // this is a temporary hack, until we read FreeType paths directly
120 friend class ArthurOutputDev;
123 #endif