| 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 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // Get the underlying platform specific GL context "handle". | 69 // Get the underlying platform specific GL context "handle". |
| 70 virtual void* GetHandle() = 0; | 70 virtual void* GetHandle() = 0; |
| 71 | 71 |
| 72 // Gets the GLStateRestorer for the context. | 72 // Gets the GLStateRestorer for the context. |
| 73 GLStateRestorer* GetGLStateRestorer(); | 73 GLStateRestorer* GetGLStateRestorer(); |
| 74 | 74 |
| 75 // Sets the GLStateRestorer for the context (takes ownership). | 75 // Sets the GLStateRestorer for the context (takes ownership). |
| 76 void SetGLStateRestorer(GLStateRestorer* state_restorer); | 76 void SetGLStateRestorer(GLStateRestorer* state_restorer); |
| 77 | 77 |
| 78 // Set swap interval. This context must be current. | 78 // Set swap interval. This context must be current. |
| 79 virtual void SetSwapInterval(int interval) = 0; | 79 void SetSwapInterval(int interval); |
| 80 |
| 81 // Forces the swap interval to zero (no vsync) regardless of any future values |
| 82 // passed to SetSwapInterval. |
| 83 void ForceSwapIntervalZero(bool force); |
| 80 | 84 |
| 81 // Returns space separated list of extensions. The context must be current. | 85 // Returns space separated list of extensions. The context must be current. |
| 82 virtual std::string GetExtensions(); | 86 virtual std::string GetExtensions(); |
| 83 | 87 |
| 84 // Returns in bytes the total amount of GPU memory for the GPU which this | 88 // Returns in bytes the total amount of GPU memory for the GPU which this |
| 85 // context is currently rendering on. Returns false if no extension exists | 89 // context is currently rendering on. Returns false if no extension exists |
| 86 // to get the exact amount of GPU memory. | 90 // to get the exact amount of GPU memory. |
| 87 virtual bool GetTotalGpuMemory(size_t* bytes); | 91 virtual bool GetTotalGpuMemory(size_t* bytes); |
| 88 | 92 |
| 89 // Indicate that it is safe to force this context to switch GPUs, since | 93 // Indicate that it is safe to force this context to switch GPUs, since |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 virtual void SetCurrent(GLSurface* surface); | 166 virtual void SetCurrent(GLSurface* surface); |
| 163 | 167 |
| 164 // Initialize function pointers to functions where the bound version depends | 168 // Initialize function pointers to functions where the bound version depends |
| 165 // on GL version or supported extensions. Should be called immediately after | 169 // on GL version or supported extensions. Should be called immediately after |
| 166 // this context is made current. | 170 // this context is made current. |
| 167 bool InitializeDynamicBindings(); | 171 bool InitializeDynamicBindings(); |
| 168 | 172 |
| 169 // Returns the last real (non-virtual) GLContext made current. | 173 // Returns the last real (non-virtual) GLContext made current. |
| 170 static GLContext* GetRealCurrent(); | 174 static GLContext* GetRealCurrent(); |
| 171 | 175 |
| 176 virtual void OnSetSwapInterval(int interval) = 0; |
| 177 |
| 172 private: | 178 private: |
| 173 friend class base::RefCounted<GLContext>; | 179 friend class base::RefCounted<GLContext>; |
| 174 | 180 |
| 175 // For GetRealCurrent. | 181 // For GetRealCurrent. |
| 176 friend class VirtualGLApi; | 182 friend class VirtualGLApi; |
| 177 | 183 |
| 178 scoped_refptr<GLShareGroup> share_group_; | 184 scoped_refptr<GLShareGroup> share_group_; |
| 179 scoped_ptr<VirtualGLApi> virtual_gl_api_; | 185 scoped_ptr<VirtualGLApi> virtual_gl_api_; |
| 180 scoped_ptr<GLStateRestorer> state_restorer_; | 186 scoped_ptr<GLStateRestorer> state_restorer_; |
| 181 scoped_ptr<GLVersionInfo> version_info_; | 187 scoped_ptr<GLVersionInfo> version_info_; |
| 182 | 188 |
| 183 std::vector<scoped_refptr<FlushEvent> > flush_events_; | 189 std::vector<scoped_refptr<FlushEvent> > flush_events_; |
| 184 | 190 |
| 191 int swap_interval_; |
| 192 bool force_swap_interval_zero_; |
| 193 |
| 185 DISALLOW_COPY_AND_ASSIGN(GLContext); | 194 DISALLOW_COPY_AND_ASSIGN(GLContext); |
| 186 }; | 195 }; |
| 187 | 196 |
| 188 class GL_EXPORT GLContextReal : public GLContext { | 197 class GL_EXPORT GLContextReal : public GLContext { |
| 189 public: | 198 public: |
| 190 explicit GLContextReal(GLShareGroup* share_group); | 199 explicit GLContextReal(GLShareGroup* share_group); |
| 191 | 200 |
| 192 protected: | 201 protected: |
| 193 ~GLContextReal() override; | 202 ~GLContextReal() override; |
| 194 | 203 |
| 195 void SetCurrent(GLSurface* surface) override; | 204 void SetCurrent(GLSurface* surface) override; |
| 196 | 205 |
| 197 private: | 206 private: |
| 198 DISALLOW_COPY_AND_ASSIGN(GLContextReal); | 207 DISALLOW_COPY_AND_ASSIGN(GLContextReal); |
| 199 }; | 208 }; |
| 200 | 209 |
| 201 } // namespace gfx | 210 } // namespace gfx |
| 202 | 211 |
| 203 #endif // UI_GL_GL_CONTEXT_H_ | 212 #endif // UI_GL_GL_CONTEXT_H_ |
| OLD | NEW |