| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 || !SkScalarIsFinite(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 Loading... |
| 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 } |
| OLD | NEW |