| 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 805a2204090d4633185df25a17eea387d9ec1577..4d50e4b5f1e8e28847cd3f7acbaa838a57da6f73 100644
|
| --- a/content/browser/compositor/gpu_process_transport_factory.cc
|
| +++ b/content/browser/compositor/gpu_process_transport_factory.cc
|
| @@ -60,6 +60,9 @@
|
| #include "ui/gfx/geometry/size.h"
|
|
|
| #if defined(MOJO_RUNNER_CLIENT)
|
| +#include "components/mus/common/gpu_service.h"
|
| +#include "content/browser/compositor/mus_browser_compositor_output_surface.h"
|
| +#include "content/public/common/mojo_shell_connection.h"
|
| #include "services/shell/runner/common/client_util.h"
|
| #endif
|
|
|
| @@ -149,6 +152,14 @@ bool IsCALayersDisabledFromCommandLine() {
|
| }
|
| #endif
|
|
|
| +bool IsUsingMus() {
|
| +#if defined(MOJO_RUNNER_CLIENT)
|
| + return shell::ShellIsRemote();
|
| +#else
|
| + return false = false;
|
| +#endif
|
| +}
|
| +
|
| } // namespace
|
|
|
| namespace content {
|
| @@ -255,9 +266,8 @@ static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) {
|
| #if defined(MOJO_RUNNER_CLIENT)
|
| // Chrome running as a mojo app currently can only use software compositing.
|
| // TODO(rjkroege): http://crbug.com/548451
|
| - if (shell::ShellIsRemote()) {
|
| + if (shell::ShellIsRemote() && !mus::GpuService::UseChromeGpuCommandBuffer())
|
| return false;
|
| - }
|
| #endif
|
|
|
| #if defined(OS_CHROMEOS)
|
| @@ -293,15 +303,22 @@ 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) {
|
| - BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
|
| - CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT,
|
| + base::Closure callback(
|
| base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel,
|
| callback_factory_.GetWeakPtr(), compositor,
|
| create_gpu_output_surface, 0));
|
| + if (!use_mus) {
|
| + BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
|
| + CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback);
|
| +#if defined(MOJO_RUNNER_CLIENT)
|
| + } else {
|
| + mus::GpuService::GetInstance()->EstablishGpuChannel(callback);
|
| +#endif
|
| + }
|
| } else {
|
| EstablishedGpuChannel(compositor, create_gpu_output_surface, 0);
|
| }
|
| @@ -338,7 +355,7 @@ 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.
|
| @@ -359,8 +376,14 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
|
| if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) {
|
| // We attempted to do EstablishGpuChannel already, so we just use
|
| // GetGpuChannel() instead of EstablishGpuChannelSync().
|
| - gpu_channel_host =
|
| - BrowserGpuChannelHostFactory::instance()->GetGpuChannel();
|
| + if (!use_mus) {
|
| + gpu_channel_host =
|
| + BrowserGpuChannelHostFactory::instance()->GetGpuChannel();
|
| +#if defined(MOJO_RUNNER_CLIENT)
|
| + } else {
|
| + gpu_channel_host = mus::GpuService::GetInstance()->GetGpuChannel();
|
| +#endif
|
| + }
|
| }
|
|
|
| if (!gpu_channel_host) {
|
| @@ -387,9 +410,11 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
|
| // we failed to make a worker context, just start over and try again.
|
| if (shared_worker_context_provider_) {
|
| bool support_locking = false;
|
| + // For mus, we create offscreen context.
|
| context_provider = CreateContextCommon(
|
| - std::move(gpu_channel_host), data->surface_handle, support_locking,
|
| - shared_worker_context_provider_.get(),
|
| + std::move(gpu_channel_host),
|
| + use_mus ? gpu::kNullSurfaceHandle : data->surface_handle,
|
| + support_locking, shared_worker_context_provider_.get(),
|
| command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT);
|
| // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is
|
| // fixed. Tracking time in BindToCurrentThread.
|
| @@ -417,11 +442,18 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
|
|
|
| if (!created_gpu_browser_compositor) {
|
| // Try again.
|
| - BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
|
| - CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT,
|
| + base::Closure callback(
|
| base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel,
|
| callback_factory_.GetWeakPtr(), compositor,
|
| create_gpu_output_surface, num_attempts + 1));
|
| + if (!use_mus) {
|
| + BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
|
| + CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback);
|
| +#if defined(MOJO_RUNNER_CLIENT)
|
| + } else {
|
| + mus::GpuService::GetInstance()->EstablishGpuChannel(callback);
|
| +#endif
|
| + }
|
| return;
|
| }
|
| }
|
| @@ -490,12 +522,23 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
|
| validator;
|
| #if !defined(OS_MACOSX)
|
| // Overlays are only supported on surfaceless output surfaces on Mac.
|
| - validator = CreateOverlayCandidateValidator(compositor->widget());
|
| + if (!use_mus)
|
| + validator = CreateOverlayCandidateValidator(compositor->widget());
|
| #endif
|
| - display_output_surface =
|
| - base::WrapUnique(new GpuBrowserCompositorOutputSurface(
|
| - context_provider, compositor->vsync_manager(),
|
| - begin_frame_source.get(), std::move(validator)));
|
| + if (!use_mus) {
|
| + display_output_surface =
|
| + base::WrapUnique(new GpuBrowserCompositorOutputSurface(
|
| + context_provider, compositor->vsync_manager(),
|
| + begin_frame_source.get(), std::move(validator)));
|
| +#if defined(MOJO_RUNNER_CLIENT)
|
| + } else {
|
| + display_output_surface =
|
| + base::WrapUnique(new MusBrowserCompositorOutputSurface(
|
| + data->surface_handle, context_provider,
|
| + compositor->vsync_manager(), begin_frame_source.get(),
|
| + std::move(validator)));
|
| +#endif
|
| + }
|
| }
|
| }
|
| }
|
| @@ -717,9 +760,18 @@ GpuProcessTransportFactory::SharedMainThreadContextProvider() {
|
|
|
| if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor())
|
| return nullptr;
|
| - scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(
|
| - BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(
|
| - CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT));
|
| +
|
| + const bool use_mus = IsUsingMus();
|
| + scoped_refptr<gpu::GpuChannelHost> gpu_channel_host;
|
| + if (!use_mus) {
|
| + gpu_channel_host =
|
| + BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(
|
| + CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT);
|
| + } else {
|
| + gpu_channel_host =
|
| + mus::GpuService::GetInstance()->EstablishGpuChannelSync();
|
| + }
|
| +
|
| if (!gpu_channel_host)
|
| return nullptr;
|
|
|
|
|