From a379da41b7b0408c834db967c0034fd7f611aa83 Mon Sep 17 00:00:00 2001 From: fmalita Date: Thu, 17 Dec 2015 14:12:30 -0800 Subject: 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 --- src/core/SkMatrix.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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) { -- cgit v1.2.3