Commit 0461c255 authored by Juanmi Huertas's avatar Juanmi Huertas Committed by Commit Bot

Fixing issue dereferencing skImage

When we transferToImageBitmap and we do a flush in the Snapshot, it can
be that the skImage was null due to some issue.

We are adding a new check to ensure that we are not returning a null
skImage contained in a valid imagebitmap.

Bug: 980057
Change-Id: I91e6b1688ec54b6029bcdd051db3d045421786cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1811157Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697787}
parent de705c28
...@@ -182,8 +182,13 @@ ImageBitmap* OffscreenCanvasRenderingContext2D::TransferToImageBitmap( ...@@ -182,8 +182,13 @@ ImageBitmap* OffscreenCanvasRenderingContext2D::TransferToImageBitmap(
if (image->IsTextureBacked()) { if (image->IsTextureBacked()) {
// Before discarding the image resource, we need to flush pending render ops // Before discarding the image resource, we need to flush pending render ops
// to fully resolve the snapshot. // to fully resolve the snapshot.
image->PaintImageForCurrentFrame().GetSkImage()->getBackendTexture( // We can only do this if the skImage is not null
true); // Flush pending ops. if (auto skImage = image->PaintImageForCurrentFrame().GetSkImage()) {
skImage->getBackendTexture(true); // Flush pending ops.
} else {
// If the SkImage was null, we better return a null ImageBitmap
return nullptr;
}
} }
Host()->DiscardResourceProvider(); // "Transfer" means no retained buffer. Host()->DiscardResourceProvider(); // "Transfer" means no retained buffer.
return ImageBitmap::Create(std::move(image)); return ImageBitmap::Create(std::move(image));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment