don't try to extract or blur a zero-sized bitmap

Bug:884473
Change-Id: Ic61238633f65c66db0d5d00c2c438f03552ec7c9
Reviewed-on: https://skia-review.googlesource.com/154634
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-09-15 12:15:27 -04:00 committed by Skia Commit-Bot
parent 8e73f4b6bb
commit 840debe9c7
2 changed files with 13 additions and 0 deletions

View File

@ -542,6 +542,9 @@ bool SkBitmap::extractAlpha(SkBitmap* dst, const SkPaint* paint,
SkMatrix identity;
SkMask srcM, dstM;
if (this->width() == 0 || this->height() == 0) {
return false;
}
srcM.fBounds.set(0, 0, this->width(), this->height());
srcM.fRowBytes = SkAlign4(this->width());
srcM.fFormat = SkMask::kA8_Format;

View File

@ -732,3 +732,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(BlurMaskBiggerThanDest, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, SkColorGetB(readback.getColor(15, 15)) == 0);
REPORTER_ASSERT(reporter, readback.getColor(31, 31) == SK_ColorBLACK);
}
DEF_TEST(zero_blur, reporter) {
SkBitmap alpha, bitmap;
SkPaint paint;
paint.setMaskFilter(SkMaskFilter::MakeBlur(kOuter_SkBlurStyle, 3));
SkIPoint offset;
bitmap.extractAlpha(&alpha, &paint, nullptr, &offset);
}