OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved. |
3 * 2006 Rob Buis <buis@kde.org> | 3 * 2006 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007-2008 Torch Mobile, Inc. | 4 * Copyright (C) 2007-2008 Torch Mobile, Inc. |
5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 15 matching lines...) Expand all Loading... |
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #ifndef Path_h | 29 #ifndef Path_h |
30 #define Path_h | 30 #define Path_h |
31 | 31 |
32 #include "platform/PlatformExport.h" | 32 #include "platform/PlatformExport.h" |
33 #include "platform/geometry/RoundedRect.h" | 33 #include "platform/geometry/RoundedRect.h" |
34 #include "platform/graphics/WindRule.h" | 34 #include "platform/graphics/WindRule.h" |
35 #include "third_party/skia/include/core/SkPath.h" | 35 #include "third_party/skia/include/core/SkPath.h" |
| 36 #include "third_party/skia/include/core/SkPathMeasure.h" |
36 #include "wtf/FastAllocBase.h" | 37 #include "wtf/FastAllocBase.h" |
37 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
38 | 39 |
39 class SkPath; | 40 class SkPath; |
40 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
42 | 43 |
43 class AffineTransform; | 44 class AffineTransform; |
44 class FloatPoint; | 45 class FloatPoint; |
45 class FloatRect; | 46 class FloatRect; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 bool contains(const FloatPoint&, WindRule = RULE_NONZERO) const; | 79 bool contains(const FloatPoint&, WindRule = RULE_NONZERO) const; |
79 bool strokeContains(const FloatPoint&, const StrokeData&) const; | 80 bool strokeContains(const FloatPoint&, const StrokeData&) const; |
80 FloatRect boundingRect() const; | 81 FloatRect boundingRect() const; |
81 FloatRect strokeBoundingRect(const StrokeData&) const; | 82 FloatRect strokeBoundingRect(const StrokeData&) const; |
82 | 83 |
83 float length() const; | 84 float length() const; |
84 FloatPoint pointAtLength(float length, bool& ok) const; | 85 FloatPoint pointAtLength(float length, bool& ok) const; |
85 float normalAngleAtLength(float length, bool& ok) const; | 86 float normalAngleAtLength(float length, bool& ok) const; |
86 bool pointAndNormalAtLength(float length, FloatPoint&, float&) const; | 87 bool pointAndNormalAtLength(float length, FloatPoint&, float&) const; |
87 | 88 |
| 89 // Helper for computing a sequence of positions and normals (normal angles)
on a path. |
| 90 // The best possible access pattern will be one where the |length| value is |
| 91 // strictly increasing. |
| 92 // For other access patterns, performance will vary depending on curvature |
| 93 // and number of segments, but should never be worse than that of the |
| 94 // state-less method on Path. |
| 95 class PLATFORM_EXPORT PositionCalculator { |
| 96 WTF_MAKE_NONCOPYABLE(PositionCalculator); |
| 97 public: |
| 98 explicit PositionCalculator(const Path&); |
| 99 |
| 100 bool pointAndNormalAtLength(float length, FloatPoint&, float&); |
| 101 |
| 102 private: |
| 103 SkPath m_path; |
| 104 SkPathMeasure m_pathMeasure; |
| 105 SkScalar m_accumulatedLength; |
| 106 }; |
| 107 |
88 void clear(); | 108 void clear(); |
89 bool isEmpty() const; | 109 bool isEmpty() const; |
90 // Gets the current point of the current path, which is conceptually the fin
al point reached by the path so far. | 110 // Gets the current point of the current path, which is conceptually the fin
al point reached by the path so far. |
91 // Note the Path can be empty (isEmpty() == true) and still have a current p
oint. | 111 // Note the Path can be empty (isEmpty() == true) and still have a current p
oint. |
92 bool hasCurrentPoint() const; | 112 bool hasCurrentPoint() const; |
93 FloatPoint currentPoint() const; | 113 FloatPoint currentPoint() const; |
94 | 114 |
95 WindRule windRule() const; | 115 WindRule windRule() const; |
96 void setWindRule(const WindRule); | 116 void setWindRule(const WindRule); |
97 | 117 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 SkPath m_path; | 150 SkPath m_path; |
131 }; | 151 }; |
132 | 152 |
133 #if !ASSERT_DISABLED | 153 #if !ASSERT_DISABLED |
134 PLATFORM_EXPORT bool ellipseIsRenderable(float startAngle, float endAngle); | 154 PLATFORM_EXPORT bool ellipseIsRenderable(float startAngle, float endAngle); |
135 #endif | 155 #endif |
136 | 156 |
137 } | 157 } |
138 | 158 |
139 #endif | 159 #endif |
OLD | NEW |