| 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" |
| 11 #include "SkOnce.h" |
| 11 #include "SkScalarCompare.h" | 12 #include "SkScalarCompare.h" |
| 12 #include "SkString.h" | 13 #include "SkString.h" |
| 13 | 14 |
| 14 #ifdef SK_SCALAR_IS_FLOAT | 15 #ifdef SK_SCALAR_IS_FLOAT |
| 15 #define kMatrix22Elem SK_Scalar1 | 16 #define kMatrix22Elem SK_Scalar1 |
| 16 | 17 |
| 17 static inline float SkDoubleToFloat(double x) { | 18 static inline float SkDoubleToFloat(double x) { |
| 18 return static_cast<float>(x); | 19 return static_cast<float>(x); |
| 19 } | 20 } |
| 20 #else | 21 #else |
| (...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1886 largerRoot = SkMaxScalar(a, c); | 1887 largerRoot = SkMaxScalar(a, c); |
| 1887 } else { | 1888 } else { |
| 1888 SkScalar aminusc = a - c; | 1889 SkScalar aminusc = a - c; |
| 1889 SkScalar apluscdiv2 = SkScalarHalf(a + c); | 1890 SkScalar apluscdiv2 = SkScalarHalf(a + c); |
| 1890 SkScalar x = SkScalarHalf(SkScalarSqrt(SkScalarMul(aminusc, aminusc) + 4
* bSqd)); | 1891 SkScalar x = SkScalarHalf(SkScalarSqrt(SkScalarMul(aminusc, aminusc) + 4
* bSqd)); |
| 1891 largerRoot = apluscdiv2 + x; | 1892 largerRoot = apluscdiv2 + x; |
| 1892 } | 1893 } |
| 1893 return SkScalarSqrt(largerRoot); | 1894 return SkScalarSqrt(largerRoot); |
| 1894 } | 1895 } |
| 1895 | 1896 |
| 1897 DEF_SK_ONCE(reset_identity_matrix, SkMatrix* identity) { |
| 1898 identity->reset(); |
| 1899 } |
| 1900 |
| 1896 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. |
| 1897 static SkMatrix gIdentity; | 1903 static SkMatrix gIdentity; |
| 1898 static bool gOnce; | 1904 SK_ONCE(reset_identity_matrix, &gIdentity); |
| 1899 if (!gOnce) { | |
| 1900 gIdentity.reset(); | |
| 1901 gOnce = true; | |
| 1902 } | |
| 1903 return gIdentity; | 1905 return gIdentity; |
| 1904 } | 1906 } |
| 1905 | 1907 |
| 1906 const SkMatrix& SkMatrix::InvalidMatrix() { | 1908 const SkMatrix& SkMatrix::InvalidMatrix() { |
| 1907 static SkMatrix gInvalid; | 1909 static SkMatrix gInvalid; |
| 1908 static bool gOnce; | 1910 static bool gOnce; |
| 1909 if (!gOnce) { | 1911 if (!gOnce) { |
| 1910 gInvalid.setAll(SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, | 1912 gInvalid.setAll(SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, |
| 1911 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, | 1913 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, |
| 1912 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax); | 1914 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 rotation1->fX = cos1; | 2102 rotation1->fX = cos1; |
| 2101 rotation1->fY = sin1; | 2103 rotation1->fY = sin1; |
| 2102 } | 2104 } |
| 2103 if (NULL != rotation2) { | 2105 if (NULL != rotation2) { |
| 2104 rotation2->fX = cos2; | 2106 rotation2->fX = cos2; |
| 2105 rotation2->fY = sin2; | 2107 rotation2->fY = sin2; |
| 2106 } | 2108 } |
| 2107 | 2109 |
| 2108 return true; | 2110 return true; |
| 2109 } | 2111 } |
| OLD | NEW |