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 "webkit/common/gpu/context_provider_in_process.h" | 5 #include "webkit/common/gpu/context_provider_in_process.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 | 59 |
| 60 return Create( | 60 return Create( |
| 61 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( | 61 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( |
| 62 attributes, lose_context_when_out_of_memory), | 62 attributes, lose_context_when_out_of_memory), |
| 63 "Offscreen"); | 63 "Offscreen"); |
| 64 } | 64 } |
| 65 | 65 |
| 66 ContextProviderInProcess::ContextProviderInProcess( | 66 ContextProviderInProcess::ContextProviderInProcess( |
| 67 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, | 67 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, |
| 68 const std::string& debug_name) | 68 const std::string& debug_name) |
| 69 : context3d_(context3d.Pass()), | 69 : gpu_trace_top_level_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( |
| 70 TRACE_DISABLED_BY_DEFAULT("gpu_toplevel"))), | |
| 71 context3d_(context3d.Pass()), | |
| 70 destroyed_(false), | 72 destroyed_(false), |
| 71 debug_name_(debug_name) { | 73 debug_name_(debug_name) { |
| 72 DCHECK(main_thread_checker_.CalledOnValidThread()); | 74 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 73 DCHECK(context3d_); | 75 DCHECK(context3d_); |
| 74 context_thread_checker_.DetachFromThread(); | 76 context_thread_checker_.DetachFromThread(); |
| 75 } | 77 } |
| 76 | 78 |
| 77 ContextProviderInProcess::~ContextProviderInProcess() { | 79 ContextProviderInProcess::~ContextProviderInProcess() { |
| 78 DCHECK(main_thread_checker_.CalledOnValidThread() || | 80 DCHECK(main_thread_checker_.CalledOnValidThread() || |
| 79 context_thread_checker_.CalledOnValidThread()); | 81 context_thread_checker_.CalledOnValidThread()); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 93 DCHECK(context_thread_checker_.CalledOnValidThread()); | 95 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 94 | 96 |
| 95 if (lost_context_callback_proxy_) | 97 if (lost_context_callback_proxy_) |
| 96 return true; | 98 return true; |
| 97 | 99 |
| 98 if (!context3d_->InitializeOnCurrentThread()) | 100 if (!context3d_->InitializeOnCurrentThread()) |
| 99 return false; | 101 return false; |
| 100 | 102 |
| 101 InitializeCapabilities(); | 103 InitializeCapabilities(); |
| 102 | 104 |
| 103 std::string unique_context_name = | 105 if (*gpu_trace_top_level_category_) { |
|
vmiura
2014/12/09 00:18:11
Same with these.
| |
| 104 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); | 106 std::string unique_context_name = |
| 105 context3d_->pushGroupMarkerEXT(unique_context_name.c_str()); | 107 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); |
| 108 TRACE_GPU_EVENT_BEGIN0(context3d_, | |
| 109 TRACE_DISABLED_BY_DEFAULT("gpu_toplevel"), | |
| 110 unique_context_name.c_str()); | |
| 111 } | |
| 106 | 112 |
| 107 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); | 113 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); |
| 108 return true; | 114 return true; |
| 109 } | 115 } |
| 110 | 116 |
| 111 void ContextProviderInProcess::InitializeCapabilities() { | 117 void ContextProviderInProcess::InitializeCapabilities() { |
| 112 capabilities_.gpu = context3d_->GetImplementation()->capabilities(); | 118 capabilities_.gpu = context3d_->GetImplementation()->capabilities(); |
| 113 | 119 |
| 114 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); | 120 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); |
| 115 capabilities_.max_transfer_buffer_usage_bytes = | 121 capabilities_.max_transfer_buffer_usage_bytes = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 destroyed_ = true; | 193 destroyed_ = true; |
| 188 } | 194 } |
| 189 if (!lost_context_callback_.is_null()) | 195 if (!lost_context_callback_.is_null()) |
| 190 base::ResetAndReturn(&lost_context_callback_).Run(); | 196 base::ResetAndReturn(&lost_context_callback_).Run(); |
| 191 if (gr_context_) | 197 if (gr_context_) |
| 192 gr_context_->OnLostContext(); | 198 gr_context_->OnLostContext(); |
| 193 } | 199 } |
| 194 | 200 |
| 195 bool ContextProviderInProcess::DestroyedOnMainThread() { | 201 bool ContextProviderInProcess::DestroyedOnMainThread() { |
| 196 DCHECK(main_thread_checker_.CalledOnValidThread()); | 202 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 203 if (*gpu_trace_top_level_category_) { | |
| 204 TRACE_GPU_EVENT_END0(context3d_); | |
| 205 } | |
| 197 | 206 |
| 198 base::AutoLock lock(destroyed_lock_); | 207 base::AutoLock lock(destroyed_lock_); |
| 199 return destroyed_; | 208 return destroyed_; |
| 200 } | 209 } |
| 201 | 210 |
| 202 void ContextProviderInProcess::SetLostContextCallback( | 211 void ContextProviderInProcess::SetLostContextCallback( |
| 203 const LostContextCallback& lost_context_callback) { | 212 const LostContextCallback& lost_context_callback) { |
| 204 DCHECK(context_thread_checker_.CalledOnValidThread()); | 213 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 205 DCHECK(lost_context_callback_.is_null() || | 214 DCHECK(lost_context_callback_.is_null() || |
| 206 lost_context_callback.is_null()); | 215 lost_context_callback.is_null()); |
| 207 lost_context_callback_ = lost_context_callback; | 216 lost_context_callback_ = lost_context_callback; |
| 208 } | 217 } |
| 209 | 218 |
| 210 void ContextProviderInProcess::SetMemoryPolicyChangedCallback( | 219 void ContextProviderInProcess::SetMemoryPolicyChangedCallback( |
| 211 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 220 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
| 212 // There's no memory manager for the in-process implementation. | 221 // There's no memory manager for the in-process implementation. |
| 213 } | 222 } |
| 214 | 223 |
| 215 } // namespace gpu | 224 } // namespace gpu |
| 216 } // namespace webkit | 225 } // namespace webkit |
| OLD | NEW |