| 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/browser/android/in_process/context_provider_in_process.h" | 5 #include "content/browser/android/in_process/context_provider_in_process.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // This is called on the thread the context will be used. | 76 // This is called on the thread the context will be used. |
| 77 DCHECK(context_thread_checker_.CalledOnValidThread()); | 77 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 78 | 78 |
| 79 if (lost_context_callback_proxy_) | 79 if (lost_context_callback_proxy_) |
| 80 return true; | 80 return true; |
| 81 | 81 |
| 82 if (!context3d_->InitializeOnCurrentThread()) | 82 if (!context3d_->InitializeOnCurrentThread()) |
| 83 return false; | 83 return false; |
| 84 | 84 |
| 85 InitializeCapabilities(); | |
| 86 | |
| 87 const std::string unique_context_name = | 85 const std::string unique_context_name = |
| 88 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); | 86 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); |
| 89 ContextGL()->TraceBeginCHROMIUM("gpu_toplevel", unique_context_name.c_str()); | 87 ContextGL()->TraceBeginCHROMIUM("gpu_toplevel", unique_context_name.c_str()); |
| 90 | 88 |
| 91 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); | 89 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); |
| 92 return true; | 90 return true; |
| 93 } | 91 } |
| 94 | 92 |
| 95 void ContextProviderInProcess::DetachFromThread() { | 93 void ContextProviderInProcess::DetachFromThread() { |
| 96 context_thread_checker_.DetachFromThread(); | 94 context_thread_checker_.DetachFromThread(); |
| 97 } | 95 } |
| 98 | 96 |
| 99 void ContextProviderInProcess::InitializeCapabilities() { | 97 gpu::Capabilities ContextProviderInProcess::ContextCapabilities() { |
| 100 capabilities_.gpu = context3d_->GetImplementation()->capabilities(); | |
| 101 | |
| 102 size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); | |
| 103 capabilities_.max_transfer_buffer_usage_bytes = | |
| 104 mapped_memory_limit == | |
| 105 WebGraphicsContext3DInProcessCommandBufferImpl::kNoLimit | |
| 106 ? std::numeric_limits<size_t>::max() | |
| 107 : mapped_memory_limit; | |
| 108 } | |
| 109 | |
| 110 cc::ContextProvider::Capabilities | |
| 111 ContextProviderInProcess::ContextCapabilities() { | |
| 112 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 98 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
| 113 DCHECK(context_thread_checker_.CalledOnValidThread()); | 99 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 114 return capabilities_; | 100 return context3d_->GetImplementation()->capabilities(); |
| 115 } | 101 } |
| 116 | 102 |
| 117 ::gpu::gles2::GLES2Interface* ContextProviderInProcess::ContextGL() { | 103 ::gpu::gles2::GLES2Interface* ContextProviderInProcess::ContextGL() { |
| 118 DCHECK(context3d_); | 104 DCHECK(context3d_); |
| 119 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 105 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
| 120 DCHECK(context_thread_checker_.CalledOnValidThread()); | 106 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 121 | 107 |
| 122 return context3d_->GetGLInterface(); | 108 return context3d_->GetGLInterface(); |
| 123 } | 109 } |
| 124 | 110 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 163 |
| 178 void ContextProviderInProcess::SetLostContextCallback( | 164 void ContextProviderInProcess::SetLostContextCallback( |
| 179 const LostContextCallback& lost_context_callback) { | 165 const LostContextCallback& lost_context_callback) { |
| 180 DCHECK(context_thread_checker_.CalledOnValidThread()); | 166 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 181 DCHECK(lost_context_callback_.is_null() || | 167 DCHECK(lost_context_callback_.is_null() || |
| 182 lost_context_callback.is_null()); | 168 lost_context_callback.is_null()); |
| 183 lost_context_callback_ = lost_context_callback; | 169 lost_context_callback_ = lost_context_callback; |
| 184 } | 170 } |
| 185 | 171 |
| 186 } // namespace content | 172 } // namespace content |
| OLD | NEW |