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

Unified Diff: tests/Matrix44Test.cpp

Issue 22904003: Make SkMatrix44::invert() check for finite 1/det instead of magic value (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Shrink range of one matrix test to pass is_identity() check on i386-linux Created 7 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 | « src/utils/SkMatrix44.cpp ('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 b2c7071b79726d050f40e58795b5ac0059ff7a58..7e31840144076e268f5b587bcd6ab5945e1c660e 100644
--- a/tests/Matrix44Test.cpp
+++ b/tests/Matrix44Test.cpp
@@ -403,6 +403,33 @@ static void TestMatrix44(skiatest::Reporter* reporter) {
iden2.setConcat(inverse, mat);
REPORTER_ASSERT(reporter, is_identity(iden2));
+ // test tiny-valued matrix inverse
+ mat.reset();
+ mat.setScale(1.0e-12, 1.0e-12, 1.0e-12);
+ rot.setRotateDegreesAbout(0, 0, -1, 90);
+ mat.postConcat(rot);
+ mat.postTranslate(1.0e-12, 1.0e-12, 1.0e-12);
+ REPORTER_ASSERT(reporter, mat.invert(NULL));
+ mat.invert(&inverse);
+ iden1.setConcat(mat, inverse);
+ REPORTER_ASSERT(reporter, is_identity(iden1));
+
+ // test mixed-valued matrix inverse
+ mat.reset();
+ mat.setScale(1.0e-11, 3.0, 1.0e+11);
+ rot.setRotateDegreesAbout(0, 0, -1, 90);
+ mat.postConcat(rot);
+ mat.postTranslate(1.0e+11, 3.0, 1.0e-11);
+ REPORTER_ASSERT(reporter, mat.invert(NULL));
+ mat.invert(&inverse);
+ iden1.setConcat(mat, inverse);
+ REPORTER_ASSERT(reporter, is_identity(iden1));
+
+ // test degenerate matrix
+ mat.reset();
+ mat.set3x3(1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0);
+ REPORTER_ASSERT(reporter, !mat.invert(NULL));
+
// test rol/col Major getters
{
mat.setTranslate(2, 3, 4);
« no previous file with comments | « src/utils/SkMatrix44.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698