aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2017-03-15 12:58:15 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-15 20:45:04 +0000
commit0361d49e2a663b9fc36352e308728a470320366b (patch)
tree2802cc5f9bcfc9a29902fe4b79ce6871238cbec7
parent0b83319b7f301145b7fc89d7096ddcea91d4a56b (diff)
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>
-rw-r--r--fuzz/FuzzCanvas.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp
index 64a818b370..d59cee034f 100644
--- a/fuzz/FuzzCanvas.cpp
+++ b/fuzz/FuzzCanvas.cpp
@@ -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;
}