OLD | NEW |
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_CONTEXT_H_ | 5 #ifndef UI_GL_GL_CONTEXT_H_ |
6 #define UI_GL_GL_CONTEXT_H_ | 6 #define UI_GL_GL_CONTEXT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... |
26 class GLContextVirtual; | 26 class GLContextVirtual; |
27 } // namespace gpu | 27 } // namespace gpu |
28 | 28 |
29 namespace gl { | 29 namespace gl { |
30 | 30 |
31 class GLSurface; | 31 class GLSurface; |
32 class GPUTiming; | 32 class GPUTiming; |
33 class GPUTimingClient; | 33 class GPUTimingClient; |
34 struct GLVersionInfo; | 34 struct GLVersionInfo; |
35 | 35 |
| 36 struct GLContextAttribs { |
| 37 GpuPreference gpu_preference = PreferIntegratedGpu; |
| 38 bool bind_generates_resource = true; |
| 39 bool webgl_compatibility_context = false; |
| 40 }; |
| 41 |
36 // Encapsulates an OpenGL context, hiding platform specific management. | 42 // Encapsulates an OpenGL context, hiding platform specific management. |
37 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { | 43 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { |
38 public: | 44 public: |
39 explicit GLContext(GLShareGroup* share_group); | 45 explicit GLContext(GLShareGroup* share_group); |
40 | 46 |
41 // Initializes the GL context to be compatible with the given surface. The GL | 47 // Initializes the GL context to be compatible with the given surface. The GL |
42 // context can be made with other surface's of the same type. The compatible | 48 // context can be made with other surface's of the same type. The compatible |
43 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It | 49 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It |
44 // should be specific for all platforms though. | 50 // should be specific for all platforms though. |
45 virtual bool Initialize( | 51 virtual bool Initialize(GLSurface* compatible_surface, |
46 GLSurface* compatible_surface, GpuPreference gpu_preference) = 0; | 52 const GLContextAttribs& attribs) = 0; |
47 | 53 |
48 // Makes the GL context and a surface current on the current thread. | 54 // Makes the GL context and a surface current on the current thread. |
49 virtual bool MakeCurrent(GLSurface* surface) = 0; | 55 virtual bool MakeCurrent(GLSurface* surface) = 0; |
50 | 56 |
51 // Releases this GL context and surface as current on the current thread. | 57 // Releases this GL context and surface as current on the current thread. |
52 virtual void ReleaseCurrent(GLSurface* surface) = 0; | 58 virtual void ReleaseCurrent(GLSurface* surface) = 0; |
53 | 59 |
54 // Returns true if this context and surface is current. Pass a null surface | 60 // Returns true if this context and surface is current. Pass a null surface |
55 // if the current surface is not important. | 61 // if the current surface is not important. |
56 virtual bool IsCurrent(GLSurface* surface) = 0; | 62 virtual bool IsCurrent(GLSurface* surface) = 0; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 std::unique_ptr<GPUTiming> gpu_timing_; | 198 std::unique_ptr<GPUTiming> gpu_timing_; |
193 DISALLOW_COPY_AND_ASSIGN(GLContextReal); | 199 DISALLOW_COPY_AND_ASSIGN(GLContextReal); |
194 }; | 200 }; |
195 | 201 |
196 // Wraps GLContext in scoped_refptr and tries to initializes it. Returns a | 202 // Wraps GLContext in scoped_refptr and tries to initializes it. Returns a |
197 // scoped_refptr containing the initialized GLContext or nullptr if | 203 // scoped_refptr containing the initialized GLContext or nullptr if |
198 // initialization fails. | 204 // initialization fails. |
199 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( | 205 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( |
200 scoped_refptr<GLContext> context, | 206 scoped_refptr<GLContext> context, |
201 GLSurface* compatible_surface, | 207 GLSurface* compatible_surface, |
202 GpuPreference gpu_preference); | 208 const GLContextAttribs& attribs); |
203 | 209 |
204 } // namespace gl | 210 } // namespace gl |
205 | 211 |
206 #endif // UI_GL_GL_CONTEXT_H_ | 212 #endif // UI_GL_GL_CONTEXT_H_ |
OLD | NEW |