Index: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc |
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc |
index 52e99bc21546408ace761a6098daef49a0b268e6..c0de053cccddc5fc59ebf62785ea4d5dbbb32cae 100644 |
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc |
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc |
@@ -237,7 +237,8 @@ WebGraphicsContext3DCommandBufferImpl:: |
Destroy(); |
} |
-bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { |
+bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL( |
+ WebGraphicsContext3DCommandBufferImpl* share_context) { |
if (initialized_) |
return true; |
@@ -246,7 +247,7 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { |
TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::MaybeInitializeGL"); |
- if (!CreateContext(surface_id_ != 0)) { |
+ if (!CreateContext(surface_id_ != 0, share_context)) { |
Destroy(); |
initialize_failed_ = true; |
return false; |
@@ -295,15 +296,20 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { |
} |
bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( |
- bool onscreen) { |
+ bool onscreen, WebGraphicsContext3DCommandBufferImpl* share_context) { |
if (!host_.get()) |
return false; |
// We need to lock g_all_shared_contexts to ensure that the context we picked |
// for our share group isn't deleted. |
// (There's also a lock in our destructor.) |
base::AutoLock lock(g_all_shared_contexts_lock.Get()); |
+ |
CommandBufferProxyImpl* share_group = NULL; |
- if (attributes_.shareResources) { |
+ |
+ if (share_context) |
+ share_group = share_context->command_buffer_.get(); |
+ |
+ if (attributes_.shareResources && !share_group) { |
ContextMap& all_contexts = g_all_shared_contexts.Get(); |
ContextMap::const_iterator it = all_contexts.find(host_.get()); |
if (it != all_contexts.end()) |
@@ -350,12 +356,12 @@ bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( |
} |
bool WebGraphicsContext3DCommandBufferImpl::CreateContext( |
- bool onscreen) { |
+ bool onscreen, WebGraphicsContext3DCommandBufferImpl* share_context) { |
// Ensure the gles2 library is initialized first in a thread safe way. |
g_gles2_initializer.Get(); |
if (!command_buffer_ && |
- !InitializeCommandBuffer(onscreen)) { |
+ !InitializeCommandBuffer(onscreen, share_context)) { |
return false; |
} |
@@ -374,7 +380,11 @@ bool WebGraphicsContext3DCommandBufferImpl::CreateContext( |
DCHECK(host_.get()); |
scoped_ptr<base::AutoLock> lock; |
scoped_refptr<gpu::gles2::ShareGroup> share_group; |
- if (attributes_.shareResources) { |
+ |
+ if (share_context) |
+ share_group = share_context->GetImplementation()->share_group(); |
+ |
+ if (attributes_.shareResources && !share_group) { |
// Make sure two clients don't try to create a new ShareGroup |
// simultaneously. |
lock.reset(new base::AutoLock(g_all_shared_contexts_lock.Get())); |
@@ -424,7 +434,7 @@ bool WebGraphicsContext3DCommandBufferImpl::CreateContext( |
} |
bool WebGraphicsContext3DCommandBufferImpl::makeContextCurrent() { |
- if (!MaybeInitializeGL()) |
+ if (!MaybeInitializeGL(NULL)) |
return false; |
gles2::SetGLContext(gl_); |
if (command_buffer_->GetLastError() != gpu::error::kNoError) |
@@ -1192,15 +1202,27 @@ WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
GpuChannelHost* host, |
const WebGraphicsContext3D::Attributes& attributes, |
const GURL& active_url, |
- const SharedMemoryLimits& limits) { |
+ const SharedMemoryLimits& limits, |
+ WebGraphicsContext3D* share_context) { |
if (!host) |
return NULL; |
- return new WebGraphicsContext3DCommandBufferImpl(0, |
- active_url, |
- host, |
- attributes, |
- false, |
- limits); |
+ |
+ WebGraphicsContext3DCommandBufferImpl* context = |
+ new WebGraphicsContext3DCommandBufferImpl(0, |
+ active_url, |
+ host, |
+ attributes, |
+ false, |
+ limits); |
+ |
+ if (context && share_context) { |
+ if (!context->MaybeInitializeGL(NULL)) { |
no sievers
2013/12/10 19:53:34
This can't be done here but has to happen on the t
no sievers
2013/12/11 00:36:27
Can you maybe just pull this out by calling makeCo
|
+ delete context; |
+ return NULL; |
+ } |
+ } |
+ |
+ return context; |
} |
DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM, |