OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gl/gl_share_group.h" | 5 #include "ui/gl/gl_share_group.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "ui/gl/gl_context.h" | 9 #include "ui/gl/gl_context.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 void* GLShareGroup::GetHandle() { | 31 void* GLShareGroup::GetHandle() { |
32 GLContext* context = GetContext(); | 32 GLContext* context = GetContext(); |
33 if (context) | 33 if (context) |
34 return context->GetHandle(); | 34 return context->GetHandle(); |
35 | 35 |
36 return NULL; | 36 return NULL; |
37 } | 37 } |
38 | 38 |
39 GLContext* GLShareGroup::GetContext() { | 39 GLContext* GLShareGroup::GetContext() { |
40 for (ContextSet::iterator it = contexts_.begin(); | 40 for (auto context : contexts_) { |
41 it != contexts_.end(); | 41 if (context->GetHandle()) |
42 ++it) { | 42 return context; |
43 if ((*it)->GetHandle()) | |
44 return *it; | |
45 } | 43 } |
46 | 44 |
47 return NULL; | 45 return NULL; |
48 } | 46 } |
49 | 47 |
50 void GLShareGroup::SetSharedContext(GLContext* context) { | 48 void GLShareGroup::SetSharedContext(GLContext* context) { |
51 DCHECK(contexts_.find(context) != contexts_.end()); | 49 DCHECK(contexts_.find(context) != contexts_.end()); |
52 shared_context_ = context; | 50 shared_context_ = context; |
53 } | 51 } |
54 | 52 |
55 GLContext* GLShareGroup::GetSharedContext() { | 53 GLContext* GLShareGroup::GetSharedContext() { |
56 return shared_context_; | 54 return shared_context_; |
57 } | 55 } |
58 | 56 |
59 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
60 void GLShareGroup::SetRendererID(int renderer_id) { | 58 void GLShareGroup::SetRendererID(int renderer_id) { |
61 renderer_id_ = renderer_id; | 59 renderer_id_ = renderer_id; |
62 } | 60 } |
63 | 61 |
64 int GLShareGroup::GetRendererID() { | 62 int GLShareGroup::GetRendererID() { |
65 return renderer_id_; | 63 return renderer_id_; |
66 } | 64 } |
67 #endif | 65 #endif |
68 | 66 |
69 GLShareGroup::~GLShareGroup() { | 67 GLShareGroup::~GLShareGroup() { |
70 } | 68 } |
71 | 69 |
72 } // namespace gfx | 70 } // namespace gfx |
OLD | NEW |