no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / gfx / 2d / PathCairo.h
blob1e58ef1512d32f74a8177b613fc8a52adae3b039
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_
10 #include "2D.h"
11 #include "cairo.h"
12 #include <vector>
14 namespace mozilla {
15 namespace gfx {
17 class PathCairo;
19 class PathBuilderCairo : public PathBuilder {
20 public:
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; }
37 bool IsActive() const override { return !mPathData.empty(); }
39 static already_AddRefed<PathBuilder> Create(FillRule aFillRule);
41 private: // data
42 friend class PathCairo;
44 FillRule mFillRule;
45 std::vector<cairo_path_data_t> mPathData;
48 class PathCairo : public Path {
49 public:
50 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathCairo, override)
52 PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t>& aPathData,
53 const Point& aCurrentPoint, const Point& aBeginPoint);
54 explicit PathCairo(cairo_t* aContext);
55 virtual ~PathCairo();
57 BackendType GetBackendType() const override { return BackendType::CAIRO; }
59 already_AddRefed<PathBuilder> CopyToBuilder(
60 FillRule aFillRule) const override;
61 already_AddRefed<PathBuilder> TransformedCopyToBuilder(
62 const Matrix& aTransform, FillRule aFillRule) const override;
64 bool ContainsPoint(const Point& aPoint,
65 const Matrix& aTransform) const override;
67 bool StrokeContainsPoint(const StrokeOptions& aStrokeOptions,
68 const Point& aPoint,
69 const Matrix& aTransform) const override;
71 Rect GetBounds(const Matrix& aTransform = Matrix()) const override;
73 Rect GetStrokedBounds(const StrokeOptions& aStrokeOptions,
74 const Matrix& aTransform = Matrix()) const override;
76 void StreamToSink(PathSink* aSink) const override;
78 FillRule GetFillRule() const override { return mFillRule; }
80 void SetPathOnContext(cairo_t* aContext) const;
82 void AppendPathToBuilder(PathBuilderCairo* aBuilder,
83 const Matrix* aTransform = nullptr) const;
85 bool IsEmpty() const override;
87 private:
88 void EnsureContainingContext(const Matrix& aTransform) const;
90 FillRule mFillRule;
91 std::vector<cairo_path_data_t> mPathData;
92 mutable cairo_t* mContainingContext;
93 mutable Matrix mContainingTransform;
94 Point mCurrentPoint;
95 Point mBeginPoint;
98 } // namespace gfx
99 } // namespace mozilla
101 #endif /* MOZILLA_GFX_PATH_CAIRO_H_ */