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_
19 class PathBuilderCairo
: public PathBuilder
{
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
; }
38 friend class PathCairo
;
41 std::vector
<cairo_path_data_t
> mPathData
;
44 class PathCairo
: public Path
{
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
);
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
,
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;
82 void EnsureContainingContext(const Matrix
& aTransform
) const;
85 std::vector
<cairo_path_data_t
> mPathData
;
86 mutable cairo_t
* mContainingContext
;
87 mutable Matrix mContainingTransform
;
93 } // namespace mozilla
95 #endif /* MOZILLA_GFX_PATH_CAIRO_H_ */