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

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

Issue 1556353002: give up on quad root if infinite (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add comment Created 4 years, 11 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 | tests/PathTest.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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]) { 83 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]) {
84 SkASSERT(roots); 84 SkASSERT(roots);
85 85
86 if (A == 0) { 86 if (A == 0) {
87 return valid_unit_divide(-C, B, roots); 87 return valid_unit_divide(-C, B, roots);
88 } 88 }
89 89
90 SkScalar* r = roots; 90 SkScalar* r = roots;
91 91
92 SkScalar R = B*B - 4*A*C; 92 SkScalar R = B*B - 4*A*C;
93 if (R < 0 || SkScalarIsNaN(R)) { // complex roots 93 if (R < 0 || !SkScalarIsFinite(R)) { // complex roots
94 // if R is infinite, it's possible that it may still produce
95 // useful results if the operation was repeated in doubles
96 // the flipside is determining if the more precise answer
97 // isn't useful because surrounding machinery (e.g., subtracting
98 // the axis offset from C) already discards the extra precision
99 // more investigation and unit tests required...
94 return 0; 100 return 0;
95 } 101 }
96 R = SkScalarSqrt(R); 102 R = SkScalarSqrt(R);
97 103
98 SkScalar Q = (B < 0) ? -(B-R)/2 : -(B+R)/2; 104 SkScalar Q = (B < 0) ? -(B-R)/2 : -(B+R)/2;
99 r += valid_unit_divide(Q, A, r); 105 r += valid_unit_divide(Q, A, r);
100 r += valid_unit_divide(C, Q, r); 106 r += valid_unit_divide(C, Q, r);
101 if (r - roots == 2) { 107 if (r - roots == 2) {
102 if (roots[0] > roots[1]) 108 if (roots[0] > roots[1])
103 SkTSwap<SkScalar>(roots[0], roots[1]); 109 SkTSwap<SkScalar>(roots[0], roots[1]);
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 matrix.preScale(SK_Scalar1, -SK_Scalar1); 1577 matrix.preScale(SK_Scalar1, -SK_Scalar1);
1572 } 1578 }
1573 if (userMatrix) { 1579 if (userMatrix) {
1574 matrix.postConcat(*userMatrix); 1580 matrix.postConcat(*userMatrix);
1575 } 1581 }
1576 for (int i = 0; i < conicCount; ++i) { 1582 for (int i = 0; i < conicCount; ++i) {
1577 matrix.mapPoints(dst[i].fPts, 3); 1583 matrix.mapPoints(dst[i].fPts, 3);
1578 } 1584 }
1579 return conicCount; 1585 return conicCount;
1580 } 1586 }
OLDNEW
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698