diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-05 14:37:48 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-05 14:37:48 +0000 |
commit | ce1f3cc1e22a50caaaaded7b91d9492b3ae5901c (patch) | |
tree | f97712b81335fff5458409f9489c7c7115e27ec7 | |
parent | 8ae714b186ae5f4eaddee239281fbfe7282320c9 (diff) |
Fix the computed (new) inverse matrix when we detect that a shader's matrix
can effectively be consider translate-only.
Review URL: https://codereview.appspot.com/7060043
git-svn-id: http://skia.googlecode.com/svn/trunk@7039 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index ec2e0dd79a..ea09c5d364 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -126,12 +126,28 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { bool fixupMatrix = clamp_clamp ? just_trans_clamp(*m, *fBitmap) : just_trans_general(*m); if (fixupMatrix) { +#ifdef SK_IGNORE_TRANS_CLAMP_FIX if (m != &fUnitInvMatrix) { // can't mutate the original fUnitInvMatrix = inv; m = &fUnitInvMatrix; } fUnitInvMatrix.set(SkMatrix::kMScaleX, SK_Scalar1); fUnitInvMatrix.set(SkMatrix::kMScaleY, SK_Scalar1); +#else + // If we can be treated just like translate, construct that inverse + // such that we landed in the proper place. Given that m may have + // some slight scale, we have to invert it to compute this new + // matrix. + SkMatrix forward; + if (m->invert(&forward)) { + SkScalar tx = -SkScalarRoundToScalar(forward.getTranslateX()); + SkScalar ty = -SkScalarRoundToScalar(forward.getTranslateY()); + fUnitInvMatrix.setTranslate(tx, ty); + m = &fUnitInvMatrix; + // now the following code will sniff m, and decide to take the + // fast case (since m is purely translate). + } +#endif } } |