| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 struct GLContextAttribs { | 61 struct GLContextAttribs { |
| 62 GpuPreference gpu_preference = PreferIntegratedGpu; | 62 GpuPreference gpu_preference = PreferIntegratedGpu; |
| 63 bool bind_generates_resource = true; | 63 bool bind_generates_resource = true; |
| 64 bool webgl_compatibility_context = false; | 64 bool webgl_compatibility_context = false; |
| 65 bool global_texture_share_group = false; | 65 bool global_texture_share_group = false; |
| 66 int client_major_es_version = 3; | 66 int client_major_es_version = 3; |
| 67 int client_minor_es_version = 0; | 67 int client_minor_es_version = 0; |
| 68 ContextPriority context_priority = ContextPriorityMedium; | 68 ContextPriority context_priority = ContextPriorityMedium; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 struct GLWorkarounds { |
| 72 // glClearColor does not always work on Intel 6xxx Mac drivers. See |
| 73 // crbug.com/710443. |
| 74 bool clear_to_zero_or_one_broken = false; |
| 75 }; |
| 76 |
| 71 // Encapsulates an OpenGL context, hiding platform specific management. | 77 // Encapsulates an OpenGL context, hiding platform specific management. |
| 72 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { | 78 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { |
| 73 public: | 79 public: |
| 74 explicit GLContext(GLShareGroup* share_group); | 80 explicit GLContext(GLShareGroup* share_group); |
| 75 | 81 |
| 76 // Initializes the GL context to be compatible with the given surface. The GL | 82 // Initializes the GL context to be compatible with the given surface. The GL |
| 77 // context can be made with other surface's of the same type. The compatible | 83 // context can be made with other surface's of the same type. The compatible |
| 78 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It | 84 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It |
| 79 // should be specific for all platforms though. | 85 // should be specific for all platforms though. |
| 80 virtual bool Initialize(GLSurface* compatible_surface, | 86 virtual bool Initialize(GLSurface* compatible_surface, |
| 81 const GLContextAttribs& attribs) = 0; | 87 const GLContextAttribs& attribs) = 0; |
| 82 | 88 |
| 83 // Makes the GL context and a surface current on the current thread. | 89 // Makes the GL context and a surface current on the current thread. |
| 84 virtual bool MakeCurrent(GLSurface* surface) = 0; | 90 virtual bool MakeCurrent(GLSurface* surface) = 0; |
| 85 | 91 |
| 86 // Releases this GL context and surface as current on the current thread. | 92 // Releases this GL context and surface as current on the current thread. |
| 87 virtual void ReleaseCurrent(GLSurface* surface) = 0; | 93 virtual void ReleaseCurrent(GLSurface* surface) = 0; |
| 88 | 94 |
| 89 // Returns true if this context and surface is current. Pass a null surface | 95 // Returns true if this context and surface is current. Pass a null surface |
| 90 // if the current surface is not important. | 96 // if the current surface is not important. |
| 91 virtual bool IsCurrent(GLSurface* surface) = 0; | 97 virtual bool IsCurrent(GLSurface* surface) = 0; |
| 92 | 98 |
| 93 // Get the underlying platform specific GL context "handle". | 99 // Get the underlying platform specific GL context "handle". |
| 94 virtual void* GetHandle() = 0; | 100 virtual void* GetHandle() = 0; |
| 95 | 101 |
| 96 // Creates a GPUTimingClient class which abstracts various GPU Timing exts. | 102 // Creates a GPUTimingClient class which abstracts various GPU Timing exts. |
| 97 virtual scoped_refptr<GPUTimingClient> CreateGPUTimingClient() = 0; | 103 virtual scoped_refptr<GPUTimingClient> CreateGPUTimingClient() = 0; |
| 98 | 104 |
| 105 // Set the GL workarounds. |
| 106 void SetGLWorkarounds(const GLWorkarounds& workarounds); |
| 107 |
| 99 // Gets the GLStateRestorer for the context. | 108 // Gets the GLStateRestorer for the context. |
| 100 GLStateRestorer* GetGLStateRestorer(); | 109 GLStateRestorer* GetGLStateRestorer(); |
| 101 | 110 |
| 102 // Sets the GLStateRestorer for the context (takes ownership). | 111 // Sets the GLStateRestorer for the context (takes ownership). |
| 103 void SetGLStateRestorer(GLStateRestorer* state_restorer); | 112 void SetGLStateRestorer(GLStateRestorer* state_restorer); |
| 104 | 113 |
| 105 // Set swap interval. This context must be current. | 114 // Set swap interval. This context must be current. |
| 106 void SetSwapInterval(int interval); | 115 void SetSwapInterval(int interval); |
| 107 | 116 |
| 108 // Forces the swap interval to zero (no vsync) regardless of any future values | 117 // Forces the swap interval to zero (no vsync) regardless of any future values |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 virtual void OnSetSwapInterval(int interval) = 0; | 224 virtual void OnSetSwapInterval(int interval) = 0; |
| 216 | 225 |
| 217 private: | 226 private: |
| 218 friend class base::RefCounted<GLContext>; | 227 friend class base::RefCounted<GLContext>; |
| 219 | 228 |
| 220 // For GetRealCurrent. | 229 // For GetRealCurrent. |
| 221 friend class gpu::GLContextVirtual; | 230 friend class gpu::GLContextVirtual; |
| 222 | 231 |
| 223 std::unique_ptr<GLVersionInfo> GenerateGLVersionInfo(); | 232 std::unique_ptr<GLVersionInfo> GenerateGLVersionInfo(); |
| 224 | 233 |
| 234 GLWorkarounds gl_workarounds_; |
| 235 |
| 225 bool static_bindings_initialized_ = false; | 236 bool static_bindings_initialized_ = false; |
| 226 bool dynamic_bindings_initialized_ = false; | 237 bool dynamic_bindings_initialized_ = false; |
| 227 std::unique_ptr<DriverGL> driver_gl_; | 238 std::unique_ptr<DriverGL> driver_gl_; |
| 228 std::unique_ptr<GLApi> gl_api_; | 239 std::unique_ptr<GLApi> gl_api_; |
| 229 std::unique_ptr<TraceGLApi> trace_gl_api_; | 240 std::unique_ptr<TraceGLApi> trace_gl_api_; |
| 230 std::unique_ptr<DebugGLApi> debug_gl_api_; | 241 std::unique_ptr<DebugGLApi> debug_gl_api_; |
| 231 std::unique_ptr<CurrentGL> current_gl_; | 242 std::unique_ptr<CurrentGL> current_gl_; |
| 232 | 243 |
| 233 // Copy of the real API (if one was created) for dynamic initialization | 244 // Copy of the real API (if one was created) for dynamic initialization |
| 234 RealGLApi* real_gl_api_ = nullptr; | 245 RealGLApi* real_gl_api_ = nullptr; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 265 // scoped_refptr containing the initialized GLContext or nullptr if | 276 // scoped_refptr containing the initialized GLContext or nullptr if |
| 266 // initialization fails. | 277 // initialization fails. |
| 267 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( | 278 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( |
| 268 scoped_refptr<GLContext> context, | 279 scoped_refptr<GLContext> context, |
| 269 GLSurface* compatible_surface, | 280 GLSurface* compatible_surface, |
| 270 const GLContextAttribs& attribs); | 281 const GLContextAttribs& attribs); |
| 271 | 282 |
| 272 } // namespace gl | 283 } // namespace gl |
| 273 | 284 |
| 274 #endif // UI_GL_GL_CONTEXT_H_ | 285 #endif // UI_GL_GL_CONTEXT_H_ |
| OLD | NEW |