| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkGeometry.h" | 8 #include "SkGeometry.h" |
| 9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
| 10 #include "SkNx.h" | 10 #include "SkNx.h" |
| (...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 for (int i = 0; i < conicCount; ++i) { | 1550 for (int i = 0; i < conicCount; ++i) { |
| 1551 dst[i].set(&quadrantPts[i * 2], quadrantWeight); | 1551 dst[i].set(&quadrantPts[i * 2], quadrantWeight); |
| 1552 } | 1552 } |
| 1553 | 1553 |
| 1554 // Now compute any remaing (sub-90-degree) arc for the last conic | 1554 // Now compute any remaing (sub-90-degree) arc for the last conic |
| 1555 const SkPoint finalP = { x, y }; | 1555 const SkPoint finalP = { x, y }; |
| 1556 const SkPoint& lastQ = quadrantPts[quadrant * 2]; // will already be a unit
-vector | 1556 const SkPoint& lastQ = quadrantPts[quadrant * 2]; // will already be a unit
-vector |
| 1557 const SkScalar dot = SkVector::DotProduct(lastQ, finalP); | 1557 const SkScalar dot = SkVector::DotProduct(lastQ, finalP); |
| 1558 SkASSERT(0 <= dot && dot <= SK_Scalar1 + SK_ScalarNearlyZero); | 1558 SkASSERT(0 <= dot && dot <= SK_Scalar1 + SK_ScalarNearlyZero); |
| 1559 | 1559 |
| 1560 if (dot < 1 - SK_ScalarNearlyZero) { | 1560 if (dot < 1) { |
| 1561 SkVector offCurve = { lastQ.x() + x, lastQ.y() + y }; | 1561 SkVector offCurve = { lastQ.x() + x, lastQ.y() + y }; |
| 1562 // compute the bisector vector, and then rescale to be the off-curve poi
nt. | 1562 // compute the bisector vector, and then rescale to be the off-curve poi
nt. |
| 1563 // we compute its length from cos(theta/2) = length / 1, using half-angl
e identity we get | 1563 // we compute its length from cos(theta/2) = length / 1, using half-angl
e identity we get |
| 1564 // length = sqrt(2 / (1 + cos(theta)). We already have cos() when to com
puted the dot. | 1564 // length = sqrt(2 / (1 + cos(theta)). We already have cos() when to com
puted the dot. |
| 1565 // This is nice, since our computed weight is cos(theta/2) as well! | 1565 // This is nice, since our computed weight is cos(theta/2) as well! |
| 1566 // | 1566 // |
| 1567 const SkScalar cosThetaOver2 = SkScalarSqrt((1 + dot) / 2); | 1567 const SkScalar cosThetaOver2 = SkScalarSqrt((1 + dot) / 2); |
| 1568 offCurve.setLength(SkScalarInvert(cosThetaOver2)); | 1568 offCurve.setLength(SkScalarInvert(cosThetaOver2)); |
| 1569 dst[conicCount].set(lastQ, offCurve, finalP, cosThetaOver2); | 1569 dst[conicCount].set(lastQ, offCurve, finalP, cosThetaOver2); |
| 1570 conicCount += 1; | 1570 conicCount += 1; |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 // now handle counter-clockwise and the initial unitStart rotation | 1573 // now handle counter-clockwise and the initial unitStart rotation |
| 1574 SkMatrix matrix; | 1574 SkMatrix matrix; |
| 1575 matrix.setSinCos(uStart.fY, uStart.fX); | 1575 matrix.setSinCos(uStart.fY, uStart.fX); |
| 1576 if (dir == kCCW_SkRotationDirection) { | 1576 if (dir == kCCW_SkRotationDirection) { |
| 1577 matrix.preScale(SK_Scalar1, -SK_Scalar1); | 1577 matrix.preScale(SK_Scalar1, -SK_Scalar1); |
| 1578 } | 1578 } |
| 1579 if (userMatrix) { | 1579 if (userMatrix) { |
| 1580 matrix.postConcat(*userMatrix); | 1580 matrix.postConcat(*userMatrix); |
| 1581 } | 1581 } |
| 1582 for (int i = 0; i < conicCount; ++i) { | 1582 for (int i = 0; i < conicCount; ++i) { |
| 1583 matrix.mapPoints(dst[i].fPts, 3); | 1583 matrix.mapPoints(dst[i].fPts, 3); |
| 1584 } | 1584 } |
| 1585 return conicCount; | 1585 return conicCount; |
| 1586 } | 1586 } |
| OLD | NEW |