/src/mozilla-central/gfx/2d/PathSkia.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 | | #ifndef MOZILLA_GFX_PATH_SKIA_H_ |
8 | | #define MOZILLA_GFX_PATH_SKIA_H_ |
9 | | |
10 | | #include "2D.h" |
11 | | #include "skia/include/core/SkPath.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace gfx { |
15 | | |
16 | | class PathSkia; |
17 | | |
18 | | class PathBuilderSkia : public PathBuilder |
19 | | { |
20 | | public: |
21 | | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderSkia, override) |
22 | | |
23 | | PathBuilderSkia(const Matrix& aTransform, const SkPath& aPath, FillRule aFillRule); |
24 | | explicit PathBuilderSkia(FillRule aFillRule); |
25 | | |
26 | | virtual void MoveTo(const Point &aPoint) override; |
27 | | virtual void LineTo(const Point &aPoint) override; |
28 | | virtual void BezierTo(const Point &aCP1, |
29 | | const Point &aCP2, |
30 | | const Point &aCP3) override; |
31 | | virtual void QuadraticBezierTo(const Point &aCP1, |
32 | | const Point &aCP2) override; |
33 | | virtual void Close() override; |
34 | | virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle, |
35 | | float aEndAngle, bool aAntiClockwise = false) override; |
36 | | virtual Point CurrentPoint() const override; |
37 | | virtual already_AddRefed<Path> Finish() override; |
38 | | |
39 | | void AppendPath(const SkPath &aPath); |
40 | | |
41 | 0 | virtual BackendType GetBackendType() const override { return BackendType::SKIA; } |
42 | | |
43 | | private: |
44 | | |
45 | | void SetFillRule(FillRule aFillRule); |
46 | | |
47 | | SkPath mPath; |
48 | | FillRule mFillRule; |
49 | | }; |
50 | | |
51 | | class PathSkia : public Path |
52 | | { |
53 | | public: |
54 | | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathSkia, override) |
55 | | |
56 | | PathSkia(SkPath& aPath, FillRule aFillRule) |
57 | | : mFillRule(aFillRule) |
58 | 0 | { |
59 | 0 | mPath.swap(aPath); |
60 | 0 | } |
61 | | |
62 | 0 | virtual BackendType GetBackendType() const override { return BackendType::SKIA; } |
63 | | |
64 | | virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule) const override; |
65 | | virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform, |
66 | | FillRule aFillRule) const override; |
67 | | |
68 | | virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const override; |
69 | | |
70 | | virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions, |
71 | | const Point &aPoint, |
72 | | const Matrix &aTransform) const override; |
73 | | |
74 | | virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const override; |
75 | | |
76 | | virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions, |
77 | | const Matrix &aTransform = Matrix()) const override; |
78 | | |
79 | | virtual void StreamToSink(PathSink *aSink) const override; |
80 | | |
81 | 0 | virtual FillRule GetFillRule() const override { return mFillRule; } |
82 | | |
83 | 0 | const SkPath& GetPath() const { return mPath; } |
84 | | |
85 | | private: |
86 | | friend class DrawTargetSkia; |
87 | | |
88 | | SkPath mPath; |
89 | | FillRule mFillRule; |
90 | | }; |
91 | | |
92 | | } // namespace gfx |
93 | | } // namespace mozilla |
94 | | |
95 | | #endif /* MOZILLA_GFX_PATH_SKIA_H_ */ |