diff options
author | jbauman <jbauman@chromium.org> | 2015-02-13 16:22:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-14 00:23:21 +0000 |
commit | 7dc2605574f04851cc6d2bc000a5a65e055d7e56 (patch) | |
tree | 785d82d568ea05bd2caee8a6d117a59773cb8452 /gpu | |
parent | a4f7c8614ff9cb6fca787635fc45a13c9655beef (diff) | |
download | chromium_src-7dc2605574f04851cc6d2bc000a5a65e055d7e56.zip chromium_src-7dc2605574f04851cc6d2bc000a5a65e055d7e56.tar.gz chromium_src-7dc2605574f04851cc6d2bc000a5a65e055d7e56.tar.bz2 |
Add lock support for in process context provider.
The context lost callback will be called on the thread that the command buffer was bound to, and with the lock held.
BUG=454500
Review URL: https://codereview.chromium.org/917223003
Cr-Commit-Position: refs/heads/master@{#316341}
Diffstat (limited to 'gpu')
5 files changed, 18 insertions, 2 deletions
diff --git a/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc b/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc index 386d349..ff83e5a 100644 --- a/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -153,6 +153,10 @@ WebGraphicsContext3DInProcessCommandBufferImpl::InitializeOnCurrentThread() { return context_ && !isContextLost(); } +void WebGraphicsContext3DInProcessCommandBufferImpl::SetLock(base::Lock* lock) { + context_->SetLock(lock); +} + bool WebGraphicsContext3DInProcessCommandBufferImpl::isContextLost() { return context_lost_reason_ != GL_NO_ERROR; } diff --git a/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h b/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h index 94816a8..8aba802 100644 --- a/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -57,6 +57,7 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl size_t GetMappedMemoryLimit(); bool InitializeOnCurrentThread(); + void SetLock(base::Lock* lock); //---------------------------------------------------------------------- // WebGraphicsContext3D methods diff --git a/gpu/command_buffer/client/gl_in_process_context.cc b/gpu/command_buffer/client/gl_in_process_context.cc index f10695ed..5d8049b 100644 --- a/gpu/command_buffer/client/gl_in_process_context.cc +++ b/gpu/command_buffer/client/gl_in_process_context.cc @@ -66,6 +66,7 @@ class GLInProcessContextImpl void SetContextLostCallback(const base::Closure& callback) override; gles2::GLES2Implementation* GetImplementation() override; size_t GetMappedMemoryLimit() override; + void SetLock(base::Lock* lock) override; #if defined(OS_ANDROID) scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( @@ -85,6 +86,7 @@ class GLInProcessContextImpl const GLInProcessContextSharedMemoryLimits mem_limits_; bool context_lost_; base::Closure context_lost_callback_; + base::Lock* lock_; DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl); }; @@ -96,7 +98,7 @@ base::LazyInstance<std::set<GLInProcessContextImpl*> > g_all_shared_contexts = GLInProcessContextImpl::GLInProcessContextImpl( const GLInProcessContextSharedMemoryLimits& mem_limits) - : mem_limits_(mem_limits), context_lost_(false) { + : mem_limits_(mem_limits), context_lost_(false), lock_(nullptr) { } GLInProcessContextImpl::~GLInProcessContextImpl() { @@ -115,12 +117,20 @@ size_t GLInProcessContextImpl::GetMappedMemoryLimit() { return mem_limits_.mapped_memory_reclaim_limit; } +void GLInProcessContextImpl::SetLock(base::Lock* lock) { + command_buffer_->SetLock(lock); + lock_ = lock; +} + void GLInProcessContextImpl::SetContextLostCallback( const base::Closure& callback) { context_lost_callback_ = callback; } void GLInProcessContextImpl::OnContextLost() { + scoped_ptr<base::AutoLock> lock; + if (lock_) + lock.reset(new base::AutoLock(*lock_)); context_lost_ = true; if (!context_lost_callback_.is_null()) { context_lost_callback_.Run(); diff --git a/gpu/command_buffer/client/gl_in_process_context.h b/gpu/command_buffer/client/gl_in_process_context.h index ef1820c..8c3a1c5 100644 --- a/gpu/command_buffer/client/gl_in_process_context.h +++ b/gpu/command_buffer/client/gl_in_process_context.h @@ -76,6 +76,8 @@ class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext { virtual size_t GetMappedMemoryLimit() = 0; + virtual void SetLock(base::Lock* lock) = 0; + #if defined(OS_ANDROID) virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( uint32 stream_id) = 0; diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc index e747aa5..c4fa167 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.cc +++ b/gpu/command_buffer/service/in_process_command_buffer.cc @@ -904,7 +904,6 @@ uint32 InProcessCommandBuffer::CreateStreamTexture(uint32 texture_id) { } void InProcessCommandBuffer::SetLock(base::Lock*) { - NOTIMPLEMENTED(); } uint32 InProcessCommandBuffer::CreateStreamTextureOnGpuThread( |