| 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 16 matching lines...) Expand all Loading... |
| 27 public: | 27 public: |
| 28 explicit GLContext(GLShareGroup* share_group); | 28 explicit GLContext(GLShareGroup* share_group); |
| 29 | 29 |
| 30 // Initializes the GL context to be compatible with the given surface. The GL | 30 // 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 | 31 // 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 | 32 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It |
| 33 // should be specific for all platforms though. | 33 // should be specific for all platforms though. |
| 34 virtual bool Initialize( | 34 virtual bool Initialize( |
| 35 GLSurface* compatible_surface, GpuPreference gpu_preference) = 0; | 35 GLSurface* compatible_surface, GpuPreference gpu_preference) = 0; |
| 36 | 36 |
| 37 class FlushEvent : public base::RefCountedThreadSafe<FlushEvent> { | |
| 38 public: | |
| 39 bool IsSignaled(); | |
| 40 | |
| 41 private: | |
| 42 friend class base::RefCountedThreadSafe<FlushEvent>; | |
| 43 friend class GLContext; | |
| 44 FlushEvent(); | |
| 45 virtual ~FlushEvent(); | |
| 46 void Signal(); | |
| 47 | |
| 48 base::CancellationFlag flag_; | |
| 49 }; | |
| 50 | |
| 51 // Needs to be called with this context current. It will return a FlushEvent | |
| 52 // that is initially unsignaled, but will transition to signaled after the | |
| 53 // next glFlush() or glFinish() occurs in this context. | |
| 54 scoped_refptr<FlushEvent> SignalFlush(); | |
| 55 | |
| 56 // Destroys the GL context. | 37 // Destroys the GL context. |
| 57 virtual void Destroy() = 0; | 38 virtual void Destroy() = 0; |
| 58 | 39 |
| 59 // Makes the GL context and a surface current on the current thread. | 40 // Makes the GL context and a surface current on the current thread. |
| 60 virtual bool MakeCurrent(GLSurface* surface) = 0; | 41 virtual bool MakeCurrent(GLSurface* surface) = 0; |
| 61 | 42 |
| 62 // Releases this GL context and surface as current on the current thread. | 43 // Releases this GL context and surface as current on the current thread. |
| 63 virtual void ReleaseCurrent(GLSurface* surface) = 0; | 44 virtual void ReleaseCurrent(GLSurface* surface) = 0; |
| 64 | 45 |
| 65 // Returns true if this context and surface is current. Pass a null surface | 46 // Returns true if this context and surface is current. Pass a null surface |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Notify this context that |virtual_context|, that was using us, is | 117 // Notify this context that |virtual_context|, that was using us, is |
| 137 // being released or destroyed. | 118 // being released or destroyed. |
| 138 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); | 119 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); |
| 139 | 120 |
| 140 // Returns the GL version string. The context must be current. | 121 // Returns the GL version string. The context must be current. |
| 141 virtual std::string GetGLVersion(); | 122 virtual std::string GetGLVersion(); |
| 142 | 123 |
| 143 // Returns the GL renderer string. The context must be current. | 124 // Returns the GL renderer string. The context must be current. |
| 144 virtual std::string GetGLRenderer(); | 125 virtual std::string GetGLRenderer(); |
| 145 | 126 |
| 146 // Called when glFlush()/glFinish() is called with this context current. | |
| 147 void OnFlush(); | |
| 148 | |
| 149 protected: | 127 protected: |
| 150 virtual ~GLContext(); | 128 virtual ~GLContext(); |
| 151 | 129 |
| 152 // Will release the current context when going out of scope, unless canceled. | 130 // Will release the current context when going out of scope, unless canceled. |
| 153 class ScopedReleaseCurrent { | 131 class ScopedReleaseCurrent { |
| 154 public: | 132 public: |
| 155 ScopedReleaseCurrent(); | 133 ScopedReleaseCurrent(); |
| 156 ~ScopedReleaseCurrent(); | 134 ~ScopedReleaseCurrent(); |
| 157 | 135 |
| 158 void Cancel(); | 136 void Cancel(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 179 friend class base::RefCounted<GLContext>; | 157 friend class base::RefCounted<GLContext>; |
| 180 | 158 |
| 181 // For GetRealCurrent. | 159 // For GetRealCurrent. |
| 182 friend class VirtualGLApi; | 160 friend class VirtualGLApi; |
| 183 | 161 |
| 184 scoped_refptr<GLShareGroup> share_group_; | 162 scoped_refptr<GLShareGroup> share_group_; |
| 185 scoped_ptr<VirtualGLApi> virtual_gl_api_; | 163 scoped_ptr<VirtualGLApi> virtual_gl_api_; |
| 186 scoped_ptr<GLStateRestorer> state_restorer_; | 164 scoped_ptr<GLStateRestorer> state_restorer_; |
| 187 scoped_ptr<GLVersionInfo> version_info_; | 165 scoped_ptr<GLVersionInfo> version_info_; |
| 188 | 166 |
| 189 std::vector<scoped_refptr<FlushEvent> > flush_events_; | |
| 190 | |
| 191 int swap_interval_; | 167 int swap_interval_; |
| 192 bool force_swap_interval_zero_; | 168 bool force_swap_interval_zero_; |
| 193 | 169 |
| 194 DISALLOW_COPY_AND_ASSIGN(GLContext); | 170 DISALLOW_COPY_AND_ASSIGN(GLContext); |
| 195 }; | 171 }; |
| 196 | 172 |
| 197 class GL_EXPORT GLContextReal : public GLContext { | 173 class GL_EXPORT GLContextReal : public GLContext { |
| 198 public: | 174 public: |
| 199 explicit GLContextReal(GLShareGroup* share_group); | 175 explicit GLContextReal(GLShareGroup* share_group); |
| 200 | 176 |
| 201 protected: | 177 protected: |
| 202 ~GLContextReal() override; | 178 ~GLContextReal() override; |
| 203 | 179 |
| 204 void SetCurrent(GLSurface* surface) override; | 180 void SetCurrent(GLSurface* surface) override; |
| 205 | 181 |
| 206 private: | 182 private: |
| 207 DISALLOW_COPY_AND_ASSIGN(GLContextReal); | 183 DISALLOW_COPY_AND_ASSIGN(GLContextReal); |
| 208 }; | 184 }; |
| 209 | 185 |
| 210 } // namespace gfx | 186 } // namespace gfx |
| 211 | 187 |
| 212 #endif // UI_GL_GL_CONTEXT_H_ | 188 #endif // UI_GL_GL_CONTEXT_H_ |
| OLD | NEW |