Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/gpu/client/context_provider_command_buffer.h" | 5 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 60 |
| 61 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { | 61 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { |
| 62 DCHECK(main_thread_checker_.CalledOnValidThread() || | 62 DCHECK(main_thread_checker_.CalledOnValidThread() || |
| 63 context_thread_checker_.CalledOnValidThread()); | 63 context_thread_checker_.CalledOnValidThread()); |
| 64 | 64 |
| 65 base::AutoLock lock(main_thread_lock_); | 65 base::AutoLock lock(main_thread_lock_); |
| 66 | 66 |
| 67 // Destroy references to the context3d_ before leaking it. | 67 // Destroy references to the context3d_ before leaking it. |
| 68 if (context3d_->GetCommandBufferProxy()) { | 68 if (context3d_->GetCommandBufferProxy()) { |
| 69 context3d_->GetCommandBufferProxy()->SetLock(nullptr); | 69 context3d_->GetCommandBufferProxy()->SetLock(nullptr); |
| 70 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( | |
| 71 CommandBufferProxyImpl::MemoryAllocationChangedCallback()); | |
| 72 } | 70 } |
| 73 lost_context_callback_proxy_.reset(); | 71 lost_context_callback_proxy_.reset(); |
| 74 } | 72 } |
| 75 | 73 |
| 76 | 74 |
| 77 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { | 75 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { |
| 78 return context3d_->GetCommandBufferProxy(); | 76 return context3d_->GetCommandBufferProxy(); |
| 79 } | 77 } |
| 80 | 78 |
| 81 WebGraphicsContext3DCommandBufferImpl* | 79 WebGraphicsContext3DCommandBufferImpl* |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 if (destroyed_) | 186 if (destroyed_) |
| 189 return; | 187 return; |
| 190 destroyed_ = true; | 188 destroyed_ = true; |
| 191 } | 189 } |
| 192 if (!lost_context_callback_.is_null()) | 190 if (!lost_context_callback_.is_null()) |
| 193 base::ResetAndReturn(&lost_context_callback_).Run(); | 191 base::ResetAndReturn(&lost_context_callback_).Run(); |
| 194 if (gr_context_) | 192 if (gr_context_) |
| 195 gr_context_->OnLostContext(); | 193 gr_context_->OnLostContext(); |
| 196 } | 194 } |
| 197 | 195 |
| 198 void ContextProviderCommandBuffer::OnMemoryAllocationChanged( | 196 void ContextProviderCommandBuffer::OnMemoryAllocationChanged( |
|
piman
2015/09/24 21:34:08
nit: remove
sohanjg
2015/09/28 07:35:49
Done.
| |
| 199 const gpu::MemoryAllocation& allocation) { | 197 const gpu::MemoryAllocation& allocation) { |
| 200 DCHECK(context_thread_checker_.CalledOnValidThread()); | 198 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 201 | 199 |
| 202 if (memory_policy_changed_callback_.is_null()) | 200 if (memory_policy_changed_callback_.is_null()) |
| 203 return; | 201 return; |
| 204 | 202 |
| 205 memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation)); | 203 memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation)); |
| 206 } | 204 } |
| 207 | 205 |
| 208 void ContextProviderCommandBuffer::InitializeCapabilities() { | 206 void ContextProviderCommandBuffer::InitializeCapabilities() { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 225 } | 223 } |
| 226 | 224 |
| 227 void ContextProviderCommandBuffer::SetLostContextCallback( | 225 void ContextProviderCommandBuffer::SetLostContextCallback( |
| 228 const LostContextCallback& lost_context_callback) { | 226 const LostContextCallback& lost_context_callback) { |
| 229 DCHECK(context_thread_checker_.CalledOnValidThread()); | 227 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 230 DCHECK(lost_context_callback_.is_null() || | 228 DCHECK(lost_context_callback_.is_null() || |
| 231 lost_context_callback.is_null()); | 229 lost_context_callback.is_null()); |
| 232 lost_context_callback_ = lost_context_callback; | 230 lost_context_callback_ = lost_context_callback; |
| 233 } | 231 } |
| 234 | 232 |
| 235 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | |
| 236 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | |
| 237 DCHECK(context_thread_checker_.CalledOnValidThread()); | |
| 238 DCHECK(memory_policy_changed_callback_.is_null() || | |
| 239 memory_policy_changed_callback.is_null()); | |
| 240 memory_policy_changed_callback_ = memory_policy_changed_callback; | |
| 241 | |
| 242 if (!memory_policy_changed_callback_.is_null()) { | |
| 243 DCHECK(context3d_->GetCommandBufferProxy()); | |
| 244 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( | |
| 245 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged, | |
| 246 base::Unretained(this))); | |
| 247 } | |
| 248 } | |
| 249 | |
| 250 } // namespace content | 233 } // namespace content |
| OLD | NEW |