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 #include "ui/gl/gl_context.h" | 5 #include "ui/gl/gl_context.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 GLSurface::SetCurrent(surface); | 203 GLSurface::SetCurrent(surface); |
204 // Leave the real GL api current so that unit tests work correctly. | 204 // Leave the real GL api current so that unit tests work correctly. |
205 // TODO(sievers): Remove this, but needs all gpu_unittest classes | 205 // TODO(sievers): Remove this, but needs all gpu_unittest classes |
206 // to create and make current a context. | 206 // to create and make current a context. |
207 if (!surface && GetGLImplementation() != kGLImplementationMockGL && | 207 if (!surface && GetGLImplementation() != kGLImplementationMockGL && |
208 GetGLImplementation() != kGLImplementationStubGL) { | 208 GetGLImplementation() != kGLImplementationStubGL) { |
209 SetCurrentGL(nullptr); | 209 SetCurrentGL(nullptr); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 GLWorkarounds GLContext::GetGLWorkarounds() { | |
214 return gl_workarounds_; | |
215 } | |
216 | |
217 void GLContext::SetGLWorkarounds(const GLWorkarounds& workarounds) { | |
218 gl_workarounds_ = workarounds; | |
219 } | |
220 | |
213 GLStateRestorer* GLContext::GetGLStateRestorer() { | 221 GLStateRestorer* GLContext::GetGLStateRestorer() { |
214 return state_restorer_.get(); | 222 return state_restorer_.get(); |
215 } | 223 } |
216 | 224 |
217 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) { | 225 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) { |
218 state_restorer_ = base::WrapUnique(state_restorer); | 226 state_restorer_ = base::WrapUnique(state_restorer); |
219 } | 227 } |
220 | 228 |
221 void GLContext::SetSwapInterval(int interval) { | 229 void GLContext::SetSwapInterval(int interval) { |
222 if (swap_interval_ == interval) | 230 if (swap_interval_ == interval) |
(...skipping 13 matching lines...) Expand all Loading... | |
236 return false; | 244 return false; |
237 } | 245 } |
238 | 246 |
239 void GLContext::InitializeDynamicBindings() { | 247 void GLContext::InitializeDynamicBindings() { |
240 DCHECK(IsCurrent(nullptr)); | 248 DCHECK(IsCurrent(nullptr)); |
241 DCHECK(static_bindings_initialized_); | 249 DCHECK(static_bindings_initialized_); |
242 if (!dynamic_bindings_initialized_) { | 250 if (!dynamic_bindings_initialized_) { |
243 if (real_gl_api_) { | 251 if (real_gl_api_) { |
244 real_gl_api_->InitializeFilteredExtensions(); | 252 real_gl_api_->InitializeFilteredExtensions(); |
245 real_gl_api_->set_version(GenerateGLVersionInfo()); | 253 real_gl_api_->set_version(GenerateGLVersionInfo()); |
254 real_gl_api_->setGLContext(this); | |
Zhenyao Mo
2017/06/26 21:45:22
This is less optimal. GLContext owns real_gl_api_
jiajia.qin
2017/06/28 10:03:38
Sorry for so many iterations. Please check the new
| |
246 } | 255 } |
247 | 256 |
248 driver_gl_->InitializeDynamicBindings(GetVersionInfo(), GetExtensions()); | 257 driver_gl_->InitializeDynamicBindings(GetVersionInfo(), GetExtensions()); |
249 dynamic_bindings_initialized_ = true; | 258 dynamic_bindings_initialized_ = true; |
250 } | 259 } |
251 } | 260 } |
252 | 261 |
253 bool GLContext::MakeVirtuallyCurrent( | 262 bool GLContext::MakeVirtuallyCurrent( |
254 GLContext* virtual_context, GLSurface* surface) { | 263 GLContext* virtual_context, GLSurface* surface) { |
255 if (!ForceGpuSwitchIfNeeded()) | 264 if (!ForceGpuSwitchIfNeeded()) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 | 348 |
340 scoped_refptr<GLContext> InitializeGLContext(scoped_refptr<GLContext> context, | 349 scoped_refptr<GLContext> InitializeGLContext(scoped_refptr<GLContext> context, |
341 GLSurface* compatible_surface, | 350 GLSurface* compatible_surface, |
342 const GLContextAttribs& attribs) { | 351 const GLContextAttribs& attribs) { |
343 if (!context->Initialize(compatible_surface, attribs)) | 352 if (!context->Initialize(compatible_surface, attribs)) |
344 return nullptr; | 353 return nullptr; |
345 return context; | 354 return context; |
346 } | 355 } |
347 | 356 |
348 } // namespace gl | 357 } // namespace gl |
OLD | NEW |