FuzzCanvas: make fuzzing drawImgNine easier

Change-Id: I82c8723d0b9192008b323f65232054d9acafddcc
Reviewed-on: https://skia-review.googlesource.com/9724
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
Hal Canary 2017-03-15 12:58:15 -04:00 committed by Skia Commit-Bot
parent 0b83319b7f
commit 0361d49e2a

View File

@ -1462,10 +1462,19 @@ static void fuzz_canvas(Fuzz* fuzz, SkCanvas* canvas, int depth = 9) {
SkIRect center;
SkRect dst;
bool usePaint;
fuzz->next(&center, &dst, &usePaint);
fuzz->next(&usePaint);
if (usePaint) {
fuzz_paint(fuzz, &paint, depth - 1);
}
if (make_fuzz_t<bool>(fuzz)) {
fuzz->next(&center);
} else { // Make valid center, see SkLatticeIter::Valid().
fuzz->nextRange(&center.fLeft, 0, img->width() - 1);
fuzz->nextRange(&center.fTop, 0, img->height() - 1);
fuzz->nextRange(&center.fRight, center.fLeft + 1, img->width());
fuzz->nextRange(&center.fBottom, center.fTop + 1, img->height());
}
fuzz->next(&dst);
canvas->drawImageNine(img, center, dst, usePaint ? &paint : nullptr);
break;
}
@ -1528,10 +1537,19 @@ static void fuzz_canvas(Fuzz* fuzz, SkCanvas* canvas, int depth = 9) {
SkIRect center;
SkRect dst;
bool usePaint;
fuzz->next(&center, &dst, &usePaint);
fuzz->next(&usePaint);
if (usePaint) {
fuzz_paint(fuzz, &paint, depth - 1);
}
if (make_fuzz_t<bool>(fuzz)) {
fuzz->next(&center);
} else { // Make valid center, see SkLatticeIter::Valid().
fuzz->nextRange(&center.fLeft, 0, img.width() - 1);
fuzz->nextRange(&center.fTop, 0, img.height() - 1);
fuzz->nextRange(&center.fRight, center.fLeft + 1, img.width());
fuzz->nextRange(&center.fBottom, center.fTop + 1, img.height());
}
fuzz->next(&dst);
canvas->drawBitmapNine(img, center, dst, usePaint ? &paint : nullptr);
break;
}