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" | |
15 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" | 14 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" |
16 | 15 |
17 namespace content { | 16 namespace content { |
18 | 17 |
19 class ContextProviderCommandBuffer::LostContextCallbackProxy | 18 class ContextProviderCommandBuffer::LostContextCallbackProxy |
20 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 19 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
21 public: | 20 public: |
22 explicit LostContextCallbackProxy(ContextProviderCommandBuffer* provider) | 21 explicit LostContextCallbackProxy(ContextProviderCommandBuffer* provider) |
23 : provider_(provider) { | 22 : provider_(provider) { |
24 provider_->context3d_->setContextLostCallback(this); | 23 provider_->context3d_->setContextLostCallback(this); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 gr_context_.reset( | 134 gr_context_.reset( |
136 new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get())); | 135 new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get())); |
137 | 136 |
138 // If GlContext is already lost, also abandon the new GrContext. | 137 // If GlContext is already lost, also abandon the new GrContext. |
139 if (IsContextLost()) | 138 if (IsContextLost()) |
140 gr_context_->get()->abandonContext(); | 139 gr_context_->get()->abandonContext(); |
141 | 140 |
142 return gr_context_->get(); | 141 return gr_context_->get(); |
143 } | 142 } |
144 | 143 |
| 144 void ContextProviderCommandBuffer::InvalidateGrContext(uint32_t state) { |
| 145 if (gr_context_) { |
| 146 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
| 147 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 148 gr_context_->get()->resetContext(state); |
| 149 } |
| 150 } |
| 151 |
145 void ContextProviderCommandBuffer::SetupLock() { | 152 void ContextProviderCommandBuffer::SetupLock() { |
146 DCHECK(context3d_); | 153 DCHECK(context3d_); |
147 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); | 154 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); |
148 } | 155 } |
149 | 156 |
150 base::Lock* ContextProviderCommandBuffer::GetLock() { | 157 base::Lock* ContextProviderCommandBuffer::GetLock() { |
151 return &context_lock_; | 158 return &context_lock_; |
152 } | 159 } |
153 | 160 |
154 cc::ContextProvider::Capabilities | 161 cc::ContextProvider::Capabilities |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 241 |
235 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 242 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
236 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 243 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
237 DCHECK(context_thread_checker_.CalledOnValidThread()); | 244 DCHECK(context_thread_checker_.CalledOnValidThread()); |
238 DCHECK(memory_policy_changed_callback_.is_null() || | 245 DCHECK(memory_policy_changed_callback_.is_null() || |
239 memory_policy_changed_callback.is_null()); | 246 memory_policy_changed_callback.is_null()); |
240 memory_policy_changed_callback_ = memory_policy_changed_callback; | 247 memory_policy_changed_callback_ = memory_policy_changed_callback; |
241 } | 248 } |
242 | 249 |
243 } // namespace content | 250 } // namespace content |
OLD | NEW |