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