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" |
11 #include "ui/gl/gl_surface.h" | 11 #include "ui/gl/gl_surface.h" |
| 12 #include "ui/gl/gl_surface_stub.h" |
12 #include "webkit/common/gpu/context_provider_in_process.h" | 13 #include "webkit/common/gpu/context_provider_in_process.h" |
13 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 14 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
14 | 15 |
15 using webkit::gpu::ContextProviderWebContext; | 16 using webkit::gpu::ContextProviderWebContext; |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 blink::WebGraphicsContext3D::Attributes GetDefaultAttribs() { | 22 blink::WebGraphicsContext3D::Attributes GetDefaultAttribs() { |
22 blink::WebGraphicsContext3D::Attributes attributes; | 23 blink::WebGraphicsContext3D::Attributes attributes; |
23 attributes.antialias = false; | 24 attributes.antialias = false; |
24 attributes.shareResources = true; | 25 attributes.shareResources = true; |
25 attributes.noAutomaticFlushes = true; | 26 attributes.noAutomaticFlushes = true; |
| 27 attributes.stencil = false; |
| 28 attributes.depth = false; |
26 | 29 |
27 return attributes; | 30 return attributes; |
28 } | 31 } |
29 | 32 |
30 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; | 33 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
31 | 34 |
32 scoped_ptr<gpu::GLInProcessContext> CreateContext( | 35 scoped_ptr<gpu::GLInProcessContext> CreateContext( |
33 scoped_refptr<gfx::GLSurface> surface, | 36 scoped_refptr<gfx::GLSurface> surface, |
34 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 37 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
35 gpu::GLInProcessContext* share_context) { | 38 gpu::GLInProcessContext* share_context) { |
(...skipping 27 matching lines...) Expand all Loading... |
63 class VideoContextProvider | 66 class VideoContextProvider |
64 : public StreamTextureFactorySynchronousImpl::ContextProvider { | 67 : public StreamTextureFactorySynchronousImpl::ContextProvider { |
65 public: | 68 public: |
66 VideoContextProvider( | 69 VideoContextProvider( |
67 scoped_ptr<gpu::GLInProcessContext> gl_in_process_context) | 70 scoped_ptr<gpu::GLInProcessContext> gl_in_process_context) |
68 : gl_in_process_context_(gl_in_process_context.get()) { | 71 : gl_in_process_context_(gl_in_process_context.get()) { |
69 | 72 |
70 context_provider_ = webkit::gpu::ContextProviderInProcess::Create( | 73 context_provider_ = webkit::gpu::ContextProviderInProcess::Create( |
71 WrapContext(gl_in_process_context.Pass()), | 74 WrapContext(gl_in_process_context.Pass()), |
72 "Video-Offscreen-main-thread"); | 75 "Video-Offscreen-main-thread"); |
| 76 context_provider_->BindToCurrentThread(); |
73 } | 77 } |
74 | 78 |
75 virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( | 79 virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( |
76 uint32 stream_id) OVERRIDE { | 80 uint32 stream_id) OVERRIDE { |
77 return gl_in_process_context_->GetSurfaceTexture(stream_id); | 81 return gl_in_process_context_->GetSurfaceTexture(stream_id); |
78 } | 82 } |
79 | 83 |
80 virtual gpu::gles2::GLES2Interface* ContextGL() OVERRIDE { | 84 virtual gpu::gles2::GLES2Interface* ContextGL() OVERRIDE { |
81 return context_provider_->ContextGL(); | 85 return context_provider_->ContextGL(); |
82 } | 86 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // the same task. This is ok because in-process WGC3D creation may happen on | 155 // the same task. This is ok because in-process WGC3D creation may happen on |
152 // any thread and is lightweight. | 156 // any thread and is lightweight. |
153 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: | 157 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: |
154 GetOffscreenContextProviderForCompositorThread() { | 158 GetOffscreenContextProviderForCompositorThread() { |
155 base::AutoLock lock(offscreen_context_for_compositor_thread_lock_); | 159 base::AutoLock lock(offscreen_context_for_compositor_thread_lock_); |
156 DCHECK(service_); | 160 DCHECK(service_); |
157 bool failed = false; | 161 bool failed = false; |
158 if (!offscreen_context_for_compositor_thread_.get() || | 162 if (!offscreen_context_for_compositor_thread_.get() || |
159 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { | 163 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { |
160 scoped_ptr<gpu::GLInProcessContext> context = | 164 scoped_ptr<gpu::GLInProcessContext> context = |
161 CreateContext(NULL, service_, NULL); | 165 CreateContext(new gfx::GLSurfaceStub, service_, NULL); |
162 wrapped_gl_context_for_compositor_thread_ = context.get(); | 166 wrapped_gl_context_for_compositor_thread_ = context.get(); |
163 offscreen_context_for_compositor_thread_ = | 167 offscreen_context_for_compositor_thread_ = |
164 webkit::gpu::ContextProviderInProcess::Create( | 168 webkit::gpu::ContextProviderInProcess::Create( |
165 WrapContext(context.Pass()), | 169 WrapContext(context.Pass()), |
166 "Compositor-Offscreen-compositor-thread"); | 170 "Compositor-Offscreen-compositor-thread"); |
167 failed = !offscreen_context_for_compositor_thread_.get() || | 171 failed = !offscreen_context_for_compositor_thread_.get() || |
168 !offscreen_context_for_compositor_thread_->BindToCurrentThread(); | 172 !offscreen_context_for_compositor_thread_->BindToCurrentThread(); |
169 } | 173 } |
170 if (failed) { | 174 if (failed) { |
171 offscreen_context_for_compositor_thread_ = NULL; | 175 offscreen_context_for_compositor_thread_ = NULL; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> | 239 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> |
236 context_provider; | 240 context_provider; |
237 // This check only guarantees the main thread context is created after | 241 // This check only guarantees the main thread context is created after |
238 // a compositor did successfully initialize hardware draw in the past. | 242 // a compositor did successfully initialize hardware draw in the past. |
239 // In particular this does not guarantee that the main thread context | 243 // In particular this does not guarantee that the main thread context |
240 // will fail creation when all compositors release hardware draw. | 244 // will fail creation when all compositors release hardware draw. |
241 if (CanCreateMainThreadContext() && !video_context_provider_) { | 245 if (CanCreateMainThreadContext() && !video_context_provider_) { |
242 DCHECK(service_); | 246 DCHECK(service_); |
243 DCHECK(wrapped_gl_context_for_compositor_thread_); | 247 DCHECK(wrapped_gl_context_for_compositor_thread_); |
244 | 248 |
245 video_context_provider_ = new VideoContextProvider(CreateContext( | 249 video_context_provider_ = new VideoContextProvider( |
246 NULL, service_, wrapped_gl_context_for_compositor_thread_)); | 250 CreateContext(new gfx::GLSurfaceStub, |
| 251 service_, |
| 252 wrapped_gl_context_for_compositor_thread_)); |
247 } | 253 } |
248 return video_context_provider_; | 254 return video_context_provider_; |
249 } | 255 } |
250 | 256 |
251 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( | 257 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( |
252 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | 258 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
253 DCHECK(!service_); | 259 DCHECK(!service_); |
254 service_ = service; | 260 service_ = service; |
255 } | 261 } |
256 | 262 |
257 } // namespace content | 263 } // namespace content |
OLD | NEW |