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

Side by Side Diff: content/common/gpu/client/context_provider_command_buffer.cc

Issue 1324413003: Move gpu memory calculations to Compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comment + android_arm64_dbg_recipe bot issue. 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 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 context_thread_checker_.DetachFromThread(); 56 context_thread_checker_.DetachFromThread();
57 } 57 }
58 58
59 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { 59 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() {
60 DCHECK(main_thread_checker_.CalledOnValidThread() || 60 DCHECK(main_thread_checker_.CalledOnValidThread() ||
61 context_thread_checker_.CalledOnValidThread()); 61 context_thread_checker_.CalledOnValidThread());
62 62
63 base::AutoLock lock(main_thread_lock_); 63 base::AutoLock lock(main_thread_lock_);
64 64
65 // Destroy references to the context3d_ before leaking it. 65 // Destroy references to the context3d_ before leaking it.
66 if (context3d_->GetCommandBufferProxy()) { 66 if (context3d_->GetCommandBufferProxy())
67 context3d_->GetCommandBufferProxy()->SetLock(nullptr); 67 context3d_->GetCommandBufferProxy()->SetLock(nullptr);
68 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
69 CommandBufferProxyImpl::MemoryAllocationChangedCallback());
70 }
71 lost_context_callback_proxy_.reset(); 68 lost_context_callback_proxy_.reset();
72 } 69 }
73 70
74 71
75 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { 72 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() {
76 return context3d_->GetCommandBufferProxy(); 73 return context3d_->GetCommandBufferProxy();
77 } 74 }
78 75
79 WebGraphicsContext3DCommandBufferImpl* 76 WebGraphicsContext3DCommandBufferImpl*
80 ContextProviderCommandBuffer::WebContext3D() { 77 ContextProviderCommandBuffer::WebContext3D() {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if (destroyed_) 183 if (destroyed_)
187 return; 184 return;
188 destroyed_ = true; 185 destroyed_ = true;
189 } 186 }
190 if (!lost_context_callback_.is_null()) 187 if (!lost_context_callback_.is_null())
191 base::ResetAndReturn(&lost_context_callback_).Run(); 188 base::ResetAndReturn(&lost_context_callback_).Run();
192 if (gr_context_) 189 if (gr_context_)
193 gr_context_->OnLostContext(); 190 gr_context_->OnLostContext();
194 } 191 }
195 192
196 void ContextProviderCommandBuffer::OnMemoryAllocationChanged(
197 const gpu::MemoryAllocation& allocation) {
198 DCHECK(context_thread_checker_.CalledOnValidThread());
199
200 if (memory_policy_changed_callback_.is_null())
201 return;
202
203 memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation));
204 }
205
206 void ContextProviderCommandBuffer::InitializeCapabilities() { 193 void ContextProviderCommandBuffer::InitializeCapabilities() {
207 Capabilities caps; 194 Capabilities caps;
208 caps.gpu = context3d_->GetImplementation()->capabilities(); 195 caps.gpu = context3d_->GetImplementation()->capabilities();
209 196
210 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); 197 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit();
211 caps.max_transfer_buffer_usage_bytes = 198 caps.max_transfer_buffer_usage_bytes =
212 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit 199 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit
213 ? std::numeric_limits<size_t>::max() : mapped_memory_limit; 200 ? std::numeric_limits<size_t>::max() : mapped_memory_limit;
214 201
215 capabilities_ = caps; 202 capabilities_ = caps;
216 } 203 }
217 204
218 bool ContextProviderCommandBuffer::DestroyedOnMainThread() { 205 bool ContextProviderCommandBuffer::DestroyedOnMainThread() {
219 DCHECK(main_thread_checker_.CalledOnValidThread()); 206 DCHECK(main_thread_checker_.CalledOnValidThread());
220 207
221 base::AutoLock lock(main_thread_lock_); 208 base::AutoLock lock(main_thread_lock_);
222 return destroyed_; 209 return destroyed_;
223 } 210 }
224 211
225 void ContextProviderCommandBuffer::SetLostContextCallback( 212 void ContextProviderCommandBuffer::SetLostContextCallback(
226 const LostContextCallback& lost_context_callback) { 213 const LostContextCallback& lost_context_callback) {
227 DCHECK(context_thread_checker_.CalledOnValidThread()); 214 DCHECK(context_thread_checker_.CalledOnValidThread());
228 DCHECK(lost_context_callback_.is_null() || 215 DCHECK(lost_context_callback_.is_null() ||
229 lost_context_callback.is_null()); 216 lost_context_callback.is_null());
230 lost_context_callback_ = lost_context_callback; 217 lost_context_callback_ = lost_context_callback;
231 } 218 }
232 219
233 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback(
234 const MemoryPolicyChangedCallback& memory_policy_changed_callback) {
235 DCHECK(context_thread_checker_.CalledOnValidThread());
236 DCHECK(memory_policy_changed_callback_.is_null() ||
237 memory_policy_changed_callback.is_null());
238 memory_policy_changed_callback_ = memory_policy_changed_callback;
239
240 if (!memory_policy_changed_callback_.is_null()) {
241 DCHECK(context3d_->GetCommandBufferProxy());
242 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback(
243 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged,
244 base::Unretained(this)));
245 }
246 }
247
248 } // namespace content 220 } // 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