Index: Source/platform/graphics/Path.h |
diff --git a/Source/platform/graphics/Path.h b/Source/platform/graphics/Path.h |
index 1970b97d500acbfe4b0dda535631c36f5c7d9ac0..3ed72b952d0c53303bade41e88e09209bdebf42e 100644 |
--- a/Source/platform/graphics/Path.h |
+++ b/Source/platform/graphics/Path.h |
@@ -33,6 +33,7 @@ |
#include "platform/geometry/RoundedRect.h" |
#include "platform/graphics/WindRule.h" |
#include "third_party/skia/include/core/SkPath.h" |
+#include "third_party/skia/include/core/SkPathMeasure.h" |
#include "wtf/FastAllocBase.h" |
#include "wtf/Forward.h" |
@@ -85,6 +86,25 @@ public: |
float normalAngleAtLength(float length, bool& ok) const; |
bool pointAndNormalAtLength(float length, FloatPoint&, float&) const; |
+ // Helper for computing a sequence of positions and normals (normal angles) on a path. |
+ // The best possible access pattern will be one where the |length| value is |
+ // strictly increasing. |
+ // For other access patterns, performance will vary depending on curvature |
+ // and number of segments, but should never be worse than that of the |
+ // state-less method on Path. |
+ class PLATFORM_EXPORT PositionCalculator { |
+ WTF_MAKE_NONCOPYABLE(PositionCalculator); |
+ public: |
+ explicit PositionCalculator(const Path&); |
+ |
+ bool pointAndNormalAtLength(float length, FloatPoint&, float&); |
+ |
+ private: |
+ SkPath m_path; |
+ SkPathMeasure m_pathMeasure; |
+ SkScalar m_accumulatedLength; |
+ }; |
+ |
void clear(); |
bool isEmpty() const; |
// Gets the current point of the current path, which is conceptually the final point reached by the path so far. |