Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2091)

Unified Diff: content/common/gpu/client/context_provider_command_buffer.cc

Issue 1412923004: Revert of Move gpu memory calculations to Compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « content/common/gpu/client/context_provider_command_buffer.h ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698