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 "SkFloatBits.h" | 8 #include "SkFloatBits.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 #include "SkNx.h" | 10 #include "SkNx.h" |
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1561 SkScalar x = SkScalarHalf(SkScalarSqrt(aminusc * aminusc + 4 * bSqd)); | 1561 SkScalar x = SkScalarHalf(SkScalarSqrt(aminusc * aminusc + 4 * bSqd)); |
1562 if (kMin_MinMaxOrBoth == MIN_MAX_OR_BOTH) { | 1562 if (kMin_MinMaxOrBoth == MIN_MAX_OR_BOTH) { |
1563 results[0] = apluscdiv2 - x; | 1563 results[0] = apluscdiv2 - x; |
1564 } else if (kMax_MinMaxOrBoth == MIN_MAX_OR_BOTH) { | 1564 } else if (kMax_MinMaxOrBoth == MIN_MAX_OR_BOTH) { |
1565 results[0] = apluscdiv2 + x; | 1565 results[0] = apluscdiv2 + x; |
1566 } else { | 1566 } else { |
1567 results[0] = apluscdiv2 - x; | 1567 results[0] = apluscdiv2 - x; |
1568 results[1] = apluscdiv2 + x; | 1568 results[1] = apluscdiv2 + x; |
1569 } | 1569 } |
1570 } | 1570 } |
1571 if (SkScalarIsNaN(results[0])) { | 1571 if (!SkScalarIsFinite(results[0])) { |
1572 return false; | 1572 return false; |
1573 } | 1573 } |
1574 if (results[0] < 0 && results[0] > -SK_ScalarNearlyZero) { | |
jvanverth1
2016/07/15 13:49:05
I missed something here -- why was this changed to
reed1
2016/07/17 00:15:17
Agreed. This reads oddly -- we clamp nearly-zero-n
| |
1575 results[0] = 0; | |
1576 } | |
1574 SkASSERT(results[0] >= 0); | 1577 SkASSERT(results[0] >= 0); |
1575 results[0] = SkScalarSqrt(results[0]); | 1578 results[0] = SkScalarSqrt(results[0]); |
1576 if (kBoth_MinMaxOrBoth == MIN_MAX_OR_BOTH) { | 1579 if (kBoth_MinMaxOrBoth == MIN_MAX_OR_BOTH) { |
1577 if (SkScalarIsNaN(results[1])) { | 1580 if (!SkScalarIsFinite(results[1])) { |
1578 return false; | 1581 return false; |
1579 } | 1582 } |
1583 if (results[1] < 0 && results[1] > -SK_ScalarNearlyZero) { | |
1584 results[1] = 0; | |
1585 } | |
1580 SkASSERT(results[1] >= 0); | 1586 SkASSERT(results[1] >= 0); |
1581 results[1] = SkScalarSqrt(results[1]); | 1587 results[1] = SkScalarSqrt(results[1]); |
1582 } | 1588 } |
1583 return true; | 1589 return true; |
1584 } | 1590 } |
1585 | 1591 |
1586 SkScalar SkMatrix::getMinScale() const { | 1592 SkScalar SkMatrix::getMinScale() const { |
1587 SkScalar factor; | 1593 SkScalar factor; |
1588 if (get_scale_factor<kMin_MinMaxOrBoth>(this->getType(), fMat, &factor)) { | 1594 if (get_scale_factor<kMin_MinMaxOrBoth>(this->getType(), fMat, &factor)) { |
1589 return factor; | 1595 return factor; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1877 const SkScalar m10 = -m01; | 1883 const SkScalar m10 = -m01; |
1878 const SkScalar m11 = m00; | 1884 const SkScalar m11 = m00; |
1879 const SkScalar m12 = fTy; | 1885 const SkScalar m12 = fTy; |
1880 | 1886 |
1881 quad[0].set(m02, m12); | 1887 quad[0].set(m02, m12); |
1882 quad[1].set(m00 * width + m02, m10 * width + m12); | 1888 quad[1].set(m00 * width + m02, m10 * width + m12); |
1883 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); | 1889 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); |
1884 quad[3].set(m01 * height + m02, m11 * height + m12); | 1890 quad[3].set(m01 * height + m02, m11 * height + m12); |
1885 #endif | 1891 #endif |
1886 } | 1892 } |
OLD | NEW |