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 282d9755c637d7dad3fc4b1f651803e3ca3020dc..e635c81926ec7e43e34f80372ef7891a4cbc0087 100644 |
| --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc |
| +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc |
| @@ -39,40 +39,16 @@ blink::WebGraphicsContext3D::Attributes GetDefaultAttribs() { |
| return attributes; |
| } |
| -scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext( |
| - const blink::WebGraphicsContext3D::Attributes& attributes) { |
| - const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| - |
| - gpu::gles2::ContextCreationAttribHelper in_process_attribs; |
| - WebGraphicsContext3DImpl::ConvertAttributes( |
| - attributes, &in_process_attribs); |
| - in_process_attribs.lose_context_when_out_of_memory = true; |
| - |
| - scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( |
| - NULL /* service */, |
| - NULL /* surface */, |
| - true /* is_offscreen */, |
| - gfx::kNullAcceleratedWidget, |
| - gfx::Size(1, 1), |
| - NULL /* share_context */, |
| - attributes.shareResources, |
| - in_process_attribs, |
| - gpu_preference, |
| - gpu::GLInProcessContextSharedMemoryLimits(), |
| - nullptr, |
| - nullptr)); |
| - return context.Pass(); |
| -} |
| - |
| -scoped_ptr<gpu::GLInProcessContext> CreateContext( |
| +scoped_ptr<gpu::GLInProcessContext> CreateContextHolder( |
| + const blink::WebGraphicsContext3D::Attributes& attributes, |
| scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
| const gpu::GLInProcessContextSharedMemoryLimits& mem_limits, |
| - bool is_offscreen, |
| - bool share_resources) { |
| + bool share_resources, |
| + bool is_offscreen) { |
| const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| + |
| gpu::gles2::ContextCreationAttribHelper in_process_attribs; |
| - WebGraphicsContext3DImpl::ConvertAttributes( |
| - GetDefaultAttribs(), &in_process_attribs); |
| + WebGraphicsContext3DImpl::ConvertAttributes(attributes, &in_process_attribs); |
| in_process_attribs.lose_context_when_out_of_memory = true; |
| scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( |
| @@ -82,7 +58,7 @@ scoped_ptr<gpu::GLInProcessContext> CreateContext( |
| gfx::kNullAcceleratedWidget, |
| gfx::Size(1, 1), |
| NULL /* share_context */, |
| - share_resources /* share_resources */, |
| + is_offscreen ? attributes.shareResources : share_resources, |
|
boliu
2015/04/07 02:23:26
Can just make this attributes.shareResources? Anyt
tfarina
2015/04/07 04:01:43
Done.
|
| in_process_attribs, |
| gpu_preference, |
| mem_limits, |
| @@ -207,8 +183,9 @@ scoped_refptr<ContextProviderWebContext> |
| SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider( |
| const blink::WebGraphicsContext3D::Attributes& attributes, |
| const std::string& debug_name) { |
| - scoped_ptr<gpu::GLInProcessContext> context = |
| - CreateOffscreenContext(attributes); |
| + scoped_ptr<gpu::GLInProcessContext> context = CreateContextHolder( |
| + attributes, nullptr, gpu::GLInProcessContextSharedMemoryLimits(), true, |
| + true); |
| return webkit::gpu::ContextProviderInProcess::Create( |
| WrapContext(context.Pass()), debug_name); |
| } |
| @@ -222,7 +199,8 @@ SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor() { |
| // pipeline is only one frame deep. |
| mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; |
| return webkit::gpu::ContextProviderInProcess::Create( |
| - WrapContext(CreateContext(nullptr, mem_limits, true, true)), |
| + WrapContext(CreateContextHolder(GetDefaultAttribs(), nullptr, mem_limits, |
| + true, true)), |
| "Child-Compositor"); |
| } |
| @@ -240,8 +218,11 @@ SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { |
| WebGraphicsContext3DInProcessCommandBufferImpl* |
| SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D( |
| const blink::WebGraphicsContext3D::Attributes& attributes) { |
| - return WrapContextWithAttributes(CreateOffscreenContext(attributes), |
| - attributes).release(); |
| + return WrapContextWithAttributes( |
| + CreateContextHolder(attributes, nullptr, |
| + gpu::GLInProcessContextSharedMemoryLimits(), |
| + true, true), |
| + attributes).release(); |
| } |
| void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() { |
| @@ -293,8 +274,9 @@ SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() { |
| // This needs to run in on-screen |service_| context due to SurfaceTexture |
| // limitations. |
| - video_context_provider_ = new VideoContextProvider(CreateContext( |
| - service_, gpu::GLInProcessContextSharedMemoryLimits(), false, false)); |
| + video_context_provider_ = new VideoContextProvider(CreateContextHolder( |
| + GetDefaultAttribs(), service_, |
| + gpu::GLInProcessContextSharedMemoryLimits(), false, false)); |
| } |
| return video_context_provider_; |
| } |