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>
This commit is contained in:
parent
240516f772
commit
f221b4942c
@ -279,6 +279,9 @@ bool SkBlurMask::BlurRect(SkScalar sigma, SkMask *dst,
|
||||
const SkRect &src, SkBlurStyle style,
|
||||
SkIPoint *margin, SkMask::CreateMode createMode) {
|
||||
int profileSize = SkScalarCeilToInt(6*sigma);
|
||||
if (profileSize <= 0) {
|
||||
return false; // no blur to compute
|
||||
}
|
||||
|
||||
int pad = profileSize/2;
|
||||
if (margin) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user