Commit d1de71e1 authored by Khushal's avatar Khushal Committed by Commit Bot

blink/canvas2d: Add null-checks for SkImage in SkiaTextureHolder.

Skia may fail to create an SkImage when initializing the
SkiaTextureHolder from a mailbox or a provided texture id. Handle this
safely in SkiaTextureHolder.

R=fserb@chromium.org

Bug: 978659
Change-Id: I5e76292b55302cd9045568dd4bc912d1d765af98
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1679737
Auto-Submit: Khushal <khushalsagar@chromium.org>
Commit-Queue: Fernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#673431}
parent 002ba86a
...@@ -142,7 +142,7 @@ SkiaTextureHolder::~SkiaTextureHolder() { ...@@ -142,7 +142,7 @@ SkiaTextureHolder::~SkiaTextureHolder() {
} }
bool SkiaTextureHolder::IsValid() const { bool SkiaTextureHolder::IsValid() const {
return !!ContextProviderWrapper(); return !!image_ && !!ContextProviderWrapper();
} }
} // namespace blink } // namespace blink
...@@ -21,10 +21,14 @@ class PLATFORM_EXPORT SkiaTextureHolder final : public TextureHolder { ...@@ -21,10 +21,14 @@ class PLATFORM_EXPORT SkiaTextureHolder final : public TextureHolder {
// TextureHolder impl. // TextureHolder impl.
IntSize Size() const final { IntSize Size() const final {
return IntSize(image_->width(), image_->height()); if (image_)
return IntSize(image_->width(), image_->height());
return IntSize();
} }
bool IsValid() const final; bool IsValid() const final;
bool CurrentFrameKnownToBeOpaque() const final { return image_->isOpaque(); } bool CurrentFrameKnownToBeOpaque() const final {
return image_ && image_->isOpaque();
}
const sk_sp<SkImage>& GetSkImage() const { return image_; } const sk_sp<SkImage>& GetSkImage() const { return 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