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 "content/common/gpu/client/grcontext_for_webgraphicscontext3d.h" |
13 #include "gpu/command_buffer/client/gles2_implementation.h" | 14 #include "gpu/command_buffer/client/gles2_implementation.h" |
14 #include "third_party/skia/include/gpu/GrContext.h" | 15 #include "third_party/skia/include/gpu/GrContext.h" |
15 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" | |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 class ContextProviderCommandBuffer::LostContextCallbackProxy | 19 class ContextProviderCommandBuffer::LostContextCallbackProxy |
20 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 20 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
21 public: | 21 public: |
22 explicit LostContextCallbackProxy(ContextProviderCommandBuffer* provider) | 22 explicit LostContextCallbackProxy(ContextProviderCommandBuffer* provider) |
23 : provider_(provider) { | 23 : provider_(provider) { |
24 provider_->context3d_->setContextLostCallback(this); | 24 provider_->context3d_->setContextLostCallback(this); |
25 } | 25 } |
(...skipping 101 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 gr_context_.reset( | 137 gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get())); |
138 new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get())); | |
139 | 138 |
140 // If GlContext is already lost, also abandon the new GrContext. | 139 // If GlContext is already lost, also abandon the new GrContext. |
141 if (IsContextLost()) | 140 if (IsContextLost()) |
142 gr_context_->get()->abandonContext(); | 141 gr_context_->get()->abandonContext(); |
143 | 142 |
144 return gr_context_->get(); | 143 return gr_context_->get(); |
145 } | 144 } |
146 | 145 |
147 void ContextProviderCommandBuffer::SetupLock() { | 146 void ContextProviderCommandBuffer::SetupLock() { |
148 DCHECK(context3d_); | 147 DCHECK(context3d_); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 235 |
237 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( | 236 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( |
238 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 237 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
239 DCHECK(context_thread_checker_.CalledOnValidThread()); | 238 DCHECK(context_thread_checker_.CalledOnValidThread()); |
240 DCHECK(memory_policy_changed_callback_.is_null() || | 239 DCHECK(memory_policy_changed_callback_.is_null() || |
241 memory_policy_changed_callback.is_null()); | 240 memory_policy_changed_callback.is_null()); |
242 memory_policy_changed_callback_ = memory_policy_changed_callback; | 241 memory_policy_changed_callback_ = memory_policy_changed_callback; |
243 } | 242 } |
244 | 243 |
245 } // namespace content | 244 } // namespace content |
OLD | NEW |