Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Side by Side Diff: ui/gl/gl_context.h

Issue 222103008: Revert r258965 aka reland r258122 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/texture_definition.cc ('k') | ui/gl/gl_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/synchronization/cancellation_flag.h"
13 #include "ui/gl/gl_share_group.h" 15 #include "ui/gl/gl_share_group.h"
14 #include "ui/gl/gl_state_restorer.h" 16 #include "ui/gl/gl_state_restorer.h"
15 #include "ui/gl/gpu_preference.h" 17 #include "ui/gl/gpu_preference.h"
16 18
17 namespace gfx { 19 namespace gfx {
18 20
19 class GLSurface; 21 class GLSurface;
20 class VirtualGLApi; 22 class VirtualGLApi;
21 struct GLVersionInfo; 23 struct GLVersionInfo;
22 24
23 // Encapsulates an OpenGL context, hiding platform specific management. 25 // Encapsulates an OpenGL context, hiding platform specific management.
24 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { 26 class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
25 public: 27 public:
26 explicit GLContext(GLShareGroup* share_group); 28 explicit GLContext(GLShareGroup* share_group);
27 29
28 // 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
29 // 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
30 // 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
31 // should be specific for all platforms though. 33 // should be specific for all platforms though.
32 virtual bool Initialize( 34 virtual bool Initialize(
33 GLSurface* compatible_surface, GpuPreference gpu_preference) = 0; 35 GLSurface* compatible_surface, GpuPreference gpu_preference) = 0;
34 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
35 // Destroys the GL context. 56 // Destroys the GL context.
36 virtual void Destroy() = 0; 57 virtual void Destroy() = 0;
37 58
38 // Makes the GL context and a surface current on the current thread. 59 // Makes the GL context and a surface current on the current thread.
39 virtual bool MakeCurrent(GLSurface* surface) = 0; 60 virtual bool MakeCurrent(GLSurface* surface) = 0;
40 61
41 // Releases this GL context and surface as current on the current thread. 62 // Releases this GL context and surface as current on the current thread.
42 virtual void ReleaseCurrent(GLSurface* surface) = 0; 63 virtual void ReleaseCurrent(GLSurface* surface) = 0;
43 64
44 // Returns true if this context and surface is current. Pass a null surface 65 // Returns true if this context and surface is current. Pass a null surface
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Notify this context that |virtual_context|, that was using us, is 128 // Notify this context that |virtual_context|, that was using us, is
108 // being released or destroyed. 129 // being released or destroyed.
109 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); 130 void OnReleaseVirtuallyCurrent(GLContext* virtual_context);
110 131
111 // Returns the GL version string. The context must be current. 132 // Returns the GL version string. The context must be current.
112 virtual std::string GetGLVersion(); 133 virtual std::string GetGLVersion();
113 134
114 // Returns the GL renderer string. The context must be current. 135 // Returns the GL renderer string. The context must be current.
115 virtual std::string GetGLRenderer(); 136 virtual std::string GetGLRenderer();
116 137
138 // Called when glFlush()/glFinish() is called with this context current.
139 void OnFlush();
140
117 protected: 141 protected:
118 virtual ~GLContext(); 142 virtual ~GLContext();
119 143
120 // Will release the current context when going out of scope, unless canceled. 144 // Will release the current context when going out of scope, unless canceled.
121 class ScopedReleaseCurrent { 145 class ScopedReleaseCurrent {
122 public: 146 public:
123 ScopedReleaseCurrent(); 147 ScopedReleaseCurrent();
124 ~ScopedReleaseCurrent(); 148 ~ScopedReleaseCurrent();
125 149
126 void Cancel(); 150 void Cancel();
(...skipping 18 matching lines...) Expand all
145 friend class base::RefCounted<GLContext>; 169 friend class base::RefCounted<GLContext>;
146 170
147 // For GetRealCurrent. 171 // For GetRealCurrent.
148 friend class VirtualGLApi; 172 friend class VirtualGLApi;
149 173
150 scoped_refptr<GLShareGroup> share_group_; 174 scoped_refptr<GLShareGroup> share_group_;
151 scoped_ptr<VirtualGLApi> virtual_gl_api_; 175 scoped_ptr<VirtualGLApi> virtual_gl_api_;
152 scoped_ptr<GLStateRestorer> state_restorer_; 176 scoped_ptr<GLStateRestorer> state_restorer_;
153 scoped_ptr<GLVersionInfo> version_info_; 177 scoped_ptr<GLVersionInfo> version_info_;
154 178
179 std::vector<scoped_refptr<FlushEvent> > flush_events_;
180
155 DISALLOW_COPY_AND_ASSIGN(GLContext); 181 DISALLOW_COPY_AND_ASSIGN(GLContext);
156 }; 182 };
157 183
158 class GL_EXPORT GLContextReal : public GLContext { 184 class GL_EXPORT GLContextReal : public GLContext {
159 public: 185 public:
160 explicit GLContextReal(GLShareGroup* share_group); 186 explicit GLContextReal(GLShareGroup* share_group);
161 187
162 protected: 188 protected:
163 virtual ~GLContextReal(); 189 virtual ~GLContextReal();
164 190
165 virtual void SetCurrent(GLSurface* surface) OVERRIDE; 191 virtual void SetCurrent(GLSurface* surface) OVERRIDE;
166 192
167 private: 193 private:
168 DISALLOW_COPY_AND_ASSIGN(GLContextReal); 194 DISALLOW_COPY_AND_ASSIGN(GLContextReal);
169 }; 195 };
170 196
171 } // namespace gfx 197 } // namespace gfx
172 198
173 #endif // UI_GL_GL_CONTEXT_H_ 199 #endif // UI_GL_GL_CONTEXT_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_definition.cc ('k') | ui/gl/gl_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698