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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "cc/output/managed_memory_policy.h" | 10 #include "cc/output/managed_memory_policy.h" |
11 #include "content/common/gpu/client/grcontext_for_webgraphicscontext3d.h" | 11 #include "content/common/gpu/client/grcontext_for_webgraphicscontext3d.h" |
12 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" | 12 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.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 | 15 |
15 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; | 16 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 class ContextProviderInProcess::LostContextCallbackProxy | 20 class ContextProviderInProcess::LostContextCallbackProxy |
20 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 21 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
21 public: | 22 public: |
22 explicit LostContextCallbackProxy(ContextProviderInProcess* provider) | 23 explicit LostContextCallbackProxy(ContextProviderInProcess* provider) |
23 : provider_(provider) { | 24 : provider_(provider) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 153 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
153 DCHECK(context_thread_checker_.CalledOnValidThread()); | 154 DCHECK(context_thread_checker_.CalledOnValidThread()); |
154 | 155 |
155 if (gr_context_) | 156 if (gr_context_) |
156 return gr_context_->get(); | 157 return gr_context_->get(); |
157 | 158 |
158 gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get())); | 159 gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get())); |
159 return gr_context_->get(); | 160 return gr_context_->get(); |
160 } | 161 } |
161 | 162 |
| 163 void ContextProviderInProcess::InvalidateGrContext(uint32_t state) { |
| 164 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
| 165 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 166 |
| 167 if (gr_context_) |
| 168 return gr_context_->get()->resetContext(state); |
| 169 } |
| 170 |
162 void ContextProviderInProcess::SetupLock() { | 171 void ContextProviderInProcess::SetupLock() { |
163 context3d_->SetLock(&context_lock_); | 172 context3d_->SetLock(&context_lock_); |
164 } | 173 } |
165 | 174 |
166 base::Lock* ContextProviderInProcess::GetLock() { | 175 base::Lock* ContextProviderInProcess::GetLock() { |
167 return &context_lock_; | 176 return &context_lock_; |
168 } | 177 } |
169 | 178 |
170 bool ContextProviderInProcess::IsContextLost() { | 179 bool ContextProviderInProcess::IsContextLost() { |
171 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 180 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 lost_context_callback.is_null()); | 226 lost_context_callback.is_null()); |
218 lost_context_callback_ = lost_context_callback; | 227 lost_context_callback_ = lost_context_callback; |
219 } | 228 } |
220 | 229 |
221 void ContextProviderInProcess::SetMemoryPolicyChangedCallback( | 230 void ContextProviderInProcess::SetMemoryPolicyChangedCallback( |
222 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 231 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
223 // There's no memory manager for the in-process implementation. | 232 // There's no memory manager for the in-process implementation. |
224 } | 233 } |
225 | 234 |
226 } // namespace content | 235 } // namespace content |
OLD | NEW |