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

Side by Side 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, 1 month 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 unified diff | Download patch
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 DCHECK(main_thread_checker_.CalledOnValidThread()); 53 DCHECK(main_thread_checker_.CalledOnValidThread());
54 DCHECK(context3d_); 54 DCHECK(context3d_);
55 context_thread_checker_.DetachFromThread(); 55 context_thread_checker_.DetachFromThread();
56 } 56 }
57 57
58 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { 58 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() {
59 DCHECK(main_thread_checker_.CalledOnValidThread() || 59 DCHECK(main_thread_checker_.CalledOnValidThread() ||
60 context_thread_checker_.CalledOnValidThread()); 60 context_thread_checker_.CalledOnValidThread());
61 61
62 // Destroy references to the context3d_ before leaking it. 62 // Destroy references to the context3d_ before leaking it.
63 if (context3d_->GetCommandBufferProxy()) 63 if (context3d_->GetCommandBufferProxy()) {
64 context3d_->GetCommandBufferProxy()->SetLock(nullptr); 64 context3d_->GetCommandBufferProxy()->SetLock(nullptr);
65 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
66 CommandBufferProxyImpl::MemoryAllocationChangedCallback());
67 }
65 lost_context_callback_proxy_.reset(); 68 lost_context_callback_proxy_.reset();
66 } 69 }
67 70
68 71
69 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { 72 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() {
70 return context3d_->GetCommandBufferProxy(); 73 return context3d_->GetCommandBufferProxy();
71 } 74 }
72 75
73 WebGraphicsContext3DCommandBufferImpl* 76 WebGraphicsContext3DCommandBufferImpl*
74 ContextProviderCommandBuffer::WebContext3D() { 77 ContextProviderCommandBuffer::WebContext3D() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 170
168 void ContextProviderCommandBuffer::OnLostContext() { 171 void ContextProviderCommandBuffer::OnLostContext() {
169 DCHECK(context_thread_checker_.CalledOnValidThread()); 172 DCHECK(context_thread_checker_.CalledOnValidThread());
170 173
171 if (!lost_context_callback_.is_null()) 174 if (!lost_context_callback_.is_null())
172 base::ResetAndReturn(&lost_context_callback_).Run(); 175 base::ResetAndReturn(&lost_context_callback_).Run();
173 if (gr_context_) 176 if (gr_context_)
174 gr_context_->OnLostContext(); 177 gr_context_->OnLostContext();
175 } 178 }
176 179
180 void ContextProviderCommandBuffer::OnMemoryAllocationChanged(
181 const gpu::MemoryAllocation& allocation) {
182 DCHECK(context_thread_checker_.CalledOnValidThread());
183
184 if (memory_policy_changed_callback_.is_null())
185 return;
186
187 memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation));
188 }
189
177 void ContextProviderCommandBuffer::InitializeCapabilities() { 190 void ContextProviderCommandBuffer::InitializeCapabilities() {
178 Capabilities caps; 191 Capabilities caps;
179 caps.gpu = context3d_->GetImplementation()->capabilities(); 192 caps.gpu = context3d_->GetImplementation()->capabilities();
180 193
181 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); 194 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit();
182 caps.max_transfer_buffer_usage_bytes = 195 caps.max_transfer_buffer_usage_bytes =
183 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit 196 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit
184 ? std::numeric_limits<size_t>::max() : mapped_memory_limit; 197 ? std::numeric_limits<size_t>::max() : mapped_memory_limit;
185 198
186 capabilities_ = caps; 199 capabilities_ = caps;
187 } 200 }
188 201
189 void ContextProviderCommandBuffer::SetLostContextCallback( 202 void ContextProviderCommandBuffer::SetLostContextCallback(
190 const LostContextCallback& lost_context_callback) { 203 const LostContextCallback& lost_context_callback) {
191 DCHECK(context_thread_checker_.CalledOnValidThread()); 204 DCHECK(context_thread_checker_.CalledOnValidThread());
192 DCHECK(lost_context_callback_.is_null() || 205 DCHECK(lost_context_callback_.is_null() ||
193 lost_context_callback.is_null()); 206 lost_context_callback.is_null());
194 lost_context_callback_ = lost_context_callback; 207 lost_context_callback_ = lost_context_callback;
195 } 208 }
196 209
210 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback(
211 const MemoryPolicyChangedCallback& memory_policy_changed_callback) {
212 DCHECK(context_thread_checker_.CalledOnValidThread());
213 DCHECK(memory_policy_changed_callback_.is_null() ||
214 memory_policy_changed_callback.is_null());
215 memory_policy_changed_callback_ = memory_policy_changed_callback;
216
217 if (!memory_policy_changed_callback_.is_null()) {
218 DCHECK(context3d_->GetCommandBufferProxy());
219 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
220 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged,
221 base::Unretained(this)));
222 }
223 }
224
197 } // namespace content 225 } // namespace content
OLDNEW
« 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