Commit 9cc4e8de authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Migrate DisplayClient to the new Mojo types

This CL applies pending_receiver to CreateLayeredWindowUpdater
in DisplayClient. According to the change, related classes
are also changed with mojo::PendingReceiver, mojo::PendingRemote,
and mojo::Remote.

Bug: 955171
Change-Id: Ib40de7fdf35bace79e97d1aa8a5f55e8c7c414b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824792Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#700045}
parent 8dddf1d5
...@@ -48,14 +48,14 @@ void HostDisplayClient::OnDisplayReceivedCALayerParams( ...@@ -48,14 +48,14 @@ void HostDisplayClient::OnDisplayReceivedCALayerParams(
#if defined(OS_WIN) #if defined(OS_WIN)
void HostDisplayClient::CreateLayeredWindowUpdater( void HostDisplayClient::CreateLayeredWindowUpdater(
mojom::LayeredWindowUpdaterRequest request) { mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver) {
if (!NeedsToUseLayerWindow(widget_)) { if (!NeedsToUseLayerWindow(widget_)) {
DLOG(ERROR) << "HWND shouldn't be using a layered window"; DLOG(ERROR) << "HWND shouldn't be using a layered window";
return; return;
} }
layered_window_updater_ = layered_window_updater_ =
std::make_unique<LayeredWindowUpdaterImpl>(widget_, std::move(request)); std::make_unique<LayeredWindowUpdaterImpl>(widget_, std::move(receiver));
} }
#endif #endif
......
...@@ -39,7 +39,7 @@ class VIZ_HOST_EXPORT HostDisplayClient : public mojom::DisplayClient { ...@@ -39,7 +39,7 @@ class VIZ_HOST_EXPORT HostDisplayClient : public mojom::DisplayClient {
#if defined(OS_WIN) #if defined(OS_WIN)
void CreateLayeredWindowUpdater( void CreateLayeredWindowUpdater(
mojom::LayeredWindowUpdaterRequest request) override; mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver) override;
#endif #endif
#if defined(USE_X11) #if defined(USE_X11)
......
...@@ -15,8 +15,8 @@ namespace viz { ...@@ -15,8 +15,8 @@ namespace viz {
LayeredWindowUpdaterImpl::LayeredWindowUpdaterImpl( LayeredWindowUpdaterImpl::LayeredWindowUpdaterImpl(
HWND hwnd, HWND hwnd,
mojom::LayeredWindowUpdaterRequest request) mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver)
: hwnd_(hwnd), binding_(this, std::move(request)) {} : hwnd_(hwnd), receiver_(this, std::move(receiver)) {}
LayeredWindowUpdaterImpl::~LayeredWindowUpdaterImpl() = default; LayeredWindowUpdaterImpl::~LayeredWindowUpdaterImpl() = default;
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/unsafe_shared_memory_region.h" #include "base/memory/unsafe_shared_memory_region.h"
#include "components/viz/host/viz_host_export.h" #include "components/viz/host/viz_host_export.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/viz/privileged/mojom/compositing/layered_window_updater.mojom.h" #include "services/viz/privileged/mojom/compositing/layered_window_updater.mojom.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
...@@ -26,8 +27,9 @@ namespace viz { ...@@ -26,8 +27,9 @@ namespace viz {
class VIZ_HOST_EXPORT LayeredWindowUpdaterImpl class VIZ_HOST_EXPORT LayeredWindowUpdaterImpl
: public mojom::LayeredWindowUpdater { : public mojom::LayeredWindowUpdater {
public: public:
LayeredWindowUpdaterImpl(HWND hwnd, LayeredWindowUpdaterImpl(
mojom::LayeredWindowUpdaterRequest request); HWND hwnd,
mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver);
~LayeredWindowUpdaterImpl() override; ~LayeredWindowUpdaterImpl() override;
// mojom::LayeredWindowUpdater implementation. // mojom::LayeredWindowUpdater implementation.
...@@ -37,7 +39,7 @@ class VIZ_HOST_EXPORT LayeredWindowUpdaterImpl ...@@ -37,7 +39,7 @@ class VIZ_HOST_EXPORT LayeredWindowUpdaterImpl
private: private:
const HWND hwnd_; const HWND hwnd_;
mojo::Binding<mojom::LayeredWindowUpdater> binding_; mojo::Receiver<mojom::LayeredWindowUpdater> receiver_;
std::unique_ptr<SkCanvas> canvas_; std::unique_ptr<SkCanvas> canvas_;
DISALLOW_COPY_AND_ASSIGN(LayeredWindowUpdaterImpl); DISALLOW_COPY_AND_ASSIGN(LayeredWindowUpdaterImpl);
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "components/viz/common/display/use_layered_window.h" #include "components/viz/common/display/use_layered_window.h"
#include "components/viz/common/resources/resource_sizes.h" #include "components/viz/common/resources/resource_sizes.h"
#include "components/viz/service/display_embedder/output_device_backing.h" #include "components/viz/service/display_embedder/output_device_backing.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"
#include "services/viz/privileged/mojom/compositing/layered_window_updater.mojom.h" #include "services/viz/privileged/mojom/compositing/layered_window_updater.mojom.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
...@@ -179,7 +181,7 @@ class SoftwareOutputDeviceWinProxy : public SoftwareOutputDeviceWinBase { ...@@ -179,7 +181,7 @@ class SoftwareOutputDeviceWinProxy : public SoftwareOutputDeviceWinBase {
public: public:
SoftwareOutputDeviceWinProxy( SoftwareOutputDeviceWinProxy(
HWND hwnd, HWND hwnd,
mojom::LayeredWindowUpdaterPtr layered_window_updater); mojo::PendingRemote<mojom::LayeredWindowUpdater> layered_window_updater);
~SoftwareOutputDeviceWinProxy() override = default; ~SoftwareOutputDeviceWinProxy() override = default;
// SoftwareOutputDevice implementation. // SoftwareOutputDevice implementation.
...@@ -194,7 +196,7 @@ class SoftwareOutputDeviceWinProxy : public SoftwareOutputDeviceWinBase { ...@@ -194,7 +196,7 @@ class SoftwareOutputDeviceWinProxy : public SoftwareOutputDeviceWinBase {
// Runs |swap_ack_callback_| after draw has happened. // Runs |swap_ack_callback_| after draw has happened.
void DrawAck(); void DrawAck();
mojom::LayeredWindowUpdaterPtr layered_window_updater_; mojo::Remote<mojom::LayeredWindowUpdater> layered_window_updater_;
std::unique_ptr<SkCanvas> canvas_; std::unique_ptr<SkCanvas> canvas_;
bool waiting_on_draw_ack_ = false; bool waiting_on_draw_ack_ = false;
...@@ -205,7 +207,7 @@ class SoftwareOutputDeviceWinProxy : public SoftwareOutputDeviceWinBase { ...@@ -205,7 +207,7 @@ class SoftwareOutputDeviceWinProxy : public SoftwareOutputDeviceWinBase {
SoftwareOutputDeviceWinProxy::SoftwareOutputDeviceWinProxy( SoftwareOutputDeviceWinProxy::SoftwareOutputDeviceWinProxy(
HWND hwnd, HWND hwnd,
mojom::LayeredWindowUpdaterPtr layered_window_updater) mojo::PendingRemote<mojom::LayeredWindowUpdater> layered_window_updater)
: SoftwareOutputDeviceWinBase(hwnd), : SoftwareOutputDeviceWinBase(hwnd),
layered_window_updater_(std::move(layered_window_updater)) { layered_window_updater_(std::move(layered_window_updater)) {
DCHECK(layered_window_updater_.is_bound()); DCHECK(layered_window_updater_.is_bound());
...@@ -293,9 +295,9 @@ std::unique_ptr<SoftwareOutputDevice> CreateSoftwareOutputDeviceWin( ...@@ -293,9 +295,9 @@ std::unique_ptr<SoftwareOutputDevice> CreateSoftwareOutputDeviceWin(
// Setup mojom::LayeredWindowUpdater implementation in the browser process // Setup mojom::LayeredWindowUpdater implementation in the browser process
// to draw to the HWND. // to draw to the HWND.
mojom::LayeredWindowUpdaterPtr layered_window_updater; mojo::PendingRemote<mojom::LayeredWindowUpdater> layered_window_updater;
display_client->CreateLayeredWindowUpdater( display_client->CreateLayeredWindowUpdater(
mojo::MakeRequest(&layered_window_updater)); layered_window_updater.InitWithNewPipeAndPassReceiver());
return std::make_unique<SoftwareOutputDeviceWinProxy>( return std::make_unique<SoftwareOutputDeviceWinProxy>(
hwnd, std::move(layered_window_updater)); hwnd, std::move(layered_window_updater));
......
...@@ -22,7 +22,7 @@ void FakeDisplayClient::OnDisplayReceivedCALayerParams( ...@@ -22,7 +22,7 @@ void FakeDisplayClient::OnDisplayReceivedCALayerParams(
#if defined(OS_WIN) #if defined(OS_WIN)
void FakeDisplayClient::CreateLayeredWindowUpdater( void FakeDisplayClient::CreateLayeredWindowUpdater(
mojom::LayeredWindowUpdaterRequest request) {} mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver) {}
#endif #endif
#if defined(USE_X11) #if defined(USE_X11)
......
...@@ -28,7 +28,7 @@ class FakeDisplayClient : public mojom::DisplayClient { ...@@ -28,7 +28,7 @@ class FakeDisplayClient : public mojom::DisplayClient {
#if defined(OS_WIN) #if defined(OS_WIN)
void CreateLayeredWindowUpdater( void CreateLayeredWindowUpdater(
mojom::LayeredWindowUpdaterRequest request) override; mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver) override;
#endif #endif
#if defined(USE_X11) #if defined(USE_X11)
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "build/build_config.h" #include "build/build_config.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"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/viz/privileged/mojom/compositing/frame_sink_manager.mojom.h" #include "services/viz/privileged/mojom/compositing/frame_sink_manager.mojom.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
...@@ -26,7 +27,7 @@ class MockDisplayClient : public mojom::DisplayClient { ...@@ -26,7 +27,7 @@ class MockDisplayClient : public mojom::DisplayClient {
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
MOCK_METHOD1(CreateLayeredWindowUpdater, MOCK_METHOD1(CreateLayeredWindowUpdater,
void(mojom::LayeredWindowUpdaterRequest)); void(mojo::PendingReceiver<mojom::LayeredWindowUpdater>));
#endif #endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
MOCK_METHOD1(DidCompleteSwapWithSize, void(const gfx::Size&)); MOCK_METHOD1(DidCompleteSwapWithSize, void(const gfx::Size&));
......
...@@ -85,7 +85,7 @@ interface DisplayClient { ...@@ -85,7 +85,7 @@ interface DisplayClient {
// Creates a LayeredWindowUpdater implementation to draw into a layered // Creates a LayeredWindowUpdater implementation to draw into a layered
// window. // window.
[EnableIf=is_win] [EnableIf=is_win]
CreateLayeredWindowUpdater(LayeredWindowUpdater& layered_window_updater); CreateLayeredWindowUpdater(pending_receiver<LayeredWindowUpdater> receiver);
// Notifies that a swap has occurred and provides information about the pixel // Notifies that a swap has occurred and provides information about the pixel
// size of the swapped frame. // size of the swapped frame.
......
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