diff options
author | 2016-11-03 11:42:49 -0700 | |
---|---|---|
committer | 2016-11-03 11:42:49 -0700 | |
commit | b1c7f88df9ec40b4efb52d314304adfbaf95697c (patch) | |
tree | b1dbe3e726dbbd203a47b167d6cf938d23255d28 | |
parent | bdabcc4cb873dc4de39263c995900a05e6a32cf4 (diff) |
Fix kMediumQuality invMatrix setup for sizes == mip levels
When downscaling with kMediumQuality in non-clamp mode, if we happen to hit a size == mip level, then SkBitmapProcInfo::init takes the trivial matrix path and doesn't set up a matrix for normalized coords on the assumption that we're going to ignore the transform. But kMediumQuality disables allow_ignore_fractional_translate, so we take the filter path after all - but with an incorrect matrix.
R=reed@google.com
BUG=chromium:661180
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2476713002
Review-Url: https://codereview.chromium.org/2476713002
-rw-r--r-- | gm/bmpfilterqualityrepeat.cpp | 39 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 4 |
2 files changed, 28 insertions, 15 deletions
diff --git a/gm/bmpfilterqualityrepeat.cpp b/gm/bmpfilterqualityrepeat.cpp index c55626f6b2..1ddc72635c 100644 --- a/gm/bmpfilterqualityrepeat.cpp +++ b/gm/bmpfilterqualityrepeat.cpp @@ -35,10 +35,17 @@ protected: SkString onShortName() override { return SkString("bmp_filter_quality_repeat"); } - SkISize onISize() override { return SkISize::Make(1000, 235); } + SkISize onISize() override { return SkISize::Make(1000, 400); } void onDraw(SkCanvas* canvas) override { + this->drawAll(canvas, 2.5f); + canvas->translate(0, 250); + canvas->scale(0.5, 0.5); + this->drawAll(canvas, 1); + } +private: + void drawAll(SkCanvas* canvas, SkScalar scaleX) const { constexpr struct { SkFilterQuality fQuality; const char* fName; @@ -49,27 +56,31 @@ protected: {kHigh_SkFilterQuality, "high"}, }; - for (size_t q = 0; q < SK_ARRAY_COUNT(kQualities); ++q) { - SkPaint paint; - sk_tool_utils::set_portable_typeface(&paint); - paint.setFilterQuality(kQualities[q].fQuality); - SkPaint bmpPaint(paint); - SkMatrix lm = SkMatrix::I(); - lm.setScaleX(2.5); - lm.setTranslateX(423); - lm.setTranslateY(330); + SkRect rect = SkRect::MakeLTRB(20, 60, 220, 210); + SkMatrix lm = SkMatrix::I(); + lm.setScaleX(scaleX); + lm.setTranslateX(423); + lm.setTranslateY(330); + + SkPaint textPaint; + sk_tool_utils::set_portable_typeface(&textPaint); + textPaint.setAntiAlias(true); + + SkPaint bmpPaint(textPaint); + SkAutoCanvasRestore acr(canvas, true); + + for (size_t q = 0; q < SK_ARRAY_COUNT(kQualities); ++q) { constexpr SkShader::TileMode kTM = SkShader::kRepeat_TileMode; bmpPaint.setShader(SkShader::MakeBitmapShader(fBmp, kTM, kTM, &lm)); - SkRect rect = SkRect::MakeLTRB(20, 60, 220, 210); + bmpPaint.setFilterQuality(kQualities[q].fQuality); canvas->drawRect(rect, bmpPaint); - paint.setAntiAlias(true); - canvas->drawText(kQualities[q].fName, strlen(kQualities[q].fName), 20, 40, paint); + canvas->drawText(kQualities[q].fName, strlen(kQualities[q].fName), 20, 40, textPaint); canvas->translate(250, 0); } + } -private: SkBitmap fBmp; typedef skiagm::GM INHERITED; diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 1508f94643..f04379cf20 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -158,7 +158,9 @@ bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) { // We don't do this if we're either trivial (can ignore the matrix) or clamping // in both X and Y since clamping to width,height is just as easy as to 0xFFFF. - if (!(clampClamp || trivialMatrix)) { + // Note that we cannot ignore the matrix when allow_ignore_fractional_translate is false. + + if (!(clampClamp || (trivialMatrix && allow_ignore_fractional_translate))) { fInvMatrix.postIDiv(fPixmap.width(), fPixmap.height()); } |