| 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 gfx { | 19 namespace gfx { |
| 20 | 20 |
| 21 class GLSurface; | 21 class GLSurface; |
| 22 class GPUTiming; |
| 23 class GPUTimingClient; |
| 22 class VirtualGLApi; | 24 class VirtualGLApi; |
| 23 struct GLVersionInfo; | 25 struct GLVersionInfo; |
| 24 | 26 |
| 27 |
| 25 // Encapsulates an OpenGL context, hiding platform specific management. | 28 // Encapsulates an OpenGL context, hiding platform specific management. |
| 26 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { | 29 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { |
| 27 public: | 30 public: |
| 28 explicit GLContext(GLShareGroup* share_group); | 31 explicit GLContext(GLShareGroup* share_group); |
| 29 | 32 |
| 30 // Initializes the GL context to be compatible with the given surface. The GL | 33 // Initializes the GL context to be compatible with the given surface. The GL |
| 31 // context can be made with other surface's of the same type. The compatible | 34 // context can be made with other surface's of the same type. The compatible |
| 32 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It | 35 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It |
| 33 // should be specific for all platforms though. | 36 // should be specific for all platforms though. |
| 34 virtual bool Initialize( | 37 virtual bool Initialize( |
| 35 GLSurface* compatible_surface, GpuPreference gpu_preference) = 0; | 38 GLSurface* compatible_surface, GpuPreference gpu_preference) = 0; |
| 36 | 39 |
| 37 // Destroys the GL context. | 40 // Destroys the GL context. |
| 38 virtual void Destroy() = 0; | 41 virtual void Destroy() = 0; |
| 39 | 42 |
| 40 // Makes the GL context and a surface current on the current thread. | 43 // Makes the GL context and a surface current on the current thread. |
| 41 virtual bool MakeCurrent(GLSurface* surface) = 0; | 44 virtual bool MakeCurrent(GLSurface* surface) = 0; |
| 42 | 45 |
| 43 // Releases this GL context and surface as current on the current thread. | 46 // Releases this GL context and surface as current on the current thread. |
| 44 virtual void ReleaseCurrent(GLSurface* surface) = 0; | 47 virtual void ReleaseCurrent(GLSurface* surface) = 0; |
| 45 | 48 |
| 46 // Returns true if this context and surface is current. Pass a null surface | 49 // Returns true if this context and surface is current. Pass a null surface |
| 47 // if the current surface is not important. | 50 // if the current surface is not important. |
| 48 virtual bool IsCurrent(GLSurface* surface) = 0; | 51 virtual bool IsCurrent(GLSurface* surface) = 0; |
| 49 | 52 |
| 50 // Get the underlying platform specific GL context "handle". | 53 // Get the underlying platform specific GL context "handle". |
| 51 virtual void* GetHandle() = 0; | 54 virtual void* GetHandle() = 0; |
| 52 | 55 |
| 56 // Creates a GPUTimingClient class which abstracts various GPU Timing exts. |
| 57 virtual scoped_refptr<gfx::GPUTimingClient> CreateGPUTimingClient() = 0; |
| 58 |
| 53 // Gets the GLStateRestorer for the context. | 59 // Gets the GLStateRestorer for the context. |
| 54 GLStateRestorer* GetGLStateRestorer(); | 60 GLStateRestorer* GetGLStateRestorer(); |
| 55 | 61 |
| 56 // Sets the GLStateRestorer for the context (takes ownership). | 62 // Sets the GLStateRestorer for the context (takes ownership). |
| 57 void SetGLStateRestorer(GLStateRestorer* state_restorer); | 63 void SetGLStateRestorer(GLStateRestorer* state_restorer); |
| 58 | 64 |
| 59 // Set swap interval. This context must be current. | 65 // Set swap interval. This context must be current. |
| 60 void SetSwapInterval(int interval); | 66 void SetSwapInterval(int interval); |
| 61 | 67 |
| 62 // Forces the swap interval to zero (no vsync) regardless of any future values | 68 // Forces the swap interval to zero (no vsync) regardless of any future values |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 172 |
| 167 int swap_interval_; | 173 int swap_interval_; |
| 168 bool force_swap_interval_zero_; | 174 bool force_swap_interval_zero_; |
| 169 | 175 |
| 170 DISALLOW_COPY_AND_ASSIGN(GLContext); | 176 DISALLOW_COPY_AND_ASSIGN(GLContext); |
| 171 }; | 177 }; |
| 172 | 178 |
| 173 class GL_EXPORT GLContextReal : public GLContext { | 179 class GL_EXPORT GLContextReal : public GLContext { |
| 174 public: | 180 public: |
| 175 explicit GLContextReal(GLShareGroup* share_group); | 181 explicit GLContextReal(GLShareGroup* share_group); |
| 182 scoped_refptr<gfx::GPUTimingClient> CreateGPUTimingClient() override; |
| 176 | 183 |
| 177 protected: | 184 protected: |
| 178 ~GLContextReal() override; | 185 ~GLContextReal() override; |
| 179 | 186 |
| 180 void SetCurrent(GLSurface* surface) override; | 187 void SetCurrent(GLSurface* surface) override; |
| 181 | 188 |
| 182 private: | 189 private: |
| 190 scoped_ptr<gfx::GPUTiming> gpu_timing_; |
| 183 DISALLOW_COPY_AND_ASSIGN(GLContextReal); | 191 DISALLOW_COPY_AND_ASSIGN(GLContextReal); |
| 184 }; | 192 }; |
| 185 | 193 |
| 186 } // namespace gfx | 194 } // namespace gfx |
| 187 | 195 |
| 188 #endif // UI_GL_GL_CONTEXT_H_ | 196 #endif // UI_GL_GL_CONTEXT_H_ |
| OLD | NEW |