diff options
author | scroggo <scroggo@chromium.org> | 2016-05-09 13:20:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-09 13:20:58 -0700 |
commit | e6cad6b370d781c0e8345b5be74b83c2c328074c (patch) | |
tree | 833291cf912bb11fc5ff516cebf1da77f1737fb1 /gm/surface.cpp | |
parent | 97fd2d42b97104fa32a58d7e7a5b7255913f9c9d (diff) |
Stop valgrind bot from crashing
make_surface is returning nullptr, resulting in an invalid read.
Add an error message with debugging information and skip this
iteration.
Also switch to cleaner for loop syntax.
BUG=skia:5282
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1959173002
Review-Url: https://codereview.chromium.org/1959173002
Diffstat (limited to 'gm/surface.cpp')
-rw-r--r-- | gm/surface.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gm/surface.cpp b/gm/surface.cpp index 6b79479492..15d362efd5 100644 --- a/gm/surface.cpp +++ b/gm/surface.cpp @@ -85,7 +85,7 @@ protected: const struct { SkPixelGeometry fGeo; const char* fLabel; - } rec[] = { + } recs[] = { { kUnknown_SkPixelGeometry, "Unknown" }, { kRGB_H_SkPixelGeometry, "RGB_H" }, { kBGR_H_SkPixelGeometry, "BGR_H" }, @@ -97,10 +97,16 @@ protected: for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) { for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) { SkScalar y = 0; - for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) { - auto surface(make_surface(ctx, info, rec[i].fGeo, disallowAA, disallowDither, + for (const auto& rec : recs) { + auto surface(make_surface(ctx, info, rec.fGeo, disallowAA, disallowDither, gammaCorrect)); - test_draw(surface->getCanvas(), rec[i].fLabel); + if (!surface) { + SkDebugf("failed to create surface! label: %s AA: %s dither: %s\n", + rec.fLabel, (disallowAA == 1 ? "disallowed" : "allowed"), + (disallowDither == 1 ? "disallowed" : "allowed")); + continue; + } + test_draw(surface->getCanvas(), rec.fLabel); surface->draw(canvas, x, y, nullptr); y += H; } |