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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/cancelable_callback.h" | 12 #include "base/cancelable_callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | |
15 #include "base/synchronization/cancellation_flag.h" | 16 #include "base/synchronization/cancellation_flag.h" |
16 #include "ui/gl/gl_export.h" | 17 #include "ui/gl/gl_export.h" |
17 #include "ui/gl/gl_share_group.h" | 18 #include "ui/gl/gl_share_group.h" |
18 #include "ui/gl/gl_state_restorer.h" | 19 #include "ui/gl/gl_state_restorer.h" |
19 #include "ui/gl/gpu_preference.h" | 20 #include "ui/gl/gpu_preference.h" |
20 | 21 |
21 namespace gl { | 22 namespace gl { |
22 class YUVToRGBConverter; | 23 class YUVToRGBConverter; |
23 } // namespace gl | 24 } // namespace gl |
24 | 25 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 | 125 |
125 // Returns the GL version string. The context must be current. | 126 // Returns the GL version string. The context must be current. |
126 virtual std::string GetGLVersion(); | 127 virtual std::string GetGLVersion(); |
127 | 128 |
128 // Returns the GL renderer string. The context must be current. | 129 // Returns the GL renderer string. The context must be current. |
129 virtual std::string GetGLRenderer(); | 130 virtual std::string GetGLRenderer(); |
130 | 131 |
131 // Returns a helper structure to convert YUV textures to RGB textures. | 132 // Returns a helper structure to convert YUV textures to RGB textures. |
132 virtual YUVToRGBConverter* GetYUVToRGBConverter(); | 133 virtual YUVToRGBConverter* GetYUVToRGBConverter(); |
133 | 134 |
135 base::WeakPtr<GLContext> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } | |
piman
2016/09/22 21:24:55
The contexts already tell their GLShareGroup when
Tom (Use chromium acct)
2016/09/23 20:00:37
Done.
| |
136 | |
134 protected: | 137 protected: |
135 virtual ~GLContext(); | 138 virtual ~GLContext(); |
136 | 139 |
137 // Will release the current context when going out of scope, unless canceled. | 140 // Will release the current context when going out of scope, unless canceled. |
138 class ScopedReleaseCurrent { | 141 class ScopedReleaseCurrent { |
139 public: | 142 public: |
140 ScopedReleaseCurrent(); | 143 ScopedReleaseCurrent(); |
141 ~ScopedReleaseCurrent(); | 144 ~ScopedReleaseCurrent(); |
142 | 145 |
143 void Cancel(); | 146 void Cancel(); |
(...skipping 24 matching lines...) Expand all Loading... | |
168 | 171 |
169 scoped_refptr<GLShareGroup> share_group_; | 172 scoped_refptr<GLShareGroup> share_group_; |
170 GLContext* current_virtual_context_; | 173 GLContext* current_virtual_context_; |
171 bool state_dirtied_externally_; | 174 bool state_dirtied_externally_; |
172 std::unique_ptr<GLStateRestorer> state_restorer_; | 175 std::unique_ptr<GLStateRestorer> state_restorer_; |
173 std::unique_ptr<GLVersionInfo> version_info_; | 176 std::unique_ptr<GLVersionInfo> version_info_; |
174 | 177 |
175 int swap_interval_; | 178 int swap_interval_; |
176 bool force_swap_interval_zero_; | 179 bool force_swap_interval_zero_; |
177 | 180 |
181 base::WeakPtrFactory<GLContext> weak_factory_; | |
182 | |
178 DISALLOW_COPY_AND_ASSIGN(GLContext); | 183 DISALLOW_COPY_AND_ASSIGN(GLContext); |
179 }; | 184 }; |
180 | 185 |
181 class GL_EXPORT GLContextReal : public GLContext { | 186 class GL_EXPORT GLContextReal : public GLContext { |
182 public: | 187 public: |
183 explicit GLContextReal(GLShareGroup* share_group); | 188 explicit GLContextReal(GLShareGroup* share_group); |
184 scoped_refptr<GPUTimingClient> CreateGPUTimingClient() override; | 189 scoped_refptr<GPUTimingClient> CreateGPUTimingClient() override; |
185 | 190 |
186 protected: | 191 protected: |
187 ~GLContextReal() override; | 192 ~GLContextReal() override; |
188 | 193 |
189 void SetCurrent(GLSurface* surface) override; | 194 void SetCurrent(GLSurface* surface) override; |
190 | 195 |
191 private: | 196 private: |
192 std::unique_ptr<GPUTiming> gpu_timing_; | 197 std::unique_ptr<GPUTiming> gpu_timing_; |
193 DISALLOW_COPY_AND_ASSIGN(GLContextReal); | 198 DISALLOW_COPY_AND_ASSIGN(GLContextReal); |
194 }; | 199 }; |
195 | 200 |
196 // Wraps GLContext in scoped_refptr and tries to initializes it. Returns a | 201 // Wraps GLContext in scoped_refptr and tries to initializes it. Returns a |
197 // scoped_refptr containing the initialized GLContext or nullptr if | 202 // scoped_refptr containing the initialized GLContext or nullptr if |
198 // initialization fails. | 203 // initialization fails. |
199 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( | 204 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( |
200 scoped_refptr<GLContext> context, | 205 scoped_refptr<GLContext> context, |
201 GLSurface* compatible_surface, | 206 GLSurface* compatible_surface, |
202 GpuPreference gpu_preference); | 207 GpuPreference gpu_preference); |
203 | 208 |
204 } // namespace gl | 209 } // namespace gl |
205 | 210 |
206 #endif // UI_GL_GL_CONTEXT_H_ | 211 #endif // UI_GL_GL_CONTEXT_H_ |
OLD | NEW |