diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-08 07:20:43 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-08 07:20:43 +0000 |
commit | ebac3e5419fd6abecc9a4225a8a9e6d44bfbd0b5 (patch) | |
tree | 10a9aee75d3d80532ed4649d1b547fd706687898 /gpu | |
parent | c548d906788658674fa75e041f0b40091083cfb1 (diff) | |
download | chromium_src-ebac3e5419fd6abecc9a4225a8a9e6d44bfbd0b5.zip chromium_src-ebac3e5419fd6abecc9a4225a8a9e6d44bfbd0b5.tar.gz chromium_src-ebac3e5419fd6abecc9a4225a8a9e6d44bfbd0b5.tar.bz2 |
Route surface visibility notifications through ContextSupport/GpuControl
This obsoletes the WebGraphicsContext3D::setVisibilityCHROMIUM call and
instead routes surface visibility notifications from the compositor to
the gpu stack through gpu::ContextSupport and from the gpu stack to the
command buffer embedder through gpu::GpuControl. The implementation of
gpu::ContextSupport (GLES2Implementation) frees up command buffers/etc
that it owns and the implementation of gpu::GpuControl
(CommandBufferProxyImpl) sends the content IPC that drives the memory
manager.
This means migrating some logic from content::WebGraphicsContext3DCommandBufferImpl
down to gpu::GLES2Implementation, such as the free everything when invisible.
BUG=181120
R=piman
Review URL: https://codereview.chromium.org/107663002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239390 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/client/client_test_helper.h | 1 | ||||
-rw-r--r-- | gpu/command_buffer/client/context_support.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/client/gl_in_process_context.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 17 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.h | 5 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_unittest.cc | 1 | ||||
-rw-r--r-- | gpu/command_buffer/common/gpu_control.h | 2 | ||||
-rw-r--r-- | gpu/command_buffer/service/gpu_control_service.cc | 4 | ||||
-rw-r--r-- | gpu/command_buffer/service/gpu_control_service.h | 1 | ||||
-rw-r--r-- | gpu/command_buffer/service/in_process_command_buffer.cc | 2 | ||||
-rw-r--r-- | gpu/command_buffer/service/in_process_command_buffer.h | 1 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_manager.cc | 3 | ||||
-rw-r--r-- | gpu/gles2_conform_support/egl/display.cc | 7 |
13 files changed, 52 insertions, 2 deletions
diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h index 4842cc0..6f0bc6d 100644 --- a/gpu/command_buffer/client/client_test_helper.h +++ b/gpu/command_buffer/client/client_test_helper.h @@ -101,6 +101,7 @@ class MockClientGpuControl : public GpuControl { const base::Closure& callback)); MOCK_METHOD2(SignalQuery, void(uint32 query, const base::Closure& callback)); + MOCK_METHOD1(SetSurfaceVisible, void(bool visible)); MOCK_METHOD1(SendManagedMemoryStats, void(const ManagedMemoryStats& stats)); diff --git a/gpu/command_buffer/client/context_support.h b/gpu/command_buffer/client/context_support.h index a620cd3..dcb0842 100644 --- a/gpu/command_buffer/client/context_support.h +++ b/gpu/command_buffer/client/context_support.h @@ -20,6 +20,10 @@ class ContextSupport { // passed the glEndQueryEXT() point. virtual void SignalQuery(uint32 query, const base::Closure& callback) = 0; + // For onscreen contexts, indicates that the surface visibility has changed. + // Clients aren't expected to draw to an invisible surface. + virtual void SetSurfaceVisible(bool visible) = 0; + virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) = 0; protected: diff --git a/gpu/command_buffer/client/gl_in_process_context.cc b/gpu/command_buffer/client/gl_in_process_context.cc index ab5cede..1bd4c62 100644 --- a/gpu/command_buffer/client/gl_in_process_context.cc +++ b/gpu/command_buffer/client/gl_in_process_context.cc @@ -232,12 +232,16 @@ bool GLInProcessContextImpl::Initialize( // Create a transfer buffer. transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get())); + bool bind_generates_resources = false; + bool free_everything_when_invisible = false; + // Create the object exposing the OpenGL API. gles2_implementation_.reset(new gles2::GLES2Implementation( gles2_helper_.get(), share_group, transfer_buffer_.get(), - false, + bind_generates_resources, + free_everything_when_invisible, command_buffer_.get())); if (share_resources) { diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 6f6798f..62fc6d2 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -86,6 +86,7 @@ GLES2Implementation::GLES2Implementation( ShareGroup* share_group, TransferBufferInterface* transfer_buffer, bool bind_generates_resource, + bool free_everything_when_invisible, GpuControl* gpu_control) : helper_(helper), transfer_buffer_(transfer_buffer), @@ -112,6 +113,8 @@ GLES2Implementation::GLES2Implementation( current_query_(NULL), error_message_callback_(NULL), gpu_control_(gpu_control), + surface_visible_(true), + free_everything_when_invisible_(free_everything_when_invisible), capabilities_(gpu_control->GetCapabilities()), weak_ptr_factory_(this) { DCHECK(helper); @@ -337,6 +340,15 @@ void GLES2Implementation::SignalQuery(uint32 query, callback)); } +void GLES2Implementation::SetSurfaceVisible(bool visible) { + // TODO(piman): This probably should be ShallowFlushCHROMIUM(). + Flush(); + surface_visible_ = visible; + gpu_control_->SetSurfaceVisible(visible); + if (!visible) + FreeEverything(); +} + void GLES2Implementation::SendManagedMemoryStats( const ManagedMemoryStats& stats) { gpu_control_->SendManagedMemoryStats(stats); @@ -835,6 +847,8 @@ void GLES2Implementation::Flush() { // Flush our command buffer // (tell the service to execute up to the flush cmd.) helper_->CommandBufferHelper::Flush(); + if (!surface_visible_ && free_everything_when_invisible_) + FreeEverything(); } void GLES2Implementation::ShallowFlushCHROMIUM() { @@ -843,11 +857,14 @@ void GLES2Implementation::ShallowFlushCHROMIUM() { // Flush our command buffer // (tell the service to execute up to the flush cmd.) helper_->CommandBufferHelper::Flush(); + // TODO(piman): Add the FreeEverything() logic here. } void GLES2Implementation::Finish() { GPU_CLIENT_SINGLE_THREAD_CHECK(); FinishHelper(); + if (!surface_visible_ && free_everything_when_invisible_) + FreeEverything(); } void GLES2Implementation::ShallowFinishCHROMIUM() { diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index c32f407..66b33d9 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -185,6 +185,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation ShareGroup* share_group, TransferBufferInterface* transfer_buffer, bool bind_generates_resource, + bool free_everything_when_invisible, GpuControl* gpu_control); virtual ~GLES2Implementation(); @@ -232,6 +233,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation const base::Closure& callback) OVERRIDE; virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; + virtual void SetSurfaceVisible(bool visible) OVERRIDE; virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) OVERRIDE; @@ -695,6 +697,9 @@ class GLES2_IMPL_EXPORT GLES2Implementation GpuControl* gpu_control_; + bool surface_visible_; + bool free_everything_when_invisible_; + Capabilities capabilities_; base::WeakPtrFactory<GLES2Implementation> weak_ptr_factory_; diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index 5bc0c71..e6e0861 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -405,6 +405,7 @@ class GLES2ImplementationTest : public testing::Test { NULL, transfer_buffer_.get(), bind_generates_resource, + false /* free_everything_when_invisible */, gpu_control_.get())); ASSERT_TRUE(gl_->Initialize( kTransferBufferSize, diff --git a/gpu/command_buffer/common/gpu_control.h b/gpu/command_buffer/common/gpu_control.h index eb17153..1331a25 100644 --- a/gpu/command_buffer/common/gpu_control.h +++ b/gpu/command_buffer/common/gpu_control.h @@ -56,6 +56,8 @@ class GPU_EXPORT GpuControl { // passed the glEndQueryEXT() point. virtual void SignalQuery(uint32 query, const base::Closure& callback) = 0; + virtual void SetSurfaceVisible(bool visible) = 0; + virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) = 0; private: diff --git a/gpu/command_buffer/service/gpu_control_service.cc b/gpu/command_buffer/service/gpu_control_service.cc index 1cb15bf..abb8e91 100644 --- a/gpu/command_buffer/service/gpu_control_service.cc +++ b/gpu/command_buffer/service/gpu_control_service.cc @@ -92,6 +92,10 @@ void GpuControlService::SignalQuery(uint32 query_id, query->AddCallback(callback); } +void GpuControlService::SetSurfaceVisible(bool visible) { + NOTREACHED(); +} + void GpuControlService::SendManagedMemoryStats( const ManagedMemoryStats& stats) { NOTREACHED(); diff --git a/gpu/command_buffer/service/gpu_control_service.h b/gpu/command_buffer/service/gpu_control_service.h index df77850..13bb3c0 100644 --- a/gpu/command_buffer/service/gpu_control_service.h +++ b/gpu/command_buffer/service/gpu_control_service.h @@ -46,6 +46,7 @@ class GPU_EXPORT GpuControlService : public GpuControl { const base::Closure& callback) OVERRIDE; virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; + virtual void SetSurfaceVisible(bool visible) OVERRIDE; virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) OVERRIDE; diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc index f8cc141..4de4531 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.cc +++ b/gpu/command_buffer/service/in_process_command_buffer.cc @@ -729,6 +729,8 @@ void InProcessCommandBuffer::SignalQuery(unsigned query, WrapCallback(callback))); } +void InProcessCommandBuffer::SetSurfaceVisible(bool visible) {} + void InProcessCommandBuffer::SendManagedMemoryStats( const gpu::ManagedMemoryStats& stats) { } diff --git a/gpu/command_buffer/service/in_process_command_buffer.h b/gpu/command_buffer/service/in_process_command_buffer.h index 404ac9d..6665b9f 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.h +++ b/gpu/command_buffer/service/in_process_command_buffer.h @@ -122,6 +122,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, const base::Closure& callback) OVERRIDE; virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; + virtual void SetSurfaceVisible(bool visible) OVERRIDE; virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats) OVERRIDE; diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc index 1da8d67..ff2de9c 100644 --- a/gpu/command_buffer/tests/gl_manager.cc +++ b/gpu/command_buffer/tests/gl_manager.cc @@ -189,12 +189,15 @@ void GLManager::Initialize(const GLManager::Options& options) { // Create a transfer buffer. transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get())); + bool free_everything_when_invisible = false; + // Create the object exposing the OpenGL API. gles2_implementation_.reset(new gles2::GLES2Implementation( gles2_helper_.get(), client_share_group, transfer_buffer_.get(), options.bind_generates_resource, + free_everything_when_invisible , gpu_control_.get())); ASSERT_TRUE(gles2_implementation_->Initialize( diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc index 118ef72..92d8f71 100644 --- a/gpu/gles2_conform_support/egl/display.cc +++ b/gpu/gles2_conform_support/egl/display.cc @@ -227,11 +227,16 @@ EGLContext Display::CreateContext(EGLConfig config, DCHECK(command_buffer_ != NULL); DCHECK(transfer_buffer_.get()); + + bool bind_generates_resources = true; + bool free_everything_when_invisible = false; + context_.reset(new gpu::gles2::GLES2Implementation( gles2_cmd_helper_.get(), NULL, transfer_buffer_.get(), - true, + bind_generates_resources, + free_everything_when_invisible, gpu_control_.get())); if (!context_->Initialize( |