| 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 "SkMatrix.h" | 8 #include "SkMatrix.h" |
| 9 #include "Sk64.h" | 9 #include "Sk64.h" |
| 10 #include "SkFloatBits.h" | 10 #include "SkFloatBits.h" |
| (...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 SkScalar c = SkScalarMul(fMat[kMSkewX], fMat[kMSkewX]) + | 1801 SkScalar c = SkScalarMul(fMat[kMSkewX], fMat[kMSkewX]) + |
| 1802 SkScalarMul(fMat[kMScaleY], fMat[kMScaleY]); | 1802 SkScalarMul(fMat[kMScaleY], fMat[kMScaleY]); |
| 1803 // eigenvalues of A^T*A are the squared singular values of A. | 1803 // eigenvalues of A^T*A are the squared singular values of A. |
| 1804 // characteristic equation is det((A^T*A) - l*I) = 0 | 1804 // characteristic equation is det((A^T*A) - l*I) = 0 |
| 1805 // l^2 - (a + c)l + (ac-b^2) | 1805 // l^2 - (a + c)l + (ac-b^2) |
| 1806 // solve using quadratic equation (divisor is non-zero since l^2 has 1 coeff | 1806 // solve using quadratic equation (divisor is non-zero since l^2 has 1 coeff |
| 1807 // and roots are guaraunteed to be pos and real). | 1807 // and roots are guaraunteed to be pos and real). |
| 1808 SkScalar largerRoot; | 1808 SkScalar largerRoot; |
| 1809 SkScalar bSqd = SkScalarMul(b,b); | 1809 SkScalar bSqd = SkScalarMul(b,b); |
| 1810 // if upper left 2x2 is orthogonal save some math | 1810 // if upper left 2x2 is orthogonal save some math |
| 1811 if (bSqd <= SK_ScalarNearlyZero) { | 1811 if (bSqd <= SK_ScalarNearlyZero*SK_ScalarNearlyZero) { |
| 1812 largerRoot = SkMaxScalar(a, c); | 1812 largerRoot = SkMaxScalar(a, c); |
| 1813 } else { | 1813 } else { |
| 1814 SkScalar aminusc = a - c; | 1814 SkScalar aminusc = a - c; |
| 1815 SkScalar apluscdiv2 = SkScalarHalf(a + c); | 1815 SkScalar apluscdiv2 = SkScalarHalf(a + c); |
| 1816 SkScalar x = SkScalarHalf(SkScalarSqrt(SkScalarMul(aminusc, aminusc) + 4
* bSqd)); | 1816 SkScalar x = SkScalarHalf(SkScalarSqrt(SkScalarMul(aminusc, aminusc) + 4
* bSqd)); |
| 1817 largerRoot = apluscdiv2 + x; | 1817 largerRoot = apluscdiv2 + x; |
| 1818 } | 1818 } |
| 1819 return SkScalarSqrt(largerRoot); | 1819 return SkScalarSqrt(largerRoot); |
| 1820 } | 1820 } |
| 1821 | 1821 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1924 dst.fLeft *= scale; | 1924 dst.fLeft *= scale; |
| 1925 dst.fTop *= scale; | 1925 dst.fTop *= scale; |
| 1926 dst.fRight *= scale; | 1926 dst.fRight *= scale; |
| 1927 dst.fBottom *= scale; | 1927 dst.fBottom *= scale; |
| 1928 } | 1928 } |
| 1929 | 1929 |
| 1930 SkIRect idst; | 1930 SkIRect idst; |
| 1931 dst.round(&idst); | 1931 dst.round(&idst); |
| 1932 return isrc == idst; | 1932 return isrc == idst; |
| 1933 } | 1933 } |
| OLD | NEW |