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
; }
51 void EnsureActive(const Point
& aPoint
);
53 RefPtr
<ID2D1GeometrySink
> mSink
;
54 RefPtr
<ID2D1PathGeometry
> mGeometry
;
58 BackendType mBackendType
;
61 class PathD2D
: public Path
{
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
),
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
,
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
; }
97 friend class DrawTargetD2D
;
98 friend class DrawTargetD2D1
;
100 mutable RefPtr
<ID2D1PathGeometry
> mGeometry
;
104 BackendType mBackendType
;
108 } // namespace mozilla
110 #endif /* MOZILLA_GFX_PATHD2D_H_ */