Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: tests/MatrixTest.cpp

Issue 1006173005: add SkMatrix::decomposeScale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add unittest Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698