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

Unified Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 2056833002: WIP HW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/compositor/DEPS ('k') | content/browser/compositor/mus_browser_compositor_output_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2c0e1453fad86e443e081853eb71cdc6a48b3917..cc9ffb0908302e09f6a5a00bc138942c6236f960 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
@@ -255,9 +258,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()) {
- return false;
- }
+ if (shell::ShellIsRemote())
+ return mus::GpuService::UseChromeGpuCommandBuffer();
#endif
#if defined(OS_CHROMEOS)
@@ -293,15 +295,28 @@ void GpuProcessTransportFactory::CreateOutputSurface(
#endif
const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider());
+#if defined(MOJO_RUNNER_CLIENT)
+ const bool use_mus = shell::ShellIsRemote();
+#else
+ const bool use_mus = false;
+#endif
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 {
+ auto connector = MojoShellConnection::GetForProcess()->GetConnector();
+ mus::GpuService::GetInstance()->EstablishGpuChannel(connector, callback);
+#endif
+ }
} else {
EstablishedGpuChannel(compositor, create_gpu_output_surface, 0);
}
@@ -338,6 +353,11 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider =
SharedVulkanContextProvider();
+#if defined(MOJO_RUNNER_CLIENT)
+ const bool use_mus = shell::ShellIsRemote();
+#else
+ const bool use_mus = false;
+#endif
scoped_refptr<ContextProviderCommandBuffer> context_provider;
if (create_gpu_output_surface && !vulkan_context_provider) {
@@ -359,8 +379,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 +413,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 +445,20 @@ 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 {
+ auto connector = MojoShellConnection::GetForProcess()->GetConnector();
+ mus::GpuService::GetInstance()->EstablishGpuChannel(connector,
+ callback);
+#endif
+ }
return;
}
}
@@ -490,12 +527,22 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
validator;
#if !defined(OS_MACOSX)
// Overlays are only supported on surfaceless output surfaces on Mac.
- validator = CreateOverlayCandidateValidator(compositor->widget());
+// 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
+ }
}
}
}
@@ -514,33 +561,39 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
begin_frame_source.get(), compositor->task_runner().get(),
display_output_surface->capabilities().max_frames_pending));
- // The Display owns and uses the |display_output_surface| created above.
- data->display = base::MakeUnique<cc::Display>(
- surface_manager_.get(), HostSharedBitmapManager::current(),
- BrowserGpuMemoryBufferManager::current(),
- compositor->GetRendererSettings(),
- compositor->surface_id_allocator()->id_namespace(),
- std::move(begin_frame_source), std::move(display_output_surface),
- std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>(
- compositor->task_runner().get()));
-
- // The |delegated_output_surface| is given back to the compositor, it
- // delegates to the Display as its root surface. Importantly, it shares the
- // same ContextProvider as the Display's output surface.
- std::unique_ptr<cc::SurfaceDisplayOutputSurface> delegated_output_surface(
- vulkan_context_provider
- ? new cc::SurfaceDisplayOutputSurface(
- surface_manager_.get(), compositor->surface_id_allocator(),
- data->display.get(),
- static_cast<scoped_refptr<cc::VulkanContextProvider>>(
- vulkan_context_provider))
- : new cc::SurfaceDisplayOutputSurface(
- surface_manager_.get(), compositor->surface_id_allocator(),
- data->display.get(), context_provider,
- shared_worker_context_provider_));
- data->display->Resize(compositor->size());
- data->display->SetOutputIsSecure(data->output_is_secure);
- compositor->SetOutputSurface(std::move(delegated_output_surface));
+ if (!(use_mus && create_gpu_output_surface)) {
+ // The Display owns and uses the |display_output_surface| created above.
+ data->display = base::MakeUnique<cc::Display>(
+ surface_manager_.get(), HostSharedBitmapManager::current(),
+ BrowserGpuMemoryBufferManager::current(),
+ compositor->GetRendererSettings(),
+ compositor->surface_id_allocator()->id_namespace(),
+ std::move(begin_frame_source), std::move(display_output_surface),
+ std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>(
+ compositor->task_runner().get()));
+
+ // The |delegated_output_surface| is given back to the compositor, it
+ // delegates to the Display as its root surface. Importantly, it shares the
+ // same ContextProvider as the Display's output surface.
+ std::unique_ptr<cc::SurfaceDisplayOutputSurface> delegated_output_surface(
+ vulkan_context_provider
+ ? new cc::SurfaceDisplayOutputSurface(
+ surface_manager_.get(), compositor->surface_id_allocator(),
+ data->display.get(),
+ static_cast<scoped_refptr<cc::VulkanContextProvider>>(
+ vulkan_context_provider))
+ : new cc::SurfaceDisplayOutputSurface(
+ surface_manager_.get(), compositor->surface_id_allocator(),
+ data->display.get(), context_provider,
+ shared_worker_context_provider_));
+ data->display->Resize(compositor->size());
+ data->display->SetOutputIsSecure(data->output_is_secure);
+ compositor->SetOutputSurface(std::move(delegated_output_surface));
+#if defined(MOJO_RUNNER_CLIENT)
+ } else {
+ compositor->SetOutputSurface(std::move(display_output_surface));
+#endif
+ }
}
std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector(
@@ -717,9 +770,24 @@ 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));
+ scoped_refptr<gpu::GpuChannelHost> gpu_channel_host;
+
+#if defined(MOJO_RUNNER_CLIENT)
+ const bool use_mus = shell::ShellIsRemote();
+#else
+ const bool use_mus = false;
+#endif
+
+ if (!use_mus) {
+ gpu_channel_host =
+ BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(
+ CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT);
+ } else {
+ auto connector = MojoShellConnection::GetForProcess()->GetConnector();
+ gpu_channel_host =
+ mus::GpuService::GetInstance()->EstablishGpuChannelSync(connector);
+ }
+
if (!gpu_channel_host)
return nullptr;
« no previous file with comments | « content/browser/compositor/DEPS ('k') | content/browser/compositor/mus_browser_compositor_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698