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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 R = (2*a*a*a - 9*a*b + 27*c) / 54; | 736 R = (2*a*a*a - 9*a*b + 27*c) / 54; |
737 | 737 |
738 SkScalar Q3 = Q * Q * Q; | 738 SkScalar Q3 = Q * Q * Q; |
739 SkScalar R2MinusQ3 = R * R - Q3; | 739 SkScalar R2MinusQ3 = R * R - Q3; |
740 SkScalar adiv3 = a / 3; | 740 SkScalar adiv3 = a / 3; |
741 | 741 |
742 SkScalar* roots = tValues; | 742 SkScalar* roots = tValues; |
743 SkScalar r; | 743 SkScalar r; |
744 | 744 |
745 if (R2MinusQ3 < 0) { // we have 3 real roots | 745 if (R2MinusQ3 < 0) { // we have 3 real roots |
746 SkScalar theta = SkScalarACos(R / SkScalarSqrt(Q3)); | 746 SkScalar theta = SkScalarACos(SkScalarPin(R / SkScalarSqrt(Q3), -1, 1)); // bug.skia.org/5222 |
reed1
2016/05/25 17:12:52
Perhaps ah comment as to why we pin ...
1. the div
| |
747 SkScalar neg2RootQ = -2 * SkScalarSqrt(Q); | 747 SkScalar neg2RootQ = -2 * SkScalarSqrt(Q); |
748 | 748 |
749 r = neg2RootQ * SkScalarCos(theta/3) - adiv3; | 749 r = neg2RootQ * SkScalarCos(theta/3) - adiv3; |
750 if (is_unit_interval(r)) { | 750 if (is_unit_interval(r)) { |
751 *roots++ = r; | 751 *roots++ = r; |
752 } | 752 } |
753 r = neg2RootQ * SkScalarCos((theta + 2*SK_ScalarPI)/3) - adiv3; | 753 r = neg2RootQ * SkScalarCos((theta + 2*SK_ScalarPI)/3) - adiv3; |
754 if (is_unit_interval(r)) { | 754 if (is_unit_interval(r)) { |
755 *roots++ = r; | 755 *roots++ = r; |
756 } | 756 } |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1338 matrix.preScale(SK_Scalar1, -SK_Scalar1); | 1338 matrix.preScale(SK_Scalar1, -SK_Scalar1); |
1339 } | 1339 } |
1340 if (userMatrix) { | 1340 if (userMatrix) { |
1341 matrix.postConcat(*userMatrix); | 1341 matrix.postConcat(*userMatrix); |
1342 } | 1342 } |
1343 for (int i = 0; i < conicCount; ++i) { | 1343 for (int i = 0; i < conicCount; ++i) { |
1344 matrix.mapPoints(dst[i].fPts, 3); | 1344 matrix.mapPoints(dst[i].fPts, 3); |
1345 } | 1345 } |
1346 return conicCount; | 1346 return conicCount; |
1347 } | 1347 } |
OLD | NEW |