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

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

Issue 1652873002: Android: Use virtualized context only for those with compatible config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 10 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
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/cancelable_callback.h" 11 #include "base/cancelable_callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/synchronization/cancellation_flag.h" 15 #include "base/synchronization/cancellation_flag.h"
16 #include "ui/gl/gl_share_group.h" 16 #include "ui/gl/gl_share_group.h"
17 #include "ui/gl/gl_state_restorer.h" 17 #include "ui/gl/gl_state_restorer.h"
18 #include "ui/gl/gl_surface.h"
18 #include "ui/gl/gpu_preference.h" 19 #include "ui/gl/gpu_preference.h"
19 20
20 namespace gpu { 21 namespace gpu {
21 class GLContextVirtual; 22 class GLContextVirtual;
22 } // namespace gpu 23 } // namespace gpu
23 24
24 namespace gfx { 25 namespace gfx {
25 26
26 class GLSurface; 27 class GLSurface;
27 class GPUTiming; 28 class GPUTiming;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Set swap interval. This context must be current. 68 // Set swap interval. This context must be current.
68 void SetSwapInterval(int interval); 69 void SetSwapInterval(int interval);
69 70
70 // Forces the swap interval to zero (no vsync) regardless of any future values 71 // Forces the swap interval to zero (no vsync) regardless of any future values
71 // passed to SetSwapInterval. 72 // passed to SetSwapInterval.
72 void ForceSwapIntervalZero(bool force); 73 void ForceSwapIntervalZero(bool force);
73 74
74 // Returns space separated list of extensions. The context must be current. 75 // Returns space separated list of extensions. The context must be current.
75 virtual std::string GetExtensions(); 76 virtual std::string GetExtensions();
76 77
77 // Indicate that it is safe to force this context to switch GPUs, since 78 // Indicates that it is safe to force this context to switch GPUs, since
78 // transitioning can cause corruption and hangs (OS X only). 79 // transitioning can cause corruption and hangs (OS X only).
79 virtual void SetSafeToForceGpuSwitch(); 80 virtual void SetSafeToForceGpuSwitch();
80 81
81 // Attempt to force the context to move to the GPU of its sharegroup. Return 82 // Attempts to force the context to move to the GPU of its sharegroup. Return
82 // false only in the event of an unexpected error on the context. 83 // false only in the event of an unexpected error on the context.
83 virtual bool ForceGpuSwitchIfNeeded(); 84 virtual bool ForceGpuSwitchIfNeeded();
84 85
85 // Indicate that the real context switches should unbind the FBO first 86 // Indicates that the real context switches should unbind the FBO first
86 // (For an Android work-around only). 87 // (For an Android work-around only).
87 virtual void SetUnbindFboOnMakeCurrent(); 88 virtual void SetUnbindFboOnMakeCurrent();
88 89
90 // Updates the shared context to a matched configuration.
91 virtual void UpdateSharedContext(GLContext* context);
92
89 // Returns whether the current context supports the named extension. The 93 // Returns whether the current context supports the named extension. The
90 // context must be current. 94 // context must be current.
91 bool HasExtension(const char* name); 95 bool HasExtension(const char* name);
92 96
93 // Returns version info of the underlying GL context. The context must be 97 // Returns version info of the underlying GL context. The context must be
94 // current. 98 // current.
95 const GLVersionInfo* GetVersionInfo(); 99 const GLVersionInfo* GetVersionInfo();
96 100
97 GLShareGroup* share_group(); 101 GLShareGroup* share_group();
98 102
(...skipping 29 matching lines...) Expand all
128 virtual std::string GetGLRenderer(); 132 virtual std::string GetGLRenderer();
129 133
130 // Return a callback that, when called, indicates that the state the 134 // Return a callback that, when called, indicates that the state the
131 // underlying context has been changed by code outside of the command buffer, 135 // underlying context has been changed by code outside of the command buffer,
132 // and will need to be restored. 136 // and will need to be restored.
133 virtual base::Closure GetStateWasDirtiedExternallyCallback(); 137 virtual base::Closure GetStateWasDirtiedExternallyCallback();
134 138
135 // Restore the context's state if it was dirtied by an external caller. 139 // Restore the context's state if it was dirtied by an external caller.
136 virtual void RestoreStateIfDirtiedExternally(); 140 virtual void RestoreStateIfDirtiedExternally();
137 141
142 GLSurface::Format GetFormat() { return format_; }
143
138 protected: 144 protected:
139 virtual ~GLContext(); 145 virtual ~GLContext();
140 146
141 // Will release the current context when going out of scope, unless canceled. 147 // Will release the current context when going out of scope, unless canceled.
142 class ScopedReleaseCurrent { 148 class ScopedReleaseCurrent {
143 public: 149 public:
144 ScopedReleaseCurrent(); 150 ScopedReleaseCurrent();
145 ~ScopedReleaseCurrent(); 151 ~ScopedReleaseCurrent();
146 152
147 void Cancel(); 153 void Cancel();
(...skipping 12 matching lines...) Expand all
160 bool InitializeDynamicBindings(); 166 bool InitializeDynamicBindings();
161 167
162 // Returns the last real (non-virtual) GLContext made current. 168 // Returns the last real (non-virtual) GLContext made current.
163 static GLContext* GetRealCurrent(); 169 static GLContext* GetRealCurrent();
164 170
165 virtual void OnSetSwapInterval(int interval) = 0; 171 virtual void OnSetSwapInterval(int interval) = 0;
166 172
167 bool GetStateWasDirtiedExternally() const; 173 bool GetStateWasDirtiedExternally() const;
168 void SetStateWasDirtiedExternally(bool dirtied_externally); 174 void SetStateWasDirtiedExternally(bool dirtied_externally);
169 175
170 private: 176 GLSurface::Format format_;
177
178 private:
171 friend class base::RefCounted<GLContext>; 179 friend class base::RefCounted<GLContext>;
172 180
173 // For GetRealCurrent. 181 // For GetRealCurrent.
174 friend class VirtualGLApi; 182 friend class VirtualGLApi;
175 friend class gpu::GLContextVirtual; 183 friend class gpu::GLContextVirtual;
176 184
177 scoped_refptr<GLShareGroup> share_group_; 185 scoped_refptr<GLShareGroup> share_group_;
178 scoped_ptr<VirtualGLApi> virtual_gl_api_; 186 scoped_ptr<VirtualGLApi> virtual_gl_api_;
179 bool state_dirtied_externally_; 187 bool state_dirtied_externally_;
180 scoped_ptr<GLStateRestorer> state_restorer_; 188 scoped_ptr<GLStateRestorer> state_restorer_;
(...skipping 18 matching lines...) Expand all
199 void SetCurrent(GLSurface* surface) override; 207 void SetCurrent(GLSurface* surface) override;
200 208
201 private: 209 private:
202 scoped_ptr<gfx::GPUTiming> gpu_timing_; 210 scoped_ptr<gfx::GPUTiming> gpu_timing_;
203 DISALLOW_COPY_AND_ASSIGN(GLContextReal); 211 DISALLOW_COPY_AND_ASSIGN(GLContextReal);
204 }; 212 };
205 213
206 } // namespace gfx 214 } // namespace gfx
207 215
208 #endif // UI_GL_GL_CONTEXT_H_ 216 #endif // UI_GL_GL_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698