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 "base/command_line.h" | |
8 #include "base/observer_list.h" | 7 #include "base/observer_list.h" |
9 #include "content/browser/android/in_process/synchronous_compositor_external_beg
in_frame_source.h" | 8 #include "content/browser/android/in_process/synchronous_compositor_external_beg
in_frame_source.h" |
10 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 9 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
11 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 10 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
12 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
13 #include "content/renderer/gpu/frame_swap_message_queue.h" | 12 #include "content/renderer/gpu/frame_swap_message_queue.h" |
14 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" | 13 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" |
15 #include "gpu/command_buffer/client/gl_in_process_context.h" | 14 #include "gpu/command_buffer/client/gl_in_process_context.h" |
16 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
17 #include "gpu/command_buffer/service/gpu_switches.h" | |
18 #include "ui/gl/android/surface_texture.h" | 16 #include "ui/gl/android/surface_texture.h" |
19 #include "ui/gl/gl_surface.h" | 17 #include "ui/gl/gl_surface.h" |
20 #include "ui/gl/gl_surface_stub.h" | 18 #include "ui/gl/gl_surface_stub.h" |
21 #include "webkit/common/gpu/context_provider_in_process.h" | 19 #include "webkit/common/gpu/context_provider_in_process.h" |
22 | 20 |
23 using gpu_blink::WebGraphicsContext3DImpl; | 21 using gpu_blink::WebGraphicsContext3DImpl; |
24 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; | 22 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; |
25 using webkit::gpu::ContextProviderWebContext; | 23 using webkit::gpu::ContextProviderWebContext; |
26 | 24 |
27 namespace content { | 25 namespace content { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 in_process_attribs, | 57 in_process_attribs, |
60 gpu_preference, | 58 gpu_preference, |
61 gpu::GLInProcessContextSharedMemoryLimits(), | 59 gpu::GLInProcessContextSharedMemoryLimits(), |
62 nullptr, | 60 nullptr, |
63 nullptr)); | 61 nullptr)); |
64 return context.Pass(); | 62 return context.Pass(); |
65 } | 63 } |
66 | 64 |
67 scoped_ptr<gpu::GLInProcessContext> CreateContext( | 65 scoped_ptr<gpu::GLInProcessContext> CreateContext( |
68 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 66 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
69 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits, | 67 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { |
70 bool is_offscreen) { | |
71 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 68 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
72 gpu::gles2::ContextCreationAttribHelper in_process_attribs; | 69 gpu::gles2::ContextCreationAttribHelper in_process_attribs; |
73 WebGraphicsContext3DImpl::ConvertAttributes( | 70 WebGraphicsContext3DImpl::ConvertAttributes( |
74 GetDefaultAttribs(), &in_process_attribs); | 71 GetDefaultAttribs(), &in_process_attribs); |
75 in_process_attribs.lose_context_when_out_of_memory = true; | 72 in_process_attribs.lose_context_when_out_of_memory = true; |
76 | 73 |
77 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( | 74 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( |
78 service, | 75 service, |
79 NULL /* surface */, | 76 NULL /* surface */, |
80 is_offscreen, | 77 false /* is_offscreen */, |
81 gfx::kNullAcceleratedWidget, | 78 gfx::kNullAcceleratedWidget, |
82 gfx::Size(1, 1), | 79 gfx::Size(1, 1), |
83 NULL /* share_context */, | 80 NULL /* share_context */, |
84 false /* share_resources */, | 81 false /* share_resources */, |
85 in_process_attribs, | 82 in_process_attribs, |
86 gpu_preference, | 83 gpu_preference, |
87 mem_limits, | 84 mem_limits, |
88 nullptr, | 85 nullptr, |
89 nullptr)); | 86 nullptr)); |
90 return context.Pass(); | 87 return context.Pass(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 212 |
216 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: | 213 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: |
217 CreateOnscreenContextProviderForCompositorThread() { | 214 CreateOnscreenContextProviderForCompositorThread() { |
218 DCHECK(service_.get()); | 215 DCHECK(service_.get()); |
219 | 216 |
220 gpu::GLInProcessContextSharedMemoryLimits mem_limits; | 217 gpu::GLInProcessContextSharedMemoryLimits mem_limits; |
221 // This is half of what RenderWidget uses because synchronous compositor | 218 // This is half of what RenderWidget uses because synchronous compositor |
222 // pipeline is only one frame deep. | 219 // pipeline is only one frame deep. |
223 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; | 220 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; |
224 return webkit::gpu::ContextProviderInProcess::Create( | 221 return webkit::gpu::ContextProviderInProcess::Create( |
225 WrapContext(CreateContext(nullptr, mem_limits, true)), | 222 WrapContext(CreateContext(service_, mem_limits)), |
226 "Child-Compositor"); | 223 "Child-Compositor"); |
227 } | 224 } |
228 | 225 |
229 scoped_refptr<StreamTextureFactory> | 226 scoped_refptr<StreamTextureFactory> |
230 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { | 227 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { |
231 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( | 228 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( |
232 StreamTextureFactorySynchronousImpl::Create( | 229 StreamTextureFactorySynchronousImpl::Create( |
233 base::Bind( | 230 base::Bind( |
234 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, | 231 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, |
235 base::Unretained(this)), | 232 base::Unretained(this)), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // |video_context_provider_| to null is also not safe since it makes | 281 // |video_context_provider_| to null is also not safe since it makes |
285 // synchronous destruction uncontrolled and possibly deadlock. | 282 // synchronous destruction uncontrolled and possibly deadlock. |
286 if (!CanCreateMainThreadContext()) { | 283 if (!CanCreateMainThreadContext()) { |
287 return | 284 return |
288 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>(); | 285 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>(); |
289 } | 286 } |
290 | 287 |
291 if (!video_context_provider_.get()) { | 288 if (!video_context_provider_.get()) { |
292 DCHECK(service_.get()); | 289 DCHECK(service_.get()); |
293 | 290 |
294 // This needs to run in on-screen |service_| context due to SurfaceTexture | 291 video_context_provider_ = new VideoContextProvider( |
295 // limitations. | 292 CreateContext(service_, |
296 video_context_provider_ = new VideoContextProvider(CreateContext( | 293 gpu::GLInProcessContextSharedMemoryLimits())); |
297 service_, gpu::GLInProcessContextSharedMemoryLimits(), false)); | |
298 } | 294 } |
299 return video_context_provider_; | 295 return video_context_provider_; |
300 } | 296 } |
301 | 297 |
302 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( | 298 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( |
303 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | 299 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
304 DCHECK(!service_.get()); | 300 DCHECK(!service_.get()); |
305 service_ = service; | 301 service_ = service; |
306 } | 302 } |
307 | 303 |
308 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( | 304 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( |
309 bool record_full_document) { | 305 bool record_full_document) { |
310 record_full_layer_ = record_full_document; | 306 record_full_layer_ = record_full_document; |
311 } | 307 } |
312 | 308 |
313 } // namespace content | 309 } // namespace content |
OLD | NEW |