| 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 7b16a0278cfcb824c4e4dda2eb05307b204f612b..90a1b5e356f525c6a7bcf3b7f29d3cf5dd38ea89 100644
|
| --- a/content/common/gpu/client/context_provider_command_buffer.cc
|
| +++ b/content/common/gpu/client/context_provider_command_buffer.cc
|
| @@ -60,8 +60,11 @@ ContextProviderCommandBuffer::~ContextProviderCommandBuffer() {
|
| context_thread_checker_.CalledOnValidThread());
|
|
|
| // Destroy references to the context3d_ before leaking it.
|
| - if (context3d_->GetCommandBufferProxy())
|
| + if (context3d_->GetCommandBufferProxy()) {
|
| context3d_->GetCommandBufferProxy()->SetLock(nullptr);
|
| + context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
|
| + CommandBufferProxyImpl::MemoryAllocationChangedCallback());
|
| + }
|
| lost_context_callback_proxy_.reset();
|
| }
|
|
|
| @@ -174,6 +177,16 @@ void ContextProviderCommandBuffer::OnLostContext() {
|
| gr_context_->OnLostContext();
|
| }
|
|
|
| +void ContextProviderCommandBuffer::OnMemoryAllocationChanged(
|
| + const gpu::MemoryAllocation& allocation) {
|
| + DCHECK(context_thread_checker_.CalledOnValidThread());
|
| +
|
| + if (memory_policy_changed_callback_.is_null())
|
| + return;
|
| +
|
| + memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation));
|
| +}
|
| +
|
| void ContextProviderCommandBuffer::InitializeCapabilities() {
|
| Capabilities caps;
|
| caps.gpu = context3d_->GetImplementation()->capabilities();
|
| @@ -194,4 +207,19 @@ void ContextProviderCommandBuffer::SetLostContextCallback(
|
| lost_context_callback_ = lost_context_callback;
|
| }
|
|
|
| +void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback(
|
| + const MemoryPolicyChangedCallback& memory_policy_changed_callback) {
|
| + DCHECK(context_thread_checker_.CalledOnValidThread());
|
| + DCHECK(memory_policy_changed_callback_.is_null() ||
|
| + memory_policy_changed_callback.is_null());
|
| + memory_policy_changed_callback_ = memory_policy_changed_callback;
|
| +
|
| + if (!memory_policy_changed_callback_.is_null()) {
|
| + DCHECK(context3d_->GetCommandBufferProxy());
|
| + context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
|
| + base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged,
|
| + base::Unretained(this)));
|
| + }
|
| +}
|
| +
|
| } // namespace content
|
|
|