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" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "cc/output/managed_memory_policy.h" | 12 #include "cc/output/managed_memory_policy.h" |
13 #include "gpu/command_buffer/client/gles2_implementation.h" | 13 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 14 #include "third_party/skia/include/gpu/GrContext.h" |
14 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" | 15 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 class ContextProviderCommandBuffer::LostContextCallbackProxy | 19 class ContextProviderCommandBuffer::LostContextCallbackProxy |
19 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 20 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
20 public: | 21 public: |
21 explicit LostContextCallbackProxy(ContextProviderCommandBuffer* provider) | 22 explicit LostContextCallbackProxy(ContextProviderCommandBuffer* provider) |
22 : provider_(provider) { | 23 : provider_(provider) { |
23 provider_->context3d_->setContextLostCallback(this); | 24 provider_->context3d_->setContextLostCallback(this); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 127 |
127 class GrContext* ContextProviderCommandBuffer::GrContext() { | 128 class GrContext* ContextProviderCommandBuffer::GrContext() { |
128 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 129 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
129 DCHECK(context_thread_checker_.CalledOnValidThread()); | 130 DCHECK(context_thread_checker_.CalledOnValidThread()); |
130 | 131 |
131 if (gr_context_) | 132 if (gr_context_) |
132 return gr_context_->get(); | 133 return gr_context_->get(); |
133 | 134 |
134 gr_context_.reset( | 135 gr_context_.reset( |
135 new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get())); | 136 new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get())); |
| 137 |
| 138 // If GlContext is already lost, also abandon the new GrContext. |
| 139 if (IsContextLost()) |
| 140 gr_context_->get()->abandonContext(); |
| 141 |
136 return gr_context_->get(); | 142 return gr_context_->get(); |
137 } | 143 } |
138 | 144 |
139 void ContextProviderCommandBuffer::SetupLock() { | 145 void ContextProviderCommandBuffer::SetupLock() { |
140 DCHECK(context3d_); | 146 DCHECK(context3d_); |
141 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); | 147 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); |
142 } | 148 } |
143 | 149 |
144 base::Lock* ContextProviderCommandBuffer::GetLock() { | 150 base::Lock* ContextProviderCommandBuffer::GetLock() { |
145 return &context_lock_; | 151 return &context_lock_; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 234 |
229 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 235 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
230 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 236 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
231 DCHECK(context_thread_checker_.CalledOnValidThread()); | 237 DCHECK(context_thread_checker_.CalledOnValidThread()); |
232 DCHECK(memory_policy_changed_callback_.is_null() || | 238 DCHECK(memory_policy_changed_callback_.is_null() || |
233 memory_policy_changed_callback.is_null()); | 239 memory_policy_changed_callback.is_null()); |
234 memory_policy_changed_callback_ = memory_policy_changed_callback; | 240 memory_policy_changed_callback_ = memory_policy_changed_callback; |
235 } | 241 } |
236 | 242 |
237 } // namespace content | 243 } // namespace content |
OLD | NEW |