| Index: content/common/gpu/client/context_provider_command_buffer.cc
|
| diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc
|
| index ba9f0ebfbed6a6f75196c29a7bf89da933557773..7a0f67a3f563f6a8f96e8d4a377792f8476a6a0c 100644
|
| --- a/content/common/gpu/client/context_provider_command_buffer.cc
|
| +++ b/content/common/gpu/client/context_provider_command_buffer.cc
|
| @@ -52,6 +52,7 @@ ContextProviderCommandBuffer::ContextProviderCommandBuffer(
|
| : context3d_(context3d.Pass()),
|
| context_type_(type),
|
| debug_name_(CommandBufferContextTypeToString(type)),
|
| + lost_(false),
|
| destroyed_(false) {
|
| DCHECK(main_thread_checker_.CalledOnValidThread());
|
| DCHECK(context3d_);
|
| @@ -59,18 +60,8 @@ ContextProviderCommandBuffer::ContextProviderCommandBuffer(
|
| }
|
|
|
| ContextProviderCommandBuffer::~ContextProviderCommandBuffer() {
|
| - DCHECK(main_thread_checker_.CalledOnValidThread() ||
|
| - context_thread_checker_.CalledOnValidThread());
|
| -
|
| base::AutoLock lock(main_thread_lock_);
|
| -
|
| - // Destroy references to the context3d_ before leaking it.
|
| - if (context3d_->GetCommandBufferProxy()) {
|
| - context3d_->GetCommandBufferProxy()->SetLock(nullptr);
|
| - context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
|
| - CommandBufferProxyImpl::MemoryAllocationChangedCallback());
|
| - }
|
| - lost_context_callback_proxy_.reset();
|
| + DestroyWithLockAcquired();
|
| }
|
|
|
|
|
| @@ -78,6 +69,14 @@ CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() {
|
| return context3d_->GetCommandBufferProxy();
|
| }
|
|
|
| +void ContextProviderCommandBuffer::Destroy() {
|
| + DCHECK(context_thread_checker_.CalledOnValidThread());
|
| + DCHECK(context3d_);
|
| + // Verify that SetupLock() has been called.
|
| + DCHECK(context3d_->GetCommandBufferProxy()->lock());
|
| + DestroyWithLockAcquired();
|
| +}
|
| +
|
| WebGraphicsContext3DCommandBufferImpl*
|
| ContextProviderCommandBuffer::WebContext3D() {
|
| DCHECK(context3d_);
|
| @@ -151,6 +150,7 @@ void ContextProviderCommandBuffer::InvalidateGrContext(uint32_t state) {
|
|
|
| void ContextProviderCommandBuffer::SetupLock() {
|
| DCHECK(context3d_);
|
| + DCHECK(!context3d_->GetCommandBufferProxy()->lock());
|
| context3d_->GetCommandBufferProxy()->SetLock(&context_lock_);
|
| }
|
|
|
| @@ -185,9 +185,9 @@ void ContextProviderCommandBuffer::OnLostContext() {
|
| DCHECK(context_thread_checker_.CalledOnValidThread());
|
| {
|
| base::AutoLock lock(main_thread_lock_);
|
| - if (destroyed_)
|
| + if (lost_)
|
| return;
|
| - destroyed_ = true;
|
| + lost_ = true;
|
| }
|
| if (!lost_context_callback_.is_null())
|
| base::ResetAndReturn(&lost_context_callback_).Run();
|
| @@ -217,11 +217,11 @@ void ContextProviderCommandBuffer::InitializeCapabilities() {
|
| capabilities_ = caps;
|
| }
|
|
|
| -bool ContextProviderCommandBuffer::DestroyedOnMainThread() {
|
| +bool ContextProviderCommandBuffer::HasBeenLostOnMainThread() {
|
| DCHECK(main_thread_checker_.CalledOnValidThread());
|
|
|
| base::AutoLock lock(main_thread_lock_);
|
| - return destroyed_;
|
| + return lost_;
|
| }
|
|
|
| void ContextProviderCommandBuffer::SetLostContextCallback(
|
| @@ -247,4 +247,21 @@ void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback(
|
| }
|
| }
|
|
|
| +bool ContextProviderCommandBuffer::HasBeenDestroyed() {
|
| + DCHECK(context_thread_checker_.CalledOnValidThread());
|
| + return destroyed_;
|
| +}
|
| +
|
| +void ContextProviderCommandBuffer::DestroyWithLockAcquired() {
|
| + if (context3d_ && context3d_->GetCommandBufferProxy()) {
|
| + context3d_->GetCommandBufferProxy()->SetLock(nullptr);
|
| + context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
|
| + CommandBufferProxyImpl::MemoryAllocationChangedCallback());
|
| + }
|
| + lost_context_callback_proxy_.reset();
|
| + gr_context_.reset();
|
| + context3d_.reset();
|
| + destroyed_ = true;
|
| +}
|
| +
|
| } // namespace content
|
|
|