Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: src/core/SkGeometry.cpp

Issue 2006653006: pin before calling acos (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pathops/SkPathOpsCubic.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | src/pathops/SkPathOpsCubic.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698