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..e266258ccf79c85ed6848562dfe26b654967fc87 100644 |
| --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc |
| +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc |
| @@ -39,68 +39,6 @@ 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_refptr<gpu::InProcessCommandBuffer::Service> service, |
| - const gpu::GLInProcessContextSharedMemoryLimits& mem_limits, |
| - bool is_offscreen, |
| - bool share_resources) { |
| - const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| - gpu::gles2::ContextCreationAttribHelper in_process_attribs; |
| - WebGraphicsContext3DImpl::ConvertAttributes( |
| - GetDefaultAttribs(), &in_process_attribs); |
| - in_process_attribs.lose_context_when_out_of_memory = true; |
| - |
| - scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( |
| - service, |
| - NULL /* surface */, |
| - is_offscreen, |
| - gfx::kNullAcceleratedWidget, |
| - gfx::Size(1, 1), |
| - NULL /* share_context */, |
| - share_resources /* share_resources */, |
| - in_process_attribs, |
| - gpu_preference, |
| - mem_limits, |
| - nullptr, |
| - nullptr)); |
| - return context.Pass(); |
| -} |
| - |
| -scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext( |
| - scoped_ptr<gpu::GLInProcessContext> context) { |
| - if (!context.get()) |
| - return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(); |
| - |
| - return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>( |
| - WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( |
| - context.Pass(), GetDefaultAttribs())); |
| -} |
| - |
| scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> |
| WrapContextWithAttributes( |
| scoped_ptr<gpu::GLInProcessContext> context, |
| @@ -119,12 +57,10 @@ class SynchronousCompositorFactoryImpl::VideoContextProvider |
| : public StreamTextureFactorySynchronousImpl::ContextProvider { |
| public: |
| VideoContextProvider( |
| - scoped_ptr<gpu::GLInProcessContext> gl_in_process_context) |
| - : gl_in_process_context_(gl_in_process_context.get()) { |
| - |
| - context_provider_ = webkit::gpu::ContextProviderInProcess::Create( |
| - WrapContext(gl_in_process_context.Pass()), |
| - "Video-Offscreen-main-thread"); |
| + scoped_refptr<ContextProviderWebContext> context_provider, |
| + gpu::GLInProcessContext* context) |
| + : context_provider_(context_provider), |
| + gl_in_process_context_(context) { |
| context_provider_->BindToCurrentThread(); |
| } |
| @@ -155,7 +91,7 @@ class SynchronousCompositorFactoryImpl::VideoContextProvider |
| friend class base::RefCountedThreadSafe<VideoContextProvider>; |
| ~VideoContextProvider() override {} |
| - scoped_refptr<cc::ContextProvider> context_provider_; |
| + scoped_refptr<ContextProviderWebContext> context_provider_; |
|
boliu
2015/03/09 02:17:54
nit: This doesn't need to change
|
| gpu::GLInProcessContext* gl_in_process_context_; |
| ObserverList<StreamTextureFactoryContextObserver> observer_list_; |
| @@ -176,8 +112,7 @@ SynchronousCompositorFactoryImpl::GetCompositorMessageLoop() { |
| return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
| } |
| -bool |
| -SynchronousCompositorFactoryImpl::RecordFullLayer() { |
| +bool SynchronousCompositorFactoryImpl::RecordFullLayer() { |
| return record_full_layer_; |
| } |
| @@ -200,30 +135,26 @@ scoped_ptr<cc::BeginFrameSource> |
| SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( |
| int routing_id) { |
| return make_scoped_ptr( |
| - new SynchronousCompositorExternalBeginFrameSource(routing_id)); |
| + new SynchronousCompositorExternalBeginFrameSource(routing_id)); |
| } |
| scoped_refptr<ContextProviderWebContext> |
| SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider( |
| const blink::WebGraphicsContext3D::Attributes& attributes, |
| const std::string& debug_name) { |
| - scoped_ptr<gpu::GLInProcessContext> context = |
| - CreateOffscreenContext(attributes); |
| - return webkit::gpu::ContextProviderInProcess::Create( |
| - WrapContext(context.Pass()), debug_name); |
| + return callback_.Run(false, attributes, true, |
| + gpu::GLInProcessContextSharedMemoryLimits()) |
| + .context_provider; |
| } |
| scoped_refptr<cc::ContextProvider> |
| SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor() { |
| - DCHECK(service_.get()); |
| - |
| gpu::GLInProcessContextSharedMemoryLimits mem_limits; |
| // This is half of what RenderWidget uses because synchronous compositor |
| // 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)), |
| - "Child-Compositor"); |
| + return callback_.Run(false, GetDefaultAttribs(), true, mem_limits) |
| + .context_provider; |
| } |
| scoped_refptr<StreamTextureFactory> |
| @@ -240,8 +171,12 @@ SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { |
| WebGraphicsContext3DInProcessCommandBufferImpl* |
| SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D( |
| const blink::WebGraphicsContext3D::Attributes& attributes) { |
| - return WrapContextWithAttributes(CreateOffscreenContext(attributes), |
| - attributes).release(); |
| + return WrapContextWithAttributes( |
| + make_scoped_ptr( |
| + callback_.Run(false, attributes, true, |
| + gpu::GLInProcessContextSharedMemoryLimits()) |
| + .context), |
| + attributes).release(); |
| } |
| void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() { |
| @@ -284,25 +219,26 @@ SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() { |
| // |video_context_provider_| to null is also not safe since it makes |
| // synchronous destruction uncontrolled and possibly deadlock. |
| if (!CanCreateMainThreadContext()) { |
| - return |
| - scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>(); |
| + return scoped_refptr< |
| + StreamTextureFactorySynchronousImpl::ContextProvider>(); |
| } |
| if (!video_context_provider_.get()) { |
| - DCHECK(service_.get()); |
| - |
| - // This needs to run in on-screen |service_| context due to SurfaceTexture |
| + blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs(); |
| + attributes.shareResources = true; |
| + SynchronousCompositor::ContextHolder holder = callback_.Run( |
| + true, attributes, false, gpu::GLInProcessContextSharedMemoryLimits()); |
| + // This needs to run in on-screen context due to SurfaceTexture |
| // limitations. |
| - video_context_provider_ = new VideoContextProvider(CreateContext( |
| - service_, gpu::GLInProcessContextSharedMemoryLimits(), false, false)); |
| + video_context_provider_ = |
| + new VideoContextProvider(holder.context_provider, holder.context); |
| } |
| return video_context_provider_; |
| } |
| -void SynchronousCompositorFactoryImpl::SetDeferredGpuService( |
| - scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
| - DCHECK(!service_.get()); |
| - service_ = service; |
| +void SynchronousCompositorFactoryImpl::SetCreateContextCallback( |
| + SynchronousCompositor::CreateContextCallback callback) { |
| + callback_ = callback; |
| } |
| void SynchronousCompositorFactoryImpl::SetRecordFullDocument( |