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

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

Issue 2852353003: Add more strict DCHECKs around context state. (Closed)
Patch Set: Created 3 years, 7 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 #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
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));
270 269
271 if (switched_real_contexts || virtual_context != current_virtual_context_) { 270 if (switched_real_contexts || virtual_context != current_virtual_context_) {
272 #if DCHECK_IS_ON() 271 #if DCHECK_IS_ON()
273 GLenum error = glGetError(); 272 GLenum error = glGetError();
274 // Accepting a context loss error here enables using debug mode to work on 273 // Accepting a context loss error here enables using debug mode to work on
275 // context loss handling in virtual context mode. 274 // context loss handling in virtual context mode.
276 // There should be no other errors from the previous context leaking into 275 // There should be no other errors from the previous context leaking into
277 // the new context. 276 // the new context.
278 DCHECK(error == GL_NO_ERROR || error == GL_CONTEXT_LOST_KHR) << 277 DCHECK(error == GL_NO_ERROR || error == GL_CONTEXT_LOST_KHR) <<
279 "GL error was: " << error; 278 "GL error was: " << error;
(...skipping 14 matching lines...) Expand all
294 (current_state && !switched_real_contexts) ? current_state : NULL); 293 (current_state && !switched_real_contexts) ? current_state : NULL);
295 } 294 }
296 current_virtual_context_ = virtual_context; 295 current_virtual_context_ = virtual_context;
297 } 296 }
298 297
299 virtual_context->SetCurrent(surface); 298 virtual_context->SetCurrent(surface);
300 if (!surface->OnMakeCurrent(virtual_context)) { 299 if (!surface->OnMakeCurrent(virtual_context)) {
301 LOG(ERROR) << "Could not make GLSurface current."; 300 LOG(ERROR) << "Could not make GLSurface current.";
302 return false; 301 return false;
303 } 302 }
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698