aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-05-18 09:29:27 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-18 14:09:14 +0000
commit4f3ad4e2d1ebfbdec52f976c765691eafd55bcb9 (patch)
treea2d4a9397ecb0ac11d85af56337315821c82b359 /src/effects
parent72f6668eb73405874155b7b03077230559ee681e (diff)
Fix bugs related to SkMatrixConvolutionImageFilter in repeat mode
This should fix most of the fuzzer complaints Change-Id: I47a616e78b47bd162cbef647b03f5c1f23017c6f Reviewed-on: https://skia-review.googlesource.com/129165 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkMatrixConvolutionImageFilter.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index 10f417bea4..2c695e7685 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -229,7 +229,16 @@ void SkMatrixConvolutionImageFilter::filterInteriorPixels(const SkBitmap& src,
SkIVector& offset,
const SkIRect& rect,
const SkIRect& bounds) const {
- filterPixels<UncheckedPixelFetcher>(src, result, offset, rect, bounds);
+ switch (fTileMode) {
+ case kRepeat_TileMode:
+ // In repeat mode, we still need to wrap the samples around the src
+ filterPixels<RepeatPixelFetcher>(src, result, offset, rect, bounds);
+ break;
+ case kClamp_TileMode:
+ case kClampToBlack_TileMode:
+ filterPixels<UncheckedPixelFetcher>(src, result, offset, rect, bounds);
+ break;
+ }
}
void SkMatrixConvolutionImageFilter::filterBorderPixels(const SkBitmap& src,
@@ -392,6 +401,13 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilter::onFilterImage(SkSpecialIma
dstBounds.top() + fKernelOffset.fY,
dstBounds.width() - fKernelSize.fWidth + 1,
dstBounds.height() - fKernelSize.fHeight + 1);
+
+ if (kRepeat_TileMode == fTileMode) {
+ // In repeat mode the above computation of interior can exceed the bounds of 'dst'.
+ interior.sort();
+ interior.intersect(dstBounds);
+ }
+
SkIRect top = SkIRect::MakeLTRB(dstBounds.left(), dstBounds.top(),
dstBounds.right(), interior.top());
SkIRect bottom = SkIRect::MakeLTRB(dstBounds.left(), interior.bottom(),