Chromium Code Reviews| Index: content/browser/android/in_process/synchronous_compositor_factory_impl.cc |
| diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc |
| index 88d69afc1567d5dba4dcad81ee866fd13101677b..9d4cbf0d749c3015f32e7b765a262681410aad13 100644 |
| --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc |
| +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc |
| @@ -13,10 +13,14 @@ |
| #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
| #include "content/browser/android/in_process/synchronous_compositor_output_surface.h" |
| #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| +#include "content/common/gpu/client/context_provider_command_buffer.h" |
| +#include "content/common/gpu/client/gpu_channel_host.h" |
| +#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| #include "content/gpu/in_process_gpu_thread.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/gpu_data_manager.h" |
| #include "content/renderer/gpu/frame_swap_message_queue.h" |
| +#include "content/renderer/render_thread_impl.h" |
| #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" |
| #include "gpu/command_buffer/client/gl_in_process_context.h" |
| #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| @@ -76,6 +80,24 @@ ContextHolder CreateContextHolder( |
| return holder; |
| } |
| +scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D( |
| + const blink::WebGraphicsContext3D::Attributes& attributes, |
| + const content::WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits& |
| + mem_limits) { |
| + DCHECK(RenderThreadImpl::current()); |
| + CauseForGpuLaunch cause = |
| + CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
| + scoped_refptr<GpuChannelHost> gpu_channel_host( |
| + RenderThreadImpl::current()->EstablishGpuChannelSync(cause)); |
| + CHECK(gpu_channel_host.get()); |
| + |
| + int surface_id = 0; |
| + bool lose_context_when_out_of_memory = true; |
|
no sievers
2015/07/22 22:17:47
really? do you even handle lost contexts? :)
boliu
2015/07/22 22:28:58
No.. but does it really matter? This has been true
|
| + return make_scoped_ptr(new WebGraphicsContext3DCommandBufferImpl( |
| + surface_id, GURL(), gpu_channel_host.get(), attributes, |
| + lose_context_when_out_of_memory, mem_limits, NULL)); |
| +} |
| + |
| } // namespace |
| class SynchronousCompositorFactoryImpl::VideoContextProvider |
| @@ -123,9 +145,9 @@ class SynchronousCompositorFactoryImpl::VideoContextProvider |
| DISALLOW_COPY_AND_ASSIGN(VideoContextProvider); |
| }; |
| - |
| SynchronousCompositorFactoryImpl::SynchronousCompositorFactoryImpl() |
| : record_full_layer_(true), |
| + use_ipc_command_buffer_(false), |
| num_hardware_compositors_(0) { |
| SynchronousCompositorFactory::SetInstance(this); |
| } |
| @@ -167,10 +189,15 @@ SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( |
| new SynchronousCompositorExternalBeginFrameSource(routing_id)); |
| } |
| +bool SynchronousCompositorFactoryImpl::OverrideWithFactory() { |
| + return !use_ipc_command_buffer_; |
| +} |
| + |
| scoped_refptr<ContextProviderWebContext> |
| SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider( |
| const blink::WebGraphicsContext3D::Attributes& attributes, |
| const std::string& debug_name) { |
| + DCHECK(use_ipc_command_buffer_); |
| ContextHolder holder = |
| CreateContextHolder(attributes, GpuThreadService(), |
| gpu::GLInProcessContextSharedMemoryLimits(), true); |
| @@ -180,16 +207,24 @@ SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider( |
| scoped_refptr<cc::ContextProvider> |
| SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor() { |
| - blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); |
| - gpu::GLInProcessContextSharedMemoryLimits mem_limits; |
| // This is half of what RenderWidget uses because synchronous compositor |
| - // pipeline is only one frame deep. |
| - if (base::SysInfo::IsLowEndDevice()) { |
| - // But twice of half here because 16bit texture is not supported. |
| - mem_limits.mapped_memory_reclaim_limit = 2 * 1024 * 1024; |
| - } else { |
| - mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; |
| + // pipeline is only one frame deep. But twice of half for low end here |
| + // because 16bit texture is not supported. |
| + unsigned int mapped_memory_reclaim_limit = |
| + (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024; |
| + blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); |
| + |
| + if (use_ipc_command_buffer_) { |
| + WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits; |
| + mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; |
| + scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context = |
| + CreateContext3D(GetDefaultAttribs(), mem_limits); |
| + return ContextProviderCommandBuffer::Create(context.Pass(), |
| + RENDER_WORKER_CONTEXT); |
|
no sievers
2015/07/22 22:17:47
you mean RENDER_COMPOSITOR_CONTEXT?
boliu
2015/07/22 22:28:58
Actually both. This is called for both the composi
|
| } |
| + |
| + gpu::GLInProcessContextSharedMemoryLimits mem_limits; |
| + mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit; |
| ContextHolder holder = |
| CreateContextHolder(attributes, GpuThreadService(), mem_limits, true); |
| return ContextProviderInProcess::Create(holder.command_buffer.Pass(), |
| @@ -210,6 +245,7 @@ SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { |
| WebGraphicsContext3DInProcessCommandBufferImpl* |
| SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D( |
| const blink::WebGraphicsContext3D::Attributes& attributes) { |
| + DCHECK(use_ipc_command_buffer_); |
|
no sievers
2015/07/22 22:17:48
DCHECK(!use_ipc_command_buffer)?
boliu
2015/07/22 22:28:58
/facepalm
Fixed all 3
|
| ContextHolder holder = |
| CreateContextHolder(attributes, GpuThreadService(), |
| gpu::GLInProcessContextSharedMemoryLimits(), true); |
| @@ -217,6 +253,7 @@ SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D( |
| } |
| gpu::GPUInfo SynchronousCompositorFactoryImpl::GetGPUInfo() const { |
| + DCHECK(use_ipc_command_buffer_); |
|
no sievers
2015/07/22 22:17:48
same here? since this code was here before
|
| return content::GpuDataManager::GetInstance()->GetGPUInfo(); |
| } |
| @@ -311,4 +348,8 @@ void SynchronousCompositorFactoryImpl::SetRecordFullDocument( |
| record_full_layer_ = record_full_document; |
| } |
| +void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() { |
| + use_ipc_command_buffer_ = true; |
| +} |
| + |
| } // namespace content |