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

Side by Side Diff: ui/gfx/gl/gl_context.h

Issue 8233027: Support dynamic switching between integrated and discrete GPUs on Mac OS X. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_GFX_GL_GL_CONTEXT_H_ 5 #ifndef UI_GFX_GL_GL_CONTEXT_H_
6 #define UI_GFX_GL_GL_CONTEXT_H_ 6 #define UI_GFX_GL_GL_CONTEXT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "ui/gfx/gl/gl_share_group.h" 13 #include "ui/gfx/gl/gl_share_group.h"
14 #include "ui/gfx/gl/gpu_preference.h"
14 15
15 namespace gfx { 16 namespace gfx {
16 17
17 class GLSurface; 18 class GLSurface;
18 19
19 // Encapsulates an OpenGL context, hiding platform specific management. 20 // Encapsulates an OpenGL context, hiding platform specific management.
20 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { 21 class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
21 public: 22 public:
22 explicit GLContext(GLShareGroup* share_group); 23 explicit GLContext(GLShareGroup* share_group);
23 24
24 // Initializes the GL context to be compatible with the given surface. The GL 25 // Initializes the GL context to be compatible with the given surface. The GL
25 // context can be made with other surface's of the same type. The compatible 26 // context can be made with other surface's of the same type. The compatible
26 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It 27 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It
27 // should be specific for all platforms though. 28 // should be specific for all platforms though.
28 virtual bool Initialize(GLSurface* compatible_surface) = 0; 29 virtual bool Initialize(
30 GLSurface* compatible_surface, GpuPreference gpu_preference) = 0;
29 31
30 // Destroys the GL context. 32 // Destroys the GL context.
31 virtual void Destroy() = 0; 33 virtual void Destroy() = 0;
32 34
33 // Makes the GL context and a surface current on the current thread. 35 // Makes the GL context and a surface current on the current thread.
34 virtual bool MakeCurrent(GLSurface* surface) = 0; 36 virtual bool MakeCurrent(GLSurface* surface) = 0;
35 37
36 // Releases this GL context and surface as current on the current thread. 38 // Releases this GL context and surface as current on the current thread.
37 virtual void ReleaseCurrent(GLSurface* surface) = 0; 39 virtual void ReleaseCurrent(GLSurface* surface) = 0;
38 40
(...skipping 14 matching lines...) Expand all
53 // context must be current. 55 // context must be current.
54 bool HasExtension(const char* name); 56 bool HasExtension(const char* name);
55 57
56 GLShareGroup* share_group(); 58 GLShareGroup* share_group();
57 59
58 // Create a GL context that is compatible with the given surface. 60 // Create a GL context that is compatible with the given surface.
59 // |share_group|, if non-NULL, is a group of contexts which the 61 // |share_group|, if non-NULL, is a group of contexts which the
60 // internally created OpenGL context shares textures and other resources. 62 // internally created OpenGL context shares textures and other resources.
61 static scoped_refptr<GLContext> CreateGLContext( 63 static scoped_refptr<GLContext> CreateGLContext(
62 GLShareGroup* share_group, 64 GLShareGroup* share_group,
63 GLSurface* compatible_surface); 65 GLSurface* compatible_surface,
66 GpuPreference gpu_preference);
64 67
65 static bool LosesAllContextsOnContextLost(); 68 static bool LosesAllContextsOnContextLost();
66 69
70 static bool SupportsDualGpus();
71
67 static GLContext* GetCurrent(); 72 static GLContext* GetCurrent();
68 73
69 virtual bool WasAllocatedUsingARBRobustness(); 74 virtual bool WasAllocatedUsingARBRobustness();
70 75
71 protected: 76 protected:
72 virtual ~GLContext(); 77 virtual ~GLContext();
73 static void SetCurrent(GLContext* context, GLSurface* surface); 78 static void SetCurrent(GLContext* context, GLSurface* surface);
74 79
75 private: 80 private:
76 scoped_refptr<GLShareGroup> share_group_; 81 scoped_refptr<GLShareGroup> share_group_;
77 friend class base::RefCounted<GLContext>; 82 friend class base::RefCounted<GLContext>;
78 DISALLOW_COPY_AND_ASSIGN(GLContext); 83 DISALLOW_COPY_AND_ASSIGN(GLContext);
79 }; 84 };
80 85
81 } // namespace gfx 86 } // namespace gfx
82 87
83 #endif // UI_GFX_GL_GL_CONTEXT_H_ 88 #endif // UI_GFX_GL_GL_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698