1//========================================================================
2//
3// SplashXPath.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) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
15// Copyright (C) 2018, 2021 Albert Astals Cid <aacid@kde.org>
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 SPLASHXPATH_H
23#define SPLASHXPATH_H
24
25#include "SplashTypes.h"
26
27class SplashPath;
28struct SplashXPathAdjust;
29
30//------------------------------------------------------------------------
31
32#define splashMaxCurveSplits (1 << 10)
33
34//------------------------------------------------------------------------
35// SplashXPathSeg
36//------------------------------------------------------------------------
37
38struct SplashXPathSeg
39{
40 SplashCoord x0, y0; // first endpoint
41 SplashCoord x1, y1; // second endpoint
42 SplashCoord dxdy; // slope: delta-x / delta-y
43 SplashCoord dydx; // slope: delta-y / delta-x
44 unsigned int flags;
45};
46
47#define splashXPathHoriz \
48 0x01 // segment is vertical (y0 == y1)
49 // (dxdy is undef)
50#define splashXPathVert \
51 0x02 // segment is horizontal (x0 == x1)
52 // (dydx is undef)
53#define splashXPathFlip 0x04 // y0 > y1
54
55//------------------------------------------------------------------------
56// SplashXPath
57//------------------------------------------------------------------------
58
59class SplashXPath
60{
61public:
62 // Expands (converts to segments) and flattens (converts curves to
63 // lines) <path>. Transforms all points from user space to device
64 // space, via <matrix>. If <closeSubpaths> is true, closes all open
65 // subpaths.
66 SplashXPath(SplashPath *path, SplashCoord *matrix, SplashCoord flatness, bool closeSubpaths, bool adjustLines = false, int linePosI = 0);
67
68 ~SplashXPath();
69
70 SplashXPath(const SplashXPath &) = delete;
71 SplashXPath &operator=(const SplashXPath &) = delete;
72
73 // Multiply all coordinates by splashAASize, in preparation for
74 // anti-aliased rendering.
75 void aaScale();
76
77 // Sort by upper coordinate (lower y), in y-major order.
78 void sort();
79
80protected:
81 void transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi, SplashCoord *xo, SplashCoord *yo);
82 void strokeAdjust(SplashXPathAdjust *adjust, SplashCoord *xp, SplashCoord *yp);
83 void grow(int nSegs);
84 void addCurve(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1, SplashCoord x2, SplashCoord y2, SplashCoord x3, SplashCoord y3, SplashCoord flatness, bool first, bool last, bool end0, bool end1);
85 void addSegment(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1);
86
87 SplashXPathSeg *segs;
88 int length, size; // length and size of segs array
89
90 friend class SplashXPathScanner;
91 friend class SplashClip;
92 friend class Splash;
93};
94
95#endif
96

source code of poppler/splash/SplashXPath.h