1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gl/gl_share_group.h"
7 #include "base/logging.h"
8 #include "ui/gl/gl_context.h"
12 GLShareGroup::GLShareGroup()
13 : shared_context_(NULL
)
14 #if defined(OS_MACOSX)
20 void GLShareGroup::AddContext(GLContext
* context
) {
21 contexts_
.insert(context
);
24 void GLShareGroup::RemoveContext(GLContext
* context
) {
25 contexts_
.erase(context
);
26 if (shared_context_
== context
)
27 shared_context_
= NULL
;
30 void* GLShareGroup::GetHandle() {
31 GLContext
* context
= GetContext();
33 return context
->GetHandle();
38 GLContext
* GLShareGroup::GetContext() {
39 for (ContextSet::iterator it
= contexts_
.begin();
40 it
!= contexts_
.end();
42 if ((*it
)->GetHandle())
49 void GLShareGroup::SetSharedContext(GLContext
* context
) {
50 DCHECK(contexts_
.find(context
) != contexts_
.end());
51 shared_context_
= context
;
54 GLContext
* GLShareGroup::GetSharedContext() {
55 return shared_context_
;
58 #if defined(OS_MACOSX)
59 void GLShareGroup::SetRendererID(int renderer_id
) {
60 renderer_id_
= renderer_id
;
63 int GLShareGroup::GetRendererID() {
68 GLShareGroup::~GLShareGroup() {