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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1877343002: Switch SkMatrixConvolutionImageFilter over to new onFilterImage interface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix return value Created 4 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 unified diff | Download patch
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapDevice.h" 9 #include "SkBitmapDevice.h"
10 #include "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 SkPaint filterPaint; 1086 SkPaint filterPaint;
1087 filterPaint.setImageFilter(std::move(filter)); 1087 filterPaint.setImageFilter(std::move(filter));
1088 SkRect bounds = SkRect::MakeWH(1, 10); 1088 SkRect bounds = SkRect::MakeWH(1, 10);
1089 SkRect rect = SkRect::Make(SkIRect::MakeWH(width, height)); 1089 SkRect rect = SkRect::Make(SkIRect::MakeWH(width, height));
1090 SkPaint rectPaint; 1090 SkPaint rectPaint;
1091 canvas.saveLayer(&bounds, &filterPaint); 1091 canvas.saveLayer(&bounds, &filterPaint);
1092 canvas.drawRect(rect, rectPaint); 1092 canvas.drawRect(rect, rectPaint);
1093 canvas.restore(); 1093 canvas.restore();
1094 } 1094 }
1095 1095
1096 static void test_big_kernel(SkImageFilter::Proxy* proxy,
1097 skiatest::Reporter* reporter,
1098 GrContext* context) {
1099 // Check that a kernel that is too big for the GPU still works
1100 SkScalar identityKernel[49] = {
1101 0, 0, 0, 0, 0, 0, 0,
1102 0, 0, 0, 0, 0, 0, 0,
1103 0, 0, 0, 0, 0, 0, 0,
1104 0, 0, 0, 1, 0, 0, 0,
1105 0, 0, 0, 0, 0, 0, 0,
1106 0, 0, 0, 0, 0, 0, 0,
1107 0, 0, 0, 0, 0, 0, 0
1108 };
1109 SkISize kernelSize = SkISize::Make(7, 7);
1110 SkScalar gain = SK_Scalar1, bias = 0;
1111 SkIPoint kernelOffset = SkIPoint::Make(0, 0);
1112
1113 sk_sp<SkImageFilter> filter(SkMatrixConvolutionImageFilter::Make(
1114 kernelSize, identityKernel, gain, bias, kernelOffset,
1115 SkMatrixConvolutionImageFilter::kClamp_T ileMode,
1116 true, nullptr));
1117
1118 sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100) );
1119 SkASSERT(srcImg);
1120
1121 SkIPoint offset;
1122 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr );
1123 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offs et));
1124 REPORTER_ASSERT(reporter, resultImg);
1125 REPORTER_ASSERT(reporter, SkToBool(context) == resultImg->isTextureBacked()) ;
1126 REPORTER_ASSERT(reporter, resultImg->width() == 100 && resultImg->height() = = 100);
1127 REPORTER_ASSERT(reporter, offset.fX == 0 && offset.fY == 0);
1128 }
1129
1130 DEF_TEST(ImageFilterMatrixConvolutionBigKernel, reporter) {
1131 run_raster_test(reporter, 100, test_big_kernel);
1132 }
1133
1134 #if SK_SUPPORT_GPU
1135 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterMatrixConvolutionBigKernel_Gpu,
1136 reporter, ctxInfo) {
1137 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_big_kernel);
1138 }
1139 #endif
1140
1096 DEF_TEST(ImageFilterCropRect, reporter) { 1141 DEF_TEST(ImageFilterCropRect, reporter) {
1097 run_raster_test(reporter, 100, test_crop_rects); 1142 run_raster_test(reporter, 100, test_crop_rects);
1098 } 1143 }
1099 1144
1100 #if SK_SUPPORT_GPU 1145 #if SK_SUPPORT_GPU
1101 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCropRect_Gpu, reporter, ctxInfo) { 1146 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCropRect_Gpu, reporter, ctxInfo) {
1102 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_crop_rects); 1147 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_crop_rects);
1103 } 1148 }
1104 #endif 1149 #endif
1105 1150
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 1767
1723 test_xfermode_cropped_input(&canvas, reporter); 1768 test_xfermode_cropped_input(&canvas, reporter);
1724 } 1769 }
1725 1770
1726 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(ImageFilterBlurLargeImage_Gpu, reporter, ctxInfo ) { 1771 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(ImageFilterBlurLargeImage_Gpu, reporter, ctxInfo ) {
1727 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe s, 1772 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe s,
1728 SkImageInfo::MakeN32Premul(100, 100 ))); 1773 SkImageInfo::MakeN32Premul(100, 100 )));
1729 test_large_blur_input(reporter, surface->getCanvas()); 1774 test_large_blur_input(reporter, surface->getCanvas());
1730 } 1775 }
1731 #endif 1776 #endif
OLDNEW
« 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