diff options
author | Mike Reed <reed@google.com> | 2018-02-15 11:38:20 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-15 17:00:39 +0000 |
commit | f221b4942cce519a230c24b8ed9a14522f28e54f (patch) | |
tree | 5fff2e5ab589f6ac5af94ff7da96f30d911d250a /tests/BlurTest.cpp | |
parent | 240516f772ea27e62f477ba510aabeb84b6f68d5 (diff) |
abort blur if the sigma is too small
Bug: oss-fuzz:6375
Change-Id: I8f21ea05b44f2ed6fdcdfe2573ac9415f238d833
Reviewed-on: https://skia-review.googlesource.com/107784
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'tests/BlurTest.cpp')
-rw-r--r-- | tests/BlurTest.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp index d8d917fe8f..29c44d7886 100644 --- a/tests/BlurTest.cpp +++ b/tests/BlurTest.cpp @@ -10,6 +10,7 @@ #include "SkBlurDrawLooper.h" #include "SkCanvas.h" #include "SkColorFilter.h" +#include "SkColorPriv.h" #include "SkEmbossMaskFilter.h" #include "SkLayerDrawLooper.h" #include "SkMaskFilterBase.h" @@ -669,3 +670,35 @@ DEF_TEST(EmbossPerlinCrash, reporter) { } /////////////////////////////////////////////////////////////////////////////////////////// +#include "SkSurface.h" +#include "sk_pixel_iter.h" + +DEF_TEST(BlurZeroSigma, reporter) { + auto surf = SkSurface::MakeRasterN32Premul(20, 20); + SkPaint paint; + paint.setAntiAlias(true); + + const SkIRect ir = { 5, 5, 15, 15 }; + const SkRect r = SkRect::Make(ir); + + const SkScalar sigmas[] = { 0, SkBits2Float(1) }; + // if sigma is zero (or nearly so), we need to draw correctly (unblurred) and not crash + // or assert. + for (auto sigma : sigmas) { + paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma)); + surf->getCanvas()->drawRect(r, paint); + + sk_tool_utils::PixelIter iter(surf.get()); + SkIPoint loc; + while (const SkPMColor* p = (const SkPMColor*)iter.next(&loc)) { + if (ir.contains(loc.fX, loc.fY)) { + // inside the rect we draw (opaque black) + REPORTER_ASSERT(reporter, *p == SkPackARGB32(0xFF, 0, 0, 0)); + } else { + // outside the rect we didn't draw at all, no blurred edges + REPORTER_ASSERT(reporter, *p == 0); + } + } + } +} + |