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

Unified Diff: src/utils/SkMatrix44.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: 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 | « no previous file | tests/Matrix44Test.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkMatrix44.cpp
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp
index 92c8715faaec94972770f8db05b372c1245366a8..a33b2ed8ae9dc3a5f0d75139ecf3e0b6c1fd2090 100644
--- a/src/utils/SkMatrix44.cpp
+++ b/src/utils/SkMatrix44.cpp
@@ -529,13 +529,13 @@ bool SkMatrix44::invert(SkMatrix44* inverse) const {
// Calculate the determinant
double det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
- if (dabs(det) < TOO_SMALL_FOR_DETERMINANT) {
+ double invdet = 1.0 / det;
reed1 2013/08/15 19:40:46 // If det is zero, we want to return false. Howeve
+ if (!isfinite(invdet)) {
return false;
}
if (NULL == inverse) {
return true;
}
- double invdet = 1.0 / det;
b00 *= invdet;
b01 *= invdet;
@@ -568,7 +568,6 @@ bool SkMatrix44::invert(SkMatrix44* inverse) const {
inverse->fMat[3][3] = SkDoubleToMScalar(a20 * b03 - a21 * b01 + a22 * b00);
inverse->dirtyTypeMask();
- inverse->dirtyTypeMask();
return true;
}
« no previous file with comments | « no previous file | tests/Matrix44Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698