OLD | NEW |
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 if (!context3d_->InitializeOnCurrentThread()) | 98 if (!context3d_->InitializeOnCurrentThread()) |
99 return false; | 99 return false; |
100 | 100 |
101 InitializeCapabilities(); | 101 InitializeCapabilities(); |
102 | 102 |
103 std::string unique_context_name = | 103 std::string unique_context_name = |
104 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); | 104 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); |
105 context3d_->traceBeginCHROMIUM("gpu_toplevel", unique_context_name.c_str()); | 105 context3d_->traceBeginCHROMIUM("gpu_toplevel", unique_context_name.c_str()); |
106 | 106 |
107 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); | 107 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); |
108 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( | |
109 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged, | |
110 base::Unretained(this))); | |
111 return true; | 108 return true; |
112 } | 109 } |
113 | 110 |
114 void ContextProviderCommandBuffer::DetachFromThread() { | 111 void ContextProviderCommandBuffer::DetachFromThread() { |
115 context_thread_checker_.DetachFromThread(); | 112 context_thread_checker_.DetachFromThread(); |
116 } | 113 } |
117 | 114 |
118 gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { | 115 gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { |
119 DCHECK(context3d_); | 116 DCHECK(context3d_); |
120 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 117 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 lost_context_callback.is_null()); | 231 lost_context_callback.is_null()); |
235 lost_context_callback_ = lost_context_callback; | 232 lost_context_callback_ = lost_context_callback; |
236 } | 233 } |
237 | 234 |
238 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 235 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
239 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 236 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
240 DCHECK(context_thread_checker_.CalledOnValidThread()); | 237 DCHECK(context_thread_checker_.CalledOnValidThread()); |
241 DCHECK(memory_policy_changed_callback_.is_null() || | 238 DCHECK(memory_policy_changed_callback_.is_null() || |
242 memory_policy_changed_callback.is_null()); | 239 memory_policy_changed_callback.is_null()); |
243 memory_policy_changed_callback_ = memory_policy_changed_callback; | 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 } |
244 } | 248 } |
245 | 249 |
246 } // namespace content | 250 } // namespace content |
OLD | NEW |