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
|
2013-11-11 03:42:07 +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/. */
|
|
|
|
|
|
|
|
#include "2D.h"
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
struct FlatPathOp {
|
|
|
|
enum OpType {
|
|
|
|
OP_MOVETO,
|
|
|
|
OP_LINETO,
|
|
|
|
};
|
|
|
|
|
|
|
|
OpType mType;
|
|
|
|
Point mPoint;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FlattenedPath : public PathSink {
|
|
|
|
public:
|
2017-11-06 06:37:28 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FlattenedPath, override)
|
|
|
|
|
2013-11-11 03:42:07 +04:00
|
|
|
FlattenedPath() : mCachedLength(0), mCalculatedLength(false) {}
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
virtual void MoveTo(const Point& aPoint) override;
|
|
|
|
virtual void LineTo(const Point& aPoint) override;
|
|
|
|
virtual void BezierTo(const Point& aCP1, const Point& aCP2,
|
|
|
|
const Point& aCP3) override;
|
|
|
|
virtual void QuadraticBezierTo(const Point& aCP1, const Point& aCP2) override;
|
2017-11-06 06:37:28 +03:00
|
|
|
virtual void Close() override;
|
2019-05-01 11:47:10 +03:00
|
|
|
virtual void Arc(const Point& aOrigin, float aRadius, float aStartAngle,
|
2017-11-06 06:37:28 +03:00
|
|
|
float aEndAngle, bool aAntiClockwise = false) override;
|
2013-11-11 03:42:07 +04:00
|
|
|
|
2017-11-06 06:37:28 +03:00
|
|
|
virtual Point CurrentPoint() const override {
|
|
|
|
return mPathOps.empty() ? Point() : mPathOps[mPathOps.size() - 1].mPoint;
|
|
|
|
}
|
2013-11-11 03:42:07 +04:00
|
|
|
|
|
|
|
Float ComputeLength();
|
2019-05-01 11:47:10 +03:00
|
|
|
Point ComputePointAtLength(Float aLength, Point* aTangent);
|
2013-11-11 03:42:07 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
Float mCachedLength;
|
|
|
|
bool mCalculatedLength;
|
|
|
|
|
|
|
|
std::vector<FlatPathOp> mPathOps;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|