Index: content/browser/compositor/gpu_process_transport_factory.cc |
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc |
index 8a60ed12838d8017107585a330d04eb7f0458f8f..77d9f84fcb36d1093c2d7f7f9c0e90e0b7dc907d 100644 |
--- a/content/browser/compositor/gpu_process_transport_factory.cc |
+++ b/content/browser/compositor/gpu_process_transport_factory.cc |
@@ -303,33 +303,30 @@ void GpuProcessTransportFactory::CreateOutputSurface( |
#endif |
const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); |
- const bool use_mus = IsUsingMus(); |
const bool create_gpu_output_surface = |
ShouldCreateGpuOutputSurface(compositor.get()); |
if (create_gpu_output_surface && !use_vulkan) { |
- base::Closure callback( |
+ gpu::GpuChannelEstablishedCallback callback( |
base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
callback_factory_.GetWeakPtr(), compositor, |
create_gpu_output_surface, 0)); |
- if (!use_mus) { |
+ auto* factory = gpu::GpuChannelEstablishFactory::GetInstance(); |
+ if (factory) { |
+ factory->EstablishGpuChannel(callback); |
+ } else { |
BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback); |
- } else { |
-#if defined(MOJO_RUNNER_CLIENT) |
- ui::GpuService::GetInstance()->EstablishGpuChannel(callback); |
-#else |
- NOTREACHED(); |
-#endif |
} |
} else { |
- EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); |
+ EstablishedGpuChannel(compositor, create_gpu_output_surface, 0, nullptr); |
} |
} |
void GpuProcessTransportFactory::EstablishedGpuChannel( |
base::WeakPtr<ui::Compositor> compositor, |
bool create_gpu_output_surface, |
- int num_attempts) { |
+ int num_attempts, |
+ scoped_refptr<gpu::GpuChannelHost> established_channel_host) { |
if (!compositor) |
return; |
@@ -357,7 +354,6 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = |
SharedVulkanContextProvider(); |
- const bool use_mus = IsUsingMus(); |
scoped_refptr<ContextProviderCommandBuffer> context_provider; |
if (create_gpu_output_surface && !vulkan_context_provider) { |
// Try to reuse existing worker context provider. |
@@ -375,20 +371,8 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
} |
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
- if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { |
- // We attempted to do EstablishGpuChannel already, so we just use |
- // GetGpuChannel() instead of EstablishGpuChannelSync(). |
- if (!use_mus) { |
- gpu_channel_host = |
- BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); |
- } else { |
-#if defined(MOJO_RUNNER_CLIENT) |
- gpu_channel_host = ui::GpuService::GetInstance()->GetGpuChannel(); |
-#else |
- NOTREACHED(); |
-#endif |
- } |
- } |
+ if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
+ gpu_channel_host = std::move(established_channel_host); |
if (!gpu_channel_host) { |
shared_worker_context_provider_ = nullptr; |
@@ -453,19 +437,17 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
if (!created_gpu_browser_compositor) { |
// Try again. |
- base::Closure callback( |
+ gpu::GpuChannelEstablishedCallback callback( |
base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
callback_factory_.GetWeakPtr(), compositor, |
create_gpu_output_surface, num_attempts + 1)); |
- if (!use_mus) { |
+ auto* factory = gpu::GpuChannelEstablishFactory::GetInstance(); |
+ if (factory) { |
+ DCHECK(IsUsingMus()); |
+ factory->EstablishGpuChannel(callback); |
+ } else { |
BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback); |
- } else { |
-#if defined(MOJO_RUNNER_CLIENT) |
- ui::GpuService::GetInstance()->EstablishGpuChannel(callback); |
-#else |
- NOTREACHED(); |
-#endif |
} |
return; |
} |
@@ -533,6 +515,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
} else { |
std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
validator; |
+ const bool use_mus = IsUsingMus(); |
#if !defined(OS_MACOSX) |
// Overlays are only supported on surfaceless output surfaces on Mac. |
if (!use_mus) |
@@ -797,18 +780,14 @@ GpuProcessTransportFactory::SharedMainThreadContextProvider() { |
if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
return nullptr; |
- const bool use_mus = IsUsingMus(); |
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
- if (!use_mus) { |
+ auto* factory = gpu::GpuChannelEstablishFactory::GetInstance(); |
+ if (factory) { |
+ gpu_channel_host = factory->EstablishGpuChannelSync(); |
+ } else { |
gpu_channel_host = |
BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( |
CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT); |
- } else { |
-#if defined(MOJO_RUNNER_CLIENT) |
- gpu_channel_host = ui::GpuService::GetInstance()->EstablishGpuChannelSync(); |
-#else |
- NOTREACHED(); |
-#endif |
} |
if (!gpu_channel_host) |