[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / ui / gl / gl_share_group.cc
blob8e8958b49a42179c15d2b96811e6006a96554dac
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"
10 namespace gfx {
12 GLShareGroup::GLShareGroup()
13 : shared_context_(NULL)
14 #if defined(OS_MACOSX)
15 , renderer_id_(-1)
16 #endif
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();
32 if (context)
33 return context->GetHandle();
35 return NULL;
38 GLContext* GLShareGroup::GetContext() {
39 for (ContextSet::iterator it = contexts_.begin();
40 it != contexts_.end();
41 ++it) {
42 if ((*it)->GetHandle())
43 return *it;
46 return NULL;
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() {
64 return renderer_id_;
66 #endif
68 GLShareGroup::~GLShareGroup() {
71 } // namespace gfx