| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 | 81 |
| 82 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { | 82 CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { |
| 83 return context3d_->GetCommandBufferProxy(); | 83 return context3d_->GetCommandBufferProxy(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 int ContextProviderCommandBuffer::GetGPUProcessID() { | 86 int ContextProviderCommandBuffer::GetGPUProcessID() { |
| 87 return context3d_->GetGPUProcessID(); | 87 return context3d_->GetGPUProcessID(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 blink::WebGraphicsContext3D* ContextProviderCommandBuffer::WebContext3D() { |
| 91 DCHECK(context3d_); |
| 92 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
| 93 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 94 |
| 95 return context3d_.get(); |
| 96 } |
| 97 |
| 90 bool ContextProviderCommandBuffer::BindToCurrentThread() { | 98 bool ContextProviderCommandBuffer::BindToCurrentThread() { |
| 91 // This is called on the thread the context will be used. | 99 // This is called on the thread the context will be used. |
| 92 DCHECK(context_thread_checker_.CalledOnValidThread()); | 100 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 93 | 101 |
| 94 if (lost_context_callback_proxy_) | 102 if (lost_context_callback_proxy_) |
| 95 return true; | 103 return true; |
| 96 | 104 |
| 97 if (!context3d_->makeContextCurrent()) | 105 if (!context3d_->makeContextCurrent()) |
| 98 return false; | 106 return false; |
| 99 | 107 |
| 100 InitializeCapabilities(); | 108 InitializeCapabilities(); |
| 101 | 109 |
| 102 std::string unique_context_name = | 110 std::string unique_context_name = |
| 103 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); | 111 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); |
| 104 context3d_->pushGroupMarkerEXT(unique_context_name.c_str()); | 112 context3d_->pushGroupMarkerEXT(unique_context_name.c_str()); |
| 105 | 113 |
| 106 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); | 114 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); |
| 107 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( | 115 context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( |
| 108 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged, | 116 base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged, |
| 109 base::Unretained(this))); | 117 base::Unretained(this))); |
| 110 return true; | 118 return true; |
| 111 } | 119 } |
| 112 | 120 |
| 113 WebGraphicsContext3DCommandBufferImpl* | |
| 114 ContextProviderCommandBuffer::Context3d() { | |
| 115 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | |
| 116 DCHECK(context_thread_checker_.CalledOnValidThread()); | |
| 117 | |
| 118 return context3d_.get(); | |
| 119 } | |
| 120 | |
| 121 gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { | 121 gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { |
| 122 DCHECK(context3d_); | 122 DCHECK(context3d_); |
| 123 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 123 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
| 124 DCHECK(context_thread_checker_.CalledOnValidThread()); | 124 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 125 | 125 |
| 126 return context3d_->GetImplementation(); | 126 return context3d_->GetImplementation(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 gpu::ContextSupport* ContextProviderCommandBuffer::ContextSupport() { | 129 gpu::ContextSupport* ContextProviderCommandBuffer::ContextSupport() { |
| 130 return context3d_->GetContextSupport(); | 130 return context3d_->GetContextSupport(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 230 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
| 231 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 231 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
| 232 DCHECK(context_thread_checker_.CalledOnValidThread()); | 232 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 233 DCHECK(memory_policy_changed_callback_.is_null() || | 233 DCHECK(memory_policy_changed_callback_.is_null() || |
| 234 memory_policy_changed_callback.is_null()); | 234 memory_policy_changed_callback.is_null()); |
| 235 memory_policy_changed_callback_ = memory_policy_changed_callback; | 235 memory_policy_changed_callback_ = memory_policy_changed_callback; |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace content | 238 } // namespace content |
| OLD | NEW |