Fix for SkMatrix::invert() for large coordinate values.

See http://codereview.appspot.com/1731053



git-svn-id: http://skia.googlecode.com/svn/trunk@589 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
senorblanco@chromium.org 2010-07-20 15:20:01 +00:00
parent 097a351353
commit 0e21ec009a

View File

@ -653,9 +653,10 @@ bool SkMatrix::postConcat(const SkMatrix& mat) {
det = (double)mat[SkMatrix::kMScaleX] * mat[SkMatrix::kMScaleY] - (double)mat[SkMatrix::kMSkewX] * mat[SkMatrix::kMSkewY]; det = (double)mat[SkMatrix::kMScaleX] * mat[SkMatrix::kMScaleY] - (double)mat[SkMatrix::kMSkewX] * mat[SkMatrix::kMSkewY];
} }
// Since the determinant is on the order of the square of the matrix members, // Since the determinant is on the order of the cube of the matrix members,
// compare to the square of the default nearly-zero constant // compare to the cube of the default nearly-zero constant (although an
if (SkScalarNearlyZero((float)det, SK_ScalarNearlyZero * SK_ScalarNearlyZero)) { // estimate of the condition number would be better if it wasn't so expensive).
if (SkScalarNearlyZero((float)det, SK_ScalarNearlyZero * SK_ScalarNearlyZero * SK_ScalarNearlyZero)) {
return 0; return 0;
} }
return 1.0 / det; return 1.0 / det;