From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Thu, 20 Sep 2018 17:45:36 -0700 Subject: compositor_delegate.patch diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc index ff4e3109b11fea4e0a732ebf9ac9c17e4b5d5e8e..09eee0aae0306545af49258a8f11813c06655023 100644 --- a/content/browser/compositor/gpu_process_transport_factory.cc +++ b/content/browser/compositor/gpu_process_transport_factory.cc @@ -451,11 +451,20 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( // surfaces as they are not following the correct mode. DisableGpuCompositing(compositor.get()); } + + std::unique_ptr output_device; + if (compositor->delegate()) { + output_device = + compositor->delegate()->CreateSoftwareOutputDevice(compositor.get()); + } + if (!output_device) { + output_device = CreateSoftwareOutputDevice(compositor->widget(), + compositor->task_runner()); + } + display_output_surface = std::make_unique( - CreateSoftwareOutputDevice(compositor->widget(), - compositor->task_runner()), - std::move(vsync_callback)); + std::move(output_device), std::move(vsync_callback)); } else { DCHECK(context_provider); const auto& capabilities = context_provider->ContextCapabilities(); diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h index 29784c677f4be6e4fd7cfb298ab3554d22e1beaa..07b61abe7ce666b5eb6448ef795f838ddb805947 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -25,6 +25,7 @@ #include "components/viz/common/surfaces/frame_sink_id.h" #include "components/viz/common/surfaces/local_surface_id_allocation.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 "third_party/skia/include/core/SkMatrix44.h" #include "ui/compositor/compositor_animation_observer.h" @@ -193,6 +194,15 @@ class COMPOSITOR_EXPORT ContextFactory { virtual bool SyncTokensRequiredForDisplayCompositor() = 0; }; +class COMPOSITOR_EXPORT CompositorDelegate { + public: + virtual std::unique_ptr CreateSoftwareOutputDevice( + ui::Compositor* compositor) = 0; + + 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 @@ -235,6 +245,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 @@ -458,6 +471,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;