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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 enum PathElementType { | 48 enum PathElementType { |
49 PathElementMoveToPoint, // The points member will contain 1 value. | 49 PathElementMoveToPoint, // The points member will contain 1 value. |
50 PathElementAddLineToPoint, // The points member will contain 1 value. | 50 PathElementAddLineToPoint, // The points member will contain 1 value. |
51 PathElementAddQuadCurveToPoint, // The points member will contain 2 values. | 51 PathElementAddQuadCurveToPoint, // The points member will contain 2 values. |
52 PathElementAddCurveToPoint, // The points member will contain 3 values. | 52 PathElementAddCurveToPoint, // The points member will contain 3 values. |
53 PathElementCloseSubpath // The points member will contain no values. | 53 PathElementCloseSubpath // The points member will contain no values. |
54 }; | 54 }; |
55 | 55 |
56 // The points in the structure are the same as those that would be used with the | 56 // The points in the structure are the same as those that would be used with the |
57 // add... method. For example, a line returns the endpoint, while a cubic return
s | 57 // add... method. For example, a line returns the endpoint, while a cubic |
58 // two tangent points and the endpoint. | 58 // returns two tangent points and the endpoint. |
59 struct PathElement { | 59 struct PathElement { |
60 PathElementType type; | 60 PathElementType type; |
61 FloatPoint* points; | 61 FloatPoint* points; |
62 }; | 62 }; |
63 | 63 |
64 typedef void (*PathApplierFunction)(void* info, const PathElement*); | 64 typedef void (*PathApplierFunction)(void* info, const PathElement*); |
65 | 65 |
66 class PLATFORM_EXPORT Path { | 66 class PLATFORM_EXPORT Path { |
67 USING_FAST_MALLOC(Path); | 67 USING_FAST_MALLOC(Path); |
68 | 68 |
(...skipping 16 matching lines...) Expand all Loading... |
85 Exact, // Tight, slower version. | 85 Exact, // Tight, slower version. |
86 }; | 86 }; |
87 FloatRect boundingRect(BoundsType = BoundsType::Conservative) const; | 87 FloatRect boundingRect(BoundsType = BoundsType::Conservative) const; |
88 FloatRect strokeBoundingRect(const StrokeData&, | 88 FloatRect strokeBoundingRect(const StrokeData&, |
89 BoundsType = BoundsType::Conservative) const; | 89 BoundsType = BoundsType::Conservative) const; |
90 | 90 |
91 float length() const; | 91 float length() const; |
92 FloatPoint pointAtLength(float length) const; | 92 FloatPoint pointAtLength(float length) const; |
93 void pointAndNormalAtLength(float length, FloatPoint&, float&) const; | 93 void pointAndNormalAtLength(float length, FloatPoint&, float&) const; |
94 | 94 |
95 // Helper for computing a sequence of positions and normals (normal angles) on
a path. | 95 // Helper for computing a sequence of positions and normals (normal angles) on |
96 // The best possible access pattern will be one where the |length| value is | 96 // a path. The best possible access pattern will be one where the |length| |
97 // strictly increasing. | 97 // value is strictly increasing. For other access patterns, performance will |
98 // For other access patterns, performance will vary depending on curvature | 98 // vary depending on curvature and number of segments, but should never be |
99 // and number of segments, but should never be worse than that of the | 99 // worse than that of the state-less method on Path. |
100 // state-less method on Path. | |
101 class PLATFORM_EXPORT PositionCalculator { | 100 class PLATFORM_EXPORT PositionCalculator { |
102 WTF_MAKE_NONCOPYABLE(PositionCalculator); | 101 WTF_MAKE_NONCOPYABLE(PositionCalculator); |
103 USING_FAST_MALLOC(PositionCalculator); | 102 USING_FAST_MALLOC(PositionCalculator); |
104 | 103 |
105 public: | 104 public: |
106 explicit PositionCalculator(const Path&); | 105 explicit PositionCalculator(const Path&); |
107 | 106 |
108 void pointAndNormalAtLength(float length, FloatPoint&, float&); | 107 void pointAndNormalAtLength(float length, FloatPoint&, float&); |
109 | 108 |
110 private: | 109 private: |
111 SkPath m_path; | 110 SkPath m_path; |
112 SkPathMeasure m_pathMeasure; | 111 SkPathMeasure m_pathMeasure; |
113 SkScalar m_accumulatedLength; | 112 SkScalar m_accumulatedLength; |
114 }; | 113 }; |
115 | 114 |
116 void clear(); | 115 void clear(); |
117 bool isEmpty() const; | 116 bool isEmpty() const; |
118 bool isClosed() const; | 117 bool isClosed() const; |
119 // Specify whether this path is volatile. Temporary paths that are discarded o
r | 118 |
120 // modified after use should be marked as volatile. This is a hint to the devi
ce | 119 // Specify whether this path is volatile. Temporary paths that are discarded |
121 // to not cache this path. | 120 // or modified after use should be marked as volatile. This is a hint to the |
| 121 // device to not cache this path. |
122 void setIsVolatile(bool); | 122 void setIsVolatile(bool); |
123 // Gets the current point of the current path, which is conceptually the final
point reached by the path so far. | 123 |
124 // Note the Path can be empty (isEmpty() == true) and still have a current poi
nt. | 124 // Gets the current point of the current path, which is conceptually the final |
| 125 // point reached by the path so far. Note the Path can be empty |
| 126 // (isEmpty() == true) and still have a current point. |
125 bool hasCurrentPoint() const; | 127 bool hasCurrentPoint() const; |
126 FloatPoint currentPoint() const; | 128 FloatPoint currentPoint() const; |
127 | 129 |
128 void setWindRule(const WindRule); | 130 void setWindRule(const WindRule); |
129 | 131 |
130 void moveTo(const FloatPoint&); | 132 void moveTo(const FloatPoint&); |
131 void addLineTo(const FloatPoint&); | 133 void addLineTo(const FloatPoint&); |
132 void addQuadCurveTo(const FloatPoint& controlPoint, | 134 void addQuadCurveTo(const FloatPoint& controlPoint, |
133 const FloatPoint& endPoint); | 135 const FloatPoint& endPoint); |
134 void addBezierCurveTo(const FloatPoint& controlPoint1, | 136 void addBezierCurveTo(const FloatPoint& controlPoint1, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 void transform(const AffineTransform&); | 177 void transform(const AffineTransform&); |
176 | 178 |
177 void addPathForRoundedRect(const FloatRect&, | 179 void addPathForRoundedRect(const FloatRect&, |
178 const FloatSize& topLeftRadius, | 180 const FloatSize& topLeftRadius, |
179 const FloatSize& topRightRadius, | 181 const FloatSize& topRightRadius, |
180 const FloatSize& bottomLeftRadius, | 182 const FloatSize& bottomLeftRadius, |
181 const FloatSize& bottomRightRadius); | 183 const FloatSize& bottomRightRadius); |
182 | 184 |
183 bool subtractPath(const Path&); | 185 bool subtractPath(const Path&); |
184 | 186 |
185 // Updates the path to the union (inclusive-or) of itself with the given argum
ent. | 187 // Updates the path to the union (inclusive-or) of itself with the given |
| 188 // argument. |
186 bool unionPath(const Path& other); | 189 bool unionPath(const Path& other); |
| 190 |
187 bool intersectPath(const Path& other); | 191 bool intersectPath(const Path& other); |
188 | 192 |
189 private: | 193 private: |
190 void addEllipse(const FloatPoint&, | 194 void addEllipse(const FloatPoint&, |
191 float radiusX, | 195 float radiusX, |
192 float radiusY, | 196 float radiusY, |
193 float startAngle, | 197 float startAngle, |
194 float endAngle, | 198 float endAngle, |
195 bool anticlockwise); | 199 bool anticlockwise); |
196 SkPath strokePath(const StrokeData&) const; | 200 SkPath strokePath(const StrokeData&) const; |
197 | 201 |
198 SkPath m_path; | 202 SkPath m_path; |
199 }; | 203 }; |
200 | 204 |
201 #if ENABLE(ASSERT) | 205 #if ENABLE(ASSERT) |
202 PLATFORM_EXPORT bool ellipseIsRenderable(float startAngle, float endAngle); | 206 PLATFORM_EXPORT bool ellipseIsRenderable(float startAngle, float endAngle); |
203 #endif | 207 #endif |
204 | 208 |
205 } // namespace blink | 209 } // namespace blink |
206 | 210 |
207 #endif | 211 #endif |
OLD | NEW |