Bringing apdf from vendor into main branch.
[AROS-Contrib.git] / apdf / splash / SplashXPath.h
bloba9fe9a2a672f2bde79701ed5deddbd1d19246f56
1 //========================================================================
2 //
3 // SplashXPath.h
4 //
5 //========================================================================
7 #ifndef SPLASHXPATH_H
8 #define SPLASHXPATH_H
10 #include <aconf.h>
12 #ifdef USE_GCC_PRAGMAS
13 #pragma interface
14 #endif
16 #include "SplashTypes.h"
18 class SplashPath;
20 //------------------------------------------------------------------------
21 // SplashXPathSeg
22 //------------------------------------------------------------------------
24 struct SplashXPathSeg {
25 SplashCoord x0, y0; // first endpoint
26 SplashCoord x1, y1; // second endpoint
27 SplashCoord dxdy; // slope: delta-x / delta-y
28 SplashCoord dydx; // slope: delta-y / delta-x
29 Guint flags;
32 #define splashXPathFirst 0x01 // first segment of a subpath
33 #define splashXPathLast 0x02 // last segment of a subpath
34 #define splashXPathEnd0 0x04 // first endpoint is end of an open subpath
35 #define splashXPathEnd1 0x08 // second endpoint is end of an open subpath
36 #define splashXPathHoriz 0x10 // segment is vertical (y0 == y1)
37 // (dxdy is undef)
38 #define splashXPathVert 0x20 // segment is horizontal (x0 == x1)
39 // (dydx is undef)
40 #define splashXPathFlip 0x40 // y0 > y1
42 //------------------------------------------------------------------------
43 // SplashXPath
44 //------------------------------------------------------------------------
46 class SplashXPath {
47 public:
49 // Expands (converts to segments) and flattens (converts curves to
50 // lines) <path>. If <closeSubpaths> is true, closes all open
51 // subpaths.
52 SplashXPath(SplashPath *path, SplashCoord flatness,
53 GBool closeSubpaths);
55 // Copy an expanded path.
56 SplashXPath *copy() { return new SplashXPath(this); }
58 ~SplashXPath();
60 // Sort by upper coordinate (lower y), in y-major order.
61 void sort();
63 private:
65 SplashXPath();
66 SplashXPath(SplashXPath *xPath);
67 void grow(int nSegs);
68 void addCurve(SplashCoord x0, SplashCoord y0,
69 SplashCoord x1, SplashCoord y1,
70 SplashCoord x2, SplashCoord y2,
71 SplashCoord x3, SplashCoord y3,
72 SplashCoord flatness,
73 GBool first, GBool last, GBool end0, GBool end1);
74 void addArc(SplashCoord x0, SplashCoord y0,
75 SplashCoord x1, SplashCoord y1,
76 SplashCoord xc, SplashCoord yc,
77 SplashCoord r, int quad,
78 SplashCoord flatness,
79 GBool first, GBool last, GBool end0, GBool end1);
80 void addSegment(SplashCoord x0, SplashCoord y0,
81 SplashCoord x1, SplashCoord y1,
82 GBool first, GBool last, GBool end0, GBool end1);
84 SplashXPathSeg *segs;
85 int length, size; // length and size of segs array
87 friend class SplashXPathScanner;
88 friend class SplashClip;
89 friend class Splash;
92 #endif