michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "2D.h" michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: struct FlatPathOp michael@0: { michael@0: enum OpType { michael@0: OP_MOVETO, michael@0: OP_LINETO, michael@0: }; michael@0: michael@0: OpType mType; michael@0: Point mPoint; michael@0: }; michael@0: michael@0: class FlattenedPath : public PathSink michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FlattenedPath) michael@0: FlattenedPath() : mCachedLength(0) michael@0: , mCalculatedLength(false) michael@0: { michael@0: } michael@0: michael@0: virtual void MoveTo(const Point &aPoint); michael@0: virtual void LineTo(const Point &aPoint); michael@0: virtual void BezierTo(const Point &aCP1, michael@0: const Point &aCP2, michael@0: const Point &aCP3); michael@0: virtual void QuadraticBezierTo(const Point &aCP1, michael@0: const Point &aCP2); michael@0: virtual void Close(); michael@0: virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle, michael@0: float aEndAngle, bool aAntiClockwise = false); michael@0: michael@0: virtual Point CurrentPoint() const { return mPathOps.empty() ? Point() : mPathOps[mPathOps.size() - 1].mPoint; } michael@0: michael@0: Float ComputeLength(); michael@0: Point ComputePointAtLength(Float aLength, Point *aTangent); michael@0: michael@0: private: michael@0: Float mCachedLength; michael@0: bool mCalculatedLength; michael@0: Point mLastMove; michael@0: michael@0: std::vector mPathOps; michael@0: }; michael@0: michael@0: } michael@0: }