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

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

Issue 1652873002: Android: Use virtualized context only for those with compatible config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 10 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 <map>
8 #include <set> 9 #include <set>
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"
13 #include "base/memory/scoped_ptr.h"
12 #include "build/build_config.h" 14 #include "build/build_config.h"
13 #include "ui/gl/gl_export.h" 15 #include "ui/gl/gl_export.h"
16 #include "ui/gl/gl_surface.h"
17 #include "ui/gl/gpu_preference.h"
14 18
15 namespace gfx { 19 namespace gfx {
16 20
17 class GLContext; 21 class GLContext;
18 22
19 // A group of GL contexts that share an ID namespace. 23 // A group of GL contexts that share an ID namespace.
20 class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> { 24 class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
21 public: 25 public:
22 GLShareGroup(); 26 GLShareGroup();
23 27
24 // These two should only be called from the constructor and destructor of 28 // These two should only be called from the constructor and destructor of
25 // GLContext. 29 // GLContext.
26 void AddContext(GLContext* context); 30 void AddContext(GLContext* context);
27 void RemoveContext(GLContext* context); 31 void RemoveContext(GLContext* context);
28 32
29 // Returns a handle to any initialized context in the share group or NULL if 33 // Returns a handle to any initialized context in the share group or NULL if
30 // there are no initialized contexts in the share group. 34 // there are no initialized contexts in the share group.
31 void* GetHandle(); 35 void* GetHandle();
32 36
33 // Returns a pointer to any initialized context in the share group 37 // Returns a pointer to any initialized context in the share group
34 // or NULL if there are no initialized contexts in the share group. 38 // or NULL if there are no initialized contexts in the share group.
35 GLContext* GetContext(); 39 GLContext* GetContext();
36 40
37 // Sets and returns the unique shared GL context. Used for context 41 // Updates the shared context pool and sets the active shared GL context
38 // virtualization. 42 // used for virtualization to match the configuration.
39 void SetSharedContext(GLContext* context); 43 void UpdateActiveSharedContext(GLSurface* surface, GpuPreference preference);
40 GLContext* GetSharedContext(); 44 GLContext* GetSharedContext();
41 45
42 #if defined(OS_MACOSX) 46 #if defined(OS_MACOSX)
43 // Sets and returns the ID of the renderer that all contexts in this share 47 // Sets and returns the ID of the renderer that all contexts in this share
44 // group should be on. 48 // group should be on.
45 void SetRendererID(int renderer_id); 49 void SetRendererID(int renderer_id);
46 int GetRendererID(); 50 int GetRendererID();
47 #endif 51 #endif
48 52
49 private: 53 private:
50 friend class base::RefCounted<GLShareGroup>; 54 friend class base::RefCounted<GLShareGroup>;
51 55
52 ~GLShareGroup(); 56 ~GLShareGroup();
53 57
54 // References to GLContext are by raw pointer to avoid a reference count 58 // References to GLContext are by raw pointer to avoid a reference count
55 // cycle. 59 // cycle.
56 typedef std::set<GLContext*> ContextSet; 60 typedef std::set<GLContext*> ContextSet;
57 ContextSet contexts_; 61 ContextSet contexts_;
58 62
59 GLContext* shared_context_; 63 // USe refptr for GL Contexts to keep the shared contexts temporarily not
64 // referenced by any virtual GL context. Will be destroyed together with
65 // the share group.
66 scoped_ptr<std::map<GLSurface::Format,
67 scoped_refptr<GLContext>>> shared_contexts_;
68 GLContext* active_context_;
69 GLSurface::Format format_;
60 70
61 #if defined(OS_MACOSX) 71 #if defined(OS_MACOSX)
62 int renderer_id_; 72 int renderer_id_;
63 #endif 73 #endif
64 74
65 DISALLOW_COPY_AND_ASSIGN(GLShareGroup); 75 DISALLOW_COPY_AND_ASSIGN(GLShareGroup);
66 }; 76 };
67 77
68 } // namespace gfx 78 } // namespace gfx
69 79
70 #endif // UI_GL_GL_SHARE_GROUP_H_ 80 #endif // UI_GL_GL_SHARE_GROUP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698