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

Unified Diff: tests/ImageFilterTest.cpp

Issue 1807673005: Image filters: fix the zero-sigma fast path in SkBlurImageFilter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkBlurImageFilter.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 dfb0d35e484a0a0350804f34806dca015f774d4e..a0bc5f010e6937d177a67a3389596c83fee1ea98 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -158,23 +158,27 @@ static SkImageFilter* make_blue(SkImageFilter* input, const SkImageFilter::CropR
return SkColorFilterImageFilter::Create(filter, input, cropRect);
}
-static SkSpecialImage* create_empty_special_image(GrContext* context,
- SkImageFilter::Proxy* proxy,
- int widthHeight) {
- SkAutoTUnref<SkSpecialSurface> surf;
-
+static SkSpecialSurface* create_empty_special_surface(GrContext* context,
+ SkImageFilter::Proxy* proxy,
+ int widthHeight) {
if (context) {
GrSurfaceDesc desc;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = widthHeight;
desc.fHeight = widthHeight;
- surf.reset(SkSpecialSurface::NewRenderTarget(proxy, context, desc));
+ return SkSpecialSurface::NewRenderTarget(proxy, context, desc);
} else {
const SkImageInfo info = SkImageInfo::MakeN32(widthHeight, widthHeight,
kOpaque_SkAlphaType);
- surf.reset(SkSpecialSurface::NewRaster(proxy, info));
+ return SkSpecialSurface::NewRaster(proxy, info);
}
+}
+
+static SkSpecialImage* create_empty_special_image(GrContext* context,
+ SkImageFilter::Proxy* proxy,
+ int widthHeight) {
+ SkAutoTUnref<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, widthHeight));
SkASSERT(surf);
@@ -508,6 +512,52 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(TestNegativeBlurSigma_Gpu, reporter, context) {
}
#endif
+static void test_zero_blur_sigma(SkImageFilter::Proxy* proxy,
+ skiatest::Reporter* reporter,
+ GrContext* context) {
+ // Check that SkBlurImageFilter with a zero sigma and a non-zero srcOffset works correctly.
+ SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(5, 0, 5, 10)));
+ SkAutoTUnref<SkImageFilter> input(SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect));
+ SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(0, 0, input, &cropRect));
+
+ SkAutoTUnref<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, 10));
+ surf->getCanvas()->clear(SK_ColorGREEN);
+ SkAutoTUnref<SkSpecialImage> image(surf->newImageSnapshot());
+
+ SkIPoint offset;
+ SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr);
+
+ SkAutoTUnref<SkSpecialImage> result(filter->filterImage(image, ctx, &offset));
+ REPORTER_ASSERT(reporter, offset.fX == 5 && offset.fY == 0);
+ REPORTER_ASSERT(reporter, result);
+ REPORTER_ASSERT(reporter, result->width() == 5 && result->height() == 10);
+
+ SkBitmap resultBM;
+
+ TestingSpecialImageAccess::GetROPixels(result, &resultBM);
+
+ SkAutoLockPixels lock(resultBM);
+ for (int y = 0; y < resultBM.height(); y++) {
+ for (int x = 0; x < resultBM.width(); x++) {
+ bool diff = *resultBM.getAddr32(x, y) != SK_ColorGREEN;
+ REPORTER_ASSERT(reporter, !diff);
+ if (diff) {
+ break;
+ }
+ }
+ }
+}
+
+DEF_TEST(TestZeroBlurSigma, reporter) {
+ run_raster_test(reporter, 100, test_zero_blur_sigma);
+}
+
+#if SK_SUPPORT_GPU
+DEF_GPUTEST_FOR_NATIVE_CONTEXT(TestZeroBlurSigma_Gpu, reporter, context) {
+ run_gpu_test(reporter, context, 100, test_zero_blur_sigma);
+}
+#endif
+
DEF_TEST(ImageFilterDrawTiled, reporter) {
// Check that all filters when drawn tiled (with subsequent clip rects) exactly
// match the same filters drawn with a single full-canvas bitmap draw.
« no previous file with comments | « src/effects/SkBlurImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698