Commit a5be7190 authored by sievers's avatar sievers Committed by Commit bot

InProcessGL: Share MailboxManager per service

The current logic ends up creating a MailboxManager per ContextGroup,
so change this to share the mailbox manager across
InProcessCommandBuffer::Service instances.

This also allows for removing code in Android WebView that deals with
passing around the share group. None of these contexts (child, parent
compositor and video) need client-side share groups since mailbox names
are used.

TBR=tedchoc@chromium.org for content/public

Review URL: https://codereview.chromium.org/540143002

Cr-Commit-Position: refs/heads/master@{#293902}
parent e0dd0295
...@@ -268,9 +268,6 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { ...@@ -268,9 +268,6 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) {
hardware_enabled_ = compositor_->InitializeHwDraw(); hardware_enabled_ = compositor_->InitializeHwDraw();
if (hardware_enabled_) { if (hardware_enabled_) {
tile_manager_key_ = GlobalTileManager::GetInstance()->PushBack(this); tile_manager_key_ = GlobalTileManager::GetInstance()->PushBack(this);
gpu::GLInProcessContext* share_context = compositor_->GetShareContext();
DCHECK(share_context);
shared_renderer_state_->SetSharedContext(share_context);
} }
} }
if (!hardware_enabled_) if (!hardware_enabled_)
...@@ -476,7 +473,6 @@ void BrowserViewRenderer::ReleaseHardware() { ...@@ -476,7 +473,6 @@ void BrowserViewRenderer::ReleaseHardware() {
DCHECK(shared_renderer_state_->ReturnedResourcesEmpty()); DCHECK(shared_renderer_state_->ReturnedResourcesEmpty());
compositor_->ReleaseHwDraw(); compositor_->ReleaseHwDraw();
shared_renderer_state_->SetSharedContext(NULL);
hardware_enabled_ = false; hardware_enabled_ = false;
SynchronousCompositorMemoryPolicy zero_policy; SynchronousCompositorMemoryPolicy zero_policy;
......
...@@ -38,8 +38,7 @@ using webkit::gpu::WebGraphicsContext3DImpl; ...@@ -38,8 +38,7 @@ using webkit::gpu::WebGraphicsContext3DImpl;
scoped_refptr<cc::ContextProvider> CreateContext( scoped_refptr<cc::ContextProvider> CreateContext(
scoped_refptr<gfx::GLSurface> surface, scoped_refptr<gfx::GLSurface> surface,
scoped_refptr<gpu::InProcessCommandBuffer::Service> service, scoped_refptr<gpu::InProcessCommandBuffer::Service> service) {
gpu::GLInProcessContext* share_context) {
const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
blink::WebGraphicsContext3D::Attributes attributes; blink::WebGraphicsContext3D::Attributes attributes;
...@@ -59,7 +58,7 @@ scoped_refptr<cc::ContextProvider> CreateContext( ...@@ -59,7 +58,7 @@ scoped_refptr<cc::ContextProvider> CreateContext(
surface->IsOffscreen(), surface->IsOffscreen(),
gfx::kNullAcceleratedWidget, gfx::kNullAcceleratedWidget,
surface->GetSize(), surface->GetSize(),
share_context, NULL /* share_context */,
false /* share_resources */, false /* share_resources */,
attribs_for_gles2, attribs_for_gles2,
gpu_preference, gpu_preference,
...@@ -242,8 +241,7 @@ scoped_ptr<cc::OutputSurface> HardwareRenderer::CreateOutputSurface( ...@@ -242,8 +241,7 @@ scoped_ptr<cc::OutputSurface> HardwareRenderer::CreateOutputSurface(
DCHECK(!fallback); DCHECK(!fallback);
scoped_refptr<cc::ContextProvider> context_provider = scoped_refptr<cc::ContextProvider> context_provider =
CreateContext(gl_surface_, CreateContext(gl_surface_,
DeferredGpuCommandService::GetInstance(), DeferredGpuCommandService::GetInstance());
shared_renderer_state_->GetSharedContext());
scoped_ptr<ParentOutputSurface> output_surface_holder( scoped_ptr<ParentOutputSurface> output_surface_holder(
new ParentOutputSurface(context_provider)); new ParentOutputSurface(context_provider));
output_surface_ = output_surface_holder.get(); output_surface_ = output_surface_holder.get();
......
...@@ -80,8 +80,7 @@ SharedRendererState::SharedRendererState( ...@@ -80,8 +80,7 @@ SharedRendererState::SharedRendererState(
client_on_ui_(client), client_on_ui_(client),
weak_factory_on_ui_thread_(this), weak_factory_on_ui_thread_(this),
ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()), ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()),
inside_hardware_release_(false), inside_hardware_release_(false) {
share_context_(NULL) {
DCHECK(ui_loop_->BelongsToCurrentThread()); DCHECK(ui_loop_->BelongsToCurrentThread());
DCHECK(client_on_ui_); DCHECK(client_on_ui_);
ResetRequestDrawGLCallback(); ResetRequestDrawGLCallback();
...@@ -179,18 +178,6 @@ bool SharedRendererState::IsInsideHardwareRelease() const { ...@@ -179,18 +178,6 @@ bool SharedRendererState::IsInsideHardwareRelease() const {
return inside_hardware_release_; return inside_hardware_release_;
} }
void SharedRendererState::SetSharedContext(gpu::GLInProcessContext* context) {
base::AutoLock lock(lock_);
DCHECK(!share_context_ || !context);
share_context_ = context;
}
gpu::GLInProcessContext* SharedRendererState::GetSharedContext() const {
base::AutoLock lock(lock_);
DCHECK(share_context_);
return share_context_;
}
void SharedRendererState::InsertReturnedResources( void SharedRendererState::InsertReturnedResources(
const cc::ReturnedResourceArray& resources) { const cc::ReturnedResourceArray& resources) {
base::AutoLock lock(lock_); base::AutoLock lock(lock_);
......
...@@ -64,9 +64,6 @@ class SharedRendererState { ...@@ -64,9 +64,6 @@ class SharedRendererState {
const ParentCompositorDrawConstraints ParentDrawConstraints() const; const ParentCompositorDrawConstraints ParentDrawConstraints() const;
void SetSharedContext(gpu::GLInProcessContext* context);
gpu::GLInProcessContext* GetSharedContext() const;
void InsertReturnedResources(const cc::ReturnedResourceArray& resources); void InsertReturnedResources(const cc::ReturnedResourceArray& resources);
void SwapReturnedResources(cc::ReturnedResourceArray* resources); void SwapReturnedResources(cc::ReturnedResourceArray* resources);
bool ReturnedResourcesEmpty() const; bool ReturnedResourcesEmpty() const;
...@@ -91,7 +88,6 @@ class SharedRendererState { ...@@ -91,7 +88,6 @@ class SharedRendererState {
scoped_ptr<DrawGLInput> draw_gl_input_; scoped_ptr<DrawGLInput> draw_gl_input_;
bool inside_hardware_release_; bool inside_hardware_release_;
ParentCompositorDrawConstraints parent_draw_constraints_; ParentCompositorDrawConstraints parent_draw_constraints_;
gpu::GLInProcessContext* share_context_;
cc::ReturnedResourceArray returned_resources_; cc::ReturnedResourceArray returned_resources_;
base::Closure request_draw_gl_closure_; base::Closure request_draw_gl_closure_;
......
...@@ -60,7 +60,6 @@ scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext( ...@@ -60,7 +60,6 @@ scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext(
scoped_ptr<gpu::GLInProcessContext> CreateContext( scoped_ptr<gpu::GLInProcessContext> CreateContext(
scoped_refptr<gpu::InProcessCommandBuffer::Service> service, scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
gpu::GLInProcessContext* share_context,
const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) {
const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
gpu::gles2::ContextCreationAttribHelper in_process_attribs; gpu::gles2::ContextCreationAttribHelper in_process_attribs;
...@@ -74,7 +73,7 @@ scoped_ptr<gpu::GLInProcessContext> CreateContext( ...@@ -74,7 +73,7 @@ scoped_ptr<gpu::GLInProcessContext> CreateContext(
false /* is_offscreen */, false /* is_offscreen */,
gfx::kNullAcceleratedWidget, gfx::kNullAcceleratedWidget,
gfx::Size(1, 1), gfx::Size(1, 1),
share_context, NULL /* share_context */,
false /* share_resources */, false /* share_resources */,
in_process_attribs, in_process_attribs,
gpu_preference, gpu_preference,
...@@ -187,24 +186,15 @@ scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: ...@@ -187,24 +186,15 @@ scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl::
CreateOnscreenContextProviderForCompositorThread() { CreateOnscreenContextProviderForCompositorThread() {
DCHECK(service_); DCHECK(service_);
if (!share_context_.get()) {
share_context_ = CreateContext(
service_, NULL, gpu::GLInProcessContextSharedMemoryLimits());
}
gpu::GLInProcessContextSharedMemoryLimits mem_limits; gpu::GLInProcessContextSharedMemoryLimits mem_limits;
// This is half of what RenderWidget uses because synchronous compositor // This is half of what RenderWidget uses because synchronous compositor
// pipeline is only one frame deep. // pipeline is only one frame deep.
mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024;
return webkit::gpu::ContextProviderInProcess::Create( return webkit::gpu::ContextProviderInProcess::Create(
WrapContext(CreateContext(service_, share_context_.get(), mem_limits)), WrapContext(CreateContext(service_, mem_limits)),
"Child-Compositor"); "Child-Compositor");
} }
gpu::GLInProcessContext* SynchronousCompositorFactoryImpl::GetShareContext() {
DCHECK(share_context_.get());
return share_context_.get();
}
scoped_refptr<StreamTextureFactory> scoped_refptr<StreamTextureFactory>
SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) {
scoped_refptr<StreamTextureFactorySynchronousImpl> factory( scoped_refptr<StreamTextureFactorySynchronousImpl> factory(
...@@ -252,11 +242,9 @@ SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() { ...@@ -252,11 +242,9 @@ SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() {
if (!video_context_provider_) { if (!video_context_provider_) {
DCHECK(service_); DCHECK(service_);
DCHECK(share_context_.get());
video_context_provider_ = new VideoContextProvider( video_context_provider_ = new VideoContextProvider(
CreateContext(service_, CreateContext(service_,
share_context_.get(),
gpu::GLInProcessContextSharedMemoryLimits())); gpu::GLInProcessContextSharedMemoryLimits()));
} }
return video_context_provider_; return video_context_provider_;
......
...@@ -60,7 +60,6 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory { ...@@ -60,7 +60,6 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
scoped_refptr<cc::ContextProvider> scoped_refptr<cc::ContextProvider>
CreateOnscreenContextProviderForCompositorThread(); CreateOnscreenContextProviderForCompositorThread();
gpu::GLInProcessContext* GetShareContext();
private: private:
bool CanCreateMainThreadContext(); bool CanCreateMainThreadContext();
...@@ -70,7 +69,6 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory { ...@@ -70,7 +69,6 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
SynchronousInputEventFilter synchronous_input_event_filter_; SynchronousInputEventFilter synchronous_input_event_filter_;
scoped_refptr<gpu::InProcessCommandBuffer::Service> service_; scoped_refptr<gpu::InProcessCommandBuffer::Service> service_;
scoped_ptr<gpu::GLInProcessContext> share_context_;
scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
video_context_provider_; video_context_provider_;
......
...@@ -115,11 +115,6 @@ void SynchronousCompositorImpl::ReleaseHwDraw() { ...@@ -115,11 +115,6 @@ void SynchronousCompositorImpl::ReleaseHwDraw() {
g_factory.Get().CompositorReleasedHardwareDraw(); g_factory.Get().CompositorReleasedHardwareDraw();
} }
gpu::GLInProcessContext* SynchronousCompositorImpl::GetShareContext() {
DCHECK(CalledOnValidThread());
return g_factory.Get().GetShareContext();
}
scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw( scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw(
gfx::Size surface_size, gfx::Size surface_size,
const gfx::Transform& transform, const gfx::Transform& transform,
......
...@@ -53,7 +53,6 @@ class SynchronousCompositorImpl ...@@ -53,7 +53,6 @@ class SynchronousCompositorImpl
OVERRIDE; OVERRIDE;
virtual bool InitializeHwDraw() OVERRIDE; virtual bool InitializeHwDraw() OVERRIDE;
virtual void ReleaseHwDraw() OVERRIDE; virtual void ReleaseHwDraw() OVERRIDE;
virtual gpu::GLInProcessContext* GetShareContext() OVERRIDE;
virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw( virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw(
gfx::Size surface_size, gfx::Size surface_size,
const gfx::Transform& transform, const gfx::Transform& transform,
......
...@@ -80,11 +80,6 @@ class CONTENT_EXPORT SynchronousCompositor { ...@@ -80,11 +80,6 @@ class CONTENT_EXPORT SynchronousCompositor {
// releases all hardware resources. // releases all hardware resources.
virtual void ReleaseHwDraw() = 0; virtual void ReleaseHwDraw() = 0;
// Get the share context of the compositor. The returned context is owned
// by the compositor and is only valid between InitializeHwDraw and
// ReleaseHwDraw.
virtual gpu::GLInProcessContext* GetShareContext() = 0;
// "On demand" hardware draw. The content is first clipped to |damage_area|, // "On demand" hardware draw. The content is first clipped to |damage_area|,
// then transformed through |transform|, and finally clipped to |view_size|. // then transformed through |transform|, and finally clipped to |view_size|.
virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw( virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw(
......
...@@ -190,6 +190,13 @@ InProcessCommandBuffer::Service::Service() {} ...@@ -190,6 +190,13 @@ InProcessCommandBuffer::Service::Service() {}
InProcessCommandBuffer::Service::~Service() {} InProcessCommandBuffer::Service::~Service() {}
scoped_refptr<gles2::MailboxManager>
InProcessCommandBuffer::Service::mailbox_manager() {
if (!mailbox_manager_.get())
mailbox_manager_ = new gles2::MailboxManager();
return mailbox_manager_;
}
scoped_refptr<InProcessCommandBuffer::Service> scoped_refptr<InProcessCommandBuffer::Service>
InProcessCommandBuffer::GetDefaultService() { InProcessCommandBuffer::GetDefaultService() {
base::AutoLock lock(default_thread_clients_lock_.Get()); base::AutoLock lock(default_thread_clients_lock_.Get());
...@@ -342,7 +349,7 @@ bool InProcessCommandBuffer::InitializeOnGpuThread( ...@@ -342,7 +349,7 @@ bool InProcessCommandBuffer::InitializeOnGpuThread(
decoder_.reset(gles2::GLES2Decoder::Create( decoder_.reset(gles2::GLES2Decoder::Create(
params.context_group params.context_group
? params.context_group->decoder_->GetContextGroup() ? params.context_group->decoder_->GetContextGroup()
: new gles2::ContextGroup(NULL, : new gles2::ContextGroup(service_->mailbox_manager(),
NULL, NULL,
service_->shader_translator_cache(), service_->shader_translator_cache(),
NULL, NULL,
......
...@@ -48,6 +48,7 @@ namespace gpu { ...@@ -48,6 +48,7 @@ namespace gpu {
namespace gles2 { namespace gles2 {
class GLES2Decoder; class GLES2Decoder;
class MailboxManager;
class ShaderTranslatorCache; class ShaderTranslatorCache;
} }
...@@ -153,6 +154,10 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, ...@@ -153,6 +154,10 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
virtual bool UseVirtualizedGLContexts() = 0; virtual bool UseVirtualizedGLContexts() = 0;
virtual scoped_refptr<gles2::ShaderTranslatorCache> virtual scoped_refptr<gles2::ShaderTranslatorCache>
shader_translator_cache() = 0; shader_translator_cache() = 0;
scoped_refptr<gles2::MailboxManager> mailbox_manager();
private:
scoped_refptr<gles2::MailboxManager> mailbox_manager_;
}; };
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment