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

Unified Diff: tests/ImageFilterTest.cpp

Issue 1555333002: Add null check for bmp->tex result in SkImageFilter::filterInputGpu (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add comment Created 4 years, 11 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/core/SkImageFilter.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 1bf8cbdb736962aec6104b1e3dcaa35d90cd50d8..fa1569d89ad530e447bc68cdf137f2bc1251d489 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -1261,6 +1261,53 @@ DEF_TEST(ImageFilterImageSourceSerialization, reporter) {
REPORTER_ASSERT(reporter, *bm.getAddr32(0, 0) == SkPreMultiplyColor(SK_ColorGREEN));
}
+static void test_large_blur_input(skiatest::Reporter* reporter, SkCanvas* canvas) {
+ SkBitmap largeBmp;
+ int largeW = 5000;
+ int largeH = 5000;
+#if SK_SUPPORT_GPU
+ // If we're GPU-backed make the bitmap too large to be converted into a texture.
+ if (GrContext* ctx = canvas->getGrContext()) {
+ largeW = ctx->caps()->maxTextureSize() + 1;
+ }
+#endif
+
+ largeBmp.allocN32Pixels(largeW, largeH);
+ if (!largeBmp.getPixels()) {
+ ERRORF(reporter, "Failed to allocate large bmp.");
+ return;
+ }
+
+ SkAutoTUnref<SkImage> largeImage(SkImage::NewFromBitmap(largeBmp));
+ if (!largeImage) {
+ ERRORF(reporter, "Failed to create large image.");
+ return;
+ }
+
+ SkAutoTUnref<SkImageFilter> largeSource(SkImageSource::Create(largeImage));
+ if (!largeSource) {
+ ERRORF(reporter, "Failed to create large SkImageSource.");
+ return;
+ }
+
+ SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(10.f, 10.f, largeSource));
+ if (!blur) {
+ ERRORF(reporter, "Failed to create SkBlurImageFilter.");
+ return;
+ }
+
+ SkPaint paint;
+ paint.setImageFilter(blur);
+
+ // This should not crash (http://crbug.com/570479).
+ canvas->drawRect(SkRect::MakeIWH(largeW, largeH), paint);
+}
+
+DEF_TEST(BlurLargeImage, reporter) {
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(SkImageInfo::MakeN32Premul(100, 100)));
+ test_large_blur_input(reporter, surface->getCanvas());
+}
+
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_NATIVE_CONTEXT(ImageFilterCropRect_Gpu, reporter, context) {
@@ -1318,4 +1365,11 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(TestNegativeBlurSigma_Gpu, reporter, context) {
test_negative_blur_sigma(&proxy, reporter);
}
+
+DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) {
+ SkAutoTUnref<SkSurface> surface(
+ SkSurface::NewRenderTarget(context, SkSurface::kYes_Budgeted,
+ SkImageInfo::MakeN32Premul(100, 100)));
+ test_large_blur_input(reporter, surface->getCanvas());
+}
#endif
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698