From 4f3ad4e2d1ebfbdec52f976c765691eafd55bcb9 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Fri, 18 May 2018 09:29:27 -0400 Subject: 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 Commit-Queue: Robert Phillips --- src/effects/SkMatrixConvolutionImageFilter.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/effects') 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(src, result, offset, rect, bounds); + switch (fTileMode) { + case kRepeat_TileMode: + // In repeat mode, we still need to wrap the samples around the src + filterPixels(src, result, offset, rect, bounds); + break; + case kClamp_TileMode: + case kClampToBlack_TileMode: + filterPixels(src, result, offset, rect, bounds); + break; + } } void SkMatrixConvolutionImageFilter::filterBorderPixels(const SkBitmap& src, @@ -392,6 +401,13 @@ sk_sp 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(), -- cgit v1.2.3