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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 FloatPoint Path::pointAtLength(float length, bool& ok) const | 163 FloatPoint Path::pointAtLength(float length, bool& ok) const |
164 { | 164 { |
165 FloatPoint point; | 165 FloatPoint point; |
166 float normal; | 166 float normal; |
167 ok = pointAndNormalAtLength(length, point, normal); | 167 ok = pointAndNormalAtLength(length, point, normal); |
168 return point; | 168 return point; |
169 } | 169 } |
170 | 170 |
171 float Path::normalAngleAtLength(float length, bool& ok) const | |
172 { | |
173 FloatPoint point; | |
174 float normal; | |
175 ok = pointAndNormalAtLength(length, point, normal); | |
176 return normal; | |
177 } | |
178 | |
179 static bool calculatePointAndNormalOnPath(SkPathMeasure& measure, SkScalar lengt
h, FloatPoint& point, float& normalAngle, SkScalar* accumulatedLength = 0) | 171 static bool calculatePointAndNormalOnPath(SkPathMeasure& measure, SkScalar lengt
h, FloatPoint& point, float& normalAngle, SkScalar* accumulatedLength = 0) |
180 { | 172 { |
181 do { | 173 do { |
182 SkScalar contourLength = measure.getLength(); | 174 SkScalar contourLength = measure.getLength(); |
183 if (length <= contourLength) { | 175 if (length <= contourLength) { |
184 SkVector tangent; | 176 SkVector tangent; |
185 SkPoint position; | 177 SkPoint position; |
186 | 178 |
187 if (measure.getPosTan(length, &position, &tangent)) { | 179 if (measure.getPosTan(length, &position, &tangent)) { |
188 normalAngle = rad2deg(SkScalarToFloat(SkScalarATan2(tangent.fY,
tangent.fX))); | 180 normalAngle = rad2deg(SkScalarToFloat(SkScalarATan2(tangent.fY,
tangent.fX))); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 result.setX(SkScalarToFloat(skResult.fX)); | 258 result.setX(SkScalarToFloat(skResult.fX)); |
267 result.setY(SkScalarToFloat(skResult.fY)); | 259 result.setY(SkScalarToFloat(skResult.fY)); |
268 return result; | 260 return result; |
269 } | 261 } |
270 | 262 |
271 // FIXME: Why does this return quietNaN? Other ports return 0,0. | 263 // FIXME: Why does this return quietNaN? Other ports return 0,0. |
272 float quietNaN = std::numeric_limits<float>::quiet_NaN(); | 264 float quietNaN = std::numeric_limits<float>::quiet_NaN(); |
273 return FloatPoint(quietNaN, quietNaN); | 265 return FloatPoint(quietNaN, quietNaN); |
274 } | 266 } |
275 | 267 |
276 WindRule Path::windRule() const | |
277 { | |
278 return m_path.getFillType() == SkPath::kEvenOdd_FillType | |
279 ? RULE_EVENODD | |
280 : RULE_NONZERO; | |
281 } | |
282 | |
283 void Path::setWindRule(const WindRule rule) | 268 void Path::setWindRule(const WindRule rule) |
284 { | 269 { |
285 m_path.setFillType(WebCoreWindRuleToSkFillType(rule)); | 270 m_path.setFillType(WebCoreWindRuleToSkFillType(rule)); |
286 } | 271 } |
287 | 272 |
288 void Path::moveTo(const FloatPoint& point) | 273 void Path::moveTo(const FloatPoint& point) |
289 { | 274 { |
290 m_path.moveTo(point.data()); | 275 m_path.moveTo(point.data()); |
291 } | 276 } |
292 | 277 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 void Path::translate(const FloatSize& size) | 472 void Path::translate(const FloatSize& size) |
488 { | 473 { |
489 m_path.offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(s
ize.height())); | 474 m_path.offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(s
ize.height())); |
490 } | 475 } |
491 | 476 |
492 bool Path::subtractPath(const Path& other) | 477 bool Path::subtractPath(const Path& other) |
493 { | 478 { |
494 return Op(m_path, other.m_path, kDifference_SkPathOp, &m_path); | 479 return Op(m_path, other.m_path, kDifference_SkPathOp, &m_path); |
495 } | 480 } |
496 | 481 |
497 bool Path::intersectPath(const Path& other) | |
498 { | |
499 return Op(m_path, other.m_path, kIntersect_SkPathOp, &m_path); | |
500 } | |
501 | |
502 bool Path::unionPath(const Path& other) | 482 bool Path::unionPath(const Path& other) |
503 { | 483 { |
504 return Op(m_path, other.m_path, kUnion_SkPathOp, &m_path); | 484 return Op(m_path, other.m_path, kUnion_SkPathOp, &m_path); |
505 } | 485 } |
506 | 486 |
507 #if ENABLE(ASSERT) | 487 #if ENABLE(ASSERT) |
508 bool ellipseIsRenderable(float startAngle, float endAngle) | 488 bool ellipseIsRenderable(float startAngle, float endAngle) |
509 { | 489 { |
510 return (std::abs(endAngle - startAngle) < twoPiFloat) | 490 return (std::abs(endAngle - startAngle) < twoPiFloat) |
511 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); | 491 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); |
512 } | 492 } |
513 #endif | 493 #endif |
514 | 494 |
515 } // namespace blink | 495 } // namespace blink |
OLD | NEW |