aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ImageFilterTest.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-04-13 04:54:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-13 04:54:36 -0700
commitdada4dd9cf03e42369ca5b38086dba77f01a68e6 (patch)
tree2f2c671b1e6498d016f9aa77753e81014ab596cd /tests/ImageFilterTest.cpp
parent58700da76b3823de878dde82fee11b80daf7fe18 (diff)
Switch SkMatrixConvolutionImageFilter over to new onFilterImage interface
Diffstat (limited to 'tests/ImageFilterTest.cpp')
-rw-r--r--tests/ImageFilterTest.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index a6ff0875b7..114c342ada 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -1093,6 +1093,51 @@ DEF_TEST(ImageFilterMatrixConvolutionBorder, reporter) {
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);
}