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

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 2083853002: exo: Recreate Surface resources on context lost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix browser test Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/compositor/gpu_process_transport_factory.h" 5 #include "content/browser/compositor/gpu_process_transport_factory.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // Destroying the GLHelper may cause some async actions to be cancelled, 582 // Destroying the GLHelper may cause some async actions to be cancelled,
583 // causing things to request a new GLHelper. Due to crbug.com/176091 the 583 // causing things to request a new GLHelper. Due to crbug.com/176091 the
584 // GLHelper created in this case would be lost/leaked if we just reset() 584 // GLHelper created in this case would be lost/leaked if we just reset()
585 // on the |gl_helper_| variable directly. So instead we call reset() on a 585 // on the |gl_helper_| variable directly. So instead we call reset() on a
586 // local std::unique_ptr. 586 // local std::unique_ptr.
587 std::unique_ptr<display_compositor::GLHelper> helper = 587 std::unique_ptr<display_compositor::GLHelper> helper =
588 std::move(gl_helper_); 588 std::move(gl_helper_);
589 589
590 // If there are any observer left at this point, make sure they clean up 590 // If there are any observer left at this point, make sure they clean up
591 // before we destroy the GLHelper. 591 // before we destroy the GLHelper.
592 FOR_EACH_OBSERVER( 592 FOR_EACH_OBSERVER(ui::ContextFactoryObserver, observer_list_,
593 ImageTransportFactoryObserver, observer_list_, OnLostResources()); 593 OnLostResources());
594 594
595 helper.reset(); 595 helper.reset();
596 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " 596 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new "
597 "GLHelper to be created."; 597 "GLHelper to be created.";
598 } 598 }
599 #if defined(OS_WIN) 599 #if defined(OS_WIN)
600 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( 600 gfx::RenderingWindowManager::GetInstance()->UnregisterParent(
601 compositor->widget()); 601 compositor->widget());
602 #endif 602 #endif
603 } 603 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if (!gl_helper_ && !per_compositor_data_.empty()) { 679 if (!gl_helper_ && !per_compositor_data_.empty()) {
680 scoped_refptr<cc::ContextProvider> provider = 680 scoped_refptr<cc::ContextProvider> provider =
681 SharedMainThreadContextProvider(); 681 SharedMainThreadContextProvider();
682 if (provider.get()) 682 if (provider.get())
683 gl_helper_.reset(new display_compositor::GLHelper( 683 gl_helper_.reset(new display_compositor::GLHelper(
684 provider->ContextGL(), provider->ContextSupport())); 684 provider->ContextGL(), provider->ContextSupport()));
685 } 685 }
686 return gl_helper_.get(); 686 return gl_helper_.get();
687 } 687 }
688 688
689 void GpuProcessTransportFactory::AddObserver(
690 ImageTransportFactoryObserver* observer) {
691 observer_list_.AddObserver(observer);
692 }
693
694 void GpuProcessTransportFactory::RemoveObserver(
695 ImageTransportFactoryObserver* observer) {
696 observer_list_.RemoveObserver(observer);
697 }
698
699 #if defined(OS_MACOSX) 689 #if defined(OS_MACOSX)
700 void GpuProcessTransportFactory::SetCompositorSuspendedForRecycle( 690 void GpuProcessTransportFactory::SetCompositorSuspendedForRecycle(
701 ui::Compositor* compositor, 691 ui::Compositor* compositor,
702 bool suspended) { 692 bool suspended) {
703 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); 693 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor);
704 if (it == per_compositor_data_.end()) 694 if (it == per_compositor_data_.end())
705 return; 695 return;
706 PerCompositorData* data = it->second; 696 PerCompositorData* data = it->second;
707 DCHECK(data); 697 DCHECK(data);
708 if (data->display_output_surface) 698 if (data->display_output_surface)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 // new resources are created if needed. 771 // new resources are created if needed.
782 // Kill shared contexts for both threads in tandem so they are always in 772 // Kill shared contexts for both threads in tandem so they are always in
783 // the same share group. 773 // the same share group.
784 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = 774 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts =
785 shared_main_thread_contexts_; 775 shared_main_thread_contexts_;
786 shared_main_thread_contexts_ = NULL; 776 shared_main_thread_contexts_ = NULL;
787 777
788 std::unique_ptr<display_compositor::GLHelper> lost_gl_helper = 778 std::unique_ptr<display_compositor::GLHelper> lost_gl_helper =
789 std::move(gl_helper_); 779 std::move(gl_helper_);
790 780
791 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, 781 FOR_EACH_OBSERVER(ui::ContextFactoryObserver, observer_list_,
792 observer_list_,
793 OnLostResources()); 782 OnLostResources());
794 783
795 // Kill things that use the shared context before killing the shared context. 784 // Kill things that use the shared context before killing the shared context.
796 lost_gl_helper.reset(); 785 lost_gl_helper.reset();
797 lost_shared_main_thread_contexts = NULL; 786 lost_shared_main_thread_contexts = NULL;
798 } 787 }
799 788
800 scoped_refptr<cc::VulkanInProcessContextProvider> 789 scoped_refptr<cc::VulkanInProcessContextProvider>
801 GpuProcessTransportFactory::SharedVulkanContextProvider() { 790 GpuProcessTransportFactory::SharedVulkanContextProvider() {
802 if (!shared_vulkan_context_provider_initialized_) { 791 if (!shared_vulkan_context_provider_initialized_) {
803 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 792 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
804 switches::kEnableVulkan)) { 793 switches::kEnableVulkan)) {
805 shared_vulkan_context_provider_ = 794 shared_vulkan_context_provider_ =
806 cc::VulkanInProcessContextProvider::Create(); 795 cc::VulkanInProcessContextProvider::Create();
807 } 796 }
808 797
809 shared_vulkan_context_provider_initialized_ = true; 798 shared_vulkan_context_provider_initialized_ = true;
810 } 799 }
811 return shared_vulkan_context_provider_; 800 return shared_vulkan_context_provider_;
812 } 801 }
813 802
814 } // namespace content 803 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698