| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 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 "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/synchronization/cancellation_flag.h" | 14 #include "base/synchronization/cancellation_flag.h" |
| 15 #include "ui/gl/gl_share_group.h" | 15 #include "ui/gl/gl_share_group.h" |
| 16 #include "ui/gl/gl_state_restorer.h" | 16 #include "ui/gl/gl_state_restorer.h" |
| 17 #include "ui/gl/gpu_preference.h" | 17 #include "ui/gl/gpu_preference.h" |
| 18 | 18 |
| 19 namespace gpu { |
| 20 class GPUTiming; |
| 21 } |
| 22 |
| 19 namespace gfx { | 23 namespace gfx { |
| 20 | 24 |
| 21 class GLSurface; | 25 class GLSurface; |
| 22 class VirtualGLApi; | 26 class VirtualGLApi; |
| 23 struct GLVersionInfo; | 27 struct GLVersionInfo; |
| 24 | 28 |
| 25 // Encapsulates an OpenGL context, hiding platform specific management. | 29 // Encapsulates an OpenGL context, hiding platform specific management. |
| 26 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { | 30 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { |
| 27 public: | 31 public: |
| 28 explicit GLContext(GLShareGroup* share_group); | 32 explicit GLContext(GLShareGroup* share_group); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 virtual void SetUnbindFboOnMakeCurrent(); | 88 virtual void SetUnbindFboOnMakeCurrent(); |
| 85 | 89 |
| 86 // Returns whether the current context supports the named extension. The | 90 // Returns whether the current context supports the named extension. The |
| 87 // context must be current. | 91 // context must be current. |
| 88 bool HasExtension(const char* name); | 92 bool HasExtension(const char* name); |
| 89 | 93 |
| 90 // Returns version info of the underlying GL context. The context must be | 94 // Returns version info of the underlying GL context. The context must be |
| 91 // current. | 95 // current. |
| 92 const GLVersionInfo* GetVersionInfo(); | 96 const GLVersionInfo* GetVersionInfo(); |
| 93 | 97 |
| 98 // Returns a GPUTiming object used to create GPUTimingClients. This class |
| 99 // is used to abstract the various GPU Timing extensions. |
| 100 gpu::GPUTiming* GetGPUTiming(); |
| 101 |
| 94 GLShareGroup* share_group(); | 102 GLShareGroup* share_group(); |
| 95 | 103 |
| 96 // Create a GL context that is compatible with the given surface. | 104 // Create a GL context that is compatible with the given surface. |
| 97 // |share_group|, if non-NULL, is a group of contexts which the | 105 // |share_group|, if non-NULL, is a group of contexts which the |
| 98 // internally created OpenGL context shares textures and other resources. | 106 // internally created OpenGL context shares textures and other resources. |
| 99 static scoped_refptr<GLContext> CreateGLContext( | 107 static scoped_refptr<GLContext> CreateGLContext( |
| 100 GLShareGroup* share_group, | 108 GLShareGroup* share_group, |
| 101 GLSurface* compatible_surface, | 109 GLSurface* compatible_surface, |
| 102 GpuPreference gpu_preference); | 110 GpuPreference gpu_preference); |
| 103 | 111 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 private: | 164 private: |
| 157 friend class base::RefCounted<GLContext>; | 165 friend class base::RefCounted<GLContext>; |
| 158 | 166 |
| 159 // For GetRealCurrent. | 167 // For GetRealCurrent. |
| 160 friend class VirtualGLApi; | 168 friend class VirtualGLApi; |
| 161 | 169 |
| 162 scoped_refptr<GLShareGroup> share_group_; | 170 scoped_refptr<GLShareGroup> share_group_; |
| 163 scoped_ptr<VirtualGLApi> virtual_gl_api_; | 171 scoped_ptr<VirtualGLApi> virtual_gl_api_; |
| 164 scoped_ptr<GLStateRestorer> state_restorer_; | 172 scoped_ptr<GLStateRestorer> state_restorer_; |
| 165 scoped_ptr<GLVersionInfo> version_info_; | 173 scoped_ptr<GLVersionInfo> version_info_; |
| 174 scoped_ptr<gpu::GPUTiming> gpu_timing_; |
| 166 | 175 |
| 167 int swap_interval_; | 176 int swap_interval_; |
| 168 bool force_swap_interval_zero_; | 177 bool force_swap_interval_zero_; |
| 169 | 178 |
| 170 DISALLOW_COPY_AND_ASSIGN(GLContext); | 179 DISALLOW_COPY_AND_ASSIGN(GLContext); |
| 171 }; | 180 }; |
| 172 | 181 |
| 173 class GL_EXPORT GLContextReal : public GLContext { | 182 class GL_EXPORT GLContextReal : public GLContext { |
| 174 public: | 183 public: |
| 175 explicit GLContextReal(GLShareGroup* share_group); | 184 explicit GLContextReal(GLShareGroup* share_group); |
| 176 | 185 |
| 177 protected: | 186 protected: |
| 178 ~GLContextReal() override; | 187 ~GLContextReal() override; |
| 179 | 188 |
| 180 void SetCurrent(GLSurface* surface) override; | 189 void SetCurrent(GLSurface* surface) override; |
| 181 | 190 |
| 182 private: | 191 private: |
| 183 DISALLOW_COPY_AND_ASSIGN(GLContextReal); | 192 DISALLOW_COPY_AND_ASSIGN(GLContextReal); |
| 184 }; | 193 }; |
| 185 | 194 |
| 186 } // namespace gfx | 195 } // namespace gfx |
| 187 | 196 |
| 188 #endif // UI_GL_GL_CONTEXT_H_ | 197 #endif // UI_GL_GL_CONTEXT_H_ |
| OLD | NEW |