diff options
author | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-29 22:14:12 +0000 |
---|---|---|
committer | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-29 22:14:12 +0000 |
commit | 9d0c7166ac20ae639b25eee7a9ffc0e96308c25c (patch) | |
tree | e897ede4e52d3358cf1db2a43a64f41e12e722ac /content/common/gpu | |
parent | 71ac98bb2e70213e4ee3a9b24b7dbc315d652949 (diff) | |
download | chromium_src-9d0c7166ac20ae639b25eee7a9ffc0e96308c25c.zip chromium_src-9d0c7166ac20ae639b25eee7a9ffc0e96308c25c.tar.gz chromium_src-9d0c7166ac20ae639b25eee7a9ffc0e96308c25c.tar.bz2 |
WGC3DCommandBufferImpl: Acquire lock when accessing share group.
Grab the share group lock when accessing the list and also to assure that ShareGroup creation is not racy.
Also do not use an existing ShareGroup is we are not sharing resources.
Remove the nowadays unused share_resources flag that was still being passed around.
On a related note, remove the non-threadsafe
SetGLES2ImplementationForDestruction() which is fortunately unused.
(It was used by StrictSharedIdHandler once, but the current handlers
don't need to talk to the commandbuffer during destruction.)
TBR=brettw@chromium.org
NOTRY=True
Review URL: https://chromiumcodereview.appspot.com/20826002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214242 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/gpu')
-rw-r--r-- | content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index 5441de7..a4dd1d5 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc @@ -362,11 +362,6 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL( attributes_.antialias = pvalues[3] > 0; } - if (attributes_.shareResources) { - base::AutoLock lock(g_all_shared_contexts_lock.Get()); - g_all_shared_contexts.Pointer()->insert(this); - } - visible_ = true; initialized_ = true; return true; @@ -454,21 +449,34 @@ bool WebGraphicsContext3DCommandBufferImpl::CreateContext( // process and the GPU process. transfer_buffer_ .reset(new gpu::TransferBuffer(gles2_helper_.get())); - WebGraphicsContext3DCommandBufferImpl* share_group_context = - g_all_shared_contexts.Pointer()->empty() ? - NULL : *g_all_shared_contexts.Pointer()->begin(); + scoped_ptr<base::AutoLock> lock; + scoped_refptr<gpu::gles2::ShareGroup> share_group; + if (attributes_.shareResources) { + // Make sure two clients don't try to create a new ShareGroup + // simultaneously. + lock.reset(new base::AutoLock(g_all_shared_contexts_lock.Get())); + if (!g_all_shared_contexts.Pointer()->empty()) { + share_group = (*g_all_shared_contexts.Pointer()->begin()) + ->GetImplementation()->share_group(); + DCHECK(share_group); + } + } // Create the object exposing the OpenGL API. real_gl_.reset(new gpu::gles2::GLES2Implementation( gles2_helper_.get(), - share_group_context ? - share_group_context->GetImplementation()->share_group() : NULL, + share_group, transfer_buffer_.get(), - attributes_.shareResources, bind_generates_resources_, NULL)); gl_ = real_gl_.get(); + if (attributes_.shareResources) { + // Don't add ourselves to the list before others can get to our ShareGroup. + g_all_shared_contexts.Pointer()->insert(this); + lock.reset(); + } + if (!real_gl_->Initialize( start_transfer_buffer_size_, min_transfer_buffer_size_, |