2017-10-28 02:10:06 +03: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 15:12:37 +04: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/. */
|
2011-11-02 23:55:03 +04:00
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_PATH_SKIA_H_
|
|
|
|
#define MOZILLA_GFX_PATH_SKIA_H_
|
|
|
|
|
|
|
|
#include "2D.h"
|
2015-07-29 23:31:40 +03:00
|
|
|
#include "skia/include/core/SkPath.h"
|
2011-11-02 23:55:03 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class PathSkia;
|
|
|
|
|
|
|
|
class PathBuilderSkia : public PathBuilder {
|
|
|
|
public:
|
2017-11-06 06:37:28 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderSkia, override)
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
PathBuilderSkia(const Matrix& aTransform, const SkPath& aPath,
|
2011-11-02 23:55:03 +04:00
|
|
|
FillRule aFillRule);
|
2014-09-01 07:31:20 +04:00
|
|
|
explicit PathBuilderSkia(FillRule aFillRule);
|
2011-11-02 23:55:03 +04:00
|
|
|
|
2019-05-01 11:47:10 +03: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;
|
2019-04-11 15:36:51 +03:00
|
|
|
void Close() override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void Arc(const Point& aOrigin, float aRadius, float aStartAngle,
|
2019-04-11 15:36:51 +03:00
|
|
|
float aEndAngle, bool aAntiClockwise = false) override;
|
|
|
|
already_AddRefed<Path> Finish() override;
|
2011-11-02 23:55:03 +04:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
void AppendPath(const SkPath& aPath);
|
2013-12-13 02:37:00 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
BackendType GetBackendType() const override { return BackendType::SKIA; }
|
2013-12-13 02:37:00 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
private:
|
2019-06-05 10:55:46 +03:00
|
|
|
friend class PathSkia;
|
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
void SetFillRule(FillRule aFillRule);
|
|
|
|
|
|
|
|
SkPath mPath;
|
|
|
|
FillRule mFillRule;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PathSkia : public Path {
|
|
|
|
public:
|
2017-11-06 06:37:28 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathSkia, override)
|
|
|
|
|
2019-07-06 11:18:28 +03:00
|
|
|
PathSkia(SkPath& aPath, FillRule aFillRule, Point aCurrentPoint = Point(),
|
2019-06-05 10:55:46 +03:00
|
|
|
Point aBeginPoint = Point())
|
2019-07-06 11:18:28 +03:00
|
|
|
: mFillRule(aFillRule),
|
|
|
|
mCurrentPoint(aCurrentPoint),
|
|
|
|
mBeginPoint(aBeginPoint) {
|
2011-11-02 23:55:03 +04:00
|
|
|
mPath.swap(aPath);
|
|
|
|
}
|
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
BackendType GetBackendType() const override { return BackendType::SKIA; }
|
2017-11-06 06:37:28 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
already_AddRefed<PathBuilder> CopyToBuilder(
|
2017-11-06 06:37:28 +03:00
|
|
|
FillRule aFillRule) const override;
|
2019-04-11 15:36:51 +03:00
|
|
|
already_AddRefed<PathBuilder> TransformedCopyToBuilder(
|
2019-05-01 11:47:10 +03:00
|
|
|
const Matrix& aTransform, FillRule aFillRule) const override;
|
2017-11-06 06:37:28 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
bool ContainsPoint(const Point& aPoint,
|
|
|
|
const Matrix& aTransform) const override;
|
2011-11-02 23:55:03 +04:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
bool StrokeContainsPoint(const StrokeOptions& aStrokeOptions,
|
|
|
|
const Point& aPoint,
|
|
|
|
const Matrix& aTransform) const override;
|
2017-11-06 06:37:28 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
Rect GetBounds(const Matrix& aTransform = Matrix()) const override;
|
2012-10-29 19:54:53 +04:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
Rect GetStrokedBounds(const StrokeOptions& aStrokeOptions,
|
|
|
|
const Matrix& aTransform = Matrix()) const override;
|
2011-11-02 23:55:03 +04:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
void StreamToSink(PathSink* aSink) const override;
|
2013-11-07 13:10:12 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
FillRule GetFillRule() const override { return mFillRule; }
|
2011-11-02 23:55:03 +04:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
const SkPath& GetPath() const { return mPath; }
|
2011-11-02 23:55:03 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class DrawTargetSkia;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
SkPath mPath;
|
|
|
|
FillRule mFillRule;
|
2019-06-05 10:55:46 +03:00
|
|
|
Point mCurrentPoint;
|
|
|
|
Point mBeginPoint;
|
2011-11-02 23:55:03 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2011-11-02 23:55:03 +04:00
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_PATH_SKIA_H_ */
|