| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMaxStretch()); | 161 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMaxStretch()); |
| 162 | 162 |
| 163 SkMatrix baseMats[] = {scale, rot90Scale, rotate, | 163 SkMatrix baseMats[] = {scale, rot90Scale, rotate, |
| 164 translate, perspX, perspY}; | 164 translate, perspX, perspY}; |
| 165 SkMatrix mats[2*SK_ARRAY_COUNT(baseMats)]; | 165 SkMatrix mats[2*SK_ARRAY_COUNT(baseMats)]; |
| 166 for (size_t i = 0; i < SK_ARRAY_COUNT(baseMats); ++i) { | 166 for (size_t i = 0; i < SK_ARRAY_COUNT(baseMats); ++i) { |
| 167 mats[i] = baseMats[i]; | 167 mats[i] = baseMats[i]; |
| 168 bool invertable = mats[i].invert(&mats[i + SK_ARRAY_COUNT(baseMats)]); | 168 bool invertable = mats[i].invert(&mats[i + SK_ARRAY_COUNT(baseMats)]); |
| 169 REPORTER_ASSERT(reporter, invertable); | 169 REPORTER_ASSERT(reporter, invertable); |
| 170 } | 170 } |
| 171 SkRandom rand; | 171 SkMWCRandom rand; |
| 172 for (int m = 0; m < 1000; ++m) { | 172 for (int m = 0; m < 1000; ++m) { |
| 173 SkMatrix mat; | 173 SkMatrix mat; |
| 174 mat.reset(); | 174 mat.reset(); |
| 175 for (int i = 0; i < 4; ++i) { | 175 for (int i = 0; i < 4; ++i) { |
| 176 int x = rand.nextU() % SK_ARRAY_COUNT(mats); | 176 int x = rand.nextU() % SK_ARRAY_COUNT(mats); |
| 177 mat.postConcat(mats[x]); | 177 mat.postConcat(mats[x]); |
| 178 } | 178 } |
| 179 SkScalar stretch = mat.getMaxStretch(); | 179 SkScalar stretch = mat.getMaxStretch(); |
| 180 | 180 |
| 181 if ((stretch < 0) != mat.hasPerspective()) { | 181 if ((stretch < 0) != mat.hasPerspective()) { |
| (...skipping 280 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 |