| 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 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 largerRoot = SkMaxScalar(a, c); | 1887 largerRoot = SkMaxScalar(a, c); |
| 1888 } else { | 1888 } else { |
| 1889 SkScalar aminusc = a - c; | 1889 SkScalar aminusc = a - c; |
| 1890 SkScalar apluscdiv2 = SkScalarHalf(a + c); | 1890 SkScalar apluscdiv2 = SkScalarHalf(a + c); |
| 1891 SkScalar x = SkScalarHalf(SkScalarSqrt(SkScalarMul(aminusc, aminusc) + 4
* bSqd)); | 1891 SkScalar x = SkScalarHalf(SkScalarSqrt(SkScalarMul(aminusc, aminusc) + 4
* bSqd)); |
| 1892 largerRoot = apluscdiv2 + x; | 1892 largerRoot = apluscdiv2 + x; |
| 1893 } | 1893 } |
| 1894 return SkScalarSqrt(largerRoot); | 1894 return SkScalarSqrt(largerRoot); |
| 1895 } | 1895 } |
| 1896 | 1896 |
| 1897 DEF_SK_ONCE(reset_identity_matrix, SkMatrix* identity) { | 1897 static void reset_identity_matrix(SkMatrix* identity) { |
| 1898 identity->reset(); | 1898 identity->reset(); |
| 1899 } | 1899 } |
| 1900 | 1900 |
| 1901 const SkMatrix& SkMatrix::I() { | 1901 const SkMatrix& SkMatrix::I() { |
| 1902 // If you can use C++11 now, you might consider replacing this with a conste
xpr constructor. | 1902 // If you can use C++11 now, you might consider replacing this with a conste
xpr constructor. |
| 1903 static SkMatrix gIdentity; | 1903 static SkMatrix gIdentity; |
| 1904 SK_ONCE(reset_identity_matrix, &gIdentity); | 1904 SK_DECLARE_STATIC_ONCE(once); |
| 1905 SkOnce(&once, reset_identity_matrix, &gIdentity); |
| 1905 return gIdentity; | 1906 return gIdentity; |
| 1906 } | 1907 } |
| 1907 | 1908 |
| 1908 const SkMatrix& SkMatrix::InvalidMatrix() { | 1909 const SkMatrix& SkMatrix::InvalidMatrix() { |
| 1909 static SkMatrix gInvalid; | 1910 static SkMatrix gInvalid; |
| 1910 static bool gOnce; | 1911 static bool gOnce; |
| 1911 if (!gOnce) { | 1912 if (!gOnce) { |
| 1912 gInvalid.setAll(SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, | 1913 gInvalid.setAll(SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, |
| 1913 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, | 1914 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, |
| 1914 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax); | 1915 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 rotation1->fX = cos1; | 2103 rotation1->fX = cos1; |
| 2103 rotation1->fY = sin1; | 2104 rotation1->fY = sin1; |
| 2104 } | 2105 } |
| 2105 if (NULL != rotation2) { | 2106 if (NULL != rotation2) { |
| 2106 rotation2->fX = cos2; | 2107 rotation2->fX = cos2; |
| 2107 rotation2->fY = sin2; | 2108 rotation2->fY = sin2; |
| 2108 } | 2109 } |
| 2109 | 2110 |
| 2110 return true; | 2111 return true; |
| 2111 } | 2112 } |
| OLD | NEW |