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

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

Issue 2347383002: X11: Use better visuals for OpenGL (Closed)
Patch Set: Fix various tests 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
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 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "ui/gl/gl_export.h" 13 #include "ui/gl/gl_export.h"
14 14
15 namespace gl { 15 namespace gl {
16 16
17 class GLContext; 17 class GLContext;
18 class GLSurface;
18 19
19 // A group of GL contexts that share an ID namespace. 20 // A group of GL contexts that share an ID namespace.
20 class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> { 21 class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
21 public: 22 public:
22 GLShareGroup(); 23 GLShareGroup();
23 24
24 // These two should only be called from the constructor and destructor of 25 // These two should only be called from the constructor and destructor of
25 // GLContext. 26 // GLContext.
26 void AddContext(GLContext* context); 27 void AddContext(GLContext* context);
27 void RemoveContext(GLContext* context); 28 void RemoveContext(GLContext* context);
28 29
29 // Returns a handle to any initialized context in the share group or NULL if 30 // Returns a handle to any initialized context in the share group or NULL if
30 // there are no initialized contexts in the share group. 31 // there are no initialized contexts in the share group.
31 void* GetHandle(); 32 void* GetHandle();
32 33
33 // Returns a pointer to any initialized context in the share group 34 // Returns a pointer to any initialized context in the share group
34 // or NULL if there are no initialized contexts in the share group. 35 // or NULL if there are no initialized contexts in the share group.
35 GLContext* GetContext(); 36 GLContext* GetContext();
36 37
37 // Sets and returns the unique shared GL context. Used for context 38 // Sets and returns the shared GL context. Used for context virtualization.
38 // virtualization. 39 virtual void SetSharedContext(GLSurface* compatible, GLContext* context);
39 void SetSharedContext(GLContext* context); 40 virtual GLContext* GetSharedContext(GLSurface* compatible);
40 GLContext* GetSharedContext();
41 41
42 #if defined(OS_MACOSX) 42 #if defined(OS_MACOSX)
43 // Sets and returns the ID of the renderer that all contexts in this share 43 // Sets and returns the ID of the renderer that all contexts in this share
44 // group should be on. 44 // group should be on.
45 void SetRendererID(int renderer_id); 45 void SetRendererID(int renderer_id);
46 int GetRendererID(); 46 int GetRendererID();
47 #endif 47 #endif
48 48
49 protected:
50 virtual ~GLShareGroup();
51
49 private: 52 private:
50 friend class base::RefCounted<GLShareGroup>; 53 friend class base::RefCounted<GLShareGroup>;
51 54
52 ~GLShareGroup();
53
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 GLContext* shared_context_;
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
69 GL_EXPORT GLShareGroup* CreateGLShareGroup();
70
68 } // namespace gl 71 } // namespace gl
69 72
70 #endif // UI_GL_GL_SHARE_GROUP_H_ 73 #endif // UI_GL_GL_SHARE_GROUP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698