Bug 1686855 [wpt PR 27197] - PlzDedicatedWorker: WPT for clients.matchAll() with...
[gecko.git] / gfx / 2d / PathSkia.h
blob2e8147b77f460fa9faf2f8342ac1ea30686ed8c4
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/. */
7 #ifndef MOZILLA_GFX_PATH_SKIA_H_
8 #define MOZILLA_GFX_PATH_SKIA_H_
10 #include "2D.h"
11 #include "skia/include/core/SkPath.h"
13 namespace mozilla {
14 namespace gfx {
16 class PathSkia;
18 class PathBuilderSkia : public PathBuilder {
19 public:
20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderSkia, override)
22 PathBuilderSkia(const Matrix& aTransform, const SkPath& aPath,
23 FillRule aFillRule);
24 explicit PathBuilderSkia(FillRule aFillRule);
26 void MoveTo(const Point& aPoint) override;
27 void LineTo(const Point& aPoint) override;
28 void BezierTo(const Point& aCP1, const Point& aCP2,
29 const Point& aCP3) override;
30 void QuadraticBezierTo(const Point& aCP1, const Point& aCP2) override;
31 void Close() override;
32 void Arc(const Point& aOrigin, float aRadius, float aStartAngle,
33 float aEndAngle, bool aAntiClockwise = false) override;
34 already_AddRefed<Path> Finish() override;
36 void AppendPath(const SkPath& aPath);
38 BackendType GetBackendType() const override { return BackendType::SKIA; }
40 private:
41 friend class PathSkia;
43 void SetFillRule(FillRule aFillRule);
45 SkPath mPath;
46 FillRule mFillRule;
49 class PathSkia : public Path {
50 public:
51 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathSkia, override)
53 PathSkia(SkPath& aPath, FillRule aFillRule, Point aCurrentPoint = Point(),
54 Point aBeginPoint = Point())
55 : mFillRule(aFillRule),
56 mCurrentPoint(aCurrentPoint),
57 mBeginPoint(aBeginPoint) {
58 mPath.swap(aPath);
61 BackendType GetBackendType() const override { return BackendType::SKIA; }
63 already_AddRefed<PathBuilder> CopyToBuilder(
64 FillRule aFillRule) const override;
65 already_AddRefed<PathBuilder> TransformedCopyToBuilder(
66 const Matrix& aTransform, FillRule aFillRule) const override;
68 bool ContainsPoint(const Point& aPoint,
69 const Matrix& aTransform) const override;
71 bool StrokeContainsPoint(const StrokeOptions& aStrokeOptions,
72 const Point& aPoint,
73 const Matrix& aTransform) const override;
75 Rect GetBounds(const Matrix& aTransform = Matrix()) const override;
77 Rect GetStrokedBounds(const StrokeOptions& aStrokeOptions,
78 const Matrix& aTransform = Matrix()) const override;
80 void StreamToSink(PathSink* aSink) const override;
82 FillRule GetFillRule() const override { return mFillRule; }
84 const SkPath& GetPath() const { return mPath; }
86 private:
87 friend class DrawTargetSkia;
89 SkPath mPath;
90 FillRule mFillRule;
91 Point mCurrentPoint;
92 Point mBeginPoint;
95 } // namespace gfx
96 } // namespace mozilla
98 #endif /* MOZILLA_GFX_PATH_SKIA_H_ */