Index: tests/MatrixTest.cpp |
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp |
index 7875d9ea45cd5e726cde798521eff1c6f1d25739..95d33acabd7ac42e0545efbc93b2a84d32ca668b 100644 |
--- a/tests/MatrixTest.cpp |
+++ b/tests/MatrixTest.cpp |
@@ -771,6 +771,34 @@ static void test_matrix_homogeneous(skiatest::Reporter* reporter) { |
} |
+static bool check_decompScale(const SkMatrix& matrix) { |
+ SkSize scale; |
+ SkMatrix remaining; |
+ |
+ if (!matrix.decomposeScale(&scale, &remaining)) { |
+ return false; |
+ } |
+ if (scale.width() <= 0 || scale.height() <= 0) { |
+ return false; |
+ } |
+ remaining.preScale(scale.width(), scale.height()); |
+ return nearly_equal(matrix, remaining); |
+} |
+ |
+static void test_decompScale(skiatest::Reporter* reporter) { |
+ SkMatrix m; |
+ |
+ m.reset(); |
+ REPORTER_ASSERT(reporter, check_decompScale(m)); |
+ m.setScale(2, 3); |
+ REPORTER_ASSERT(reporter, check_decompScale(m)); |
+ m.setRotate(35, 0, 0); |
+ REPORTER_ASSERT(reporter, check_decompScale(m)); |
+ |
+ m.setScale(1, 0); |
+ REPORTER_ASSERT(reporter, !check_decompScale(m)); |
+} |
+ |
DEF_TEST(Matrix, reporter) { |
SkMatrix mat, inverse, iden1, iden2; |
@@ -889,6 +917,8 @@ DEF_TEST(Matrix, reporter) { |
test_matrix_decomposition(reporter); |
test_matrix_homogeneous(reporter); |
test_set9(reporter); |
+ |
+ test_decompScale(reporter); |
} |
DEF_TEST(Matrix_Concat, r) { |