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..2a6f6dceb7238b9c2e0ce18bc298ab378816c608 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(); |
} |
@@ -207,23 +143,19 @@ 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 +172,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() { |
@@ -289,20 +225,21 @@ SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() { |
} |
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( |