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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 return true; | 32 return true; |
33 } | 33 } |
34 | 34 |
35 static bool are_equal(skiatest::Reporter* reporter, | 35 static bool are_equal(skiatest::Reporter* reporter, |
36 const SkMatrix& a, | 36 const SkMatrix& a, |
37 const SkMatrix& b) { | 37 const SkMatrix& b) { |
38 bool equal = a == b; | 38 bool equal = a == b; |
39 bool cheapEqual = a.cheapEqualTo(b); | 39 bool cheapEqual = a.cheapEqualTo(b); |
40 if (equal != cheapEqual) { | 40 if (equal != cheapEqual) { |
41 #if SK_SCALAR_IS_FLOAT | 41 #ifdef SK_SCALAR_IS_FLOAT |
42 if (equal) { | 42 if (equal) { |
43 bool foundZeroSignDiff = false; | 43 bool foundZeroSignDiff = false; |
44 for (int i = 0; i < 9; ++i) { | 44 for (int i = 0; i < 9; ++i) { |
45 float aVal = a.get(i); | 45 float aVal = a.get(i); |
46 float bVal = b.get(i); | 46 float bVal = b.get(i); |
47 int aValI = *SkTCast<int*>(&aVal); | 47 int aValI = *SkTCast<int*>(&aVal); |
48 int bValI = *SkTCast<int*>(&bVal); | 48 int bValI = *SkTCast<int*>(&bVal); |
49 if (0 == aVal && 0 == bVal && aValI != bValI) { | 49 if (0 == aVal && 0 == bVal && aValI != bValI) { |
50 foundZeroSignDiff = true; | 50 foundZeroSignDiff = true; |
51 } else { | 51 } else { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // perspective x | 280 // perspective x |
281 mat.reset(); | 281 mat.reset(); |
282 mat.setPerspX(SkScalarToPersp(SK_Scalar1 / 2)); | 282 mat.setPerspX(SkScalarToPersp(SK_Scalar1 / 2)); |
283 REPORTER_ASSERT(reporter, !mat.isSimilarity()); | 283 REPORTER_ASSERT(reporter, !mat.isSimilarity()); |
284 | 284 |
285 // perspective y | 285 // perspective y |
286 mat.reset(); | 286 mat.reset(); |
287 mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2)); | 287 mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2)); |
288 REPORTER_ASSERT(reporter, !mat.isSimilarity()); | 288 REPORTER_ASSERT(reporter, !mat.isSimilarity()); |
289 | 289 |
290 #if SK_SCALAR_IS_FLOAT | 290 #ifdef SK_SCALAR_IS_FLOAT |
291 /* We bypass the following tests for SK_SCALAR_IS_FIXED build. | 291 /* We bypass the following tests for SK_SCALAR_IS_FIXED build. |
292 * The long discussion can be found in this issue: | 292 * The long discussion can be found in this issue: |
293 * http://codereview.appspot.com/5999050/ | 293 * http://codereview.appspot.com/5999050/ |
294 * In short, we haven't found a perfect way to fix the precision | 294 * In short, we haven't found a perfect way to fix the precision |
295 * issue, i.e. the way we use tolerance in isSimilarityTransformation | 295 * issue, i.e. the way we use tolerance in isSimilarityTransformation |
296 * is incorrect. The situation becomes worse in fixed build, so | 296 * is incorrect. The situation becomes worse in fixed build, so |
297 * we disabled rotation related tests for fixed build. | 297 * we disabled rotation related tests for fixed build. |
298 */ | 298 */ |
299 | 299 |
300 // rotate | 300 // rotate |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 REPORTER_ASSERT(reporter, !are_equal(reporter, mat, mat2)); | 462 REPORTER_ASSERT(reporter, !are_equal(reporter, mat, mat2)); |
463 #endif | 463 #endif |
464 | 464 |
465 test_matrix_max_stretch(reporter); | 465 test_matrix_max_stretch(reporter); |
466 test_matrix_is_similarity(reporter); | 466 test_matrix_is_similarity(reporter); |
467 test_matrix_recttorect(reporter); | 467 test_matrix_recttorect(reporter); |
468 } | 468 } |
469 | 469 |
470 #include "TestClassDef.h" | 470 #include "TestClassDef.h" |
471 DEFINE_TESTCLASS("Matrix", MatrixTestClass, TestMatrix) | 471 DEFINE_TESTCLASS("Matrix", MatrixTestClass, TestMatrix) |
OLD | NEW |