Commit 2790aeed authored by Justin Novosad's avatar Justin Novosad Committed by Commit Bot

Fix crash in ImageLayerBridge on gpu resource allocation failure

BUG=847725

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Ie762af63cd0a414a10a940344b90e6296dcb60a9
Reviewed-on: https://chromium-review.googlesource.com/1093161
Commit-Queue: Justin Novosad <junov@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566020}
parent a55b3520
...@@ -44,8 +44,7 @@ class PLATFORM_EXPORT AcceleratedStaticBitmapImage final ...@@ -44,8 +44,7 @@ class PLATFORM_EXPORT AcceleratedStaticBitmapImage final
scoped_refptr<StaticBitmapImage> MakeAccelerated( scoped_refptr<StaticBitmapImage> MakeAccelerated(
base::WeakPtr<WebGraphicsContext3DProviderWrapper> context_wrapper) base::WeakPtr<WebGraphicsContext3DProviderWrapper> context_wrapper)
override { override {
NOTREACHED(); // IsTextureBacked() is already true. return this;
return nullptr;
} }
void Draw(PaintCanvas*, void Draw(PaintCanvas*,
......
...@@ -108,20 +108,12 @@ bool ImageLayerBridge::PrepareTransferableResource( ...@@ -108,20 +108,12 @@ bool ImageLayerBridge::PrepareTransferableResource(
// flipped. // flipped.
layer_->SetFlipped(gpu_image); layer_->SetFlipped(gpu_image);
scoped_refptr<StaticBitmapImage> image_for_compositor; if (gpu_compositing) {
scoped_refptr<StaticBitmapImage> image_for_compositor =
// Upload to a texture if the compositor is expecting one.
if (gpu_compositing && !image_->IsTextureBacked()) {
image_for_compositor =
image_->MakeAccelerated(SharedGpuContext::ContextProviderWrapper()); image_->MakeAccelerated(SharedGpuContext::ContextProviderWrapper());
} else if (!gpu_compositing && image_->IsTextureBacked()) { if (!image_for_compositor)
image_for_compositor = image_->MakeUnaccelerated(); return false;
} else {
image_for_compositor = image_;
}
DCHECK_EQ(image_for_compositor->IsTextureBacked(), gpu_compositing);
if (gpu_compositing) {
uint32_t filter = uint32_t filter =
filter_quality_ == kNone_SkFilterQuality ? GL_NEAREST : GL_LINEAR; filter_quality_ == kNone_SkFilterQuality ? GL_NEAREST : GL_LINEAR;
image_for_compositor->EnsureMailbox(kUnverifiedSyncToken, filter); image_for_compositor->EnsureMailbox(kUnverifiedSyncToken, filter);
...@@ -133,13 +125,17 @@ bool ImageLayerBridge::PrepareTransferableResource( ...@@ -133,13 +125,17 @@ bool ImageLayerBridge::PrepareTransferableResource(
WrapWeakPersistent(this), std::move(image_for_compositor)); WrapWeakPersistent(this), std::move(image_for_compositor));
*out_release_callback = viz::SingleReleaseCallback::Create(std::move(func)); *out_release_callback = viz::SingleReleaseCallback::Create(std::move(func));
} else { } else {
sk_sp<SkImage> sk_image = // Readback if needed and retain the readback in image_ to prevent future
image_for_compositor->PaintImageForCurrentFrame().GetSkImage(); // readbacks
image_ = image_->MakeUnaccelerated();
if (!image_)
return false;
sk_sp<SkImage> sk_image = image_->PaintImageForCurrentFrame().GetSkImage();
if (!sk_image) if (!sk_image)
return false; return false;
const gfx::Size size(image_for_compositor->width(), const gfx::Size size(image_->width(), image_->height());
image_for_compositor->height());
viz::ResourceFormat resource_format = viz::RGBA_8888; viz::ResourceFormat resource_format = viz::RGBA_8888;
if (sk_image->colorType() == SkColorType::kRGBA_F16_SkColorType) if (sk_image->colorType() == SkColorType::kRGBA_F16_SkColorType)
resource_format = viz::RGBA_F16; resource_format = viz::RGBA_F16;
......
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