Switch SkMatrixConvolutionImageFilter over to new onFilterImage interface
TBR=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1877343002
Review URL: https://codereview.chromium.org/1877343002
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index a6ff087..114c342 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -1093,6 +1093,51 @@
canvas.restore();
}
+static void test_big_kernel(SkImageFilter::Proxy* proxy,
+ skiatest::Reporter* reporter,
+ GrContext* context) {
+ // Check that a kernel that is too big for the GPU still works
+ SkScalar identityKernel[49] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0
+ };
+ SkISize kernelSize = SkISize::Make(7, 7);
+ SkScalar gain = SK_Scalar1, bias = 0;
+ SkIPoint kernelOffset = SkIPoint::Make(0, 0);
+
+ sk_sp<SkImageFilter> filter(SkMatrixConvolutionImageFilter::Make(
+ kernelSize, identityKernel, gain, bias, kernelOffset,
+ SkMatrixConvolutionImageFilter::kClamp_TileMode,
+ true, nullptr));
+
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
+ SkASSERT(srcImg);
+
+ SkIPoint offset;
+ SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr);
+ sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
+ REPORTER_ASSERT(reporter, resultImg);
+ REPORTER_ASSERT(reporter, SkToBool(context) == resultImg->isTextureBacked());
+ REPORTER_ASSERT(reporter, resultImg->width() == 100 && resultImg->height() == 100);
+ REPORTER_ASSERT(reporter, offset.fX == 0 && offset.fY == 0);
+}
+
+DEF_TEST(ImageFilterMatrixConvolutionBigKernel, reporter) {
+ run_raster_test(reporter, 100, test_big_kernel);
+}
+
+#if SK_SUPPORT_GPU
+DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterMatrixConvolutionBigKernel_Gpu,
+ reporter, ctxInfo) {
+ run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_big_kernel);
+}
+#endif
+
DEF_TEST(ImageFilterCropRect, reporter) {
run_raster_test(reporter, 100, test_crop_rects);
}