diff --git content/browser/compositor/gpu_process_transport_factory.cc content/browser/compositor/gpu_process_transport_factory.cc index 45bf6b1b4618..f41d40a6887b 100644 --- content/browser/compositor/gpu_process_transport_factory.cc +++ content/browser/compositor/gpu_process_transport_factory.cc @@ -274,6 +274,13 @@ GpuProcessTransportFactory::~GpuProcessTransportFactory() { std::unique_ptr GpuProcessTransportFactory::CreateSoftwareOutputDevice( ui::Compositor* compositor) { + if (compositor->delegate()) { + std::unique_ptr output_device = + compositor->delegate()->CreateSoftwareOutputDevice(compositor); + if (output_device) + return output_device; + } + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kHeadless)) return base::WrapUnique(new viz::SoftwareOutputDevice); diff --git ui/compositor/compositor.h ui/compositor/compositor.h index d842aa55175b..5683e6fb68f8 100644 --- ui/compositor/compositor.h +++ ui/compositor/compositor.h @@ -23,6 +23,7 @@ #include "components/viz/common/surfaces/local_surface_id.h" #include "components/viz/common/surfaces/surface_sequence.h" #include "components/viz/host/host_frame_sink_client.h" +#include "components/viz/service/display/software_output_device.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/compositor/compositor_animation_observer.h" #include "ui/compositor/compositor_export.h" @@ -179,6 +180,17 @@ class COMPOSITOR_EXPORT ContextFactory { virtual void RemoveObserver(ContextFactoryObserver* observer) = 0; }; +class COMPOSITOR_EXPORT CompositorDelegate { + public: + virtual std::unique_ptr CreateSoftwareOutputDevice( + ui::Compositor* compositor) { + return nullptr; + } + + protected: + virtual ~CompositorDelegate() {} +}; + // Compositor object to take care of GPU painting. // A Browser compositor object is responsible for generating the final // displayable form of pixels comprising a single widget's contents. It draws an @@ -215,6 +227,9 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient, // Schedules a redraw of the layer tree associated with this compositor. void ScheduleDraw(); + CompositorDelegate* delegate() const { return delegate_; } + void SetDelegate(CompositorDelegate* delegate) { delegate_ = delegate; } + // Sets the root of the layer tree drawn by this Compositor. The root layer // must have no parent. The compositor's root layer is reset if the root layer // is destroyed. NULL can be passed to reset the root layer, in which case the @@ -426,6 +441,8 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient, ui::ContextFactory* context_factory_; ui::ContextFactoryPrivate* context_factory_private_; + CompositorDelegate* delegate_ = nullptr; + // The root of the Layer tree drawn by this compositor. Layer* root_layer_ = nullptr;