| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace gpu { | 25 namespace gpu { |
| 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 class VirtualGLApi; | |
| 35 struct GLVersionInfo; | 34 struct GLVersionInfo; |
| 36 | 35 |
| 37 // Encapsulates an OpenGL context, hiding platform specific management. | 36 // Encapsulates an OpenGL context, hiding platform specific management. |
| 38 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { | 37 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { |
| 39 public: | 38 public: |
| 40 explicit GLContext(GLShareGroup* share_group); | 39 explicit GLContext(GLShareGroup* share_group); |
| 41 | 40 |
| 42 // 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 |
| 43 // 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 |
| 44 // 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 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 GLSurface* compatible_surface, | 108 GLSurface* compatible_surface, |
| 110 GpuPreference gpu_preference); | 109 GpuPreference gpu_preference); |
| 111 | 110 |
| 112 static bool LosesAllContextsOnContextLost(); | 111 static bool LosesAllContextsOnContextLost(); |
| 113 | 112 |
| 114 // Returns the last GLContext made current, virtual or real. | 113 // Returns the last GLContext made current, virtual or real. |
| 115 static GLContext* GetCurrent(); | 114 static GLContext* GetCurrent(); |
| 116 | 115 |
| 117 virtual bool WasAllocatedUsingRobustnessExtension(); | 116 virtual bool WasAllocatedUsingRobustnessExtension(); |
| 118 | 117 |
| 119 // Use this context for virtualization. | |
| 120 void SetupForVirtualization(); | |
| 121 | |
| 122 // Make this context current when used for context virtualization. | 118 // Make this context current when used for context virtualization. |
| 123 bool MakeVirtuallyCurrent(GLContext* virtual_context, GLSurface* surface); | 119 bool MakeVirtuallyCurrent(GLContext* virtual_context, GLSurface* surface); |
| 124 | 120 |
| 125 // Notify this context that |virtual_context|, that was using us, is | 121 // Notify this context that |virtual_context|, that was using us, is |
| 126 // being released or destroyed. | 122 // being released or destroyed. |
| 127 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); | 123 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); |
| 128 | 124 |
| 129 // Returns the GL version string. The context must be current. | 125 // Returns the GL version string. The context must be current. |
| 130 virtual std::string GetGLVersion(); | 126 virtual std::string GetGLVersion(); |
| 131 | 127 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 161 | 157 |
| 162 // Returns the last real (non-virtual) GLContext made current. | 158 // Returns the last real (non-virtual) GLContext made current. |
| 163 static GLContext* GetRealCurrent(); | 159 static GLContext* GetRealCurrent(); |
| 164 | 160 |
| 165 virtual void OnSetSwapInterval(int interval) = 0; | 161 virtual void OnSetSwapInterval(int interval) = 0; |
| 166 | 162 |
| 167 private: | 163 private: |
| 168 friend class base::RefCounted<GLContext>; | 164 friend class base::RefCounted<GLContext>; |
| 169 | 165 |
| 170 // For GetRealCurrent. | 166 // For GetRealCurrent. |
| 171 friend class VirtualGLApi; | |
| 172 friend class gpu::GLContextVirtual; | 167 friend class gpu::GLContextVirtual; |
| 173 | 168 |
| 174 scoped_refptr<GLShareGroup> share_group_; | 169 scoped_refptr<GLShareGroup> share_group_; |
| 175 std::unique_ptr<VirtualGLApi> virtual_gl_api_; | 170 GLContext* current_virtual_context_; |
| 176 bool state_dirtied_externally_; | 171 bool state_dirtied_externally_; |
| 177 std::unique_ptr<GLStateRestorer> state_restorer_; | 172 std::unique_ptr<GLStateRestorer> state_restorer_; |
| 178 std::unique_ptr<GLVersionInfo> version_info_; | 173 std::unique_ptr<GLVersionInfo> version_info_; |
| 179 | 174 |
| 180 int swap_interval_; | 175 int swap_interval_; |
| 181 bool force_swap_interval_zero_; | 176 bool force_swap_interval_zero_; |
| 182 | 177 |
| 183 DISALLOW_COPY_AND_ASSIGN(GLContext); | 178 DISALLOW_COPY_AND_ASSIGN(GLContext); |
| 184 }; | 179 }; |
| 185 | 180 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 202 // scoped_refptr containing the initialized GLContext or nullptr if | 197 // scoped_refptr containing the initialized GLContext or nullptr if |
| 203 // initialization fails. | 198 // initialization fails. |
| 204 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( | 199 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( |
| 205 scoped_refptr<GLContext> context, | 200 scoped_refptr<GLContext> context, |
| 206 GLSurface* compatible_surface, | 201 GLSurface* compatible_surface, |
| 207 GpuPreference gpu_preference); | 202 GpuPreference gpu_preference); |
| 208 | 203 |
| 209 } // namespace gl | 204 } // namespace gl |
| 210 | 205 |
| 211 #endif // UI_GL_GL_CONTEXT_H_ | 206 #endif // UI_GL_GL_CONTEXT_H_ |
| OLD | NEW |