Commit 4bdd1fed authored by Juanmi Huertas's avatar Juanmi Huertas Committed by Commit Bot

Fixing all the cases that an image received can be null

We want to ensure that the ImageLayerBridge will not try and dereference
a potential null skImage. Adding a check to assume it was a nullptr, even
if the StaticBitmapImage was not null but pointed internally to a null.
skImage.

Changing how the white skbitmap is generated inside webgl to be more
robust against a potential context loss.

Bug: 996287
Change-Id: I2c65a34faab9f26042c1f4ccb3eca23788955dbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1784983
Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694331}
parent ab2ded5c
...@@ -557,9 +557,10 @@ scoped_refptr<StaticBitmapImage> DrawingBuffer::TransferToStaticBitmapImage( ...@@ -557,9 +557,10 @@ scoped_refptr<StaticBitmapImage> DrawingBuffer::TransferToStaticBitmapImage(
// to transferToImageBitmap are made back-to-back, or when the context gets // to transferToImageBitmap are made back-to-back, or when the context gets
// lost. We intentionally leave the transparent black image in legacy color // lost. We intentionally leave the transparent black image in legacy color
// space. // space.
sk_sp<SkSurface> surface = SkBitmap black_bitmap;
SkSurface::MakeRasterN32Premul(size_.Width(), size_.Height()); black_bitmap.allocN32Pixels(size_.Width(), size_.Height());
return StaticBitmapImage::Create(surface->makeImageSnapshot()); black_bitmap.eraseARGB(0, 255, 255, 255);
return StaticBitmapImage::Create(SkImage::MakeFromBitmap(black_bitmap));
} }
DCHECK_EQ(size_.Width(), transferable_resource.size.width()); DCHECK_EQ(size_.Width(), transferable_resource.size.width());
......
...@@ -46,6 +46,11 @@ ImageLayerBridge::~ImageLayerBridge() { ...@@ -46,6 +46,11 @@ ImageLayerBridge::~ImageLayerBridge() {
void ImageLayerBridge::SetImage(scoped_refptr<StaticBitmapImage> image) { void ImageLayerBridge::SetImage(scoped_refptr<StaticBitmapImage> image) {
if (disposed_) if (disposed_)
return; return;
// There could be the case that the current SkImage (encapsulated in the image
// parameter of the function) is null, that means that something went wrong
// during the creation of the image and we should not try and setImage with it
if (image_ && !image_->PaintImageForCurrentFrame().GetSkImage())
return;
image_ = std::move(image); image_ = std::move(image);
if (image_) { if (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