| 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" | 7 #include "base/command_line.h" |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "content/browser/android/in_process/context_provider_in_process.h" |
| 9 #include "content/browser/android/in_process/synchronous_compositor_external_beg
in_frame_source.h" | 10 #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" | 11 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
| 11 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 12 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/renderer/gpu/frame_swap_message_queue.h" | 14 #include "content/renderer/gpu/frame_swap_message_queue.h" |
| 14 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" | 15 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" |
| 15 #include "gpu/command_buffer/client/gl_in_process_context.h" | 16 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| 16 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 17 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 17 #include "gpu/command_buffer/service/gpu_switches.h" | 18 #include "gpu/command_buffer/service/gpu_switches.h" |
| 18 #include "ui/gl/android/surface_texture.h" | 19 #include "ui/gl/android/surface_texture.h" |
| 19 #include "ui/gl/gl_surface.h" | 20 #include "ui/gl/gl_surface.h" |
| 20 #include "ui/gl/gl_surface_stub.h" | 21 #include "ui/gl/gl_surface_stub.h" |
| 21 #include "webkit/common/gpu/context_provider_in_process.h" | |
| 22 | 22 |
| 23 using cc_blink::ContextProviderWebContext; | 23 using cc_blink::ContextProviderWebContext; |
| 24 using gpu_blink::WebGraphicsContext3DImpl; | 24 using gpu_blink::WebGraphicsContext3DImpl; |
| 25 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; | 25 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 struct ContextHolder { | 31 struct ContextHolder { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 return make_scoped_ptr( | 169 return make_scoped_ptr( |
| 170 new SynchronousCompositorExternalBeginFrameSource(routing_id)); | 170 new SynchronousCompositorExternalBeginFrameSource(routing_id)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 scoped_refptr<ContextProviderWebContext> | 173 scoped_refptr<ContextProviderWebContext> |
| 174 SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider( | 174 SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider( |
| 175 const blink::WebGraphicsContext3D::Attributes& attributes, | 175 const blink::WebGraphicsContext3D::Attributes& attributes, |
| 176 const std::string& debug_name) { | 176 const std::string& debug_name) { |
| 177 ContextHolder holder = CreateContextHolder( | 177 ContextHolder holder = CreateContextHolder( |
| 178 attributes, nullptr, gpu::GLInProcessContextSharedMemoryLimits(), true); | 178 attributes, nullptr, gpu::GLInProcessContextSharedMemoryLimits(), true); |
| 179 return webkit::gpu::ContextProviderInProcess::Create( | 179 return ContextProviderInProcess::Create(holder.command_buffer.Pass(), |
| 180 holder.command_buffer.Pass(), debug_name); | 180 debug_name); |
| 181 } | 181 } |
| 182 | 182 |
| 183 scoped_refptr<cc::ContextProvider> | 183 scoped_refptr<cc::ContextProvider> |
| 184 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor() { | 184 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor() { |
| 185 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); | 185 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); |
| 186 gpu::GLInProcessContextSharedMemoryLimits mem_limits; | 186 gpu::GLInProcessContextSharedMemoryLimits mem_limits; |
| 187 // This is half of what RenderWidget uses because synchronous compositor | 187 // This is half of what RenderWidget uses because synchronous compositor |
| 188 // pipeline is only one frame deep. | 188 // pipeline is only one frame deep. |
| 189 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; | 189 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; |
| 190 ContextHolder holder = | 190 ContextHolder holder = |
| 191 CreateContextHolder(attributes, nullptr, mem_limits, true); | 191 CreateContextHolder(attributes, nullptr, mem_limits, true); |
| 192 return webkit::gpu::ContextProviderInProcess::Create( | 192 return ContextProviderInProcess::Create(holder.command_buffer.Pass(), |
| 193 holder.command_buffer.Pass(), "Child-Compositor"); | 193 "Child-Compositor"); |
| 194 } | 194 } |
| 195 | 195 |
| 196 scoped_refptr<StreamTextureFactory> | 196 scoped_refptr<StreamTextureFactory> |
| 197 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { | 197 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { |
| 198 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( | 198 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( |
| 199 StreamTextureFactorySynchronousImpl::Create( | 199 StreamTextureFactorySynchronousImpl::Create( |
| 200 base::Bind( | 200 base::Bind( |
| 201 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, | 201 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, |
| 202 base::Unretained(this)), | 202 base::Unretained(this)), |
| 203 frame_id)); | 203 frame_id)); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 DCHECK(service_.get()); | 261 DCHECK(service_.get()); |
| 262 | 262 |
| 263 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); | 263 blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); |
| 264 attributes.shareResources = false; | 264 attributes.shareResources = false; |
| 265 // This needs to run in on-screen |service_| context due to SurfaceTexture | 265 // This needs to run in on-screen |service_| context due to SurfaceTexture |
| 266 // limitations. | 266 // limitations. |
| 267 ContextHolder holder = | 267 ContextHolder holder = |
| 268 CreateContextHolder(attributes, service_, | 268 CreateContextHolder(attributes, service_, |
| 269 gpu::GLInProcessContextSharedMemoryLimits(), false); | 269 gpu::GLInProcessContextSharedMemoryLimits(), false); |
| 270 video_context_provider_ = new VideoContextProvider( | 270 video_context_provider_ = new VideoContextProvider( |
| 271 webkit::gpu::ContextProviderInProcess::Create( | 271 ContextProviderInProcess::Create(holder.command_buffer.Pass(), |
| 272 holder.command_buffer.Pass(), "Video-Offscreen-main-thread"), | 272 "Video-Offscreen-main-thread"), |
| 273 holder.gl_in_process_context); | 273 holder.gl_in_process_context); |
| 274 } | 274 } |
| 275 return video_context_provider_; | 275 return video_context_provider_; |
| 276 } | 276 } |
| 277 | 277 |
| 278 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( | 278 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( |
| 279 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | 279 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
| 280 DCHECK(!service_.get()); | 280 DCHECK(!service_.get()); |
| 281 service_ = service; | 281 service_ = service; |
| 282 } | 282 } |
| 283 | 283 |
| 284 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( | 284 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( |
| 285 bool record_full_document) { | 285 bool record_full_document) { |
| 286 record_full_layer_ = record_full_document; | 286 record_full_layer_ = record_full_document; |
| 287 } | 287 } |
| 288 | 288 |
| 289 } // namespace content | 289 } // namespace content |
| OLD | NEW |