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

Unified Diff: tests/Matrix44Test.cpp

Issue 513343002: Add helper SkMatrix44::hasPerspective() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bug, call SkToBool, import tests Created 6 years, 4 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 | « include/utils/SkMatrix44.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Matrix44Test.cpp
diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp
index 443086dbef5a298c394e5aa230586231b2fb5bff..0bd4a8ba13bb0d2454b38f02099405a75cd27b3a 100644
--- a/tests/Matrix44Test.cpp
+++ b/tests/Matrix44Test.cpp
@@ -521,6 +521,35 @@ static void test_3x3_conversion(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[3], vec4transformed2[3]));
}
+static void test_has_perspective(skiatest::Reporter* reporter) {
+ SkMatrix44 transform(SkMatrix44::kIdentity_Constructor);
+
+ transform.set(3, 2, -0.1);
+ REPORTER_ASSERT(reporter, transform.hasPerspective());
+
+ transform.reset();
+ REPORTER_ASSERT(reporter, !transform.hasPerspective());
+
+ transform.set(3, 0, -1.0);
+ REPORTER_ASSERT(reporter, transform.hasPerspective());
+
+ transform.reset();
+ transform.set(3, 1, -1.0);
+ REPORTER_ASSERT(reporter, transform.hasPerspective());
+
+ transform.reset();
+ transform.set(3, 2, -0.3);
+ REPORTER_ASSERT(reporter, transform.hasPerspective());
+
+ transform.reset();
+ transform.set(3, 3, 0.5);
+ REPORTER_ASSERT(reporter, transform.hasPerspective());
+
+ transform.reset();
+ transform.set(3, 3, 0.0);
+ REPORTER_ASSERT(reporter, transform.hasPerspective());
+}
+
DEF_TEST(Matrix44, reporter) {
SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor);
@@ -626,4 +655,5 @@ DEF_TEST(Matrix44, reporter) {
test_scale(reporter);
test_map2(reporter);
test_3x3_conversion(reporter);
+ test_has_perspective(reporter);
}
« no previous file with comments | « include/utils/SkMatrix44.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698