From 0be685755f942baea26c66a87226b569fc17e960 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Thu, 4 Jun 2015 06:53:37 -0700 Subject: Fix dst bound reported by SkTileImageFilter In the example from the bug we had the filter DAG: color filter (table) 0: xfermode filter (arith) 0: tile filter [0,80,34,114] -> [0,80,800,480] 0: color filter (table) 0: bitmap src 34x34 -> [0,80,34,114] 1: color filter (table) 0: picture filter [0, 80, 800, 480] computeFastBounds was coming out of the DAG with a bound of [0,80,34,114] which didn't represent the pixels that would be drawn. This CL updates SkTileImageFilter to correctly set the bound for the pixels it will hit. BUG=493783 Committed: https://skia.googlesource.com/skia/+/05be93bbdf09576f7903130e3b106b0a8c7c4b4e Review URL: https://codereview.chromium.org/1152553006 --- src/effects/SkTileImageFilter.cpp | 13 +++++++++++++ src/effects/SkXfermodeImageFilter.cpp | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp index c5cf51871d..6acf9fd5ac 100644 --- a/src/effects/SkTileImageFilter.cpp +++ b/src/effects/SkTileImageFilter.cpp @@ -82,6 +82,10 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, return true; } +void SkTileImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { + *dst = fDstRect; +} + bool SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const { SkRect srcRect; @@ -110,6 +114,15 @@ void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const { #ifndef SK_IGNORE_TO_STRING void SkTileImageFilter::toString(SkString* str) const { str->appendf("SkTileImageFilter: ("); + str->appendf("src: %.2f %.2f %.2f %.2f", + fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom); + str->appendf(" dst: %.2f %.2f %.2f %.2f", + fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBottom); + if (this->getInput(0)) { + str->appendf("input: ("); + this->getInput(0)->toString(str); + str->appendf(")"); + } str->append(")"); } #endif diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index f98247a2f4..599fd42b12 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -105,7 +105,18 @@ void SkXfermodeImageFilter::toString(SkString* str) const { if (fMode) { fMode->toString(str); } - str->append("))"); + str->append(")"); + if (this->getInput(0)) { + str->appendf("foreground: ("); + this->getInput(0)->toString(str); + str->appendf(")"); + } + if (this->getInput(1)) { + str->appendf("background: ("); + this->getInput(1)->toString(str); + str->appendf(")"); + } + str->append(")"); } #endif -- cgit v1.2.3