OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/synchronous_compositor_factory_impl
.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_factory_impl
.h" |
6 | 6 |
7 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 7 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "gpu/command_buffer/client/gl_in_process_context.h" | 9 #include "gpu/command_buffer/client/gl_in_process_context.h" |
10 #include "ui/gl/android/surface_texture.h" | 10 #include "ui/gl/android/surface_texture.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 failed = !offscreen_context_for_main_thread_.get() || | 145 failed = !offscreen_context_for_main_thread_.get() || |
146 !offscreen_context_for_main_thread_->BindToCurrentThread(); | 146 !offscreen_context_for_main_thread_->BindToCurrentThread(); |
147 } | 147 } |
148 | 148 |
149 if (failed) { | 149 if (failed) { |
150 offscreen_context_for_main_thread_ = NULL; | 150 offscreen_context_for_main_thread_ = NULL; |
151 } | 151 } |
152 return offscreen_context_for_main_thread_; | 152 return offscreen_context_for_main_thread_; |
153 } | 153 } |
154 | 154 |
155 // This is called on both renderer main thread (offscreen context creation | 155 // This is called on the renderer compositor impl thread (InitializeHwDraw) in |
156 // path shared between cross-process and in-process platforms) and renderer | 156 // order to support Android WebView synchronously enable and disable hardware |
157 // compositor impl thread (InitializeHwDraw) in order to support Android | 157 // mode multiple times in the same task. |
158 // WebView synchronously enable and disable hardware mode multiple times in | |
159 // the same task. This is ok because in-process WGC3D creation may happen on | |
160 // any thread and is lightweight. | |
161 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: | 158 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: |
162 GetOffscreenContextProviderForCompositorThread() { | 159 GetOffscreenContextProviderForCompositorThread() { |
163 base::AutoLock lock(offscreen_context_for_compositor_thread_lock_); | |
164 DCHECK(service_); | 160 DCHECK(service_); |
165 bool failed = false; | 161 bool failed = false; |
166 if (!offscreen_context_for_compositor_thread_.get() || | 162 if (!offscreen_context_for_compositor_thread_.get() || |
167 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { | 163 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { |
168 scoped_ptr<gpu::GLInProcessContext> context = | 164 scoped_ptr<gpu::GLInProcessContext> context = |
169 CreateContext(new gfx::GLSurfaceStub, service_, NULL); | 165 CreateContext(new gfx::GLSurfaceStub, service_, NULL); |
170 wrapped_gl_context_for_compositor_thread_ = context.get(); | 166 wrapped_gl_context_for_compositor_thread_ = context.get(); |
171 offscreen_context_for_compositor_thread_ = | 167 offscreen_context_for_compositor_thread_ = |
172 webkit::gpu::ContextProviderInProcess::Create( | 168 webkit::gpu::ContextProviderInProcess::Create( |
173 WrapContext(context.Pass()), | 169 WrapContext(context.Pass()), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return video_context_provider_; | 245 return video_context_provider_; |
250 } | 246 } |
251 | 247 |
252 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( | 248 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( |
253 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | 249 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
254 DCHECK(!service_); | 250 DCHECK(!service_); |
255 service_ = service; | 251 service_ = service; |
256 } | 252 } |
257 | 253 |
258 } // namespace content | 254 } // namespace content |
OLD | NEW |