Coverage Report

Created: 2025-07-11 07:47

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