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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 share_group_->RemoveContext(this); | 54 share_group_->RemoveContext(this); |
55 if (GetCurrent() == this) { | 55 if (GetCurrent() == this) { |
56 SetCurrent(nullptr); | 56 SetCurrent(nullptr); |
57 SetCurrentGL(nullptr); | 57 SetCurrentGL(nullptr); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 GLApi* GLContext::CreateGLApi(DriverGL* driver) { | 61 GLApi* GLContext::CreateGLApi(DriverGL* driver) { |
62 real_gl_api_ = new RealGLApi; | 62 real_gl_api_ = new RealGLApi; |
63 real_gl_api_->Initialize(driver); | 63 real_gl_api_->Initialize(driver); |
| 64 real_gl_api_->set_gl_workarounds(gl_workarounds_); |
64 return real_gl_api_; | 65 return real_gl_api_; |
65 } | 66 } |
66 | 67 |
67 void GLContext::SetSafeToForceGpuSwitch() { | 68 void GLContext::SetSafeToForceGpuSwitch() { |
68 } | 69 } |
69 | 70 |
70 bool GLContext::ForceGpuSwitchIfNeeded() { | 71 bool GLContext::ForceGpuSwitchIfNeeded() { |
71 return true; | 72 return true; |
72 } | 73 } |
73 | 74 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 GLSurface::SetCurrent(surface); | 204 GLSurface::SetCurrent(surface); |
204 // Leave the real GL api current so that unit tests work correctly. | 205 // Leave the real GL api current so that unit tests work correctly. |
205 // TODO(sievers): Remove this, but needs all gpu_unittest classes | 206 // TODO(sievers): Remove this, but needs all gpu_unittest classes |
206 // to create and make current a context. | 207 // to create and make current a context. |
207 if (!surface && GetGLImplementation() != kGLImplementationMockGL && | 208 if (!surface && GetGLImplementation() != kGLImplementationMockGL && |
208 GetGLImplementation() != kGLImplementationStubGL) { | 209 GetGLImplementation() != kGLImplementationStubGL) { |
209 SetCurrentGL(nullptr); | 210 SetCurrentGL(nullptr); |
210 } | 211 } |
211 } | 212 } |
212 | 213 |
| 214 void GLContext::SetGLWorkarounds(const GLWorkarounds& workarounds) { |
| 215 DCHECK(IsCurrent(nullptr)); |
| 216 gl_workarounds_ = workarounds; |
| 217 if (real_gl_api_) { |
| 218 real_gl_api_->set_gl_workarounds(gl_workarounds_); |
| 219 } |
| 220 } |
| 221 |
213 GLStateRestorer* GLContext::GetGLStateRestorer() { | 222 GLStateRestorer* GLContext::GetGLStateRestorer() { |
214 return state_restorer_.get(); | 223 return state_restorer_.get(); |
215 } | 224 } |
216 | 225 |
217 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) { | 226 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) { |
218 state_restorer_ = base::WrapUnique(state_restorer); | 227 state_restorer_ = base::WrapUnique(state_restorer); |
219 } | 228 } |
220 | 229 |
221 void GLContext::SetSwapInterval(int interval) { | 230 void GLContext::SetSwapInterval(int interval) { |
222 if (swap_interval_ == interval) | 231 if (swap_interval_ == interval) |
(...skipping 116 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 |