Fail gracefully if MakeRenderTarget fails

We recently started passing --preAbandonGpuContext when running DM on
valgrind, resulting in this call returning nullptr. We had not been
checking for it, so we crash. Already fixed one in crrev.com/1959173002,
and now we reach another one.

BUG=skia:5282
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1972933002

Review-Url: https://codereview.chromium.org/1972933002
This commit is contained in:
scroggo 2016-05-12 06:19:37 -07:00 committed by Commit bot
parent 7c73a53894
commit a1b283345b

View File

@ -38,6 +38,9 @@ static sk_sp<SkImage> make_texture(GrContext* ctx, SkPicture* pic, const SkImage
return nullptr;
}
auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
if (!surface) {
return nullptr;
}
surface->getCanvas()->clear(0);
surface->getCanvas()->drawPicture(pic);
return surface->makeImageSnapshot();