OLD | NEW |
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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 // Destroying the GLHelper may cause some async actions to be cancelled, | 606 // Destroying the GLHelper may cause some async actions to be cancelled, |
607 // causing things to request a new GLHelper. Due to crbug.com/176091 the | 607 // causing things to request a new GLHelper. Due to crbug.com/176091 the |
608 // GLHelper created in this case would be lost/leaked if we just reset() | 608 // GLHelper created in this case would be lost/leaked if we just reset() |
609 // on the |gl_helper_| variable directly. So instead we call reset() on a | 609 // on the |gl_helper_| variable directly. So instead we call reset() on a |
610 // local std::unique_ptr. | 610 // local std::unique_ptr. |
611 std::unique_ptr<display_compositor::GLHelper> helper = | 611 std::unique_ptr<display_compositor::GLHelper> helper = |
612 std::move(gl_helper_); | 612 std::move(gl_helper_); |
613 | 613 |
614 // If there are any observer left at this point, make sure they clean up | 614 // If there are any observer left at this point, make sure they clean up |
615 // before we destroy the GLHelper. | 615 // before we destroy the GLHelper. |
616 FOR_EACH_OBSERVER(ui::ContextFactoryObserver, observer_list_, | 616 for (auto& observer : observer_list_) |
617 OnLostResources()); | 617 observer.OnLostResources(); |
618 | 618 |
619 helper.reset(); | 619 helper.reset(); |
620 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " | 620 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " |
621 "GLHelper to be created."; | 621 "GLHelper to be created."; |
622 } | 622 } |
623 #if defined(OS_WIN) | 623 #if defined(OS_WIN) |
624 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( | 624 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( |
625 compositor->widget()); | 625 compositor->widget()); |
626 #endif | 626 #endif |
627 } | 627 } |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 // new resources are created if needed. | 849 // new resources are created if needed. |
850 // Kill shared contexts for both threads in tandem so they are always in | 850 // Kill shared contexts for both threads in tandem so they are always in |
851 // the same share group. | 851 // the same share group. |
852 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = | 852 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = |
853 shared_main_thread_contexts_; | 853 shared_main_thread_contexts_; |
854 shared_main_thread_contexts_ = NULL; | 854 shared_main_thread_contexts_ = NULL; |
855 | 855 |
856 std::unique_ptr<display_compositor::GLHelper> lost_gl_helper = | 856 std::unique_ptr<display_compositor::GLHelper> lost_gl_helper = |
857 std::move(gl_helper_); | 857 std::move(gl_helper_); |
858 | 858 |
859 FOR_EACH_OBSERVER(ui::ContextFactoryObserver, observer_list_, | 859 for (auto& observer : observer_list_) |
860 OnLostResources()); | 860 observer.OnLostResources(); |
861 | 861 |
862 // Kill things that use the shared context before killing the shared context. | 862 // Kill things that use the shared context before killing the shared context. |
863 lost_gl_helper.reset(); | 863 lost_gl_helper.reset(); |
864 lost_shared_main_thread_contexts = NULL; | 864 lost_shared_main_thread_contexts = NULL; |
865 } | 865 } |
866 | 866 |
867 scoped_refptr<cc::VulkanInProcessContextProvider> | 867 scoped_refptr<cc::VulkanInProcessContextProvider> |
868 GpuProcessTransportFactory::SharedVulkanContextProvider() { | 868 GpuProcessTransportFactory::SharedVulkanContextProvider() { |
869 if (!shared_vulkan_context_provider_initialized_) { | 869 if (!shared_vulkan_context_provider_initialized_) { |
870 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 870 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
871 switches::kEnableVulkan)) { | 871 switches::kEnableVulkan)) { |
872 shared_vulkan_context_provider_ = | 872 shared_vulkan_context_provider_ = |
873 cc::VulkanInProcessContextProvider::Create(); | 873 cc::VulkanInProcessContextProvider::Create(); |
874 } | 874 } |
875 | 875 |
876 shared_vulkan_context_provider_initialized_ = true; | 876 shared_vulkan_context_provider_initialized_ = true; |
877 } | 877 } |
878 return shared_vulkan_context_provider_; | 878 return shared_vulkan_context_provider_; |
879 } | 879 } |
880 | 880 |
881 } // namespace content | 881 } // namespace content |
OLD | NEW |