Bug 1758688 [wpt PR 33067] - [FedCM] Make revoke a non-static method, a=testonly
[gecko.git] / gfx / 2d / PathD2D.h
blobdb6cadc44210d937d989b03902b252b28aba1bf5
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_PATHD2D_H_
8 #define MOZILLA_GFX_PATHD2D_H_
10 #include <d2d1.h>
12 #include "2D.h"
14 namespace mozilla {
15 namespace gfx {
17 class PathD2D;
19 class PathBuilderD2D : public PathBuilder {
20 public:
21 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderD2D, override)
22 PathBuilderD2D(ID2D1GeometrySink* aSink, ID2D1PathGeometry* aGeom,
23 FillRule aFillRule, BackendType aBackendType)
24 : mSink(aSink),
25 mGeometry(aGeom),
26 mFigureActive(false),
27 mFillRule(aFillRule),
28 mBackendType(aBackendType) {}
29 virtual ~PathBuilderD2D();
31 virtual void MoveTo(const Point& aPoint);
32 virtual void LineTo(const Point& aPoint);
33 virtual void BezierTo(const Point& aCP1, const Point& aCP2,
34 const Point& aCP3);
35 virtual void QuadraticBezierTo(const Point& aCP1, const Point& aCP2);
36 virtual void Close();
37 virtual void Arc(const Point& aOrigin, Float aRadius, Float aStartAngle,
38 Float aEndAngle, bool aAntiClockwise = false);
40 virtual already_AddRefed<Path> Finish();
42 virtual BackendType GetBackendType() const { return mBackendType; }
44 ID2D1GeometrySink* GetSink() { return mSink; }
46 bool IsFigureActive() const { return mFigureActive; }
48 private:
49 friend class PathD2D;
51 void EnsureActive(const Point& aPoint);
53 RefPtr<ID2D1GeometrySink> mSink;
54 RefPtr<ID2D1PathGeometry> mGeometry;
56 bool mFigureActive;
57 FillRule mFillRule;
58 BackendType mBackendType;
61 class PathD2D : public Path {
62 public:
63 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathD2D, override)
64 PathD2D(ID2D1PathGeometry* aGeometry, bool aEndedActive,
65 const Point& aEndPoint, FillRule aFillRule, BackendType aBackendType)
66 : mGeometry(aGeometry),
67 mEndedActive(aEndedActive),
68 mEndPoint(aEndPoint),
69 mFillRule(aFillRule),
70 mBackendType(aBackendType) {}
72 virtual BackendType GetBackendType() const { return mBackendType; }
74 virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule) const;
75 virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(
76 const Matrix& aTransform, FillRule aFillRule) const;
78 virtual bool ContainsPoint(const Point& aPoint,
79 const Matrix& aTransform) const;
81 virtual bool StrokeContainsPoint(const StrokeOptions& aStrokeOptions,
82 const Point& aPoint,
83 const Matrix& aTransform) const;
85 virtual Rect GetBounds(const Matrix& aTransform = Matrix()) const;
87 virtual Rect GetStrokedBounds(const StrokeOptions& aStrokeOptions,
88 const Matrix& aTransform = Matrix()) const;
90 virtual void StreamToSink(PathSink* aSink) const;
92 virtual FillRule GetFillRule() const { return mFillRule; }
94 ID2D1Geometry* GetGeometry() { return mGeometry; }
96 private:
97 friend class DrawTargetD2D;
98 friend class DrawTargetD2D1;
100 mutable RefPtr<ID2D1PathGeometry> mGeometry;
101 bool mEndedActive;
102 Point mEndPoint;
103 FillRule mFillRule;
104 BackendType mBackendType;
107 } // namespace gfx
108 } // namespace mozilla
110 #endif /* MOZILLA_GFX_PATHD2D_H_ */