| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 if (switched_real_contexts || !current_surface || | 259 if (switched_real_contexts || !current_surface || |
| 260 !virtual_context->IsCurrent(surface)) { | 260 !virtual_context->IsCurrent(surface)) { |
| 261 if (!MakeCurrent(surface)) { | 261 if (!MakeCurrent(surface)) { |
| 262 return false; | 262 return false; |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 DCHECK_EQ(this, GLContext::GetRealCurrent()); | 267 DCHECK_EQ(this, GLContext::GetRealCurrent()); |
| 268 DCHECK(IsCurrent(NULL)); | 268 DCHECK(IsCurrent(NULL)); |
| 269 DCHECK(virtual_context->IsCurrent(surface)); |
| 269 | 270 |
| 270 if (switched_real_contexts || virtual_context != current_virtual_context_) { | 271 if (switched_real_contexts || virtual_context != current_virtual_context_) { |
| 271 #if DCHECK_IS_ON() | 272 #if DCHECK_IS_ON() |
| 272 GLenum error = glGetError(); | 273 GLenum error = glGetError(); |
| 273 // Accepting a context loss error here enables using debug mode to work on | 274 // Accepting a context loss error here enables using debug mode to work on |
| 274 // context loss handling in virtual context mode. | 275 // context loss handling in virtual context mode. |
| 275 // There should be no other errors from the previous context leaking into | 276 // There should be no other errors from the previous context leaking into |
| 276 // the new context. | 277 // the new context. |
| 277 DCHECK(error == GL_NO_ERROR || error == GL_CONTEXT_LOST_KHR) << | 278 DCHECK(error == GL_NO_ERROR || error == GL_CONTEXT_LOST_KHR) << |
| 278 "GL error was: " << error; | 279 "GL error was: " << error; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 293 (current_state && !switched_real_contexts) ? current_state : NULL); | 294 (current_state && !switched_real_contexts) ? current_state : NULL); |
| 294 } | 295 } |
| 295 current_virtual_context_ = virtual_context; | 296 current_virtual_context_ = virtual_context; |
| 296 } | 297 } |
| 297 | 298 |
| 298 virtual_context->SetCurrent(surface); | 299 virtual_context->SetCurrent(surface); |
| 299 if (!surface->OnMakeCurrent(virtual_context)) { | 300 if (!surface->OnMakeCurrent(virtual_context)) { |
| 300 LOG(ERROR) << "Could not make GLSurface current."; | 301 LOG(ERROR) << "Could not make GLSurface current."; |
| 301 return false; | 302 return false; |
| 302 } | 303 } |
| 303 DCHECK(virtual_context->IsCurrent(surface)); | |
| 304 return true; | 304 return true; |
| 305 } | 305 } |
| 306 | 306 |
| 307 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { | 307 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { |
| 308 if (current_virtual_context_ == virtual_context) | 308 if (current_virtual_context_ == virtual_context) |
| 309 current_virtual_context_ = nullptr; | 309 current_virtual_context_ = nullptr; |
| 310 } | 310 } |
| 311 | 311 |
| 312 void GLContext::BindGLApi() { | 312 void GLContext::BindGLApi() { |
| 313 SetCurrentGL(GetCurrentGL()); | 313 SetCurrentGL(GetCurrentGL()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 335 | 335 |
| 336 scoped_refptr<GLContext> InitializeGLContext(scoped_refptr<GLContext> context, | 336 scoped_refptr<GLContext> InitializeGLContext(scoped_refptr<GLContext> context, |
| 337 GLSurface* compatible_surface, | 337 GLSurface* compatible_surface, |
| 338 const GLContextAttribs& attribs) { | 338 const GLContextAttribs& attribs) { |
| 339 if (!context->Initialize(compatible_surface, attribs)) | 339 if (!context->Initialize(compatible_surface, attribs)) |
| 340 return nullptr; | 340 return nullptr; |
| 341 return context; | 341 return context; |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace gl | 344 } // namespace gl |
| OLD | NEW |