| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 dst = src; | 106 dst = src; |
| 107 dst.fRight = src.fRight * 2; | 107 dst.fRight = src.fRight * 2; |
| 108 matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit); | 108 matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit); |
| 109 REPORTER_ASSERT(reporter, SkMatrix::kScale_Mask == matrix.getType()); | 109 REPORTER_ASSERT(reporter, SkMatrix::kScale_Mask == matrix.getType()); |
| 110 REPORTER_ASSERT(reporter, matrix.rectStaysRect()); | 110 REPORTER_ASSERT(reporter, matrix.rectStaysRect()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) { | 113 static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) { |
| 114 // add 100 in case we have a bug, I don't want to kill my stack in the test | 114 // add 100 in case we have a bug, I don't want to kill my stack in the test |
| 115 char buffer[SkMatrix::kMaxFlattenSize + 100]; | 115 static const size_t kBufferSize = SkMatrix::kMaxFlattenSize + 100; |
| 116 uint32_t size1 = m.writeToMemory(NULL); | 116 char buffer[kBufferSize]; |
| 117 uint32_t size2 = m.writeToMemory(buffer); | 117 size_t size1 = m.writeToMemory(NULL); |
| 118 size_t size2 = m.writeToMemory(buffer); |
| 118 REPORTER_ASSERT(reporter, size1 == size2); | 119 REPORTER_ASSERT(reporter, size1 == size2); |
| 119 REPORTER_ASSERT(reporter, size1 <= SkMatrix::kMaxFlattenSize); | 120 REPORTER_ASSERT(reporter, size1 <= SkMatrix::kMaxFlattenSize); |
| 120 | 121 |
| 121 SkMatrix m2; | 122 SkMatrix m2; |
| 122 uint32_t size3 = m2.readFromMemory(buffer); | 123 size_t size3 = m2.readFromMemory(buffer, kBufferSize); |
| 123 REPORTER_ASSERT(reporter, size1 == size3); | 124 REPORTER_ASSERT(reporter, size1 == size3); |
| 124 REPORTER_ASSERT(reporter, are_equal(reporter, m, m2)); | 125 REPORTER_ASSERT(reporter, are_equal(reporter, m, m2)); |
| 125 | 126 |
| 126 char buffer2[SkMatrix::kMaxFlattenSize + 100]; | 127 char buffer2[kBufferSize]; |
| 127 size3 = m2.writeToMemory(buffer2); | 128 size3 = m2.writeToMemory(buffer2); |
| 128 REPORTER_ASSERT(reporter, size1 == size3); | 129 REPORTER_ASSERT(reporter, size1 == size3); |
| 129 REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); | 130 REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); |
| 130 } | 131 } |
| 131 | 132 |
| 132 static void test_matrix_max_stretch(skiatest::Reporter* reporter) { | 133 static void test_matrix_max_stretch(skiatest::Reporter* reporter) { |
| 133 SkMatrix identity; | 134 SkMatrix identity; |
| 134 identity.reset(); | 135 identity.reset(); |
| 135 REPORTER_ASSERT(reporter, SK_Scalar1 == identity.getMaxStretch()); | 136 REPORTER_ASSERT(reporter, SK_Scalar1 == identity.getMaxStretch()); |
| 136 | 137 |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 | 799 |
| 799 test_matrix_max_stretch(reporter); | 800 test_matrix_max_stretch(reporter); |
| 800 test_matrix_is_similarity(reporter); | 801 test_matrix_is_similarity(reporter); |
| 801 test_matrix_recttorect(reporter); | 802 test_matrix_recttorect(reporter); |
| 802 test_matrix_decomposition(reporter); | 803 test_matrix_decomposition(reporter); |
| 803 test_matrix_homogeneous(reporter); | 804 test_matrix_homogeneous(reporter); |
| 804 } | 805 } |
| 805 | 806 |
| 806 #include "TestClassDef.h" | 807 #include "TestClassDef.h" |
| 807 DEFINE_TESTCLASS("Matrix", MatrixTestClass, TestMatrix) | 808 DEFINE_TESTCLASS("Matrix", MatrixTestClass, TestMatrix) |
| OLD | NEW |