Commit bbd7a380 authored by Eric Karl's avatar Eric Karl Committed by Commit Bot

Update SharedImageBackingFactoryAHB to add locks at required places.

Update the SharedImageBackingFactoryAHB to add lock in the destructor as
well as in ProduceLegacyMailbox().

TBR: vikassoni@chromium.org
Bug: 1034007, 1003686
Change-Id: I4f6109cdc05f4287ddd45e3e85ec2c03ee15edeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1974855
Commit-Queue: Eric Karl <ericrk@chromium.org>
Commit-Queue: vikas soni <vikassoni@chromium.org>
Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726566}
parent eccbf1c5
...@@ -455,6 +455,9 @@ SharedImageBackingAHB::SharedImageBackingAHB( ...@@ -455,6 +455,9 @@ SharedImageBackingAHB::SharedImageBackingAHB(
} }
SharedImageBackingAHB::~SharedImageBackingAHB() { SharedImageBackingAHB::~SharedImageBackingAHB() {
// Locking here in destructor since we are accessing member variable
// |have_context_| via have_context().
AutoLock auto_lock(this);
DCHECK(hardware_buffer_handle_.is_valid()); DCHECK(hardware_buffer_handle_.is_valid());
if (legacy_texture_) { if (legacy_texture_) {
legacy_texture_->RemoveLightweightRef(have_context()); legacy_texture_->RemoveLightweightRef(have_context());
...@@ -502,9 +505,13 @@ bool SharedImageBackingAHB::ProduceLegacyMailbox( ...@@ -502,9 +505,13 @@ bool SharedImageBackingAHB::ProduceLegacyMailbox(
legacy_texture_ = GenGLTexture(); legacy_texture_ = GenGLTexture();
if (!legacy_texture_) if (!legacy_texture_)
return false; return false;
// Make sure our |legacy_texture_| has the right initial cleared rect. {
legacy_texture_->SetLevelClearedRect(legacy_texture_->target(), 0, // Lock here to access |cleared_rect_| via ClearedRectInternal().
ClearedRectInternal()); AutoLock auto_lock(this);
// Make sure our |legacy_texture_| has the right initial cleared rect.
legacy_texture_->SetLevelClearedRect(legacy_texture_->target(), 0,
ClearedRectInternal());
}
mailbox_manager->ProduceTexture(mailbox(), legacy_texture_); mailbox_manager->ProduceTexture(mailbox(), legacy_texture_);
return true; return true;
} }
......
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