Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: ui/gl/gl_share_group.h

Issue 2347383002: X11: Use better visuals for OpenGL (Closed)
Patch Set: auto* Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_context.cc ('k') | ui/gl/gl_share_group.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef UI_GL_GL_SHARE_GROUP_H_ 5 #ifndef UI_GL_GL_SHARE_GROUP_H_
6 #define UI_GL_GL_SHARE_GROUP_H_ 6 #define UI_GL_GL_SHARE_GROUP_H_
7 7
8 #include <set> 8 #include <set>
9 #include <unordered_map>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "ui/gl/gl_export.h" 14 #include "ui/gl/gl_export.h"
14 15
15 namespace gl { 16 namespace gl {
16 17
17 class GLContext; 18 class GLContext;
19 class GLSurface;
18 20
19 // A group of GL contexts that share an ID namespace. 21 // A group of GL contexts that share an ID namespace.
20 class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> { 22 class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
21 public: 23 public:
22 GLShareGroup(); 24 GLShareGroup();
23 25
24 // These two should only be called from the constructor and destructor of 26 // These two should only be called from the constructor and destructor of
25 // GLContext. 27 // GLContext.
26 void AddContext(GLContext* context); 28 void AddContext(GLContext* context);
27 void RemoveContext(GLContext* context); 29 void RemoveContext(GLContext* context);
28 30
29 // Returns a handle to any initialized context in the share group or NULL if 31 // Returns a handle to any initialized context in the share group or NULL if
30 // there are no initialized contexts in the share group. 32 // there are no initialized contexts in the share group.
31 void* GetHandle(); 33 void* GetHandle();
32 34
33 // Returns a pointer to any initialized context in the share group 35 // Returns a pointer to any initialized context in the share group
34 // or NULL if there are no initialized contexts in the share group. 36 // or NULL if there are no initialized contexts in the share group.
35 GLContext* GetContext(); 37 GLContext* GetContext();
36 38
37 // Sets and returns the unique shared GL context. Used for context 39 // Sets and returns the shared GL context. Used for context virtualization.
38 // virtualization. 40 void SetSharedContext(GLSurface* compatible, GLContext* context);
39 void SetSharedContext(GLContext* context); 41 GLContext* GetSharedContext(GLSurface* compatible);
40 GLContext* GetSharedContext();
41 42
42 #if defined(OS_MACOSX) 43 #if defined(OS_MACOSX)
43 // Sets and returns the ID of the renderer that all contexts in this share 44 // Sets and returns the ID of the renderer that all contexts in this share
44 // group should be on. 45 // group should be on.
45 void SetRendererID(int renderer_id); 46 void SetRendererID(int renderer_id);
46 int GetRendererID(); 47 int GetRendererID();
47 #endif 48 #endif
48 49
49 private: 50 private:
50 friend class base::RefCounted<GLShareGroup>; 51 friend class base::RefCounted<GLShareGroup>;
51 52
52 ~GLShareGroup(); 53 ~GLShareGroup();
53 54
54 // References to GLContext are by raw pointer to avoid a reference count 55 // References to GLContext are by raw pointer to avoid a reference count
55 // cycle. 56 // cycle.
56 typedef std::set<GLContext*> ContextSet; 57 typedef std::set<GLContext*> ContextSet;
57 ContextSet contexts_; 58 ContextSet contexts_;
58 59
59 GLContext* shared_context_; 60 std::unordered_map<unsigned long, GLContext*> shared_contexts_;
60 61
61 #if defined(OS_MACOSX) 62 #if defined(OS_MACOSX)
62 int renderer_id_; 63 int renderer_id_;
63 #endif 64 #endif
64 65
65 DISALLOW_COPY_AND_ASSIGN(GLShareGroup); 66 DISALLOW_COPY_AND_ASSIGN(GLShareGroup);
66 }; 67 };
67 68
68 } // namespace gl 69 } // namespace gl
69 70
70 #endif // UI_GL_GL_SHARE_GROUP_H_ 71 #endif // UI_GL_GL_SHARE_GROUP_H_
OLDNEW
« no previous file with comments | « ui/gl/gl_context.cc ('k') | ui/gl/gl_share_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698