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

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: remove more redundant code. 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 context_thread_checker_.DetachFromThread(); 58 context_thread_checker_.DetachFromThread();
59 } 59 }
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 }
73 lost_context_callback_proxy_.reset(); 70 lost_context_callback_proxy_.reset();
74 } 71 }
75 72
76 73
77 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { 74 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() {
78 return context3d_->GetCommandBufferProxy(); 75 return context3d_->GetCommandBufferProxy();
79 } 76 }
80 77
81 WebGraphicsContext3DCommandBufferImpl* 78 WebGraphicsContext3DCommandBufferImpl*
82 ContextProviderCommandBuffer::WebContext3D() { 79 ContextProviderCommandBuffer::WebContext3D() {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 if (destroyed_) 185 if (destroyed_)
189 return; 186 return;
190 destroyed_ = true; 187 destroyed_ = true;
191 } 188 }
192 if (!lost_context_callback_.is_null()) 189 if (!lost_context_callback_.is_null())
193 base::ResetAndReturn(&lost_context_callback_).Run(); 190 base::ResetAndReturn(&lost_context_callback_).Run();
194 if (gr_context_) 191 if (gr_context_)
195 gr_context_->OnLostContext(); 192 gr_context_->OnLostContext();
196 } 193 }
197 194
198 void ContextProviderCommandBuffer::OnMemoryAllocationChanged(
199 const gpu::MemoryAllocation& allocation) {
200 DCHECK(context_thread_checker_.CalledOnValidThread());
201
202 if (memory_policy_changed_callback_.is_null())
203 return;
204
205 memory_policy_changed_callback_.Run(cc::ManagedMemoryPolicy(allocation));
206 }
207
208 void ContextProviderCommandBuffer::InitializeCapabilities() { 195 void ContextProviderCommandBuffer::InitializeCapabilities() {
209 Capabilities caps; 196 Capabilities caps;
210 caps.gpu = context3d_->GetImplementation()->capabilities(); 197 caps.gpu = context3d_->GetImplementation()->capabilities();
211 198
212 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); 199 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit();
213 caps.max_transfer_buffer_usage_bytes = 200 caps.max_transfer_buffer_usage_bytes =
214 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit 201 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit
215 ? std::numeric_limits<size_t>::max() : mapped_memory_limit; 202 ? std::numeric_limits<size_t>::max() : mapped_memory_limit;
216 203
217 capabilities_ = caps; 204 capabilities_ = caps;
218 } 205 }
219 206
220 bool ContextProviderCommandBuffer::DestroyedOnMainThread() { 207 bool ContextProviderCommandBuffer::DestroyedOnMainThread() {
221 DCHECK(main_thread_checker_.CalledOnValidThread()); 208 DCHECK(main_thread_checker_.CalledOnValidThread());
222 209
223 base::AutoLock lock(main_thread_lock_); 210 base::AutoLock lock(main_thread_lock_);
224 return destroyed_; 211 return destroyed_;
225 } 212 }
226 213
227 void ContextProviderCommandBuffer::SetLostContextCallback( 214 void ContextProviderCommandBuffer::SetLostContextCallback(
228 const LostContextCallback& lost_context_callback) { 215 const LostContextCallback& lost_context_callback) {
229 DCHECK(context_thread_checker_.CalledOnValidThread()); 216 DCHECK(context_thread_checker_.CalledOnValidThread());
230 DCHECK(lost_context_callback_.is_null() || 217 DCHECK(lost_context_callback_.is_null() ||
231 lost_context_callback.is_null()); 218 lost_context_callback.is_null());
232 lost_context_callback_ = lost_context_callback; 219 lost_context_callback_ = lost_context_callback;
233 } 220 }
234 221
235 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( 222 } // namespace content
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698