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 GlContext is already lost, skip trying to make a GrContext which | |
138 // could fail. | |
139 if (IsContextLost()) | |
140 return nullptr; | |
piman
2015/05/12 23:33:51
I'd skip this part. No use trying to optimize for
| |
141 | |
137 gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get())); | 142 gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get())); |
138 | 143 |
139 // If GlContext is already lost, also abandon the new GrContext. | 144 // If GlContext was lost after the GrContext initialization, delete |
140 if (IsContextLost()) | 145 // the GrContext. |
141 gr_context_->get()->abandonContext(); | 146 if (gr_context_->get() && IsContextLost()) |
147 gr_context_.reset(nullptr); | |
142 | 148 |
143 return gr_context_->get(); | 149 return gr_context_->get(); |
144 } | 150 } |
145 | 151 |
146 void ContextProviderCommandBuffer::SetupLock() { | 152 void ContextProviderCommandBuffer::SetupLock() { |
147 DCHECK(context3d_); | 153 DCHECK(context3d_); |
148 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); | 154 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); |
149 } | 155 } |
150 | 156 |
151 base::Lock* ContextProviderCommandBuffer::GetLock() { | 157 base::Lock* ContextProviderCommandBuffer::GetLock() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 | 241 |
236 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 242 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
237 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 243 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
238 DCHECK(context_thread_checker_.CalledOnValidThread()); | 244 DCHECK(context_thread_checker_.CalledOnValidThread()); |
239 DCHECK(memory_policy_changed_callback_.is_null() || | 245 DCHECK(memory_policy_changed_callback_.is_null() || |
240 memory_policy_changed_callback.is_null()); | 246 memory_policy_changed_callback.is_null()); |
241 memory_policy_changed_callback_ = memory_policy_changed_callback; | 247 memory_policy_changed_callback_ = memory_policy_changed_callback; |
242 } | 248 } |
243 | 249 |
244 } // namespace content | 250 } // namespace content |
OLD | NEW |