| Index: content/browser/renderer_host/compositor_impl_android.cc
|
| diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
|
| index c06a342f3ef292467ccad377375d5cb5d342fec0..a173ceb6df7c8d5784d0e2c7fcaa4df0435b9315 100644
|
| --- a/content/browser/renderer_host/compositor_impl_android.cc
|
| +++ b/content/browser/renderer_host/compositor_impl_android.cc
|
| @@ -50,10 +50,10 @@
|
| #include "components/display_compositor/compositor_overlay_candidate_validator_android.h"
|
| #include "components/display_compositor/gl_helper.h"
|
| #include "content/browser/android/child_process_launcher_android.h"
|
| -#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
|
| #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
|
| #include "content/browser/gpu/compositor_util.h"
|
| #include "content/browser/gpu/gpu_surface_tracker.h"
|
| +#include "content/browser/renderer_host/context_provider_factory_impl_android.h"
|
| #include "content/browser/renderer_host/render_widget_host_impl.h"
|
| #include "content/common/gpu/client/context_provider_command_buffer.h"
|
| #include "content/common/gpu_process_launch_causes.h"
|
| @@ -288,9 +288,6 @@ class VulkanOutputSurface : public cc::OutputSurface {
|
| };
|
| #endif
|
|
|
| -base::LazyInstance<scoped_refptr<cc::VulkanInProcessContextProvider>>
|
| - g_shared_vulkan_context_provider_android_ = LAZY_INSTANCE_INITIALIZER;
|
| -
|
| static bool g_initialized = false;
|
|
|
| base::LazyInstance<cc::SurfaceManager> g_surface_manager =
|
| @@ -341,20 +338,6 @@ uint32_t CompositorImpl::AllocateSurfaceClientId() {
|
| return ++g_surface_client_id;
|
| }
|
|
|
| -// static
|
| -scoped_refptr<cc::VulkanInProcessContextProvider>
|
| -CompositorImpl::SharedVulkanContextProviderAndroid() {
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kEnableVulkan)) {
|
| - scoped_refptr<cc::VulkanInProcessContextProvider>* context_provider =
|
| - g_shared_vulkan_context_provider_android_.Pointer();
|
| - if (!*context_provider)
|
| - *context_provider = cc::VulkanInProcessContextProvider::Create();
|
| - return *context_provider;
|
| - }
|
| - return nullptr;
|
| -}
|
| -
|
| CompositorImpl::CompositorImpl(CompositorClient* client,
|
| gfx::NativeWindow root_window)
|
| : surface_id_allocator_(
|
| @@ -491,7 +474,6 @@ void CompositorImpl::SetVisible(bool visible) {
|
| if (!host_->output_surface_lost())
|
| host_->ReleaseOutputSurface();
|
| pending_swapbuffers_ = 0;
|
| - establish_gpu_channel_timeout_.Stop();
|
| display_.reset();
|
| } else {
|
| host_->SetVisible(true);
|
| @@ -539,39 +521,14 @@ void CompositorImpl::UpdateLayerTreeHost() {
|
| }
|
| }
|
|
|
| -void CompositorImpl::OnGpuChannelEstablished() {
|
| - establish_gpu_channel_timeout_.Stop();
|
| - CreateOutputSurface();
|
| -}
|
| -
|
| -void CompositorImpl::OnGpuChannelTimeout() {
|
| - LOG(FATAL) << "Timed out waiting for GPU channel.";
|
| +void CompositorImpl::OnGpuChannelEstablished(
|
| + scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) {
|
| + CreateOutputSurface(std::move(gpu_channel_host));
|
| }
|
|
|
| void CompositorImpl::RequestNewOutputSurface() {
|
| output_surface_request_pending_ = true;
|
| -
|
| -#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \
|
| - defined(SYZYASAN) || defined(CYGPROFILE_INSTRUMENTATION)
|
| - const int64_t kGpuChannelTimeoutInSeconds = 40;
|
| -#else
|
| - const int64_t kGpuChannelTimeoutInSeconds = 10;
|
| -#endif
|
| -
|
| - BrowserGpuChannelHostFactory* factory =
|
| - BrowserGpuChannelHostFactory::instance();
|
| - if (!factory->GetGpuChannel()) {
|
| - factory->EstablishGpuChannel(
|
| - CAUSE_FOR_GPU_LAUNCH_DISPLAY_COMPOSITOR_CONTEXT,
|
| - base::Bind(&CompositorImpl::OnGpuChannelEstablished,
|
| - weak_factory_.GetWeakPtr()));
|
| - establish_gpu_channel_timeout_.Start(
|
| - FROM_HERE, base::TimeDelta::FromSeconds(kGpuChannelTimeoutInSeconds),
|
| - this, &CompositorImpl::OnGpuChannelTimeout);
|
| - return;
|
| - }
|
| -
|
| - CreateOutputSurface();
|
| + CreateOutputSurface(nullptr);
|
| }
|
|
|
| void CompositorImpl::DidInitializeOutputSurface() {
|
| @@ -586,7 +543,8 @@ void CompositorImpl::DidFailToInitializeOutputSurface() {
|
| RequestNewOutputSurface();
|
| }
|
|
|
| -void CompositorImpl::CreateOutputSurface() {
|
| +void CompositorImpl::CreateOutputSurface(
|
| + scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) {
|
| // We might have had a request from a LayerTreeHost that was then
|
| // hidden (and hidden means we don't have a native surface).
|
| // Also make sure we only handle this once.
|
| @@ -595,7 +553,8 @@ void CompositorImpl::CreateOutputSurface() {
|
|
|
| scoped_refptr<ContextProviderCommandBuffer> context_provider;
|
| scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider =
|
| - SharedVulkanContextProviderAndroid();
|
| + ContextProviderFactoryImpl::GetInstance()
|
| + ->GetSharedVulkanContextProviderAndroid();
|
| std::unique_ptr<cc::OutputSurface> display_output_surface;
|
| #if defined(ENABLE_VULKAN)
|
| std::unique_ptr<VulkanOutputSurface> vulkan_surface;
|
| @@ -611,6 +570,12 @@ void CompositorImpl::CreateOutputSurface() {
|
| }
|
| #endif
|
|
|
| + if (!gpu_channel_host) {
|
| + ContextProviderFactoryImpl::GetInstance()->RequestGpuChannel(base::Bind(
|
| + &CompositorImpl::OnGpuChannelEstablished, weak_factory_.GetWeakPtr()));
|
| + return;
|
| + }
|
| +
|
| if (!display_output_surface) {
|
| // This is used for the browser compositor (offscreen) and for the display
|
| // compositor (onscreen), so ask for capabilities needed by either one.
|
| @@ -647,17 +612,6 @@ void CompositorImpl::CreateOutputSurface() {
|
| DCHECK(window_);
|
| DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle);
|
|
|
| - BrowserGpuChannelHostFactory* factory =
|
| - BrowserGpuChannelHostFactory::instance();
|
| - scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(
|
| - factory->GetGpuChannel());
|
| - // If the channel was already lost, we'll get null back here and need to
|
| - // try again.
|
| - if (!gpu_channel_host) {
|
| - RequestNewOutputSurface();
|
| - return;
|
| - }
|
| -
|
| GURL url("chrome://gpu/CompositorImpl::CreateOutputSurface");
|
| constexpr bool automatic_flushes = false;
|
| constexpr bool support_locking = false;
|
|
|