/src/mozilla-central/gfx/2d/PathAnalysis.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "2D.h" |
8 | | #include <vector> |
9 | | |
10 | | namespace mozilla { |
11 | | namespace gfx { |
12 | | |
13 | | struct FlatPathOp |
14 | | { |
15 | | enum OpType { |
16 | | OP_MOVETO, |
17 | | OP_LINETO, |
18 | | }; |
19 | | |
20 | | OpType mType; |
21 | | Point mPoint; |
22 | | }; |
23 | | |
24 | | class FlattenedPath : public PathSink |
25 | | { |
26 | | public: |
27 | | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FlattenedPath, override) |
28 | | |
29 | | FlattenedPath() : mCachedLength(0) |
30 | | , mCalculatedLength(false) |
31 | 0 | { |
32 | 0 | } |
33 | | |
34 | | virtual void MoveTo(const Point &aPoint) override; |
35 | | virtual void LineTo(const Point &aPoint) override; |
36 | | virtual void BezierTo(const Point &aCP1, |
37 | | const Point &aCP2, |
38 | | const Point &aCP3) override; |
39 | | virtual void QuadraticBezierTo(const Point &aCP1, |
40 | | const Point &aCP2) override; |
41 | | virtual void Close() override; |
42 | | virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle, |
43 | | float aEndAngle, bool aAntiClockwise = false) override; |
44 | | |
45 | 0 | virtual Point CurrentPoint() const override { return mPathOps.empty() ? Point() : mPathOps[mPathOps.size() - 1].mPoint; } |
46 | | |
47 | | Float ComputeLength(); |
48 | | Point ComputePointAtLength(Float aLength, Point *aTangent); |
49 | | |
50 | | private: |
51 | | Float mCachedLength; |
52 | | bool mCalculatedLength; |
53 | | Point mLastMove; |
54 | | |
55 | | std::vector<FlatPathOp> mPathOps; |
56 | | }; |
57 | | |
58 | | } // namespace gfx |
59 | | } // namespace mozilla |