| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "cc/output/managed_memory_policy.h" | 13 #include "cc/output/managed_memory_policy.h" |
| 14 #include "content/common/gpu/client/grcontext_for_gles2_interface.h" | |
| 15 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" | 14 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" |
| 16 #include "gpu/command_buffer/client/gles2_implementation.h" | 15 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 16 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" |
| 17 #include "third_party/skia/include/gpu/GrContext.h" | 17 #include "third_party/skia/include/gpu/GrContext.h" |
| 18 | 18 |
| 19 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; | 19 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 class ContextProviderInProcess::LostContextCallbackProxy | 23 class ContextProviderInProcess::LostContextCallbackProxy |
| 24 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 24 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
| 25 public: | 25 public: |
| 26 explicit LostContextCallbackProxy(ContextProviderInProcess* provider) | 26 explicit LostContextCallbackProxy(ContextProviderInProcess* provider) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return context3d_->GetContextSupport(); | 132 return context3d_->GetContextSupport(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 class GrContext* ContextProviderInProcess::GrContext() { | 135 class GrContext* ContextProviderInProcess::GrContext() { |
| 136 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 136 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
| 137 DCHECK(context_thread_checker_.CalledOnValidThread()); | 137 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 138 | 138 |
| 139 if (gr_context_) | 139 if (gr_context_) |
| 140 return gr_context_->get(); | 140 return gr_context_->get(); |
| 141 | 141 |
| 142 gr_context_.reset( | 142 gr_context_.reset(new skia_bindings::GrContextForGLES2Interface( |
| 143 new GrContextForGLES2Interface(context3d_->GetGLInterface())); | 143 context3d_->GetGLInterface())); |
| 144 return gr_context_->get(); | 144 return gr_context_->get(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void ContextProviderInProcess::InvalidateGrContext(uint32_t state) { | 147 void ContextProviderInProcess::InvalidateGrContext(uint32_t state) { |
| 148 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 148 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
| 149 DCHECK(context_thread_checker_.CalledOnValidThread()); | 149 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 150 | 150 |
| 151 if (gr_context_) | 151 if (gr_context_) |
| 152 return gr_context_->get()->resetContext(state); | 152 return gr_context_->ResetContext(state); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void ContextProviderInProcess::SetupLock() { | 155 void ContextProviderInProcess::SetupLock() { |
| 156 context3d_->SetLock(&context_lock_); | 156 context3d_->SetLock(&context_lock_); |
| 157 } | 157 } |
| 158 | 158 |
| 159 base::Lock* ContextProviderInProcess::GetLock() { | 159 base::Lock* ContextProviderInProcess::GetLock() { |
| 160 return &context_lock_; | 160 return &context_lock_; |
| 161 } | 161 } |
| 162 | 162 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 177 | 177 |
| 178 void ContextProviderInProcess::SetLostContextCallback( | 178 void ContextProviderInProcess::SetLostContextCallback( |
| 179 const LostContextCallback& lost_context_callback) { | 179 const LostContextCallback& lost_context_callback) { |
| 180 DCHECK(context_thread_checker_.CalledOnValidThread()); | 180 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 181 DCHECK(lost_context_callback_.is_null() || | 181 DCHECK(lost_context_callback_.is_null() || |
| 182 lost_context_callback.is_null()); | 182 lost_context_callback.is_null()); |
| 183 lost_context_callback_ = lost_context_callback; | 183 lost_context_callback_ = lost_context_callback; |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace content | 186 } // namespace content |
| OLD | NEW |