Chromium Code Reviews| 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 30 matching lines...) Expand all Loading... | |
| 41 const std::string& debug_name) { | 41 const std::string& debug_name) { |
| 42 if (!context3d) | 42 if (!context3d) |
| 43 return NULL; | 43 return NULL; |
| 44 | 44 |
| 45 return new ContextProviderCommandBuffer(context3d.Pass(), debug_name); | 45 return new ContextProviderCommandBuffer(context3d.Pass(), debug_name); |
| 46 } | 46 } |
| 47 | 47 |
| 48 ContextProviderCommandBuffer::ContextProviderCommandBuffer( | 48 ContextProviderCommandBuffer::ContextProviderCommandBuffer( |
| 49 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 49 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
| 50 const std::string& debug_name) | 50 const std::string& debug_name) |
| 51 : context3d_(context3d.Pass()), | 51 : gpu_trace_top_level_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( |
| 52 TRACE_DISABLED_BY_DEFAULT("gpu_toplevel"))), | |
| 53 context3d_(context3d.Pass()), | |
| 52 debug_name_(debug_name), | 54 debug_name_(debug_name), |
| 53 destroyed_(false) { | 55 destroyed_(false) { |
| 54 DCHECK(main_thread_checker_.CalledOnValidThread()); | 56 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 55 DCHECK(context3d_); | 57 DCHECK(context3d_); |
| 56 context_thread_checker_.DetachFromThread(); | 58 context_thread_checker_.DetachFromThread(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { | 61 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { |
| 60 DCHECK(main_thread_checker_.CalledOnValidThread() || | 62 DCHECK(main_thread_checker_.CalledOnValidThread() || |
| 61 context_thread_checker_.CalledOnValidThread()); | 63 context_thread_checker_.CalledOnValidThread()); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 89 DCHECK(context_thread_checker_.CalledOnValidThread()); | 91 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 90 | 92 |
| 91 if (lost_context_callback_proxy_) | 93 if (lost_context_callback_proxy_) |
| 92 return true; | 94 return true; |
| 93 | 95 |
| 94 if (!context3d_->InitializeOnCurrentThread()) | 96 if (!context3d_->InitializeOnCurrentThread()) |
| 95 return false; | 97 return false; |
| 96 | 98 |
| 97 InitializeCapabilities(); | 99 InitializeCapabilities(); |
| 98 | 100 |
| 99 std::string unique_context_name = | 101 if (*gpu_trace_top_level_category_) { |
|
vmiura
2014/12/09 00:18:10
As in render_widget_host_view_android.cc, move the
| |
| 100 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); | 102 std::string unique_context_name = |
| 101 context3d_->pushGroupMarkerEXT(unique_context_name.c_str()); | 103 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); |
| 104 TRACE_GPU_EVENT_BEGIN0(context3d_, | |
| 105 TRACE_DISABLED_BY_DEFAULT("gpu_toplevel"), | |
| 106 unique_context_name.c_str()); | |
| 107 } | |
| 102 | 108 |
| 103 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); | 109 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); |
| 104 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( | 110 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( |
| 105 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged, | 111 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged, |
| 106 base::Unretained(this))); | 112 base::Unretained(this))); |
| 107 return true; | 113 return true; |
| 108 } | 114 } |
| 109 | 115 |
| 110 gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { | 116 gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { |
| 111 DCHECK(context3d_); | 117 DCHECK(context3d_); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); | 198 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); |
| 193 caps.max_transfer_buffer_usage_bytes = | 199 caps.max_transfer_buffer_usage_bytes = |
| 194 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit | 200 mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit |
| 195 ? std::numeric_limits<size_t>::max() : mapped_memory_limit; | 201 ? std::numeric_limits<size_t>::max() : mapped_memory_limit; |
| 196 | 202 |
| 197 capabilities_ = caps; | 203 capabilities_ = caps; |
| 198 } | 204 } |
| 199 | 205 |
| 200 bool ContextProviderCommandBuffer::DestroyedOnMainThread() { | 206 bool ContextProviderCommandBuffer::DestroyedOnMainThread() { |
| 201 DCHECK(main_thread_checker_.CalledOnValidThread()); | 207 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 208 if (*gpu_trace_top_level_category_) { | |
| 209 TRACE_GPU_EVENT_END0(context3d_); | |
| 210 } | |
| 202 | 211 |
| 203 base::AutoLock lock(main_thread_lock_); | 212 base::AutoLock lock(main_thread_lock_); |
| 204 return destroyed_; | 213 return destroyed_; |
| 205 } | 214 } |
| 206 | 215 |
| 207 void ContextProviderCommandBuffer::SetLostContextCallback( | 216 void ContextProviderCommandBuffer::SetLostContextCallback( |
| 208 const LostContextCallback& lost_context_callback) { | 217 const LostContextCallback& lost_context_callback) { |
| 209 DCHECK(context_thread_checker_.CalledOnValidThread()); | 218 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 210 DCHECK(lost_context_callback_.is_null() || | 219 DCHECK(lost_context_callback_.is_null() || |
| 211 lost_context_callback.is_null()); | 220 lost_context_callback.is_null()); |
| 212 lost_context_callback_ = lost_context_callback; | 221 lost_context_callback_ = lost_context_callback; |
| 213 } | 222 } |
| 214 | 223 |
| 215 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 224 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
| 216 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 225 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
| 217 DCHECK(context_thread_checker_.CalledOnValidThread()); | 226 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 218 DCHECK(memory_policy_changed_callback_.is_null() || | 227 DCHECK(memory_policy_changed_callback_.is_null() || |
| 219 memory_policy_changed_callback.is_null()); | 228 memory_policy_changed_callback.is_null()); |
| 220 memory_policy_changed_callback_ = memory_policy_changed_callback; | 229 memory_policy_changed_callback_ = memory_policy_changed_callback; |
| 221 } | 230 } |
| 222 | 231 |
| 223 } // namespace content | 232 } // namespace content |
| OLD | NEW |