Commit 0dad9bc7 authored by kylechar's avatar kylechar Committed by Commit Bot

Reland "Add in-process VizCompositorThread for software compositing."

This reverts commit 2b20bcdd.

Reason for revert: Relanding after reverting https://crrev.com/c/1156998.

Original change's description:
> Revert "Add in-process VizCompositorThread for software compositing."
>
> This reverts commit 7d8b7c2d.
>
> Reason for revert: Need to revert https://crrev.com/c/1156998
>
> Original change's description:
> > Add in-process VizCompositorThread for software compositing.
> >
> > We are having issues where starting a GPU process consistently fails on
> > some systems. Currently OOP-D runs the display compositor in the GPU
> > process always. This includes when both hardware acceleration and
> > SwiftShader are disabled. If we can't start the GPU process, we can't
> > run the display compositor and Chrome crashes.
> >
> > This CL changes where the VizCompositorThread runs if the GPU access is
> > disabled on Windows. We start the thread after giving up on the GPU
> > process and create FrameSinkManagerImpl + dependencies on it.
> >
> > Also fix chrome://gpu page so that OOP-D and surface sync features are
> > still correct if |gpu_access_blocked| is true.
> >
> > There is a lot of peripheral cleanup and code reuse possible as a follow
> > up to this CL. It's not attempted here to make this easier to merge back
> > to M69.
> >
> > Bug: 849639
> > Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
> > Change-Id: Ica6a3ec5b0e7951cb6807b135df4b4cfe410e394
> > Reviewed-on: https://chromium-review.googlesource.com/1158723
> > Reviewed-by: Antoine Labour <piman@chromium.org>
> > Commit-Queue: kylechar <kylechar@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#580241}
>
> TBR=sadrul@chromium.org,kylechar@chromium.org,piman@chromium.org
>
> Change-Id: I00fc978561630ef292436e2d44012a0931551d0f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 849639
> Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
> Reviewed-on: https://chromium-review.googlesource.com/1161121
> Reviewed-by: kylechar <kylechar@chromium.org>
> Commit-Queue: kylechar <kylechar@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#580264}

TBR=piman@chromium.org

Change-Id: I6beb00a3551800cae159e503e5dcb5be9a45116e
Bug: 849639
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Reviewed-on: https://chromium-review.googlesource.com/1161122
Commit-Queue: kylechar <kylechar@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580390}
parent 03914101
...@@ -155,6 +155,8 @@ viz_component("service") { ...@@ -155,6 +155,8 @@ viz_component("service") {
"hit_test/hit_test_aggregator_delegate.h", "hit_test/hit_test_aggregator_delegate.h",
"hit_test/hit_test_manager.cc", "hit_test/hit_test_manager.cc",
"hit_test/hit_test_manager.h", "hit_test/hit_test_manager.h",
"main/viz_compositor_thread_runner.cc",
"main/viz_compositor_thread_runner.h",
"surfaces/latest_local_surface_id_lookup_delegate.h", "surfaces/latest_local_surface_id_lookup_delegate.h",
"surfaces/referenced_surface_tracker.cc", "surfaces/referenced_surface_tracker.cc",
"surfaces/referenced_surface_tracker.h", "surfaces/referenced_surface_tracker.h",
......
...@@ -15,24 +15,23 @@ ...@@ -15,24 +15,23 @@
#include "components/viz/service/display/display.h" #include "components/viz/service/display/display.h"
#include "components/viz/service/display/display_scheduler.h" #include "components/viz/service/display/display_scheduler.h"
#include "components/viz/service/display_embedder/gl_output_surface.h" #include "components/viz/service/display_embedder/gl_output_surface.h"
#include "components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h" #include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
#include "components/viz/service/display_embedder/skia_output_surface_impl.h" #include "components/viz/service/display_embedder/skia_output_surface_impl.h"
#include "components/viz/service/display_embedder/software_output_surface.h" #include "components/viz/service/display_embedder/software_output_surface.h"
#include "components/viz/service/display_embedder/viz_process_context_provider.h" #include "components/viz/service/display_embedder/viz_process_context_provider.h"
#include "components/viz/service/gl/gpu_service_impl.h" #include "components/viz/service/gl/gpu_service_impl.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/client/shared_memory_limits.h" #include "gpu/command_buffer/client/shared_memory_limits.h"
#include "gpu/command_buffer/service/image_factory.h" #include "gpu/command_buffer/service/image_factory.h"
#include "gpu/ipc/command_buffer_task_executor.h" #include "gpu/ipc/command_buffer_task_executor.h"
#include "gpu/ipc/common/surface_handle.h" #include "gpu/ipc/common/surface_handle.h"
#include "gpu/ipc/service/gpu_channel_manager.h"
#include "gpu/ipc/service/gpu_channel_manager_delegate.h" #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
#include "gpu/ipc/service/gpu_memory_buffer_factory.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "components/viz/service/display_embedder/gl_output_surface_win.h" #include "components/viz/service/display_embedder/gl_output_surface_win.h"
#include "components/viz/service/display_embedder/software_output_device_win.h" #include "components/viz/service/display_embedder/software_output_device_win.h"
#include "ui/gfx/win/rendering_window_manager.h"
#endif #endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -58,40 +57,44 @@ ...@@ -58,40 +57,44 @@
#include "ui/ozone/public/surface_ozone_canvas.h" #include "ui/ozone/public/surface_ozone_canvas.h"
#endif #endif
namespace {
gpu::ImageFactory* GetImageFactory(gpu::GpuChannelManager* channel_manager) {
auto* buffer_factory = channel_manager->gpu_memory_buffer_factory();
return buffer_factory ? buffer_factory->AsImageFactory() : nullptr;
}
} // namespace
namespace viz { namespace viz {
GpuDisplayProvider::GpuDisplayProvider( GpuDisplayProvider::GpuDisplayProvider(
uint32_t restart_id, uint32_t restart_id,
GpuServiceImpl* gpu_service_impl, GpuServiceImpl* gpu_service_impl,
scoped_refptr<gpu::CommandBufferTaskExecutor> task_executor, scoped_refptr<gpu::CommandBufferTaskExecutor> task_executor,
gpu::GpuChannelManager* gpu_channel_manager, gpu::GpuChannelManagerDelegate* gpu_channel_manager_delegate,
std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager,
gpu::ImageFactory* image_factory,
ServerSharedBitmapManager* server_shared_bitmap_manager, ServerSharedBitmapManager* server_shared_bitmap_manager,
bool headless, bool headless,
bool wait_for_all_pipeline_stages_before_draw) bool wait_for_all_pipeline_stages_before_draw)
: restart_id_(restart_id), : restart_id_(restart_id),
gpu_service_impl_(gpu_service_impl), gpu_service_impl_(gpu_service_impl),
task_executor_(std::move(task_executor)), task_executor_(std::move(task_executor)),
gpu_channel_manager_delegate_(gpu_channel_manager->delegate()), gpu_channel_manager_delegate_(gpu_channel_manager_delegate),
gpu_memory_buffer_manager_( gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)),
std::make_unique<InProcessGpuMemoryBufferManager>( image_factory_(image_factory),
gpu_channel_manager)),
image_factory_(GetImageFactory(gpu_channel_manager)),
server_shared_bitmap_manager_(server_shared_bitmap_manager), server_shared_bitmap_manager_(server_shared_bitmap_manager),
task_runner_(base::ThreadTaskRunnerHandle::Get()), task_runner_(base::ThreadTaskRunnerHandle::Get()),
headless_(headless), headless_(headless),
wait_for_all_pipeline_stages_before_draw_( wait_for_all_pipeline_stages_before_draw_(
wait_for_all_pipeline_stages_before_draw) { wait_for_all_pipeline_stages_before_draw) {}
DCHECK_NE(restart_id_, BeginFrameSource::kNotRestartableId);
} GpuDisplayProvider::GpuDisplayProvider(
uint32_t restart_id,
ServerSharedBitmapManager* server_shared_bitmap_manager,
bool headless,
bool wait_for_all_pipeline_stages_before_draw)
: GpuDisplayProvider(restart_id,
/*gpu_service_impl=*/nullptr,
/*task_executor=*/nullptr,
/*gpu_channel_manager_delegate=*/nullptr,
/*gpu_memory_buffer_manager=*/nullptr,
/*image_factory=*/nullptr,
server_shared_bitmap_manager,
headless,
wait_for_all_pipeline_stages_before_draw) {}
GpuDisplayProvider::~GpuDisplayProvider() = default; GpuDisplayProvider::~GpuDisplayProvider() = default;
...@@ -128,6 +131,8 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay( ...@@ -128,6 +131,8 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay(
skia_output_surface = static_cast<SkiaOutputSurface*>(output_surface.get()); skia_output_surface = static_cast<SkiaOutputSurface*>(output_surface.get());
#endif #endif
} else { } else {
DCHECK(task_executor_);
scoped_refptr<VizProcessContextProvider> context_provider; scoped_refptr<VizProcessContextProvider> context_provider;
// Retry creating and binding |context_provider| on transient failures. // Retry creating and binding |context_provider| on transient failures.
...@@ -209,11 +214,19 @@ GpuDisplayProvider::CreateSoftwareOutputDeviceForPlatform( ...@@ -209,11 +214,19 @@ GpuDisplayProvider::CreateSoftwareOutputDeviceForPlatform(
auto device = CreateSoftwareOutputDeviceWinGpu( auto device = CreateSoftwareOutputDeviceWinGpu(
surface_handle, &output_device_backing_, display_client, &child_hwnd); surface_handle, &output_device_backing_, display_client, &child_hwnd);
// If |child_hwnd| isn't null then a new child HWND was created. Send an IPC // If |child_hwnd| isn't null then a new child HWND was created.
// to browser process for SetParent() syscall.
if (child_hwnd) { if (child_hwnd) {
gpu_channel_manager_delegate_->SendCreatedChildWindow(surface_handle, if (gpu_channel_manager_delegate_) {
child_hwnd); // Send an IPC to browser process for SetParent().
gpu_channel_manager_delegate_->SendCreatedChildWindow(surface_handle,
child_hwnd);
} else {
// We are already in the browser process.
if (!gfx::RenderingWindowManager::GetInstance()->RegisterChild(
surface_handle, child_hwnd)) {
LOG(ERROR) << "Bad parenting request.";
}
}
} }
return device; return device;
......
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
#endif #endif
namespace gpu { namespace gpu {
class GpuChannelManager;
class GpuChannelManagerDelegate;
class CommandBufferTaskExecutor; class CommandBufferTaskExecutor;
class GpuChannelManagerDelegate;
class GpuMemoryBufferManager;
class ImageFactory; class ImageFactory;
} // namespace gpu } // namespace gpu
...@@ -39,10 +39,18 @@ class SoftwareOutputDevice; ...@@ -39,10 +39,18 @@ class SoftwareOutputDevice;
// In-process implementation of DisplayProvider. // In-process implementation of DisplayProvider.
class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider { class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider {
public: public:
GpuDisplayProvider(
uint32_t restart_id,
GpuServiceImpl* gpu_service_impl,
scoped_refptr<gpu::CommandBufferTaskExecutor> task_executor,
gpu::GpuChannelManagerDelegate* gpu_channel_manager_delegate,
std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager,
gpu::ImageFactory* image_factory,
ServerSharedBitmapManager* server_shared_bitmap_manager,
bool headless,
bool wait_for_all_pipeline_stages_before_draw);
// Software compositing only.
GpuDisplayProvider(uint32_t restart_id, GpuDisplayProvider(uint32_t restart_id,
GpuServiceImpl* gpu_service_impl,
scoped_refptr<gpu::CommandBufferTaskExecutor> gpu_service,
gpu::GpuChannelManager* gpu_channel_manager,
ServerSharedBitmapManager* server_shared_bitmap_manager, ServerSharedBitmapManager* server_shared_bitmap_manager,
bool headless, bool headless,
bool wait_for_all_pipeline_stages_before_draw); bool wait_for_all_pipeline_stages_before_draw);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/viz/service/main/viz_compositor_thread_runner.h"
#include <utility>
#include "base/command_line.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/viz/common/switches.h"
#include "components/viz/service/display_embedder/gpu_display_provider.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "ui/gfx/switches.h"
namespace viz {
namespace {
const char kThreadName[] = "VizCompositorThread";
std::unique_ptr<base::Thread> CreateAndStartCompositorThread() {
auto thread = std::make_unique<base::Thread>(kThreadName);
base::Thread::Options thread_options;
#if defined(OS_WIN)
// Windows needs a UI message loop for child HWND. Other platforms can use the
// default message loop type.
thread_options.message_loop_type = base::MessageLoop::TYPE_UI;
#elif defined(OS_CHROMEOS)
thread_options.priority = base::ThreadPriority::DISPLAY;
#endif
CHECK(thread->StartWithOptions(thread_options));
return thread;
}
} // namespace
VizCompositorThreadRunner::VizCompositorThreadRunner()
: thread_(CreateAndStartCompositorThread()),
task_runner_(thread_->task_runner()) {}
VizCompositorThreadRunner::~VizCompositorThreadRunner() {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&VizCompositorThreadRunner::TearDownOnCompositorThread,
base::Unretained(this)));
thread_->Stop();
}
void VizCompositorThreadRunner::CreateFrameSinkManager(
mojom::FrameSinkManagerParamsPtr params) {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&VizCompositorThreadRunner::CreateFrameSinkManagerOnCompositorThread,
base::Unretained(this), std::move(params)));
}
void VizCompositorThreadRunner::CreateFrameSinkManagerOnCompositorThread(
mojom::FrameSinkManagerParamsPtr params) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!frame_sink_manager_);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
server_shared_bitmap_manager_ = std::make_unique<ServerSharedBitmapManager>();
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
server_shared_bitmap_manager_.get(), "ServerSharedBitmapManager",
base::ThreadTaskRunnerHandle::Get());
// Create GpuDisplayProvider usable for software compositing only.
display_provider_ = std::make_unique<GpuDisplayProvider>(
params->restart_id, server_shared_bitmap_manager_.get(),
command_line->HasSwitch(switches::kHeadless),
command_line->HasSwitch(switches::kRunAllCompositorStagesBeforeDraw));
base::Optional<uint32_t> activation_deadline_in_frames;
if (params->use_activation_deadline)
activation_deadline_in_frames = params->activation_deadline_in_frames;
frame_sink_manager_ = std::make_unique<FrameSinkManagerImpl>(
server_shared_bitmap_manager_.get(), activation_deadline_in_frames,
display_provider_.get());
frame_sink_manager_->BindAndSetClient(
std::move(params->frame_sink_manager), nullptr,
mojom::FrameSinkManagerClientPtr(
std::move(params->frame_sink_manager_client)));
}
void VizCompositorThreadRunner::TearDownOnCompositorThread() {
DCHECK(task_runner_->BelongsToCurrentThread());
if (server_shared_bitmap_manager_) {
base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
server_shared_bitmap_manager_.get());
}
frame_sink_manager_.reset();
display_provider_.reset();
server_shared_bitmap_manager_.reset();
}
} // namespace viz
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_VIZ_SERVICE_MAIN_VIZ_COMPOSITOR_THREAD_RUNNER_H_
#define COMPONENTS_VIZ_SERVICE_MAIN_VIZ_COMPOSITOR_THREAD_RUNNER_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "components/viz/service/viz_service_export.h"
#include "services/viz/privileged/interfaces/viz_main.mojom.h"
namespace base {
class SingleThreadTaskRunner;
class Thread;
} // namespace base
namespace viz {
class DisplayProvider;
class FrameSinkManagerImpl;
class ServerSharedBitmapManager;
// Starts and runs the VizCompositorThread. The thread will be started when this
// object is constructed. Objects on the thread will be initialized after
// calling CreateFrameSinkManager(). Destructor will teardown objects on thread
// and then stop the thread.
// TODO(kylechar): Convert VizMainImpl to use VizCompositorThreadRunner.
class VIZ_SERVICE_EXPORT VizCompositorThreadRunner {
public:
VizCompositorThreadRunner();
// Performs teardown on thread and then stops thread.
~VizCompositorThreadRunner();
// Create FrameSinkManager from |params|. This can be called from the thread
// that owns |this| to initialize state on VizCompositorThreadRunner.
void CreateFrameSinkManager(mojom::FrameSinkManagerParamsPtr params);
private:
void CreateFrameSinkManagerOnCompositorThread(
mojom::FrameSinkManagerParamsPtr params);
void TearDownOnCompositorThread();
// Start variables to be accessed only on |task_runner_|.
std::unique_ptr<ServerSharedBitmapManager> server_shared_bitmap_manager_;
std::unique_ptr<DisplayProvider> display_provider_;
std::unique_ptr<FrameSinkManagerImpl> frame_sink_manager_;
// End variables to be accessed only on |task_runner_|.
std::unique_ptr<base::Thread> thread_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(VizCompositorThreadRunner);
};
} // namespace viz
#endif // COMPONENTS_VIZ_SERVICE_MAIN_VIZ_COMPOSITOR_THREAD_RUNNER_H_
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/common/switches.h" #include "components/viz/common/switches.h"
#include "components/viz/service/display_embedder/gpu_display_provider.h" #include "components/viz/service/display_embedder/gpu_display_provider.h"
#include "components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h" #include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "components/viz/service/gl/gpu_service_impl.h" #include "components/viz/service/gl/gpu_service_impl.h"
...@@ -332,9 +333,17 @@ void VizMainImpl::CreateFrameSinkManagerOnCompositorThread( ...@@ -332,9 +333,17 @@ void VizMainImpl::CreateFrameSinkManagerOnCompositorThread(
server_shared_bitmap_manager_.get(), "viz::ServerSharedBitmapManager", server_shared_bitmap_manager_.get(), "viz::ServerSharedBitmapManager",
base::ThreadTaskRunnerHandle::Get()); base::ThreadTaskRunnerHandle::Get());
auto* gpu_channel_manager = gpu_service_->gpu_channel_manager();
gpu::ImageFactory* image_factory = nullptr;
if (gpu_channel_manager->gpu_memory_buffer_factory()) {
image_factory =
gpu_channel_manager->gpu_memory_buffer_factory()->AsImageFactory();
}
display_provider_ = std::make_unique<GpuDisplayProvider>( display_provider_ = std::make_unique<GpuDisplayProvider>(
params->restart_id, gpu_service_.get(), task_executor_, params->restart_id, gpu_service_.get(), task_executor_,
gpu_service_->gpu_channel_manager(), server_shared_bitmap_manager_.get(), gpu_channel_manager->delegate(),
std::make_unique<InProcessGpuMemoryBufferManager>(gpu_channel_manager),
image_factory, server_shared_bitmap_manager_.get(),
command_line->HasSwitch(switches::kHeadless), command_line->HasSwitch(switches::kHeadless),
command_line->HasSwitch(switches::kRunAllCompositorStagesBeforeDraw)); command_line->HasSwitch(switches::kRunAllCompositorStagesBeforeDraw));
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "components/viz/client/local_surface_id_provider.h" #include "components/viz/client/local_surface_id_provider.h"
#include "components/viz/common/gpu/context_provider.h" #include "components/viz/common/gpu/context_provider.h"
#include "components/viz/common/gpu/raster_context_provider.h" #include "components/viz/common/gpu/raster_context_provider.h"
#include "components/viz/common/switches.h"
#include "components/viz/host/host_frame_sink_manager.h" #include "components/viz/host/host_frame_sink_manager.h"
#include "components/viz/service/display_embedder/compositing_mode_reporter_impl.h" #include "components/viz/service/display_embedder/compositing_mode_reporter_impl.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h" #include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
...@@ -152,25 +153,47 @@ void VizProcessTransportFactory::ConnectHostFrameSinkManager() { ...@@ -152,25 +153,47 @@ void VizProcessTransportFactory::ConnectHostFrameSinkManager() {
std::move(frame_sink_manager_client_request), resize_task_runner(), std::move(frame_sink_manager_client_request), resize_task_runner(),
std::move(frame_sink_manager)); std::move(frame_sink_manager));
// Hop to the IO thread, then send the other side of interface to viz process. if (GpuDataManagerImpl::GetInstance()->GpuProcessStartAllowed()) {
auto connect_on_io_thread = // Hop to the IO thread, then send the other side of interface to viz
[](viz::mojom::FrameSinkManagerRequest request, // process.
viz::mojom::FrameSinkManagerClientPtrInfo client) { auto connect_on_io_thread =
// There should always be a GpuProcessHost instance, and GPU process, [](viz::mojom::FrameSinkManagerRequest request,
// for running the compositor thread. The exception is during shutdown viz::mojom::FrameSinkManagerClientPtrInfo client) {
// the GPU process won't be restarted and GpuProcessHost::Get() can // There should always be a GpuProcessHost instance, and GPU process,
// return null. // for running the compositor thread. The exception is during shutdown
auto* gpu_process_host = GpuProcessHost::Get(); // the GPU process won't be restarted and GpuProcessHost::Get() can
if (gpu_process_host) { // return null.
gpu_process_host->ConnectFrameSinkManager(std::move(request), auto* gpu_process_host = GpuProcessHost::Get();
std::move(client)); if (gpu_process_host) {
} gpu_process_host->ConnectFrameSinkManager(std::move(request),
}; std::move(client));
BrowserThread::PostTask( }
BrowserThread::IO, FROM_HERE, };
base::BindOnce(connect_on_io_thread, BrowserThread::PostTask(
std::move(frame_sink_manager_request), BrowserThread::IO, FROM_HERE,
frame_sink_manager_client.PassInterface())); base::BindOnce(connect_on_io_thread,
std::move(frame_sink_manager_request),
frame_sink_manager_client.PassInterface()));
} else {
DCHECK(!viz_compositor_thread_);
// GPU process access is disabled. Start a new thread to run the display
// compositor in-process and connect HostFrameSinkManager to it.
viz_compositor_thread_ = std::make_unique<viz::VizCompositorThreadRunner>();
viz::mojom::FrameSinkManagerParamsPtr params =
viz::mojom::FrameSinkManagerParams::New();
params->restart_id = viz::BeginFrameSource::kNotRestartableId;
base::Optional<uint32_t> activation_deadline_in_frames =
switches::GetDeadlineToSynchronizeSurfaces();
params->use_activation_deadline = activation_deadline_in_frames.has_value();
params->activation_deadline_in_frames =
activation_deadline_in_frames.value_or(0u);
params->frame_sink_manager = std::move(frame_sink_manager_request);
params->frame_sink_manager_client =
frame_sink_manager_client.PassInterface();
viz_compositor_thread_->CreateFrameSinkManager(std::move(params));
}
} }
void VizProcessTransportFactory::CreateLayerTreeFrameSink( void VizProcessTransportFactory::CreateLayerTreeFrameSink(
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/common/gpu/context_lost_observer.h" #include "components/viz/common/gpu/context_lost_observer.h"
#include "components/viz/service/main/viz_compositor_thread_runner.h"
#include "content/browser/compositor/image_transport_factory.h" #include "content/browser/compositor/image_transport_factory.h"
#include "gpu/command_buffer/common/context_result.h" #include "gpu/command_buffer/common/context_result.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
...@@ -128,6 +129,10 @@ class VizProcessTransportFactory : public ui::ContextFactory, ...@@ -128,6 +129,10 @@ class VizProcessTransportFactory : public ui::ContextFactory,
std::unique_ptr<cc::SingleThreadTaskGraphRunner> task_graph_runner_; std::unique_ptr<cc::SingleThreadTaskGraphRunner> task_graph_runner_;
// Will start and run the VizCompositorThread for using an in-process display
// compositor.
std::unique_ptr<viz::VizCompositorThreadRunner> viz_compositor_thread_;
base::WeakPtrFactory<VizProcessTransportFactory> weak_ptr_factory_; base::WeakPtrFactory<VizProcessTransportFactory> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(VizProcessTransportFactory); DISALLOW_COPY_AND_ASSIGN(VizProcessTransportFactory);
......
...@@ -223,8 +223,12 @@ std::unique_ptr<base::DictionaryValue> GetFeatureStatusImpl( ...@@ -223,8 +223,12 @@ std::unique_ptr<base::DictionaryValue> GetFeatureStatusImpl(
const GpuFeatureData gpu_feature_data = const GpuFeatureData gpu_feature_data =
GetGpuFeatureData(gpu_feature_info, type, i, &eof); GetGpuFeatureData(gpu_feature_info, type, i, &eof);
std::string status; std::string status;
if (gpu_feature_data.disabled || gpu_access_blocked || if (gpu_feature_data.name == "surface_synchronization") {
gpu_feature_data.status == gpu::kGpuFeatureStatusDisabled) { status = (!gpu_feature_data.disabled ? "enabled_on" : "disabled_off");
} else if (gpu_feature_data.name == "viz_display_compositor") {
status = (!gpu_feature_data.disabled ? "enabled_on" : "disabled_off");
} else if (gpu_feature_data.disabled || gpu_access_blocked ||
gpu_feature_data.status == gpu::kGpuFeatureStatusDisabled) {
status = "disabled"; status = "disabled";
if (gpu_feature_data.fallback_to_software) if (gpu_feature_data.fallback_to_software)
status += "_software"; status += "_software";
...@@ -252,14 +256,6 @@ std::unique_ptr<base::DictionaryValue> GetFeatureStatusImpl( ...@@ -252,14 +256,6 @@ std::unique_ptr<base::DictionaryValue> GetFeatureStatusImpl(
status += "_force"; status += "_force";
status += "_on"; status += "_on";
} }
if (gpu_feature_data.name == "surface_synchronization") {
if (features::IsSurfaceSynchronizationEnabled())
status += "_on";
}
if (gpu_feature_data.name == "viz_display_compositor") {
if (base::FeatureList::IsEnabled(features::kVizDisplayCompositor))
status += "_on";
}
if (gpu_feature_data.name == "skia_renderer") { if (gpu_feature_data.name == "skia_renderer") {
if (features::IsUsingSkiaRenderer()) if (features::IsUsingSkiaRenderer())
status += "_on"; status += "_on";
......
...@@ -353,8 +353,19 @@ bool GpuDataManagerImplPrivate::GpuAccessAllowed(std::string* reason) const { ...@@ -353,8 +353,19 @@ bool GpuDataManagerImplPrivate::GpuAccessAllowed(std::string* reason) const {
} }
bool GpuDataManagerImplPrivate::GpuProcessStartAllowed() const { bool GpuDataManagerImplPrivate::GpuProcessStartAllowed() const {
return base::FeatureList::IsEnabled(features::kVizDisplayCompositor) || if (GpuAccessAllowed(nullptr))
GpuAccessAllowed(nullptr); return true;
#if defined(USE_X11) || defined(OS_MACOSX)
// If GPU access is disabled with OOP-D we run the display compositor in:
// Browser process: Windows
// GPU process: Linux and Mac
// N/A: Android and Chrome OS (GPU access can't be disabled)
if (base::FeatureList::IsEnabled(features::kVizDisplayCompositor))
return true;
#endif
return false;
} }
void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() { void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment