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

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

Issue 1880923002: GLContext: Remove WasDirtiedExternally methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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_context.cc ('k') | no next file » | 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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // calls if the GLSurface uses the same underlying surface or renders to 537 // calls if the GLSurface uses the same underlying surface or renders to
538 // an FBO. 538 // an FBO.
539 if (switched_contexts || !current_surface || 539 if (switched_contexts || !current_surface ||
540 !virtual_context->IsCurrent(surface)) { 540 !virtual_context->IsCurrent(surface)) {
541 if (!real_context_->MakeCurrent(surface)) { 541 if (!real_context_->MakeCurrent(surface)) {
542 return false; 542 return false;
543 } 543 }
544 } 544 }
545 } 545 }
546 546
547 bool state_dirtied_externally = real_context_->GetStateWasDirtiedExternally();
548 real_context_->SetStateWasDirtiedExternally(false);
549
550 DCHECK_EQ(real_context_, GLContext::GetRealCurrent()); 547 DCHECK_EQ(real_context_, GLContext::GetRealCurrent());
551 DCHECK(real_context_->IsCurrent(NULL)); 548 DCHECK(real_context_->IsCurrent(NULL));
552 DCHECK(virtual_context->IsCurrent(surface)); 549 DCHECK(virtual_context->IsCurrent(surface));
553 550
554 if (state_dirtied_externally || switched_contexts || 551 if (switched_contexts || virtual_context != current_context_) {
555 virtual_context != current_context_) {
556 #if DCHECK_IS_ON() 552 #if DCHECK_IS_ON()
557 GLenum error = glGetErrorFn(); 553 GLenum error = glGetErrorFn();
558 // Accepting a context loss error here enables using debug mode to work on 554 // Accepting a context loss error here enables using debug mode to work on
559 // context loss handling in virtual context mode. 555 // context loss handling in virtual context mode.
560 // There should be no other errors from the previous context leaking into 556 // There should be no other errors from the previous context leaking into
561 // the new context. 557 // the new context.
562 DCHECK(error == GL_NO_ERROR || error == GL_CONTEXT_LOST_KHR) << 558 DCHECK(error == GL_NO_ERROR || error == GL_CONTEXT_LOST_KHR) <<
563 "GL error was: " << error; 559 "GL error was: " << error;
564 #endif 560 #endif
565 561
566 // Set all state that is different from the real state 562 // Set all state that is different from the real state
567 GLApi* temp = GetCurrentGLApi(); 563 GLApi* temp = GetCurrentGLApi();
568 SetGLToRealGLApi(); 564 SetGLToRealGLApi();
569 if (virtual_context->GetGLStateRestorer()->IsInitialized()) { 565 if (virtual_context->GetGLStateRestorer()->IsInitialized()) {
570 GLStateRestorer* virtual_state = virtual_context->GetGLStateRestorer(); 566 GLStateRestorer* virtual_state = virtual_context->GetGLStateRestorer();
571 GLStateRestorer* current_state = current_context_ ? 567 GLStateRestorer* current_state = current_context_ ?
572 current_context_->GetGLStateRestorer() : 568 current_context_->GetGLStateRestorer() :
573 nullptr; 569 nullptr;
574 if (switched_contexts || virtual_context != current_context_) { 570 if (switched_contexts || virtual_context != current_context_) {
575 if (current_state) 571 if (current_state)
576 current_state->PauseQueries(); 572 current_state->PauseQueries();
577 virtual_state->ResumeQueries(); 573 virtual_state->ResumeQueries();
578 } 574 }
579 575
580 virtual_state->RestoreState( 576 virtual_state->RestoreState(
581 (current_state && !state_dirtied_externally && !switched_contexts) 577 (current_state && !switched_contexts) ? current_state : NULL);
582 ? current_state
583 : NULL);
584 } 578 }
585 SetGLApi(temp); 579 SetGLApi(temp);
586 current_context_ = virtual_context; 580 current_context_ = virtual_context;
587 } 581 }
588 SetGLApi(this); 582 SetGLApi(this);
589 583
590 virtual_context->SetCurrent(surface); 584 virtual_context->SetCurrent(surface);
591 if (!surface->OnMakeCurrent(virtual_context)) { 585 if (!surface->OnMakeCurrent(virtual_context)) {
592 LOG(ERROR) << "Could not make GLSurface current."; 586 LOG(ERROR) << "Could not make GLSurface current.";
593 return false; 587 return false;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 627
634 void VirtualGLApi::glFlushFn() { 628 void VirtualGLApi::glFlushFn() {
635 GLApiBase::glFlushFn(); 629 GLApiBase::glFlushFn();
636 } 630 }
637 631
638 void VirtualGLApi::glFinishFn() { 632 void VirtualGLApi::glFinishFn() {
639 GLApiBase::glFinishFn(); 633 GLApiBase::glFinishFn();
640 } 634 }
641 635
642 } // namespace gfx 636 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698