Chromium Code Reviews| Index: ui/gl/gl_share_group.cc |
| diff --git a/ui/gl/gl_share_group.cc b/ui/gl/gl_share_group.cc |
| index 82fc7594f4dd4ff0090593312e133e3b2837b1ef..58d7561fcacdc90c6ca2998f612679ebeb511dd5 100644 |
| --- a/ui/gl/gl_share_group.cc |
| +++ b/ui/gl/gl_share_group.cc |
| @@ -7,13 +7,14 @@ |
| #include "base/logging.h" |
| #include "build/build_config.h" |
| #include "ui/gl/gl_context.h" |
| +#include "ui/gl/gl_implementation.h" |
| +#include "ui/gl/gl_surface.h" |
| namespace gl { |
| GLShareGroup::GLShareGroup() |
| - : shared_context_(NULL) |
| #if defined(OS_MACOSX) |
| - , renderer_id_(-1) |
| + : renderer_id_(-1) |
| #endif |
| { |
| } |
| @@ -24,8 +25,12 @@ void GLShareGroup::AddContext(GLContext* context) { |
| void GLShareGroup::RemoveContext(GLContext* context) { |
| contexts_.erase(context); |
| - if (shared_context_ == context) |
| - shared_context_ = NULL; |
| + for (const auto& pair : shared_contexts_) { |
| + if (pair.second == context) { |
| + shared_contexts_.erase(pair.first); |
| + return; |
| + } |
| + } |
| } |
| void* GLShareGroup::GetHandle() { |
| @@ -47,13 +52,17 @@ GLContext* GLShareGroup::GetContext() { |
| return NULL; |
| } |
| -void GLShareGroup::SetSharedContext(GLContext* context) { |
| +void GLShareGroup::SetSharedContext(GLSurface* compatible, GLContext* context) { |
| DCHECK(contexts_.find(context) != contexts_.end()); |
| - shared_context_ = context; |
| + shared_contexts_[compatible->GetCompatibilityKey()] = context; |
| } |
| -GLContext* GLShareGroup::GetSharedContext() { |
| - return shared_context_; |
| +GLContext* GLShareGroup::GetSharedContext(GLSurface* compatible) { |
| + int fbconfig_id = compatible->GetCompatibilityKey(); |
|
piman
2016/09/26 21:13:29
nit: compatibility_key instead of fbconfig_id?
Als
|
| + auto it = shared_contexts_.find(fbconfig_id); |
| + if (it == shared_contexts_.end()) |
| + return nullptr; |
| + return it->second; |
| } |
| #if defined(OS_MACOSX) |