Bug 1758688 [wpt PR 33067] - [FedCM] Make revoke a non-static method, a=testonly
[gecko.git] / gfx / 2d / PathCairo.h
blobdfdde8739ab3714801b829898296da9b7e62109e
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_CAIRO_H_
8 #define MOZILLA_GFX_PATH_CAIRO_H_
10 #include "2D.h"
11 #include "cairo.h"
12 #include <vector>
14 namespace mozilla {
15 namespace gfx {
17 class PathCairo;
19 class PathBuilderCairo : public PathBuilder {
20 public:
21 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderCairo, override)
23 explicit PathBuilderCairo(FillRule aFillRule);
25 void MoveTo(const Point& aPoint) override;
26 void LineTo(const Point& aPoint) override;
27 void BezierTo(const Point& aCP1, const Point& aCP2,
28 const Point& aCP3) override;
29 void QuadraticBezierTo(const Point& aCP1, const Point& aCP2) override;
30 void Close() override;
31 void Arc(const Point& aOrigin, float aRadius, float aStartAngle,
32 float aEndAngle, bool aAntiClockwise = false) override;
33 already_AddRefed<Path> Finish() override;
35 BackendType GetBackendType() const override { return BackendType::CAIRO; }
37 private: // data
38 friend class PathCairo;
40 FillRule mFillRule;
41 std::vector<cairo_path_data_t> mPathData;
44 class PathCairo : public Path {
45 public:
46 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathCairo, override)
48 PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t>& aPathData,
49 const Point& aCurrentPoint, const Point& aBeginPoint);
50 explicit PathCairo(cairo_t* aContext);
51 virtual ~PathCairo();
53 BackendType GetBackendType() const override { return BackendType::CAIRO; }
55 already_AddRefed<PathBuilder> CopyToBuilder(
56 FillRule aFillRule) const override;
57 already_AddRefed<PathBuilder> TransformedCopyToBuilder(
58 const Matrix& aTransform, FillRule aFillRule) const override;
60 bool ContainsPoint(const Point& aPoint,
61 const Matrix& aTransform) const override;
63 bool StrokeContainsPoint(const StrokeOptions& aStrokeOptions,
64 const Point& aPoint,
65 const Matrix& aTransform) const override;
67 Rect GetBounds(const Matrix& aTransform = Matrix()) const override;
69 Rect GetStrokedBounds(const StrokeOptions& aStrokeOptions,
70 const Matrix& aTransform = Matrix()) const override;
72 void StreamToSink(PathSink* aSink) const override;
74 FillRule GetFillRule() const override { return mFillRule; }
76 void SetPathOnContext(cairo_t* aContext) const;
78 void AppendPathToBuilder(PathBuilderCairo* aBuilder,
79 const Matrix* aTransform = nullptr) const;
81 private:
82 void EnsureContainingContext(const Matrix& aTransform) const;
84 FillRule mFillRule;
85 std::vector<cairo_path_data_t> mPathData;
86 mutable cairo_t* mContainingContext;
87 mutable Matrix mContainingTransform;
88 Point mCurrentPoint;
89 Point mBeginPoint;
92 } // namespace gfx
93 } // namespace mozilla
95 #endif /* MOZILLA_GFX_PATH_CAIRO_H_ */