2017-10-27 23:10:06 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 11:12:37 +00:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-01-09 22:15:10 +00:00
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_PATH_CAIRO_H_
|
|
|
|
#define MOZILLA_GFX_PATH_CAIRO_H_
|
|
|
|
|
|
|
|
#include "2D.h"
|
|
|
|
#include "cairo.h"
|
2013-09-28 14:20:24 +00:00
|
|
|
#include <vector>
|
2012-01-09 22:15:10 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
2013-09-28 14:20:24 +00:00
|
|
|
class PathCairo;
|
2012-01-09 22:15:10 +00:00
|
|
|
|
|
|
|
class PathBuilderCairo : public PathBuilder {
|
|
|
|
public:
|
2017-11-06 03:37:28 +00:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderCairo, override)
|
|
|
|
|
2014-08-08 01:17:30 +00:00
|
|
|
explicit PathBuilderCairo(FillRule aFillRule);
|
2012-01-09 22:15:10 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
void MoveTo(const Point& aPoint) override;
|
|
|
|
void LineTo(const Point& aPoint) override;
|
|
|
|
void BezierTo(const Point& aCP1, const Point& aCP2,
|
|
|
|
const Point& aCP3) override;
|
|
|
|
void QuadraticBezierTo(const Point& aCP1, const Point& aCP2) override;
|
|
|
|
void Close() override;
|
|
|
|
void Arc(const Point& aOrigin, float aRadius, float aStartAngle,
|
|
|
|
float aEndAngle, bool aAntiClockwise = false) override;
|
|
|
|
already_AddRefed<Path> Finish() override;
|
|
|
|
|
|
|
|
BackendType GetBackendType() const override { return BackendType::CAIRO; }
|
2014-10-04 11:13:29 +00:00
|
|
|
|
2012-01-09 22:15:10 +00:00
|
|
|
private: // data
|
2013-09-28 14:20:24 +00:00
|
|
|
friend class PathCairo;
|
2012-09-03 21:48:04 +00:00
|
|
|
|
2012-01-09 22:15:10 +00:00
|
|
|
FillRule mFillRule;
|
2013-09-28 14:20:24 +00:00
|
|
|
std::vector<cairo_path_data_t> mPathData;
|
2012-01-09 22:15:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PathCairo : public Path {
|
|
|
|
public:
|
2017-11-06 03:37:28 +00:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathCairo, override)
|
|
|
|
|
2013-09-28 14:20:24 +00:00
|
|
|
PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t>& aPathData,
|
2019-06-05 07:55:46 +00:00
|
|
|
const Point& aCurrentPoint, const Point& aBeginPoint);
|
2014-08-08 01:17:30 +00:00
|
|
|
explicit PathCairo(cairo_t* aContext);
|
2019-04-11 12:36:51 +00:00
|
|
|
virtual ~PathCairo();
|
2012-01-09 22:15:10 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
BackendType GetBackendType() const override { return BackendType::CAIRO; }
|
2012-01-09 22:15:10 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
already_AddRefed<PathBuilder> CopyToBuilder(
|
2017-11-06 03:37:28 +00:00
|
|
|
FillRule aFillRule) const override;
|
2019-04-11 12:36:51 +00:00
|
|
|
already_AddRefed<PathBuilder> TransformedCopyToBuilder(
|
2017-11-06 03:37:28 +00:00
|
|
|
const Matrix& aTransform, FillRule aFillRule) const override;
|
2012-01-09 22:15:10 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
bool ContainsPoint(const Point& aPoint,
|
|
|
|
const Matrix& aTransform) const override;
|
2012-01-09 22:15:10 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
bool StrokeContainsPoint(const StrokeOptions& aStrokeOptions,
|
|
|
|
const Point& aPoint,
|
|
|
|
const Matrix& aTransform) const override;
|
2012-10-29 15:54:53 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
Rect GetBounds(const Matrix& aTransform = Matrix()) const override;
|
2012-01-09 22:15:10 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
Rect GetStrokedBounds(const StrokeOptions& aStrokeOptions,
|
|
|
|
const Matrix& aTransform = Matrix()) const override;
|
2012-01-09 22:15:10 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
void StreamToSink(PathSink* aSink) const override;
|
2013-11-07 09:10:12 +00:00
|
|
|
|
2019-04-11 12:36:51 +00:00
|
|
|
FillRule GetFillRule() const override { return mFillRule; }
|
2012-01-09 22:15:10 +00:00
|
|
|
|
2013-09-28 14:20:24 +00:00
|
|
|
void SetPathOnContext(cairo_t* aContext) const;
|
2012-01-09 22:15:10 +00:00
|
|
|
|
2013-09-28 14:20:24 +00:00
|
|
|
void AppendPathToBuilder(PathBuilderCairo* aBuilder,
|
|
|
|
const Matrix* aTransform = nullptr) const;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-01-09 22:15:10 +00:00
|
|
|
private:
|
2015-09-21 17:33:06 +00:00
|
|
|
void EnsureContainingContext(const Matrix& aTransform) const;
|
2013-09-28 14:20:24 +00:00
|
|
|
|
2012-01-09 22:15:10 +00:00
|
|
|
FillRule mFillRule;
|
2013-09-28 14:20:24 +00:00
|
|
|
std::vector<cairo_path_data_t> mPathData;
|
|
|
|
mutable cairo_t* mContainingContext;
|
2015-09-21 17:33:06 +00:00
|
|
|
mutable Matrix mContainingTransform;
|
2013-09-28 14:20:24 +00:00
|
|
|
Point mCurrentPoint;
|
2019-06-05 07:55:46 +00:00
|
|
|
Point mBeginPoint;
|
2012-01-09 22:15:10 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2012-01-09 22:15:10 +00:00
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_PATH_CAIRO_H_ */
|