OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "SkMath.h" | 9 #include "SkMath.h" |
10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
11 #include "SkMatrixUtils.h" | 11 #include "SkMatrixUtils.h" |
12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
13 | 13 |
14 static bool nearly_equal_scalar(SkScalar a, SkScalar b) { | 14 static bool nearly_equal_scalar(SkScalar a, SkScalar b) { |
15 // Note that we get more compounded error for multiple operations when | 15 // Note that we get more compounded error for multiple operations when |
16 // SK_SCALAR_IS_FIXED. | 16 // SK_SCALAR_IS_FIXED. |
17 #ifdef SK_SCALAR_IS_FLOAT | 17 #ifdef SK_SCALAR_IS_FLOAT |
18 const SkScalar tolerance = SK_Scalar1 / 200000; | 18 const SkScalar tolerance = SK_Scalar1 / 200000; |
19 #else | 19 #else |
20 const SkScalar tolerance = SK_Scalar1 / 1024; | 20 const SkScalar tolerance = SK_Scalar1 / 1024; |
21 #endif | 21 #endif |
22 | 22 |
23 return SkScalarAbs(a - b) <= tolerance; | 23 return SkScalarAbs(a - b) <= tolerance; |
24 } | 24 } |
25 | 25 |
26 static bool nearly_equal(const SkMatrix& a, const SkMatrix& b) { | 26 static bool nearly_equal(const SkMatrix& a, const SkMatrix& b) { |
27 for (int i = 0; i < 9; i++) { | 27 for (int i = 0; i < 9; i++) { |
28 if (!nearly_equal_scalar(a[i], b[i])) { | 28 if (!nearly_equal_scalar(a[i], b[i])) { |
29 printf("not equal %g %g\n", (float)a[i], (float)b[i]); | 29 SkDebugf("not equal %g %g\n", (float)a[i], (float)b[i]); |
30 return false; | 30 return false; |
31 } | 31 } |
32 } | 32 } |
33 return true; | 33 return true; |
34 } | 34 } |
35 | 35 |
36 static bool are_equal(skiatest::Reporter* reporter, | 36 static bool are_equal(skiatest::Reporter* reporter, |
37 const SkMatrix& a, | 37 const SkMatrix& a, |
38 const SkMatrix& b) { | 38 const SkMatrix& b) { |
39 bool equal = a == b; | 39 bool equal = a == b; |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 798 |
799 test_matrix_max_stretch(reporter); | 799 test_matrix_max_stretch(reporter); |
800 test_matrix_is_similarity(reporter); | 800 test_matrix_is_similarity(reporter); |
801 test_matrix_recttorect(reporter); | 801 test_matrix_recttorect(reporter); |
802 test_matrix_decomposition(reporter); | 802 test_matrix_decomposition(reporter); |
803 test_matrix_homogeneous(reporter); | 803 test_matrix_homogeneous(reporter); |
804 } | 804 } |
805 | 805 |
806 #include "TestClassDef.h" | 806 #include "TestClassDef.h" |
807 DEFINE_TESTCLASS("Matrix", MatrixTestClass, TestMatrix) | 807 DEFINE_TESTCLASS("Matrix", MatrixTestClass, TestMatrix) |
OLD | NEW |