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

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

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « ui/gl/gl_enums_implementation_autogen.h ('k') | ui/gl/gl_implementation_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_gl_api_implementation.h" 5 #include "ui/gl/gl_gl_api_implementation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // calls if the GLSurface uses the same underlying surface or renders to 459 // calls if the GLSurface uses the same underlying surface or renders to
460 // an FBO. 460 // an FBO.
461 if (switched_contexts || !current_surface || 461 if (switched_contexts || !current_surface ||
462 !virtual_context->IsCurrent(surface)) { 462 !virtual_context->IsCurrent(surface)) {
463 if (!real_context_->MakeCurrent(surface)) { 463 if (!real_context_->MakeCurrent(surface)) {
464 return false; 464 return false;
465 } 465 }
466 } 466 }
467 } 467 }
468 468
469 bool state_dirtied_externally = real_context_->GetStateWasDirtiedExternally();
470 real_context_->SetStateWasDirtiedExternally(false);
471
469 DCHECK_EQ(real_context_, GLContext::GetRealCurrent()); 472 DCHECK_EQ(real_context_, GLContext::GetRealCurrent());
470 DCHECK(real_context_->IsCurrent(NULL)); 473 DCHECK(real_context_->IsCurrent(NULL));
471 DCHECK(virtual_context->IsCurrent(surface)); 474 DCHECK(virtual_context->IsCurrent(surface));
472 475
473 if (switched_contexts || virtual_context != current_context_) { 476 if (state_dirtied_externally || switched_contexts ||
477 virtual_context != current_context_) {
474 #if DCHECK_IS_ON() 478 #if DCHECK_IS_ON()
475 GLenum error = glGetErrorFn(); 479 GLenum error = glGetErrorFn();
476 // Accepting a context loss error here enables using debug mode to work on 480 // Accepting a context loss error here enables using debug mode to work on
477 // context loss handling in virtual context mode. 481 // context loss handling in virtual context mode.
478 // There should be no other errors from the previous context leaking into 482 // There should be no other errors from the previous context leaking into
479 // the new context. 483 // the new context.
480 DCHECK(error == GL_NO_ERROR || error == GL_CONTEXT_LOST_KHR); 484 DCHECK(error == GL_NO_ERROR || error == GL_CONTEXT_LOST_KHR);
481 #endif 485 #endif
482 486
483 // Set all state that is different from the real state 487 // Set all state that is different from the real state
484 GLApi* temp = GetCurrentGLApi(); 488 GLApi* temp = GetCurrentGLApi();
485 SetGLToRealGLApi(); 489 SetGLToRealGLApi();
486 if (virtual_context->GetGLStateRestorer()->IsInitialized()) { 490 if (virtual_context->GetGLStateRestorer()->IsInitialized()) {
487 virtual_context->GetGLStateRestorer()->RestoreState( 491 virtual_context->GetGLStateRestorer()->RestoreState(
488 (current_context_ && !switched_contexts) 492 (current_context_ && !state_dirtied_externally && !switched_contexts)
489 ? current_context_->GetGLStateRestorer() 493 ? current_context_->GetGLStateRestorer()
490 : NULL); 494 : NULL);
491 } 495 }
492 SetGLApi(temp); 496 SetGLApi(temp);
493 current_context_ = virtual_context; 497 current_context_ = virtual_context;
494 } 498 }
495 SetGLApi(this); 499 SetGLApi(this);
496 500
497 virtual_context->SetCurrent(surface); 501 virtual_context->SetCurrent(surface);
498 if (!surface->OnMakeCurrent(virtual_context)) { 502 if (!surface->OnMakeCurrent(virtual_context)) {
(...skipping 28 matching lines...) Expand all
527 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi() 531 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi()
528 : old_gl_api_(GetCurrentGLApi()) { 532 : old_gl_api_(GetCurrentGLApi()) {
529 SetGLToRealGLApi(); 533 SetGLToRealGLApi();
530 } 534 }
531 535
532 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() { 536 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() {
533 SetGLApi(old_gl_api_); 537 SetGLApi(old_gl_api_);
534 } 538 }
535 539
536 } // namespace gfx 540 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_enums_implementation_autogen.h ('k') | ui/gl/gl_implementation_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698