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

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

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « ui/gl/gl_bindings_autogen_mock.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 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/cancelable_callback.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/synchronization/cancellation_flag.h" 15 #include "base/synchronization/cancellation_flag.h"
15 #include "ui/gl/gl_share_group.h" 16 #include "ui/gl/gl_share_group.h"
16 #include "ui/gl/gl_state_restorer.h" 17 #include "ui/gl/gl_state_restorer.h"
17 #include "ui/gl/gpu_preference.h" 18 #include "ui/gl/gpu_preference.h"
18 19
20 namespace gpu {
21 class GLContextVirtual;
22 } // namespace gpu
23
19 namespace gfx { 24 namespace gfx {
20 25
21 class GLSurface; 26 class GLSurface;
22 class GPUTiming; 27 class GPUTiming;
23 class GPUTimingClient; 28 class GPUTimingClient;
24 class VirtualGLApi; 29 class VirtualGLApi;
25 struct GLVersionInfo; 30 struct GLVersionInfo;
26 31
27 32
28 // Encapsulates an OpenGL context, hiding platform specific management. 33 // Encapsulates an OpenGL context, hiding platform specific management.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Notify this context that |virtual_context|, that was using us, is 128 // Notify this context that |virtual_context|, that was using us, is
124 // being released or destroyed. 129 // being released or destroyed.
125 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); 130 void OnReleaseVirtuallyCurrent(GLContext* virtual_context);
126 131
127 // Returns the GL version string. The context must be current. 132 // Returns the GL version string. The context must be current.
128 virtual std::string GetGLVersion(); 133 virtual std::string GetGLVersion();
129 134
130 // Returns the GL renderer string. The context must be current. 135 // Returns the GL renderer string. The context must be current.
131 virtual std::string GetGLRenderer(); 136 virtual std::string GetGLRenderer();
132 137
138 // Return a callback that, when called, indicates that the state the
139 // underlying context has been changed by code outside of the command buffer,
140 // and will need to be restored.
141 virtual base::Closure GetStateWasDirtiedExternallyCallback();
142
143 // Restore the context's state if it was dirtied by an external caller.
144 virtual void RestoreStateIfDirtiedExternally();
145
133 protected: 146 protected:
134 virtual ~GLContext(); 147 virtual ~GLContext();
135 148
136 // Will release the current context when going out of scope, unless canceled. 149 // Will release the current context when going out of scope, unless canceled.
137 class ScopedReleaseCurrent { 150 class ScopedReleaseCurrent {
138 public: 151 public:
139 ScopedReleaseCurrent(); 152 ScopedReleaseCurrent();
140 ~ScopedReleaseCurrent(); 153 ~ScopedReleaseCurrent();
141 154
142 void Cancel(); 155 void Cancel();
143 156
144 private: 157 private:
145 bool canceled_; 158 bool canceled_;
146 }; 159 };
147 160
148 // Sets the GL api to the real hardware API (vs the VirtualAPI) 161 // Sets the GL api to the real hardware API (vs the VirtualAPI)
149 static void SetRealGLApi(); 162 static void SetRealGLApi();
150 virtual void SetCurrent(GLSurface* surface); 163 virtual void SetCurrent(GLSurface* surface);
151 164
152 // Initialize function pointers to functions where the bound version depends 165 // Initialize function pointers to functions where the bound version depends
153 // on GL version or supported extensions. Should be called immediately after 166 // on GL version or supported extensions. Should be called immediately after
154 // this context is made current. 167 // this context is made current.
155 bool InitializeDynamicBindings(); 168 bool InitializeDynamicBindings();
156 169
157 // Returns the last real (non-virtual) GLContext made current. 170 // Returns the last real (non-virtual) GLContext made current.
158 static GLContext* GetRealCurrent(); 171 static GLContext* GetRealCurrent();
159 172
160 virtual void OnSetSwapInterval(int interval) = 0; 173 virtual void OnSetSwapInterval(int interval) = 0;
161 174
175 bool GetStateWasDirtiedExternally() const;
176 void SetStateWasDirtiedExternally(bool dirtied_externally);
177
162 private: 178 private:
163 friend class base::RefCounted<GLContext>; 179 friend class base::RefCounted<GLContext>;
164 180
165 // For GetRealCurrent. 181 // For GetRealCurrent.
166 friend class VirtualGLApi; 182 friend class VirtualGLApi;
183 friend class gpu::GLContextVirtual;
167 184
168 scoped_refptr<GLShareGroup> share_group_; 185 scoped_refptr<GLShareGroup> share_group_;
169 scoped_ptr<VirtualGLApi> virtual_gl_api_; 186 scoped_ptr<VirtualGLApi> virtual_gl_api_;
187 bool state_dirtied_externally_;
170 scoped_ptr<GLStateRestorer> state_restorer_; 188 scoped_ptr<GLStateRestorer> state_restorer_;
171 scoped_ptr<GLVersionInfo> version_info_; 189 scoped_ptr<GLVersionInfo> version_info_;
172 190
173 int swap_interval_; 191 int swap_interval_;
174 bool force_swap_interval_zero_; 192 bool force_swap_interval_zero_;
175 193
194 base::CancelableCallback<void()> state_dirtied_callback_;
195
176 DISALLOW_COPY_AND_ASSIGN(GLContext); 196 DISALLOW_COPY_AND_ASSIGN(GLContext);
177 }; 197 };
178 198
179 class GL_EXPORT GLContextReal : public GLContext { 199 class GL_EXPORT GLContextReal : public GLContext {
180 public: 200 public:
181 explicit GLContextReal(GLShareGroup* share_group); 201 explicit GLContextReal(GLShareGroup* share_group);
182 scoped_refptr<gfx::GPUTimingClient> CreateGPUTimingClient() override; 202 scoped_refptr<gfx::GPUTimingClient> CreateGPUTimingClient() override;
183 203
184 protected: 204 protected:
185 ~GLContextReal() override; 205 ~GLContextReal() override;
186 206
187 void SetCurrent(GLSurface* surface) override; 207 void SetCurrent(GLSurface* surface) override;
188 208
189 private: 209 private:
190 scoped_ptr<gfx::GPUTiming> gpu_timing_; 210 scoped_ptr<gfx::GPUTiming> gpu_timing_;
191 DISALLOW_COPY_AND_ASSIGN(GLContextReal); 211 DISALLOW_COPY_AND_ASSIGN(GLContextReal);
192 }; 212 };
193 213
194 } // namespace gfx 214 } // namespace gfx
195 215
196 #endif // UI_GL_GL_CONTEXT_H_ 216 #endif // UI_GL_GL_CONTEXT_H_
OLDNEW
« no previous file with comments | « ui/gl/gl_bindings_autogen_mock.cc ('k') | ui/gl/gl_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698