0

Handle empty SkBitmap results in WebTestControlHost::OnImageDump().

In some cases, we'll fail to create an SkBitmap (for instance, when
printing via `TestRunner::PrintFrameToBitmap()`. We handle those cases
safely in general, but we missed a check against the color space here.
This CL punts out of image encoding early when it's unnecessary (and
impossible).

Bug: 397018488
Change-Id: If5a43f24312639391d482081671963e151040cf1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6287486
Reviewed-by: Jonathan Hao <phao@chromium.org>
Commit-Queue: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1423778}
This commit is contained in:
Mike West
2025-02-23 23:34:40 -08:00
committed by Chromium LUCI CQ
parent 48792bd8f4
commit d885a8be06

@ -1450,6 +1450,7 @@ void WebTestControlHost::OnImageDump(const std::string& actual_pixel_hash,
if (web_test_runtime_flags().dump_drag_image())
discard_transparency = false;
if (!image.drawsNothing()) {
gfx::PNGCodec::ColorFormat pixel_format;
switch (image.info().colorType()) {
case kBGRA_8888_SkColorType:
@ -1474,6 +1475,7 @@ void WebTestControlHost::OnImageDump(const std::string& actual_pixel_hash,
printer_->PrintImageBlock(png.value());
}
}
}
printer_->PrintImageFooter();
}