SkCanvas::makeSurface() can fail

This should fix the --preAbandonGpuContext bots.

Cq-Include-Trybots: luci.skia.skia.primary:Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-PreAbandonGpuContext
Change-Id: I5df65e730414c670e255eb786f16a43fee49c22f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352087
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Mike Klein 2021-01-08 14:01:36 -06:00
parent 7f39983c95
commit f8f01d44b4

View File

@ -94,6 +94,11 @@ static void draw_colorspace_gm(Strategy strategy, SkCanvas* canvas) {
case SkCanvas_makeSurface: {
sk_sp<SkSurface> offscreen =
canvas->makeSurface(canvas->imageInfo().makeColorSpace(midCS));
if (!offscreen) {
canvas->drawString("Could not allocate offscreen surface!",
W,H, SkFont{}, SkPaint{});
return;
}
offscreen->getCanvas()->drawImage(img, 0,0);
canvas->drawImage(offscreen->makeImageSnapshot(), 0,0);
} break;