Bug 1735097 - Geolocation: use EpochTimeStamp instead of DOMTimeStamp r=saschanaz...
[gecko.git] / gfx / 2d / PathAnalysis.h
blobf162d962131f83c41f74263c9186bb1b27ba6243
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 #include "2D.h"
8 #include <vector>
10 namespace mozilla {
11 namespace gfx {
13 struct FlatPathOp {
14 enum OpType {
15 OP_MOVETO,
16 OP_LINETO,
19 OpType mType;
20 Point mPoint;
23 class FlattenedPath : public PathSink {
24 public:
25 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FlattenedPath, override)
27 FlattenedPath() : mCachedLength(0), mCalculatedLength(false) {}
29 virtual void MoveTo(const Point& aPoint) override;
30 virtual void LineTo(const Point& aPoint) override;
31 virtual void BezierTo(const Point& aCP1, const Point& aCP2,
32 const Point& aCP3) override;
33 virtual void QuadraticBezierTo(const Point& aCP1, const Point& aCP2) override;
34 virtual void Close() override;
35 virtual void Arc(const Point& aOrigin, float aRadius, float aStartAngle,
36 float aEndAngle, bool aAntiClockwise = false) override;
38 virtual Point CurrentPoint() const override {
39 return mPathOps.empty() ? Point() : mPathOps[mPathOps.size() - 1].mPoint;
42 Float ComputeLength();
43 Point ComputePointAtLength(Float aLength, Point* aTangent);
45 private:
46 Float mCachedLength;
47 bool mCalculatedLength;
49 std::vector<FlatPathOp> mPathOps;
52 } // namespace gfx
53 } // namespace mozilla