| OLD | NEW |
| 1 #include "Test.h" | 1 #include "Test.h" |
| 2 #include "SkMatrix.h" | 2 #include "SkMatrix.h" |
| 3 | 3 |
| 4 static bool nearly_equal_scalar(SkScalar a, SkScalar b) { | 4 static bool nearly_equal_scalar(SkScalar a, SkScalar b) { |
| 5 #ifdef SK_SCALAR_IS_FLOAT | 5 #ifdef SK_SCALAR_IS_FLOAT |
| 6 const float tolerance = 0.000005f; | 6 const float tolerance = 0.000005f; |
| 7 #else | 7 #else |
| 8 const int32_t tolerance = 3; | 8 const int32_t tolerance = 3; |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 return nearly_equal(m, identity); | 27 return nearly_equal(m, identity); |
| 28 } | 28 } |
| 29 | 29 |
| 30 static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) { | 30 static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) { |
| 31 // add 100 in case we have a bug, I don't want to kill my stack in the test | 31 // add 100 in case we have a bug, I don't want to kill my stack in the test |
| 32 char buffer[SkMatrix::kMaxFlattenSize + 100]; | 32 char buffer[SkMatrix::kMaxFlattenSize + 100]; |
| 33 uint32_t size1 = m.flatten(NULL); | 33 uint32_t size1 = m.flatten(NULL); |
| 34 uint32_t size2 = m.flatten(buffer); | 34 uint32_t size2 = m.flatten(buffer); |
| 35 REPORTER_ASSERT(reporter, size1 == size2); | 35 REPORTER_ASSERT(reporter, size1 == size2); |
| 36 REPORTER_ASSERT(reporter, size1 <= SkMatrix::kMaxFlattenSize); | 36 REPORTER_ASSERT(reporter, size1 <= SkMatrix::kMaxFlattenSize); |
| 37 | 37 |
| 38 SkMatrix m2; | 38 SkMatrix m2; |
| 39 uint32_t size3 = m2.unflatten(buffer); | 39 uint32_t size3 = m2.unflatten(buffer); |
| 40 REPORTER_ASSERT(reporter, size1 == size2); | 40 REPORTER_ASSERT(reporter, size1 == size2); |
| 41 REPORTER_ASSERT(reporter, m == m2); | 41 REPORTER_ASSERT(reporter, m == m2); |
| 42 | 42 |
| 43 char buffer2[SkMatrix::kMaxFlattenSize + 100]; | 43 char buffer2[SkMatrix::kMaxFlattenSize + 100]; |
| 44 size3 = m2.flatten(buffer2); | 44 size3 = m2.flatten(buffer2); |
| 45 REPORTER_ASSERT(reporter, size1 == size2); | 45 REPORTER_ASSERT(reporter, size1 == size2); |
| 46 REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); | 46 REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void TestMatrix(skiatest::Reporter* reporter) { | 49 void TestMatrix(skiatest::Reporter* reporter) { |
| 50 SkMatrix mat, inverse, iden1, iden2; | 50 SkMatrix mat, inverse, iden1, iden2; |
| 51 | 51 |
| 52 mat.reset(); | 52 mat.reset(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 m.set(SkMatrix::kMSkewY, gRectStaysRectSamples[i].m10); | 112 m.set(SkMatrix::kMSkewY, gRectStaysRectSamples[i].m10); |
| 113 m.set(SkMatrix::kMScaleY, gRectStaysRectSamples[i].m11); | 113 m.set(SkMatrix::kMScaleY, gRectStaysRectSamples[i].m11); |
| 114 REPORTER_ASSERT(reporter, | 114 REPORTER_ASSERT(reporter, |
| 115 m.rectStaysRect() == gRectStaysRectSamples[i].mStaysRect); | 115 m.rectStaysRect() == gRectStaysRectSamples[i].mStaysRect); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 #include "TestClassDef.h" | 120 #include "TestClassDef.h" |
| 121 DEFINE_TESTCLASS("Matrix", MatrixTestClass, TestMatrix) | 121 DEFINE_TESTCLASS("Matrix", MatrixTestClass, TestMatrix) |
| OLD | NEW |