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_
19 class PathBuilderD2D
: public PathBuilder
{
21 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderD2D
, override
)
22 PathBuilderD2D(ID2D1GeometrySink
* aSink
, ID2D1PathGeometry
* aGeom
,
23 FillRule aFillRule
, BackendType aBackendType
)
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
,
35 virtual void QuadraticBezierTo(const Point
& aCP1
, const Point
& aCP2
);
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
);
55 void EnsureActive(const Point
& aPoint
);
57 RefPtr
<ID2D1GeometrySink
> mSink
;
58 RefPtr
<ID2D1PathGeometry
> mGeometry
;
61 bool mFigureEmpty
= true;
63 BackendType mBackendType
;
66 class PathD2D
: public Path
{
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
),
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
,
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
; }
105 friend class DrawTargetD2D
;
106 friend class DrawTargetD2D1
;
108 mutable RefPtr
<ID2D1PathGeometry
> mGeometry
;
113 BackendType mBackendType
;
117 } // namespace mozilla
119 #endif /* MOZILLA_GFX_PATHD2D_H_ */