Index: src/utils/SkMatrix44.cpp |
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp |
index 92c8715faaec94972770f8db05b372c1245366a8..9ceecbdf2a95935b3a9535188dd3937115a8f574 100644 |
--- a/src/utils/SkMatrix44.cpp |
+++ b/src/utils/SkMatrix44.cpp |
@@ -529,13 +529,16 @@ 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; |
+ // If det is zero, we want to return false. However, we also want to return false |
+ // if 1/det overflows to infinity (i.e. det is denormalized). Both of these are |
+ // handled by checking that 1/det is finite. |
+ if (!sk_float_isfinite(invdet)) { |
return false; |
} |
if (NULL == inverse) { |
return true; |
} |
- double invdet = 1.0 / det; |
b00 *= invdet; |
b01 *= invdet; |
@@ -568,7 +571,6 @@ bool SkMatrix44::invert(SkMatrix44* inverse) const { |
inverse->fMat[3][3] = SkDoubleToMScalar(a20 * b03 - a21 * b01 + a22 * b00); |
inverse->dirtyTypeMask(); |
- inverse->dirtyTypeMask(); |
return true; |
} |