Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: tests/ImageFilterTest.cpp

Issue 267863004: Fix for SkMatrixConvolutionImageFilter with large borders. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Simplify further Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageFilterTest.cpp
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index ffefb2c8cd8350e3ceb8129a4aa759a18ad34b93..08277a1ec616e41a3b8ea92247179e4306607e7c 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -398,6 +398,38 @@ DEF_TEST(ImageFilterMatrixConvolution, reporter) {
canvas.drawRect(rect, paint);
}
+DEF_TEST(ImageFilterMatrixConvolutionBorder, reporter) {
+ // Check that a filter with borders outside the target bounds
+ // does not crash.
+ SkScalar kernel[3] = {
+ 0, 0, 0,
+ };
+ SkISize kernelSize = SkISize::Make(3, 1);
+ SkScalar gain = SK_Scalar1, bias = 0;
+ SkIPoint kernelOffset = SkIPoint::Make(2, 0);
+
+ SkAutoTUnref<SkImageFilter> filter(
+ SkMatrixConvolutionImageFilter::Create(
+ kernelSize, kernel, gain, bias, kernelOffset,
+ SkMatrixConvolutionImageFilter::kClamp_TileMode, true));
+
+ SkBitmap result;
+
+ int width = 10, height = 10;
+ result.allocN32Pixels(width, height);
+ SkCanvas canvas(result);
+ canvas.clear(0);
+
+ SkPaint filterPaint;
+ filterPaint.setImageFilter(filter);
+ SkRect bounds = SkRect::MakeWH(1, 10);
+ SkRect rect = SkRect::Make(SkIRect::MakeWH(width, height));
+ SkPaint rectPaint;
+ canvas.saveLayer(&bounds, &filterPaint);
+ canvas.drawRect(rect, rectPaint);
+ canvas.restore();
+}
+
DEF_TEST(ImageFilterCropRect, reporter) {
SkBitmap temp;
temp.allocN32Pixels(100, 100);
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698