Chromium Code Reviews| 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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1344 | 1344 |
| 1345 if (dot < 1) { | 1345 if (dot < 1) { |
| 1346 SkVector offCurve = { lastQ.x() + x, lastQ.y() + y }; | 1346 SkVector offCurve = { lastQ.x() + x, lastQ.y() + y }; |
| 1347 // compute the bisector vector, and then rescale to be the off-curve poi nt. | 1347 // compute the bisector vector, and then rescale to be the off-curve poi nt. |
| 1348 // we compute its length from cos(theta/2) = length / 1, using half-angl e identity we get | 1348 // we compute its length from cos(theta/2) = length / 1, using half-angl e identity we get |
| 1349 // length = sqrt(2 / (1 + cos(theta)). We already have cos() when to com puted the dot. | 1349 // length = sqrt(2 / (1 + cos(theta)). We already have cos() when to com puted the dot. |
| 1350 // This is nice, since our computed weight is cos(theta/2) as well! | 1350 // This is nice, since our computed weight is cos(theta/2) as well! |
| 1351 // | 1351 // |
| 1352 const SkScalar cosThetaOver2 = SkScalarSqrt((1 + dot) / 2); | 1352 const SkScalar cosThetaOver2 = SkScalarSqrt((1 + dot) / 2); |
| 1353 offCurve.setLength(SkScalarInvert(cosThetaOver2)); | 1353 offCurve.setLength(SkScalarInvert(cosThetaOver2)); |
| 1354 dst[conicCount].set(lastQ, offCurve, finalP, cosThetaOver2); | 1354 if (!lastQ.equalsWithinTolerance(offCurve)) { |
| 1355 conicCount += 1; | 1355 dst[conicCount].set(lastQ, offCurve, finalP, cosThetaOver2); |
| 1356 conicCount += 1; | |
| 1357 } | |
|
Mark Kilgard
2016/08/26 17:13:07
I don't like this epsilon handling here. It's jus
| |
| 1356 } | 1358 } |
| 1357 | 1359 |
| 1358 // now handle counter-clockwise and the initial unitStart rotation | 1360 // now handle counter-clockwise and the initial unitStart rotation |
| 1359 SkMatrix matrix; | 1361 SkMatrix matrix; |
| 1360 matrix.setSinCos(uStart.fY, uStart.fX); | 1362 matrix.setSinCos(uStart.fY, uStart.fX); |
| 1361 if (dir == kCCW_SkRotationDirection) { | 1363 if (dir == kCCW_SkRotationDirection) { |
| 1362 matrix.preScale(SK_Scalar1, -SK_Scalar1); | 1364 matrix.preScale(SK_Scalar1, -SK_Scalar1); |
| 1363 } | 1365 } |
| 1364 if (userMatrix) { | 1366 if (userMatrix) { |
| 1365 matrix.postConcat(*userMatrix); | 1367 matrix.postConcat(*userMatrix); |
| 1366 } | 1368 } |
| 1367 for (int i = 0; i < conicCount; ++i) { | 1369 for (int i = 0; i < conicCount; ++i) { |
| 1368 matrix.mapPoints(dst[i].fPts, 3); | 1370 matrix.mapPoints(dst[i].fPts, 3); |
| 1369 } | 1371 } |
| 1370 return conicCount; | 1372 return conicCount; |
| 1371 } | 1373 } |
| OLD | NEW |