OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. |
3 * 2006 Rob Buis <buis@kde.org> | 3 * 2006 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
6 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 length -= contourLength; | 197 length -= contourLength; |
198 if (accumulatedLength) | 198 if (accumulatedLength) |
199 *accumulatedLength += contourLength; | 199 *accumulatedLength += contourLength; |
200 } while (measure.nextContour()); | 200 } while (measure.nextContour()); |
201 return false; | 201 return false; |
202 } | 202 } |
203 | 203 |
204 bool Path::pointAndNormalAtLength(float length, FloatPoint& point, float& normal
) const | 204 bool Path::pointAndNormalAtLength(float length, FloatPoint& point, float& normal
) const |
205 { | 205 { |
206 SkPathMeasure measure(m_path, false); | 206 SkPathMeasure measure(m_path, false); |
207 | |
208 if (calculatePointAndNormalOnPath(measure, WebCoreFloatToSkScalar(length), p
oint, normal)) | 207 if (calculatePointAndNormalOnPath(measure, WebCoreFloatToSkScalar(length), p
oint, normal)) |
209 return true; | 208 return true; |
210 | 209 |
| 210 SkPoint position = m_path.getPoint(0); |
| 211 point = FloatPoint(SkScalarToFloat(position.fX), SkScalarToFloat(position.fY
)); |
211 normal = 0; | 212 normal = 0; |
212 point = FloatPoint(0, 0); | |
213 return false; | 213 return false; |
214 } | 214 } |
215 | 215 |
216 Path::PositionCalculator::PositionCalculator(const Path& path) | 216 Path::PositionCalculator::PositionCalculator(const Path& path) |
217 : m_path(path.skPath()) | 217 : m_path(path.skPath()) |
218 , m_pathMeasure(path.skPath(), false) | 218 , m_pathMeasure(path.skPath(), false) |
219 , m_accumulatedLength(0) | 219 , m_accumulatedLength(0) |
220 { | 220 { |
221 } | 221 } |
222 | 222 |
223 bool Path::PositionCalculator::pointAndNormalAtLength(float length, FloatPoint&
point, float& normalAngle) | 223 bool Path::PositionCalculator::pointAndNormalAtLength(float length, FloatPoint&
point, float& normalAngle) |
224 { | 224 { |
225 SkScalar skLength = WebCoreFloatToSkScalar(length); | 225 SkScalar skLength = WebCoreFloatToSkScalar(length); |
226 if (skLength >= 0) { | 226 if (skLength >= 0) { |
227 if (skLength < m_accumulatedLength) { | 227 if (skLength < m_accumulatedLength) { |
228 // Reset path measurer to rewind (and restart from 0). | 228 // Reset path measurer to rewind (and restart from 0). |
229 m_pathMeasure.setPath(&m_path, false); | 229 m_pathMeasure.setPath(&m_path, false); |
230 m_accumulatedLength = 0; | 230 m_accumulatedLength = 0; |
231 } else { | 231 } else { |
232 skLength -= m_accumulatedLength; | 232 skLength -= m_accumulatedLength; |
233 } | 233 } |
234 | 234 |
235 if (calculatePointAndNormalOnPath(m_pathMeasure, skLength, point, normal
Angle, &m_accumulatedLength)) | 235 if (calculatePointAndNormalOnPath(m_pathMeasure, skLength, point, normal
Angle, &m_accumulatedLength)) |
236 return true; | 236 return true; |
237 } | 237 } |
238 | 238 |
| 239 SkPoint position = m_path.getPoint(0); |
| 240 point = FloatPoint(SkScalarToFloat(position.fX), SkScalarToFloat(position.fY
)); |
239 normalAngle = 0; | 241 normalAngle = 0; |
240 point = FloatPoint(0, 0); | |
241 return false; | 242 return false; |
242 } | 243 } |
243 | 244 |
244 void Path::clear() | 245 void Path::clear() |
245 { | 246 { |
246 m_path.reset(); | 247 m_path.reset(); |
247 } | 248 } |
248 | 249 |
249 bool Path::isEmpty() const | 250 bool Path::isEmpty() const |
250 { | 251 { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 499 |
499 #if ENABLE(ASSERT) | 500 #if ENABLE(ASSERT) |
500 bool ellipseIsRenderable(float startAngle, float endAngle) | 501 bool ellipseIsRenderable(float startAngle, float endAngle) |
501 { | 502 { |
502 return (std::abs(endAngle - startAngle) < twoPiFloat) | 503 return (std::abs(endAngle - startAngle) < twoPiFloat) |
503 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); | 504 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); |
504 } | 505 } |
505 #endif | 506 #endif |
506 | 507 |
507 } // namespace blink | 508 } // namespace blink |
OLD | NEW |