Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / gfx / 2d / PathD2D.h
blob27c900ad7d1e1d8624500ef6984215bc8c283b73
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 virtual bool IsActive() const { return IsFigureActive(); }
50 static already_AddRefed<PathBuilder> Create(FillRule aFillRule);
52 private:
53 friend class PathD2D;
55 void EnsureActive(const Point& aPoint);
57 RefPtr<ID2D1GeometrySink> mSink;
58 RefPtr<ID2D1PathGeometry> mGeometry;
60 bool mFigureActive;
61 bool mFigureEmpty = true;
62 FillRule mFillRule;
63 BackendType mBackendType;
66 class PathD2D : public Path {
67 public:
68 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathD2D, override)
69 PathD2D(ID2D1PathGeometry* aGeometry, bool aEndedActive, bool aIsEmpty,
70 const Point& aEndPoint, FillRule aFillRule, BackendType aBackendType)
71 : mGeometry(aGeometry),
72 mEndedActive(aEndedActive),
73 mIsEmpty(aIsEmpty),
74 mEndPoint(aEndPoint),
75 mFillRule(aFillRule),
76 mBackendType(aBackendType) {}
78 virtual BackendType GetBackendType() const { return mBackendType; }
80 virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule) const;
81 virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(
82 const Matrix& aTransform, FillRule aFillRule) const;
84 virtual bool ContainsPoint(const Point& aPoint,
85 const Matrix& aTransform) const;
87 virtual bool StrokeContainsPoint(const StrokeOptions& aStrokeOptions,
88 const Point& aPoint,
89 const Matrix& aTransform) const;
91 virtual Rect GetBounds(const Matrix& aTransform = Matrix()) const;
93 virtual Rect GetStrokedBounds(const StrokeOptions& aStrokeOptions,
94 const Matrix& aTransform = Matrix()) const;
96 virtual void StreamToSink(PathSink* aSink) const;
98 virtual FillRule GetFillRule() const { return mFillRule; }
100 bool IsEmpty() const override { return mIsEmpty; }
102 ID2D1Geometry* GetGeometry() { return mGeometry; }
104 private:
105 friend class DrawTargetD2D;
106 friend class DrawTargetD2D1;
108 mutable RefPtr<ID2D1PathGeometry> mGeometry;
109 bool mEndedActive;
110 bool mIsEmpty;
111 Point mEndPoint;
112 FillRule mFillRule;
113 BackendType mBackendType;
116 } // namespace gfx
117 } // namespace mozilla
119 #endif /* MOZILLA_GFX_PATHD2D_H_ */