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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 return context3d_->GetContextSupport(); | 127 return context3d_->GetContextSupport(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 class GrContext* ContextProviderCommandBuffer::GrContext() { | 130 class GrContext* ContextProviderCommandBuffer::GrContext() { |
| 131 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 131 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
| 132 DCHECK(context_thread_checker_.CalledOnValidThread()); | 132 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 133 | 133 |
| 134 if (gr_context_) | 134 if (gr_context_) |
| 135 return gr_context_->get(); | 135 return gr_context_->get(); |
| 136 | 136 |
| 137 // If 3d context is lost, skip trying to make a GrContext which could fail. | |
| 138 if (IsContextLost()) | |
| 139 return nullptr; | |
| 140 | |
| 137 gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get())); | 141 gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get())); |
| 138 | 142 |
| 139 // If GlContext is already lost, also abandon the new GrContext. | 143 // GrContext creation should not fail with a valid context. |
|
piman
2015/05/12 22:06:11
I'm not sure that's true. IsContextLost() is funda
| |
| 140 if (IsContextLost()) | 144 DCHECK(gr_context_->get()); |
| 141 gr_context_->get()->abandonContext(); | |
| 142 | 145 |
| 143 return gr_context_->get(); | 146 return gr_context_->get(); |
| 144 } | 147 } |
| 145 | 148 |
| 146 void ContextProviderCommandBuffer::SetupLock() { | 149 void ContextProviderCommandBuffer::SetupLock() { |
| 147 DCHECK(context3d_); | 150 DCHECK(context3d_); |
| 148 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); | 151 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); |
| 149 } | 152 } |
| 150 | 153 |
| 151 base::Lock* ContextProviderCommandBuffer::GetLock() { | 154 base::Lock* ContextProviderCommandBuffer::GetLock() { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 | 238 |
| 236 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 239 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
| 237 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 240 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
| 238 DCHECK(context_thread_checker_.CalledOnValidThread()); | 241 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 239 DCHECK(memory_policy_changed_callback_.is_null() || | 242 DCHECK(memory_policy_changed_callback_.is_null() || |
| 240 memory_policy_changed_callback.is_null()); | 243 memory_policy_changed_callback.is_null()); |
| 241 memory_policy_changed_callback_ = memory_policy_changed_callback; | 244 memory_policy_changed_callback_ = memory_policy_changed_callback; |
| 242 } | 245 } |
| 243 | 246 |
| 244 } // namespace content | 247 } // namespace content |
| OLD | NEW |