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_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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 extensions_ = JoinString(ext, " "); | 533 extensions_ = JoinString(ext, " "); |
534 } | 534 } |
535 | 535 |
536 bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) { | 536 bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) { |
537 bool switched_contexts = g_current_gl_context_tls->Get() != this; | 537 bool switched_contexts = g_current_gl_context_tls->Get() != this; |
538 GLSurface* current_surface = GLSurface::GetCurrent(); | 538 GLSurface* current_surface = GLSurface::GetCurrent(); |
539 if (switched_contexts || surface != current_surface) { | 539 if (switched_contexts || surface != current_surface) { |
540 // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent() | 540 // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent() |
541 // calls if the GLSurface uses the same underlying surface or renders to | 541 // calls if the GLSurface uses the same underlying surface or renders to |
542 // an FBO. | 542 // an FBO. |
543 if (switched_contexts || !current_surface || | 543 if (switched_contexts || !current_surface || !surface || |
ericrk
2015/07/13 21:15:33
This is a bit weird as IsCurrent(surface) always r
| |
544 !virtual_context->IsCurrent(surface)) { | 544 !virtual_context->IsCurrent(surface)) { |
545 if (!real_context_->MakeCurrent(surface)) { | 545 if (!real_context_->MakeCurrent(surface)) { |
546 return false; | 546 return false; |
547 } | 547 } |
548 } | 548 } |
549 } | 549 } |
550 | 550 |
551 bool state_dirtied_externally = real_context_->GetStateWasDirtiedExternally(); | 551 bool state_dirtied_externally = real_context_->GetStateWasDirtiedExternally(); |
552 real_context_->SetStateWasDirtiedExternally(false); | 552 real_context_->SetStateWasDirtiedExternally(false); |
553 | 553 |
(...skipping 20 matching lines...) Expand all Loading... | |
574 (current_context_ && !state_dirtied_externally && !switched_contexts) | 574 (current_context_ && !state_dirtied_externally && !switched_contexts) |
575 ? current_context_->GetGLStateRestorer() | 575 ? current_context_->GetGLStateRestorer() |
576 : NULL); | 576 : NULL); |
577 } | 577 } |
578 SetGLApi(temp); | 578 SetGLApi(temp); |
579 current_context_ = virtual_context; | 579 current_context_ = virtual_context; |
580 } | 580 } |
581 SetGLApi(this); | 581 SetGLApi(this); |
582 | 582 |
583 virtual_context->SetCurrent(surface); | 583 virtual_context->SetCurrent(surface); |
584 if (!surface->OnMakeCurrent(virtual_context)) { | 584 if (surface && !surface->OnMakeCurrent(virtual_context)) { |
585 LOG(ERROR) << "Could not make GLSurface current."; | 585 LOG(ERROR) << "Could not make GLSurface current."; |
586 return false; | 586 return false; |
587 } | 587 } |
588 return true; | 588 return true; |
589 } | 589 } |
590 | 590 |
591 void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { | 591 void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { |
592 if (current_context_ == virtual_context) | 592 if (current_context_ == virtual_context) |
593 current_context_ = NULL; | 593 current_context_ = NULL; |
594 } | 594 } |
(...skipping 18 matching lines...) Expand all Loading... | |
613 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi() | 613 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi() |
614 : old_gl_api_(GetCurrentGLApi()) { | 614 : old_gl_api_(GetCurrentGLApi()) { |
615 SetGLToRealGLApi(); | 615 SetGLToRealGLApi(); |
616 } | 616 } |
617 | 617 |
618 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() { | 618 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() { |
619 SetGLApi(old_gl_api_); | 619 SetGLApi(old_gl_api_); |
620 } | 620 } |
621 | 621 |
622 } // namespace gfx | 622 } // namespace gfx |
OLD | NEW |