[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 7196e01 | 2011-06-16 20:54:53 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 5 | #ifndef UI_GL_GL_SHARE_GROUP_H_ |
6 | #define UI_GL_GL_SHARE_GROUP_H_ | ||||
[email protected] | 7196e01 | 2011-06-16 20:54:53 | [diff] [blame] | 7 | |
8 | #include <set> | ||||
9 | |||||
10 | #include "base/basictypes.h" | ||||
11 | #include "base/memory/ref_counted.h" | ||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 12 | #include "ui/gl/gl_export.h" |
[email protected] | 7196e01 | 2011-06-16 20:54:53 | [diff] [blame] | 13 | |
14 | namespace gfx { | ||||
15 | |||||
16 | class GLContext; | ||||
17 | |||||
18 | // A group of GL contexts that share an ID namespace. | ||||
[email protected] | fe377e1 | 2011-08-18 17:37:36 | [diff] [blame] | 19 | class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> { |
[email protected] | 7196e01 | 2011-06-16 20:54:53 | [diff] [blame] | 20 | public: |
21 | GLShareGroup(); | ||||
22 | |||||
23 | // These two should only be called from the constructor and destructor of | ||||
24 | // GLContext. | ||||
25 | void AddContext(GLContext* context); | ||||
26 | void RemoveContext(GLContext* context); | ||||
27 | |||||
28 | // Returns a handle to any initialized context in the share group or NULL if | ||||
29 | // there are no initialized contexts in the share group. | ||||
30 | void* GetHandle(); | ||||
31 | |||||
[email protected] | 276f8906 | 2011-10-13 22:55:50 | [diff] [blame] | 32 | // Returns a pointer to any initialized context in the share group |
33 | // or NULL if there are no initialized contexts in the share group. | ||||
34 | GLContext* GetContext(); | ||||
35 | |||||
[email protected] | ee1e6aa | 2012-11-29 09:24:10 | [diff] [blame] | 36 | // Sets and returns the unique shared GL context. Used for context |
37 | // virtualization. | ||||
38 | void SetSharedContext(GLContext* context); | ||||
39 | GLContext* GetSharedContext(); | ||||
40 | |||||
[email protected] | cd195afe | 2013-03-06 09:31:37 | [diff] [blame^] | 41 | #if defined(OS_MACOSX) |
42 | // Sets and returns the ID of the renderer that all contexts in this share | ||||
43 | // group should be on. | ||||
44 | void SetRendererID(int renderer_id); | ||||
45 | int GetRendererID(); | ||||
46 | #endif | ||||
47 | |||||
[email protected] | 7196e01 | 2011-06-16 20:54:53 | [diff] [blame] | 48 | private: |
49 | friend class base::RefCounted<GLShareGroup>; | ||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 50 | |
[email protected] | 7196e01 | 2011-06-16 20:54:53 | [diff] [blame] | 51 | ~GLShareGroup(); |
52 | |||||
53 | // References to GLContext are by raw pointer to avoid a reference count | ||||
54 | // cycle. | ||||
55 | typedef std::set<GLContext*> ContextSet; | ||||
56 | ContextSet contexts_; | ||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 57 | |
[email protected] | ee1e6aa | 2012-11-29 09:24:10 | [diff] [blame] | 58 | GLContext* shared_context_; |
59 | |||||
[email protected] | cd195afe | 2013-03-06 09:31:37 | [diff] [blame^] | 60 | #if defined(OS_MACOSX) |
61 | int renderer_id_; | ||||
62 | #endif | ||||
63 | |||||
[email protected] | 7196e01 | 2011-06-16 20:54:53 | [diff] [blame] | 64 | DISALLOW_COPY_AND_ASSIGN(GLShareGroup); |
65 | }; | ||||
66 | |||||
67 | } // namespace gfx | ||||
68 | |||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 69 | #endif // UI_GL_GL_SHARE_GROUP_H_ |