diff options
Diffstat (limited to 'gpu/command_buffer/client')
6 files changed, 33 insertions, 1 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, |