add SkMatrix::decomposeScale
BUG=skia:
Review URL: https://codereview.chromium.org/1006173005
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp
index 7875d9e..95d33ac 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -771,6 +771,34 @@
}
+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 @@
test_matrix_decomposition(reporter);
test_matrix_homogeneous(reporter);
test_set9(reporter);
+
+ test_decompScale(reporter);
}
DEF_TEST(Matrix_Concat, r) {