2019-07-16 22:09:04 +02:00
|
|
|
diff --git components/viz/host/host_display_client.cc components/viz/host/host_display_client.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
index 7af928a9a030c..a702033cb2d47 100644
|
2019-07-16 22:09:04 +02:00
|
|
|
--- components/viz/host/host_display_client.cc
|
|
|
|
+++ components/viz/host/host_display_client.cc
|
2023-11-21 20:17:55 +01:00
|
|
|
@@ -47,9 +47,14 @@ void HostDisplayClient::OnDisplayReceivedCALayerParams(
|
2019-07-16 22:09:04 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
-#if BUILDFLAG(IS_WIN)
|
2019-07-16 22:09:04 +02:00
|
|
|
+void HostDisplayClient::UseProxyOutputDevice(
|
|
|
|
+ UseProxyOutputDeviceCallback callback) {
|
|
|
|
+ std::move(callback).Run(false);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void HostDisplayClient::CreateLayeredWindowUpdater(
|
2019-11-12 17:11:44 +01:00
|
|
|
mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver) {
|
2022-01-25 21:26:51 +01:00
|
|
|
+#if BUILDFLAG(IS_WIN)
|
2019-07-16 22:09:04 +02:00
|
|
|
if (!NeedsToUseLayerWindow(widget_)) {
|
|
|
|
DLOG(ERROR) << "HWND shouldn't be using a layered window";
|
|
|
|
return;
|
2023-11-21 20:17:55 +01:00
|
|
|
@@ -57,7 +62,10 @@ void HostDisplayClient::CreateLayeredWindowUpdater(
|
2019-07-16 22:09:04 +02:00
|
|
|
|
|
|
|
layered_window_updater_ =
|
2019-11-12 17:11:44 +01:00
|
|
|
std::make_unique<LayeredWindowUpdaterImpl>(widget_, std::move(receiver));
|
2022-11-15 18:50:53 +01:00
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+#if BUILDFLAG(IS_WIN)
|
|
|
|
void HostDisplayClient::AddChildWindowToBrowser(
|
|
|
|
gpu::SurfaceHandle child_window) {
|
|
|
|
NOTREACHED();
|
2019-07-16 22:09:04 +02:00
|
|
|
diff --git components/viz/host/host_display_client.h components/viz/host/host_display_client.h
|
2023-12-06 21:16:15 +01:00
|
|
|
index cb16487f9fc08..6191f8801f302 100644
|
2019-07-16 22:09:04 +02:00
|
|
|
--- components/viz/host/host_display_client.h
|
|
|
|
+++ components/viz/host/host_display_client.h
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -39,16 +39,17 @@ class VIZ_HOST_EXPORT HostDisplayClient : public mojom::DisplayClient {
|
2022-11-15 18:50:53 +01:00
|
|
|
gfx::AcceleratedWidget widget() const { return widget_; }
|
|
|
|
#endif
|
2019-07-16 22:09:04 +02:00
|
|
|
|
|
|
|
- private:
|
|
|
|
// mojom::DisplayClient implementation:
|
|
|
|
+ void UseProxyOutputDevice(UseProxyOutputDeviceCallback callback) override;
|
|
|
|
+
|
2022-01-25 21:26:51 +01:00
|
|
|
#if BUILDFLAG(IS_APPLE)
|
2019-07-16 22:09:04 +02:00
|
|
|
void OnDisplayReceivedCALayerParams(
|
|
|
|
const gfx::CALayerParams& ca_layer_params) override;
|
|
|
|
#endif
|
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
-#if BUILDFLAG(IS_WIN)
|
2019-07-16 22:09:04 +02:00
|
|
|
void CreateLayeredWindowUpdater(
|
2019-11-12 17:11:44 +01:00
|
|
|
mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver) override;
|
2022-11-15 18:50:53 +01:00
|
|
|
+#if BUILDFLAG(IS_WIN)
|
|
|
|
void AddChildWindowToBrowser(gpu::SurfaceHandle child_window) override;
|
|
|
|
#endif
|
2019-07-16 22:09:04 +02:00
|
|
|
|
|
|
|
diff --git components/viz/host/layered_window_updater_impl.cc components/viz/host/layered_window_updater_impl.cc
|
2023-06-26 12:13:38 +02:00
|
|
|
index 8f726bde2cb5d..0737835d1e9d1 100644
|
2019-07-16 22:09:04 +02:00
|
|
|
--- components/viz/host/layered_window_updater_impl.cc
|
|
|
|
+++ components/viz/host/layered_window_updater_impl.cc
|
2023-06-26 12:13:38 +02:00
|
|
|
@@ -46,7 +46,7 @@ void LayeredWindowUpdaterImpl::OnAllocatedSharedMemory(
|
2019-09-04 17:13:32 +02:00
|
|
|
// |region|'s handle will close when it goes out of scope.
|
2019-07-16 22:09:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
-void LayeredWindowUpdaterImpl::Draw(DrawCallback draw_callback) {
|
|
|
|
+void LayeredWindowUpdaterImpl::Draw(const gfx::Rect& damage_rect, DrawCallback draw_callback) {
|
|
|
|
TRACE_EVENT0("viz", "LayeredWindowUpdaterImpl::Draw");
|
|
|
|
|
|
|
|
if (!canvas_) {
|
|
|
|
diff --git components/viz/host/layered_window_updater_impl.h components/viz/host/layered_window_updater_impl.h
|
2022-09-26 21:30:45 +02:00
|
|
|
index 8af69cac78b74..9f74e511c263d 100644
|
2019-07-16 22:09:04 +02:00
|
|
|
--- components/viz/host/layered_window_updater_impl.h
|
|
|
|
+++ components/viz/host/layered_window_updater_impl.h
|
2021-12-16 23:35:54 +01:00
|
|
|
@@ -38,7 +38,7 @@ class VIZ_HOST_EXPORT LayeredWindowUpdaterImpl
|
2019-09-04 17:13:32 +02:00
|
|
|
// mojom::LayeredWindowUpdater implementation.
|
|
|
|
void OnAllocatedSharedMemory(const gfx::Size& pixel_size,
|
|
|
|
base::UnsafeSharedMemoryRegion region) override;
|
2019-07-16 22:09:04 +02:00
|
|
|
- void Draw(DrawCallback draw_callback) override;
|
|
|
|
+ void Draw(const gfx::Rect& damage_rect, DrawCallback draw_callback) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const HWND hwnd_;
|
|
|
|
diff --git components/viz/service/BUILD.gn components/viz/service/BUILD.gn
|
2024-01-26 03:12:43 +01:00
|
|
|
index 5a5791600d1aa..43cbd8abe4a75 100644
|
2019-07-16 22:09:04 +02:00
|
|
|
--- components/viz/service/BUILD.gn
|
|
|
|
+++ components/viz/service/BUILD.gn
|
2024-01-26 03:12:43 +01:00
|
|
|
@@ -249,6 +249,8 @@ viz_component("service") {
|
|
|
|
"transitions/surface_animation_manager.h",
|
2021-03-04 23:36:57 +01:00
|
|
|
"transitions/transferable_resource_tracker.cc",
|
|
|
|
"transitions/transferable_resource_tracker.h",
|
2019-07-16 22:09:04 +02:00
|
|
|
+ "//cef/libcef/browser/osr/software_output_device_proxy.cc",
|
|
|
|
+ "//cef/libcef/browser/osr/software_output_device_proxy.h",
|
2020-10-08 21:54:42 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
defines = [ "VIZ_SERVICE_IMPLEMENTATION" ]
|
2019-07-16 22:09:04 +02:00
|
|
|
diff --git components/viz/service/display_embedder/output_surface_provider_impl.cc components/viz/service/display_embedder/output_surface_provider_impl.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
index e8e3237bb2b8f..cec146af141ba 100644
|
2019-07-16 22:09:04 +02:00
|
|
|
--- components/viz/service/display_embedder/output_surface_provider_impl.cc
|
|
|
|
+++ components/viz/service/display_embedder/output_surface_provider_impl.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -18,6 +18,7 @@
|
2020-03-04 01:29:39 +01:00
|
|
|
#include "build/chromecast_buildflags.h"
|
2021-01-28 00:13:12 +01:00
|
|
|
#include "build/chromeos_buildflags.h"
|
2019-07-16 22:09:04 +02:00
|
|
|
#include "cc/base/switches.h"
|
|
|
|
+#include "cef/libcef/browser/osr/software_output_device_proxy.h"
|
|
|
|
#include "components/viz/common/display/renderer_settings.h"
|
2023-12-06 21:16:15 +01:00
|
|
|
#include "components/viz/common/features.h"
|
2019-07-16 22:09:04 +02:00
|
|
|
#include "components/viz/common/frame_sinks/begin_frame_source.h"
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -31,6 +32,7 @@
|
2022-08-23 03:37:40 +02:00
|
|
|
#include "gpu/command_buffer/service/scheduler_sequence.h"
|
2022-06-17 15:28:55 +02:00
|
|
|
#include "gpu/config/gpu_finch_features.h"
|
|
|
|
#include "gpu/ipc/common/surface_handle.h"
|
2022-04-21 20:58:48 +02:00
|
|
|
+#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
|
|
|
|
#include "ui/base/ui_base_switches.h"
|
2022-06-17 15:28:55 +02:00
|
|
|
|
|
|
|
#if BUILDFLAG(IS_WIN)
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -146,6 +148,20 @@ OutputSurfaceProviderImpl::CreateSoftwareOutputDeviceForPlatform(
|
2019-07-16 22:09:04 +02:00
|
|
|
if (headless_)
|
|
|
|
return std::make_unique<SoftwareOutputDevice>();
|
|
|
|
|
|
|
|
+ {
|
|
|
|
+ mojo::ScopedAllowSyncCallForTesting allow_sync;
|
|
|
|
+ DCHECK(display_client);
|
|
|
|
+ bool use_proxy_output_device = false;
|
|
|
|
+ if (display_client->UseProxyOutputDevice(&use_proxy_output_device) &&
|
|
|
|
+ use_proxy_output_device) {
|
2022-03-26 02:12:30 +01:00
|
|
|
+ mojo::PendingRemote<mojom::LayeredWindowUpdater> layered_window_updater;
|
2019-07-16 22:09:04 +02:00
|
|
|
+ display_client->CreateLayeredWindowUpdater(
|
2022-03-26 02:12:30 +01:00
|
|
|
+ layered_window_updater.InitWithNewPipeAndPassReceiver());
|
2019-07-16 22:09:04 +02:00
|
|
|
+ return std::make_unique<SoftwareOutputDeviceProxy>(
|
|
|
|
+ std::move(layered_window_updater));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2022-01-25 21:26:51 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2019-07-16 22:09:04 +02:00
|
|
|
return CreateSoftwareOutputDeviceWin(surface_handle, &output_device_backing_,
|
|
|
|
display_client);
|
|
|
|
diff --git components/viz/service/display_embedder/software_output_device_win.cc components/viz/service/display_embedder/software_output_device_win.cc
|
2023-06-26 12:13:38 +02:00
|
|
|
index 796ae2688436e..37a3406790210 100644
|
2019-07-16 22:09:04 +02:00
|
|
|
--- components/viz/service/display_embedder/software_output_device_win.cc
|
|
|
|
+++ components/viz/service/display_embedder/software_output_device_win.cc
|
2023-06-26 12:13:38 +02:00
|
|
|
@@ -193,8 +193,9 @@ void SoftwareOutputDeviceWinProxy::EndPaintDelegated(
|
2019-07-16 22:09:04 +02:00
|
|
|
if (!canvas_)
|
|
|
|
return;
|
|
|
|
|
|
|
|
- layered_window_updater_->Draw(base::BindOnce(
|
|
|
|
- &SoftwareOutputDeviceWinProxy::DrawAck, base::Unretained(this)));
|
|
|
|
+ layered_window_updater_->Draw(
|
|
|
|
+ damage_rect, base::BindOnce(&SoftwareOutputDeviceWinProxy::DrawAck,
|
|
|
|
+ base::Unretained(this)));
|
|
|
|
waiting_on_draw_ack_ = true;
|
|
|
|
|
|
|
|
TRACE_EVENT_ASYNC_BEGIN0("viz", "SoftwareOutputDeviceWinProxy::Draw", this);
|
2020-03-30 22:13:42 +02:00
|
|
|
diff --git content/browser/compositor/viz_process_transport_factory.cc content/browser/compositor/viz_process_transport_factory.cc
|
2024-01-26 03:12:43 +01:00
|
|
|
index 516c7f65097f1..49e0fdc6b4109 100644
|
2020-03-30 22:13:42 +02:00
|
|
|
--- content/browser/compositor/viz_process_transport_factory.cc
|
|
|
|
+++ content/browser/compositor/viz_process_transport_factory.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -408,8 +408,13 @@ void VizProcessTransportFactory::OnEstablishedGpuChannel(
|
2022-09-26 21:30:45 +02:00
|
|
|
mojo::AssociatedRemote<viz::mojom::DisplayPrivate> display_private;
|
2020-03-30 22:13:42 +02:00
|
|
|
root_params->display_private =
|
2022-09-26 21:30:45 +02:00
|
|
|
display_private.BindNewEndpointAndPassReceiver();
|
2020-03-30 22:13:42 +02:00
|
|
|
- compositor_data.display_client =
|
|
|
|
- std::make_unique<HostDisplayClient>(compositor);
|
|
|
|
+ if (compositor->delegate()) {
|
|
|
|
+ compositor_data.display_client =
|
|
|
|
+ compositor->delegate()->CreateHostDisplayClient();
|
|
|
|
+ } else {
|
|
|
|
+ compositor_data.display_client =
|
|
|
|
+ std::make_unique<HostDisplayClient>(compositor);
|
|
|
|
+ }
|
|
|
|
root_params->display_client =
|
|
|
|
compositor_data.display_client->GetBoundRemote(resize_task_runner_);
|
2022-09-26 21:30:45 +02:00
|
|
|
mojo::AssociatedRemote<viz::mojom::ExternalBeginFrameController>
|
2019-07-16 22:09:04 +02:00
|
|
|
diff --git mojo/public/cpp/bindings/sync_call_restrictions.h mojo/public/cpp/bindings/sync_call_restrictions.h
|
2023-12-06 21:16:15 +01:00
|
|
|
index 0173f9b181714..36a734d64738e 100644
|
2019-07-16 22:09:04 +02:00
|
|
|
--- mojo/public/cpp/bindings/sync_call_restrictions.h
|
|
|
|
+++ mojo/public/cpp/bindings/sync_call_restrictions.h
|
2023-11-21 20:17:55 +01:00
|
|
|
@@ -43,6 +43,7 @@ class Compositor;
|
2021-06-04 03:34:56 +02:00
|
|
|
} // namespace ui
|
2019-07-16 22:09:04 +02:00
|
|
|
|
|
|
|
namespace viz {
|
|
|
|
+class GpuDisplayProvider;
|
2021-06-04 03:34:56 +02:00
|
|
|
class GpuHostImpl;
|
|
|
|
class HostFrameSinkManager;
|
|
|
|
class HostGpuMemoryBufferManager;
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -119,6 +120,8 @@ class COMPONENT_EXPORT(MOJO_CPP_BINDINGS) SyncCallRestrictions {
|
2019-07-16 22:09:04 +02:00
|
|
|
// For preventing frame swaps of wrong size during resize on Windows.
|
|
|
|
// (https://crbug.com/811945)
|
2020-03-30 22:13:42 +02:00
|
|
|
friend class ui::Compositor;
|
|
|
|
+ // For query of whether to use SoftwareOutputDevice or not.
|
2019-07-16 22:09:04 +02:00
|
|
|
+ friend class viz::GpuDisplayProvider;
|
2020-07-08 19:23:29 +02:00
|
|
|
// For calling sync mojo API to get cdm origin. The service and the client are
|
|
|
|
// running in the same process, so it won't block anything.
|
|
|
|
// TODO(159346933) Remove once the origin isolation logic is moved outside of
|
2019-10-01 15:55:16 +02:00
|
|
|
diff --git services/viz/privileged/mojom/compositing/display_private.mojom services/viz/privileged/mojom/compositing/display_private.mojom
|
2023-12-06 21:16:15 +01:00
|
|
|
index d7deccb6e6ec6..6a91f4aae6259 100644
|
2019-10-01 15:55:16 +02:00
|
|
|
--- services/viz/privileged/mojom/compositing/display_private.mojom
|
|
|
|
+++ services/viz/privileged/mojom/compositing/display_private.mojom
|
2023-04-26 21:55:59 +02:00
|
|
|
@@ -108,13 +108,15 @@ interface DisplayPrivate {
|
2019-07-16 22:09:04 +02:00
|
|
|
|
2023-02-27 19:52:38 +01:00
|
|
|
// DisplayClient allows privileged clients to receive events from the Display.
|
2019-07-16 22:09:04 +02:00
|
|
|
interface DisplayClient {
|
|
|
|
+ [Sync]
|
|
|
|
+ UseProxyOutputDevice() => (bool success);
|
|
|
|
+
|
2023-02-27 19:52:38 +01:00
|
|
|
// Called when new Core Animation Layer params are received.
|
|
|
|
[EnableIf=is_apple]
|
2019-07-16 22:09:04 +02:00
|
|
|
OnDisplayReceivedCALayerParams(gfx.mojom.CALayerParams ca_layer_params);
|
|
|
|
|
|
|
|
// Creates a LayeredWindowUpdater implementation to draw into a layered
|
|
|
|
// window.
|
|
|
|
- [EnableIf=is_win]
|
2019-11-12 17:11:44 +01:00
|
|
|
CreateLayeredWindowUpdater(pending_receiver<LayeredWindowUpdater> receiver);
|
2019-07-16 22:09:04 +02:00
|
|
|
|
2022-11-15 18:50:53 +01:00
|
|
|
// Sends the created child window to the browser process so that it can be
|
2019-10-01 15:55:16 +02:00
|
|
|
diff --git services/viz/privileged/mojom/compositing/layered_window_updater.mojom services/viz/privileged/mojom/compositing/layered_window_updater.mojom
|
2022-09-26 21:30:45 +02:00
|
|
|
index 2f462f0deb5fc..695869b83cefa 100644
|
2019-10-01 15:55:16 +02:00
|
|
|
--- services/viz/privileged/mojom/compositing/layered_window_updater.mojom
|
|
|
|
+++ services/viz/privileged/mojom/compositing/layered_window_updater.mojom
|
2019-09-04 17:13:32 +02:00
|
|
|
@@ -26,5 +26,5 @@ interface LayeredWindowUpdater {
|
2019-07-16 22:09:04 +02:00
|
|
|
// Draws to the HWND by copying pixels from shared memory. Callback must be
|
|
|
|
// called after draw operation is complete to signal shared memory can be
|
|
|
|
// modified.
|
|
|
|
- Draw() => ();
|
|
|
|
+ Draw(gfx.mojom.Rect damage_rect) => ();
|
|
|
|
};
|
|
|
|
diff --git ui/compositor/compositor.h ui/compositor/compositor.h
|
2024-01-26 03:12:43 +01:00
|
|
|
index 86d021ca68674..26f6096b99c1f 100644
|
2019-07-16 22:09:04 +02:00
|
|
|
--- ui/compositor/compositor.h
|
|
|
|
+++ ui/compositor/compositor.h
|
2023-01-30 18:43:54 +01:00
|
|
|
@@ -33,7 +33,9 @@
|
2019-07-16 22:09:04 +02:00
|
|
|
#include "components/viz/common/frame_sinks/begin_frame_args.h"
|
|
|
|
#include "components/viz/common/surfaces/frame_sink_id.h"
|
2021-01-28 00:13:12 +01:00
|
|
|
#include "components/viz/common/surfaces/subtree_capture_id.h"
|
2019-07-16 22:09:04 +02:00
|
|
|
+#include "components/viz/host/host_display_client.h"
|
|
|
|
#include "components/viz/host/host_frame_sink_client.h"
|
|
|
|
+#include "components/viz/service/display/software_output_device.h"
|
2022-09-26 21:30:45 +02:00
|
|
|
#include "mojo/public/cpp/bindings/associated_remote.h"
|
2020-02-10 18:10:17 +01:00
|
|
|
#include "mojo/public/cpp/bindings/pending_remote.h"
|
2022-09-26 21:30:45 +02:00
|
|
|
#include "services/viz/privileged/mojom/compositing/display_private.mojom.h"
|
2024-01-26 03:12:43 +01:00
|
|
|
@@ -146,6 +148,14 @@ class COMPOSITOR_EXPORT ContextFactory {
|
2020-03-30 22:13:42 +02:00
|
|
|
virtual viz::HostFrameSinkManager* GetHostFrameSinkManager() = 0;
|
2019-07-16 22:09:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
+class COMPOSITOR_EXPORT CompositorDelegate {
|
|
|
|
+ public:
|
|
|
|
+ virtual std::unique_ptr<viz::HostDisplayClient> CreateHostDisplayClient() = 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
|
2024-01-26 03:12:43 +01:00
|
|
|
@@ -189,6 +199,9 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
|
2019-07-16 22:09:04 +02:00
|
|
|
// 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
|
2024-01-26 03:12:43 +01:00
|
|
|
@@ -539,6 +552,8 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
|
2020-03-30 22:13:42 +02:00
|
|
|
|
|
|
|
std::unique_ptr<PendingBeginFrameArgs> pending_begin_frame_args_;
|
2019-07-16 22:09:04 +02:00
|
|
|
|
|
|
|
+ CompositorDelegate* delegate_ = nullptr;
|
|
|
|
+
|
|
|
|
// The root of the Layer tree drawn by this compositor.
|
2021-12-16 23:35:54 +01:00
|
|
|
raw_ptr<Layer> root_layer_ = nullptr;
|
2019-07-16 22:09:04 +02:00
|
|
|
|