diff options
author | fmalita <fmalita@chromium.org> | 2015-12-17 14:12:30 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-17 14:12:30 -0800 |
commit | a379da41b7b0408c834db967c0034fd7f611aa83 (patch) | |
tree | fd58de1e17cbe944982c70817ed105cc17517b96 | |
parent | f5d1f8dcc841516d7ea63c151b13059af40ca76d (diff) |
SkMatrix::preScale() is too conservative
SkMatrix::preScale() always sets the kScale bit, which means something
like
m = SkMatrix::MakeScale(2, 2);
m.preScale(0.5, 0.5);
leaves m.getType() == kScale_Mask, and can throw off the bitmap proc
heuristics.
We could detect the inverse case and clear the scale bit instead.
R=reed@google.com,caryclark@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1531323002
Review URL: https://codereview.chromium.org/1531323002
-rw-r--r-- | src/core/SkMatrix.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp index 6101eb9f9a..67ae052e06 100644 --- a/src/core/SkMatrix.cpp +++ b/src/core/SkMatrix.cpp @@ -380,7 +380,20 @@ void SkMatrix::preScale(SkScalar sx, SkScalar sy) { fMat[kMScaleY] *= sy; fMat[kMPersp1] *= sy; +#ifndef SK_SUPPORT_LEGACY_PRESCALE_SEMANTICS + // Attempt to simplify our type when applying an inverse scale. + // TODO: The persp/affine preconditions are in place to keep the mask consistent with + // what computeTypeMask() would produce (persp/skew always implies kScale). + // We should investigate whether these flag dependencies are truly needed. + if (fMat[kMScaleX] == 1 && fMat[kMScaleY] == 1 + && !(fTypeMask & (kPerspective_Mask | kAffine_Mask))) { + this->clearTypeMask(kScale_Mask); + } else { + this->orTypeMask(kScale_Mask); + } +#else this->orTypeMask(kScale_Mask); +#endif } void SkMatrix::postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) { |