Commit a8420bd4 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

ozone/wayland: Use modifiers provided by Wayland compositor

Wayland compositor provides supported format modifiers.

Store them along with buffer formats and provide the
WaylandBufferManagerGpu with them during initialization step.

Then, GbmPixmapWayland can just use them if they are set.

Bug: 1002463
Change-Id: I97f6367ad9315e3e22b0f9f37c8f1aec03df07a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795326Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#699719}
parent aba3d85b
...@@ -185,8 +185,6 @@ source_set("test_support") { ...@@ -185,8 +185,6 @@ source_set("test_support") {
"test/mock_xdg_shell.h", "test/mock_xdg_shell.h",
"test/mock_xdg_surface.cc", "test/mock_xdg_surface.cc",
"test/mock_xdg_surface.h", "test/mock_xdg_surface.h",
"test/mock_zwp_linux_buffer_params.cc",
"test/mock_zwp_linux_buffer_params.h",
"test/mock_zwp_linux_dmabuf.cc", "test/mock_zwp_linux_dmabuf.cc",
"test/mock_zwp_linux_dmabuf.h", "test/mock_zwp_linux_dmabuf.h",
"test/mock_zwp_text_input.cc", "test/mock_zwp_text_input.cc",
...@@ -217,6 +215,8 @@ source_set("test_support") { ...@@ -217,6 +215,8 @@ source_set("test_support") {
"test/test_touch.h", "test/test_touch.h",
"test/test_wayland_server_thread.cc", "test/test_wayland_server_thread.cc",
"test/test_wayland_server_thread.h", "test/test_wayland_server_thread.h",
"test/test_zwp_linux_buffer_params.cc",
"test/test_zwp_linux_buffer_params.h",
"test/test_zwp_text_input_manager.cc", "test/test_zwp_text_input_manager.cc",
"test/test_zwp_text_input_manager.h", "test/test_zwp_text_input_manager.h",
] ]
...@@ -275,6 +275,7 @@ source_set("wayland_unittests") { ...@@ -275,6 +275,7 @@ source_set("wayland_unittests") {
"//ui/events/ozone:events_ozone_layout", "//ui/events/ozone:events_ozone_layout",
"//ui/ozone:platform", "//ui/ozone:platform",
"//ui/ozone:test_support", "//ui/ozone:test_support",
"//ui/ozone/common/linux:drm",
"//ui/ozone/common/linux:gbm", "//ui/ozone/common/linux:gbm",
] ]
......
...@@ -71,8 +71,9 @@ bool GbmPixmapWayland::InitializeBuffer(gfx::Size size, ...@@ -71,8 +71,9 @@ bool GbmPixmapWayland::InitializeBuffer(gfx::Size size,
} }
const uint32_t fourcc_format = GetFourCCFormatFromBufferFormat(format); const uint32_t fourcc_format = GetFourCCFormatFromBufferFormat(format);
gbm_bo_ = auto modifiers = buffer_manager_->GetModifiersForBufferFormat(format);
buffer_manager_->gbm_device()->CreateBuffer(fourcc_format, size, flags); gbm_bo_ = buffer_manager_->gbm_device()->CreateBufferWithModifiers(
fourcc_format, size, flags, modifiers);
if (!gbm_bo_) { if (!gbm_bo_) {
LOG(ERROR) << "Cannot create bo with format= " LOG(ERROR) << "Cannot create bo with format= "
<< gfx::BufferFormatToString(format) << " and usage " << gfx::BufferFormatToString(format) << " and usage "
......
...@@ -16,26 +16,25 @@ ...@@ -16,26 +16,25 @@
namespace ui { namespace ui {
WaylandBufferManagerGpu::WaylandBufferManagerGpu() WaylandBufferManagerGpu::WaylandBufferManagerGpu() = default;
: associated_binding_(this) {}
WaylandBufferManagerGpu::~WaylandBufferManagerGpu() = default; WaylandBufferManagerGpu::~WaylandBufferManagerGpu() = default;
void WaylandBufferManagerGpu::SetWaylandBufferManagerHost( void WaylandBufferManagerGpu::Initialize(
BufferManagerHostPtr buffer_manager_host_ptr) { mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host,
// This is an IO child thread meant for IPC. Bind interface in this thread and const base::flat_map<::gfx::BufferFormat, std::vector<uint64_t>>&
// do all the mojo calls on the same thread. buffer_formats_with_modifiers,
BindHostInterface(std::move(buffer_manager_host_ptr)); bool supports_dma_buf) {
DCHECK(supported_buffer_formats_with_modifiers_.empty());
supported_buffer_formats_with_modifiers_ = buffer_formats_with_modifiers;
io_thread_runner_ = base::ThreadTaskRunnerHandle::Get();
}
void WaylandBufferManagerGpu::ResetGbmDevice() {
#if defined(WAYLAND_GBM) #if defined(WAYLAND_GBM)
gbm_device_.reset(); if (!supports_dma_buf)
#else set_gbm_device(nullptr);
NOTREACHED();
#endif #endif
BindHostInterface(std::move(remote_host));
io_thread_runner_ = base::ThreadTaskRunnerHandle::Get();
} }
void WaylandBufferManagerGpu::OnSubmission(gfx::AcceleratedWidget widget, void WaylandBufferManagerGpu::OnSubmission(gfx::AcceleratedWidget widget,
...@@ -146,8 +145,19 @@ void WaylandBufferManagerGpu::DestroyBuffer(gfx::AcceleratedWidget widget, ...@@ -146,8 +145,19 @@ void WaylandBufferManagerGpu::DestroyBuffer(gfx::AcceleratedWidget widget,
} }
void WaylandBufferManagerGpu::AddBindingWaylandBufferManagerGpu( void WaylandBufferManagerGpu::AddBindingWaylandBufferManagerGpu(
ozone::mojom::WaylandBufferManagerGpuRequest request) { mojo::PendingReceiver<ozone::mojom::WaylandBufferManagerGpu> receiver) {
bindings_.AddBinding(this, std::move(request)); receiver_.Bind(std::move(receiver));
}
const std::vector<uint64_t>&
WaylandBufferManagerGpu::GetModifiersForBufferFormat(
gfx::BufferFormat buffer_format) const {
auto it = supported_buffer_formats_with_modifiers_.find(buffer_format);
if (it != supported_buffer_formats_with_modifiers_.end()) {
return it->second;
}
static std::vector<uint64_t> dummy;
return dummy;
} }
void WaylandBufferManagerGpu::CreateDmabufBasedBufferInternal( void WaylandBufferManagerGpu::CreateDmabufBasedBufferInternal(
...@@ -161,8 +171,8 @@ void WaylandBufferManagerGpu::CreateDmabufBasedBufferInternal( ...@@ -161,8 +171,8 @@ void WaylandBufferManagerGpu::CreateDmabufBasedBufferInternal(
uint32_t planes_count, uint32_t planes_count,
uint32_t buffer_id) { uint32_t buffer_id) {
DCHECK(io_thread_runner_->BelongsToCurrentThread()); DCHECK(io_thread_runner_->BelongsToCurrentThread());
DCHECK(buffer_manager_host_ptr_); DCHECK(remote_host_);
buffer_manager_host_ptr_->CreateDmabufBasedBuffer( remote_host_->CreateDmabufBasedBuffer(
widget, widget,
mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(dmabuf_fd))), mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(dmabuf_fd))),
size, strides, offsets, modifiers, current_format, planes_count, size, strides, offsets, modifiers, current_format, planes_count,
...@@ -176,8 +186,8 @@ void WaylandBufferManagerGpu::CreateShmBasedBufferInternal( ...@@ -176,8 +186,8 @@ void WaylandBufferManagerGpu::CreateShmBasedBufferInternal(
gfx::Size size, gfx::Size size,
uint32_t buffer_id) { uint32_t buffer_id) {
DCHECK(io_thread_runner_->BelongsToCurrentThread()); DCHECK(io_thread_runner_->BelongsToCurrentThread());
DCHECK(buffer_manager_host_ptr_); DCHECK(remote_host_);
buffer_manager_host_ptr_->CreateShmBasedBuffer( remote_host_->CreateShmBasedBuffer(
widget, mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(shm_fd))), widget, mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(shm_fd))),
length, size, buffer_id); length, size, buffer_id);
} }
...@@ -187,31 +197,30 @@ void WaylandBufferManagerGpu::CommitBufferInternal( ...@@ -187,31 +197,30 @@ void WaylandBufferManagerGpu::CommitBufferInternal(
uint32_t buffer_id, uint32_t buffer_id,
const gfx::Rect& damage_region) { const gfx::Rect& damage_region) {
DCHECK(io_thread_runner_->BelongsToCurrentThread()); DCHECK(io_thread_runner_->BelongsToCurrentThread());
DCHECK(buffer_manager_host_ptr_); DCHECK(remote_host_);
buffer_manager_host_ptr_->CommitBuffer(widget, buffer_id, damage_region); remote_host_->CommitBuffer(widget, buffer_id, damage_region);
} }
void WaylandBufferManagerGpu::DestroyBufferInternal( void WaylandBufferManagerGpu::DestroyBufferInternal(
gfx::AcceleratedWidget widget, gfx::AcceleratedWidget widget,
uint32_t buffer_id) { uint32_t buffer_id) {
DCHECK(io_thread_runner_->BelongsToCurrentThread()); DCHECK(io_thread_runner_->BelongsToCurrentThread());
DCHECK(buffer_manager_host_ptr_); DCHECK(remote_host_);
buffer_manager_host_ptr_->DestroyBuffer(widget, buffer_id); remote_host_->DestroyBuffer(widget, buffer_id);
} }
void WaylandBufferManagerGpu::BindHostInterface( void WaylandBufferManagerGpu::BindHostInterface(
BufferManagerHostPtr buffer_manager_host_ptr) { mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host) {
buffer_manager_host_ptr_.Bind(buffer_manager_host_ptr.PassInterface()); remote_host_.Bind(std::move(remote_host));
// Setup associated interface. // Setup associated interface.
ozone::mojom::WaylandBufferManagerGpuAssociatedPtrInfo client_ptr_info; mojo::PendingAssociatedRemote<ozone::mojom::WaylandBufferManagerGpu>
auto request = MakeRequest(&client_ptr_info); client_remote;
DCHECK(buffer_manager_host_ptr_); associated_receiver_.Bind(client_remote.InitWithNewEndpointAndPassReceiver());
buffer_manager_host_ptr_->SetWaylandBufferManagerGpuPtr( DCHECK(remote_host_);
std::move(client_ptr_info)); remote_host_->SetWaylandBufferManagerGpu(std::move(client_remote));
associated_binding_.Bind(std::move(request));
} }
void WaylandBufferManagerGpu::SubmitSwapResultOnOriginThread( void WaylandBufferManagerGpu::SubmitSwapResultOnOriginThread(
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h" #include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/public/mojom/wayland/wayland_buffer_manager.mojom.h" #include "ui/ozone/public/mojom/wayland/wayland_buffer_manager.mojom.h"
...@@ -45,10 +46,11 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { ...@@ -45,10 +46,11 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
~WaylandBufferManagerGpu() override; ~WaylandBufferManagerGpu() override;
// WaylandBufferManagerGpu overrides: // WaylandBufferManagerGpu overrides:
void SetWaylandBufferManagerHost( void Initialize(
BufferManagerHostPtr buffer_manager_host_ptr) override; mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host,
const base::flat_map<::gfx::BufferFormat, std::vector<uint64_t>>&
void ResetGbmDevice() override; buffer_formats_with_modifiers,
bool supports_dma_buf) override;
// These two calls get the surface, which backs the |widget| and notifies it // These two calls get the surface, which backs the |widget| and notifies it
// about the submission and the presentation. After the surface receives the // about the submission and the presentation. After the surface receives the
...@@ -119,7 +121,11 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { ...@@ -119,7 +121,11 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
// Adds a WaylandBufferManagerGpu binding. // Adds a WaylandBufferManagerGpu binding.
void AddBindingWaylandBufferManagerGpu( void AddBindingWaylandBufferManagerGpu(
ozone::mojom::WaylandBufferManagerGpuRequest request); mojo::PendingReceiver<ozone::mojom::WaylandBufferManagerGpu> receiver);
// Returns supported modifiers for the supplied |buffer_format|.
const std::vector<uint64_t>& GetModifiersForBufferFormat(
gfx::BufferFormat buffer_format) const;
private: private:
void CreateDmabufBasedBufferInternal(gfx::AcceleratedWidget widget, void CreateDmabufBasedBufferInternal(gfx::AcceleratedWidget widget,
...@@ -141,7 +147,8 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { ...@@ -141,7 +147,8 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
const gfx::Rect& damage_region); const gfx::Rect& damage_region);
void DestroyBufferInternal(gfx::AcceleratedWidget widget, uint32_t buffer_id); void DestroyBufferInternal(gfx::AcceleratedWidget widget, uint32_t buffer_id);
void BindHostInterface(BufferManagerHostPtr buffer_manager_host_ptr); void BindHostInterface(
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host);
// Provides the WaylandSurfaceGpu, which backs the |widget|, with swap and // Provides the WaylandSurfaceGpu, which backs the |widget|, with swap and
// presentation results. // presentation results.
...@@ -158,18 +165,24 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { ...@@ -158,18 +165,24 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
std::unique_ptr<GbmDevice> gbm_device_; std::unique_ptr<GbmDevice> gbm_device_;
#endif #endif
mojo::BindingSet<ozone::mojom::WaylandBufferManagerGpu> bindings_; mojo::Receiver<ozone::mojom::WaylandBufferManagerGpu> receiver_{this};
// A pointer to a WaylandBufferManagerHost object, which always lives on a // A pointer to a WaylandBufferManagerHost object, which always lives on a
// browser process side. It's used for a multi-process mode. // browser process side. It's used for a multi-process mode.
BufferManagerHostPtr buffer_manager_host_ptr_; mojo::Remote<ozone::mojom::WaylandBufferManagerHost> remote_host_;
mojo::AssociatedBinding<ozone::mojom::WaylandBufferManagerGpu> mojo::AssociatedReceiver<ozone::mojom::WaylandBufferManagerGpu>
associated_binding_; associated_receiver_{this};
std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*> std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*>
widget_to_surface_map_; // Guarded by |lock_|. widget_to_surface_map_; // Guarded by |lock_|.
// Supported buffer formats and modifiers sent by the Wayland compositor to
// the client. Corresponds to the map stored in WaylandZwpLinuxDmabuf and
// passed from it during initialization of this gpu host.
base::flat_map<gfx::BufferFormat, std::vector<uint64_t>>
supported_buffer_formats_with_modifiers_;
// This task runner can be used to pass messages back to the same thread, // This task runner can be used to pass messages back to the same thread,
// where the commit buffer request came from. For example, swap requests come // where the commit buffer request came from. For example, swap requests come
// from the GpuMainThread, but rerouted to the IOChildThread and then mojo // from the GpuMainThread, but rerouted to the IOChildThread and then mojo
......
...@@ -97,7 +97,7 @@ class WaylandSurfaceFactoryTest : public WaylandTest { ...@@ -97,7 +97,7 @@ class WaylandSurfaceFactoryTest : public WaylandTest {
WaylandTest::SetUp(); WaylandTest::SetUp();
auto manager_ptr = connection_->buffer_manager_host()->BindInterface(); auto manager_ptr = connection_->buffer_manager_host()->BindInterface();
buffer_manager_gpu_->SetWaylandBufferManagerHost(std::move(manager_ptr)); buffer_manager_gpu_->Initialize(std::move(manager_ptr), {}, false);
// Wait until initialization and mojo calls go through. // Wait until initialization and mojo calls go through.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
...@@ -198,7 +198,7 @@ TEST_P(WaylandSurfaceFactoryTest, CreateSurfaceCheckGbm) { ...@@ -198,7 +198,7 @@ TEST_P(WaylandSurfaceFactoryTest, CreateSurfaceCheckGbm) {
// Reset gbm now. WaylandConnectionProxy can reset it when zwp is not // Reset gbm now. WaylandConnectionProxy can reset it when zwp is not
// available. And factory must behave the same way as previously. // available. And factory must behave the same way as previously.
buffer_manager_gpu_->ResetGbmDevice(); buffer_manager_gpu_->set_gbm_device(nullptr);
gl_surface = gl_ozone->CreateSurfacelessViewGLSurface(widget_); gl_surface = gl_ozone->CreateSurfacelessViewGLSurface(widget_);
EXPECT_FALSE(gl_surface); EXPECT_FALSE(gl_surface);
} }
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h" #include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h"
namespace ui { namespace ui {
...@@ -23,17 +25,18 @@ void BindInterfaceInGpuProcess(const std::string& interface_name, ...@@ -23,17 +25,18 @@ void BindInterfaceInGpuProcess(const std::string& interface_name,
} }
template <typename Interface> template <typename Interface>
void BindInterfaceInGpuProcess(mojo::InterfaceRequest<Interface> request, void BindInterfaceInGpuProcess(mojo::PendingReceiver<Interface> request,
const BinderCallback& binder_callback) { const BinderCallback& binder_callback) {
BindInterfaceInGpuProcess( BindInterfaceInGpuProcess(Interface::Name_, std::move(request.PassPipe()),
Interface::Name_, std::move(request.PassMessagePipe()), binder_callback); binder_callback);
} }
} // namespace } // namespace
WaylandBufferManagerConnector::WaylandBufferManagerConnector( WaylandBufferManagerConnector::WaylandBufferManagerConnector(
WaylandBufferManagerHost* buffer_manager) WaylandConnection* wayland_connection)
: buffer_manager_(buffer_manager) {} : buffer_manager_(wayland_connection->buffer_manager_host()),
wayland_connection_(wayland_connection) {}
WaylandBufferManagerConnector::~WaylandBufferManagerConnector() = default; WaylandBufferManagerConnector::~WaylandBufferManagerConnector() = default;
...@@ -78,20 +81,27 @@ void WaylandBufferManagerConnector::OnGpuServiceLaunched( ...@@ -78,20 +81,27 @@ void WaylandBufferManagerConnector::OnGpuServiceLaunched(
} }
void WaylandBufferManagerConnector::OnBufferManagerHostPtrBinded( void WaylandBufferManagerConnector::OnBufferManagerHostPtrBinded(
ozone::mojom::WaylandBufferManagerHostPtr buffer_manager_host_ptr) const { mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost>
ozone::mojom::WaylandBufferManagerGpuPtr buffer_manager_gpu_ptr; buffer_manager_host) const {
auto request = mojo::MakeRequest(&buffer_manager_gpu_ptr); mojo::Remote<ozone::mojom::WaylandBufferManagerGpu> buffer_manager_gpu;
BindInterfaceInGpuProcess(std::move(request), binder_); auto receiver = buffer_manager_gpu.BindNewPipeAndPassReceiver();
DCHECK(buffer_manager_host_ptr); BindInterfaceInGpuProcess(std::move(receiver), binder_);
buffer_manager_gpu_ptr->SetWaylandBufferManagerHost( DCHECK(buffer_manager_gpu);
std::move(buffer_manager_host_ptr));
WaylandZwpLinuxDmabuf::BufferFormatsWithModifiersMap
buffer_formats_with_modifiers;
bool supports_dma_buf = false;
#if defined(WAYLAND_GBM) #if defined(WAYLAND_GBM)
if (!buffer_manager_->CanCreateDmabufBasedBuffer()) { auto* zwp_linux_dmabuf = wayland_connection_->zwp_dmabuf();
LOG(WARNING) << "zwp_linux_dmabuf is not available."; if (zwp_linux_dmabuf) {
buffer_manager_gpu_ptr->ResetGbmDevice(); supports_dma_buf = true;
buffer_formats_with_modifiers =
zwp_linux_dmabuf->supported_buffer_formats();
} }
#endif #endif
buffer_manager_gpu->Initialize(std::move(buffer_manager_host),
buffer_formats_with_modifiers,
supports_dma_buf);
} }
void WaylandBufferManagerConnector::OnTerminateGpuProcess(std::string message) { void WaylandBufferManagerConnector::OnTerminateGpuProcess(std::string message) {
......
...@@ -7,19 +7,20 @@ ...@@ -7,19 +7,20 @@
#include "ui/ozone/public/gpu_platform_support_host.h" #include "ui/ozone/public/gpu_platform_support_host.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/ozone/public/mojom/wayland/wayland_buffer_manager.mojom.h" #include "ui/ozone/public/mojom/wayland/wayland_buffer_manager.mojom.h"
namespace ui { namespace ui {
class WaylandBufferManagerHost; class WaylandBufferManagerHost;
class WaylandConnection;
// A connector class which instantiates a connection between // A connector class which instantiates a connection between
// WaylandBufferManagerGpu on the GPU side and the WaylandBufferManagerHost // WaylandBufferManagerGpu on the GPU side and the WaylandBufferManagerHost
// object on the browser process side. // object on the browser process side.
class WaylandBufferManagerConnector : public GpuPlatformSupportHost { class WaylandBufferManagerConnector : public GpuPlatformSupportHost {
public: public:
explicit WaylandBufferManagerConnector( explicit WaylandBufferManagerConnector(WaylandConnection* wayland_connection);
WaylandBufferManagerHost* buffer_manager);
~WaylandBufferManagerConnector() override; ~WaylandBufferManagerConnector() override;
// GpuPlatformSupportHost: // GpuPlatformSupportHost:
...@@ -39,14 +40,18 @@ class WaylandBufferManagerConnector : public GpuPlatformSupportHost { ...@@ -39,14 +40,18 @@ class WaylandBufferManagerConnector : public GpuPlatformSupportHost {
private: private:
void OnBufferManagerHostPtrBinded( void OnBufferManagerHostPtrBinded(
ozone::mojom::WaylandBufferManagerHostPtr buffer_manager_host_ptr) const; mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost>
buffer_manager_host) const;
void OnTerminateGpuProcess(std::string message); void OnTerminateGpuProcess(std::string message);
// Non-owning pointer, which is used to bind a mojo pointer to the // Non-owned pointer, which is used to bind a mojo pointer to the
// WaylandBufferManagerHost. // WaylandBufferManagerHost.
WaylandBufferManagerHost* const buffer_manager_; WaylandBufferManagerHost* const buffer_manager_;
// Non-owned.
WaylandConnection* const wayland_connection_;
GpuHostBindInterfaceCallback binder_; GpuHostBindInterfaceCallback binder_;
GpuHostTerminateCallback terminate_callback_; GpuHostTerminateCallback terminate_callback_;
......
...@@ -513,8 +513,8 @@ class WaylandBufferManagerHost::Surface { ...@@ -513,8 +513,8 @@ class WaylandBufferManagerHost::Surface {
// surface it backed to avoid its contents shown on screen. However, it // surface it backed to avoid its contents shown on screen. However, it
// means that the Wayland compositor no longer sends new buffer release events // means that the Wayland compositor no longer sends new buffer release events
// as long as there has not been buffer attached and no submission callback is // as long as there has not been buffer attached and no submission callback is
// sent. To avoid this, |contents_reset_| can be used as an identification of a // sent. To avoid this, |contents_reset_| can be used as an identification of
// need to call submission callback manually. // a need to call submission callback manually.
bool contents_reset_ = false; bool contents_reset_ = false;
DISALLOW_COPY_AND_ASSIGN(Surface); DISALLOW_COPY_AND_ASSIGN(Surface);
...@@ -528,7 +528,7 @@ WaylandBufferManagerHost::Surface::WaylandBuffer::~WaylandBuffer() = default; ...@@ -528,7 +528,7 @@ WaylandBufferManagerHost::Surface::WaylandBuffer::~WaylandBuffer() = default;
WaylandBufferManagerHost::WaylandBufferManagerHost( WaylandBufferManagerHost::WaylandBufferManagerHost(
WaylandConnection* connection) WaylandConnection* connection)
: connection_(connection), binding_(this), weak_factory_(this) { : connection_(connection), receiver_(this), weak_factory_(this) {
connection_->wayland_window_manager()->AddObserver(this); connection_->wayland_window_manager()->AddObserver(this);
} }
...@@ -552,31 +552,27 @@ void WaylandBufferManagerHost::SetTerminateGpuCallback( ...@@ -552,31 +552,27 @@ void WaylandBufferManagerHost::SetTerminateGpuCallback(
terminate_gpu_cb_ = std::move(terminate_callback); terminate_gpu_cb_ = std::move(terminate_callback);
} }
ozone::mojom::WaylandBufferManagerHostPtr mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost>
WaylandBufferManagerHost::BindInterface() { WaylandBufferManagerHost::BindInterface() {
DCHECK(!binding_.is_bound()); DCHECK(!receiver_.is_bound());
ozone::mojom::WaylandBufferManagerHostPtr buffer_manager_host_ptr; mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost>
binding_.Bind(MakeRequest(&buffer_manager_host_ptr)); buffer_manager_host;
return buffer_manager_host_ptr; receiver_.Bind(buffer_manager_host.InitWithNewPipeAndPassReceiver());
return buffer_manager_host;
} }
void WaylandBufferManagerHost::OnChannelDestroyed() { void WaylandBufferManagerHost::OnChannelDestroyed() {
buffer_manager_gpu_associated_ptr_.reset(); buffer_manager_gpu_associated_.reset();
binding_.Close(); receiver_.reset();
for (auto& surface_pair : surfaces_) for (auto& surface_pair : surfaces_)
surface_pair.second->ClearState(); surface_pair.second->ClearState();
} }
bool WaylandBufferManagerHost::CanCreateDmabufBasedBuffer() const { void WaylandBufferManagerHost::SetWaylandBufferManagerGpu(
return !!connection_->zwp_dmabuf(); mojo::PendingAssociatedRemote<ozone::mojom::WaylandBufferManagerGpu>
} buffer_manager_gpu_associated) {
buffer_manager_gpu_associated_.Bind(std::move(buffer_manager_gpu_associated));
void WaylandBufferManagerHost::SetWaylandBufferManagerGpuPtr(
ozone::mojom::WaylandBufferManagerGpuAssociatedPtrInfo
buffer_manager_gpu_associated_ptr) {
buffer_manager_gpu_associated_ptr_.Bind(
std::move(buffer_manager_gpu_associated_ptr));
} }
void WaylandBufferManagerHost::CreateDmabufBasedBuffer( void WaylandBufferManagerHost::CreateDmabufBasedBuffer(
...@@ -826,9 +822,8 @@ void WaylandBufferManagerHost::OnSubmission( ...@@ -826,9 +822,8 @@ void WaylandBufferManagerHost::OnSubmission(
const gfx::SwapResult& swap_result) { const gfx::SwapResult& swap_result) {
DCHECK(base::MessageLoopCurrentForUI::IsSet()); DCHECK(base::MessageLoopCurrentForUI::IsSet());
DCHECK(buffer_manager_gpu_associated_ptr_); DCHECK(buffer_manager_gpu_associated_);
buffer_manager_gpu_associated_ptr_->OnSubmission(widget, buffer_id, buffer_manager_gpu_associated_->OnSubmission(widget, buffer_id, swap_result);
swap_result);
} }
void WaylandBufferManagerHost::OnPresentation( void WaylandBufferManagerHost::OnPresentation(
...@@ -837,9 +832,8 @@ void WaylandBufferManagerHost::OnPresentation( ...@@ -837,9 +832,8 @@ void WaylandBufferManagerHost::OnPresentation(
const gfx::PresentationFeedback& feedback) { const gfx::PresentationFeedback& feedback) {
DCHECK(base::MessageLoopCurrentForUI::IsSet()); DCHECK(base::MessageLoopCurrentForUI::IsSet());
DCHECK(buffer_manager_gpu_associated_ptr_); DCHECK(buffer_manager_gpu_associated_);
buffer_manager_gpu_associated_ptr_->OnPresentation(widget, buffer_id, buffer_manager_gpu_associated_->OnPresentation(widget, buffer_id, feedback);
feedback);
} }
void WaylandBufferManagerHost::TerminateGpuProcess() { void WaylandBufferManagerHost::TerminateGpuProcess() {
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/gfx/presentation_feedback.h" #include "ui/gfx/presentation_feedback.h"
...@@ -47,24 +49,20 @@ class WaylandBufferManagerHost : public ozone::mojom::WaylandBufferManagerHost, ...@@ -47,24 +49,20 @@ class WaylandBufferManagerHost : public ozone::mojom::WaylandBufferManagerHost,
base::OnceCallback<void(std::string)> terminate_gpu_cb); base::OnceCallback<void(std::string)> terminate_gpu_cb);
// Returns bound pointer to own mojo interface. // Returns bound pointer to own mojo interface.
ozone::mojom::WaylandBufferManagerHostPtr BindInterface(); mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> BindInterface();
// Unbinds the interface and clears the state of the |buffer_manager_|. Used // Unbinds the interface and clears the state of the |buffer_manager_|. Used
// only when the GPU channel, which uses the mojo pipe to this interface, is // only when the GPU channel, which uses the mojo pipe to this interface, is
// destroyed. // destroyed.
void OnChannelDestroyed(); void OnChannelDestroyed();
// Says if zwp_linux_dmabuf interface is available, and the manager is able to
// create dmabuf based buffers.
bool CanCreateDmabufBasedBuffer() const;
// ozone::mojom::WaylandBufferManagerHost overrides: // ozone::mojom::WaylandBufferManagerHost overrides:
// //
// These overridden methods below are invoked by the GPU when hardware // These overridden methods below are invoked by the GPU when hardware
// accelerated rendering is used. // accelerated rendering is used.
void SetWaylandBufferManagerGpuPtr( void SetWaylandBufferManagerGpu(
ozone::mojom::WaylandBufferManagerGpuAssociatedPtrInfo mojo::PendingAssociatedRemote<ozone::mojom::WaylandBufferManagerGpu>
buffer_manager_gpu_associated_ptr) override; buffer_manager_gpu_associated) override;
// //
// Called by the GPU and asks to import a wl_buffer based on a gbm file // Called by the GPU and asks to import a wl_buffer based on a gbm file
// descriptor using zwp_linux_dmabuf protocol. Check comments in the // descriptor using zwp_linux_dmabuf protocol. Check comments in the
...@@ -160,9 +158,9 @@ class WaylandBufferManagerHost : public ozone::mojom::WaylandBufferManagerHost, ...@@ -160,9 +158,9 @@ class WaylandBufferManagerHost : public ozone::mojom::WaylandBufferManagerHost,
// Non-owned pointer to the main connection. // Non-owned pointer to the main connection.
WaylandConnection* const connection_; WaylandConnection* const connection_;
ozone::mojom::WaylandBufferManagerGpuAssociatedPtr mojo::AssociatedRemote<ozone::mojom::WaylandBufferManagerGpu>
buffer_manager_gpu_associated_ptr_; buffer_manager_gpu_associated_;
mojo::Binding<ozone::mojom::WaylandBufferManagerHost> binding_; mojo::Receiver<ozone::mojom::WaylandBufferManagerHost> receiver_;
// A callback, which is used to terminate a GPU process in case of invalid // A callback, which is used to terminate a GPU process in case of invalid
// data sent by the GPU to the browser process. // data sent by the GPU to the browser process.
......
...@@ -144,12 +144,6 @@ int WaylandConnection::GetKeyboardModifiers() const { ...@@ -144,12 +144,6 @@ int WaylandConnection::GetKeyboardModifiers() const {
return modifiers; return modifiers;
} }
std::vector<gfx::BufferFormat> WaylandConnection::GetSupportedBufferFormats() {
if (zwp_dmabuf_)
return zwp_dmabuf_->supported_buffer_formats();
return std::vector<gfx::BufferFormat>();
}
void WaylandConnection::StartDrag(const ui::OSExchangeData& data, void WaylandConnection::StartDrag(const ui::OSExchangeData& data,
int operation) { int operation) {
if (!dragdrop_data_source_) if (!dragdrop_data_source_)
......
...@@ -100,8 +100,6 @@ class WaylandConnection : public PlatformEventSource, ...@@ -100,8 +100,6 @@ class WaylandConnection : public PlatformEventSource,
return &wayland_window_manager_; return &wayland_window_manager_;
} }
std::vector<gfx::BufferFormat> GetSupportedBufferFormats();
// Starts drag with |data| to be delivered, |operation| supported by the // Starts drag with |data| to be delivered, |operation| supported by the
// source side initiated the dragging. // source side initiated the dragging.
void StartDrag(const ui::OSExchangeData& data, int operation); void StartDrag(const ui::OSExchangeData& data, int operation);
......
...@@ -50,18 +50,9 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::ScopedFD fd, ...@@ -50,18 +50,9 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::ScopedFD fd,
zwp_linux_dmabuf_v1_create_params(zwp_linux_dmabuf_.get()); zwp_linux_dmabuf_v1_create_params(zwp_linux_dmabuf_.get());
for (size_t i = 0; i < planes_count; i++) { for (size_t i = 0; i < planes_count; i++) {
uint32_t modifier_lo = 0;
uint32_t modifier_hi = 0;
if (modifiers[i] != DRM_FORMAT_MOD_INVALID) {
modifier_lo = modifiers[i] & UINT32_MAX;
modifier_hi = modifiers[i] >> 32;
} else {
DCHECK_EQ(planes_count, 1u) << "Invalid modifier may be passed only in "
"case of single plane format being used";
}
zwp_linux_buffer_params_v1_add(params, fd.get(), i /* plane id */, zwp_linux_buffer_params_v1_add(params, fd.get(), i /* plane id */,
offsets[i], strides[i], modifier_hi, offsets[i], strides[i], modifiers[i] >> 32,
modifier_lo); modifiers[i] & UINT32_MAX);
} }
// It's possible to avoid waiting until the buffer is created and have it // It's possible to avoid waiting until the buffer is created and have it
...@@ -83,19 +74,30 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::ScopedFD fd, ...@@ -83,19 +74,30 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::ScopedFD fd,
connection_->ScheduleFlush(); connection_->ScheduleFlush();
} }
void WaylandZwpLinuxDmabuf::AddSupportedFourCCFormat(uint32_t fourcc_format) { void WaylandZwpLinuxDmabuf::AddSupportedFourCCFormatAndModifier(
// Return on not the supported fourcc format. uint32_t fourcc_format,
base::Optional<uint64_t> modifier) {
// Return on not supported fourcc formats.
if (!IsValidBufferFormat(fourcc_format)) if (!IsValidBufferFormat(fourcc_format))
return; return;
// It can happen that ::Format or ::Modifiers call can have already added uint64_t format_modifier = modifier.value_or(DRM_FORMAT_MOD_INVALID);
// such a format. Thus, we can ignore that format.
// If the buffer format has already been stored, it must be another supported
// modifier sent by the Wayland compositor.
gfx::BufferFormat format = GetBufferFormatFromFourCCFormat(fourcc_format); gfx::BufferFormat format = GetBufferFormatFromFourCCFormat(fourcc_format);
auto it = std::find(supported_buffer_formats_.begin(), auto it = supported_buffer_formats_with_modifiers_.find(format);
supported_buffer_formats_.end(), format); if (it != supported_buffer_formats_with_modifiers_.end()) {
if (it != supported_buffer_formats_.end()) if (format_modifier != DRM_FORMAT_MOD_INVALID)
it->second.emplace_back(format_modifier);
return; return;
supported_buffer_formats_.push_back(format); } else {
std::vector<uint64_t> modifiers;
if (format_modifier != DRM_FORMAT_MOD_INVALID)
modifiers.emplace_back(format_modifier);
supported_buffer_formats_with_modifiers_.emplace(format,
std::move(modifiers));
}
} }
void WaylandZwpLinuxDmabuf::NotifyRequestCreateBufferDone( void WaylandZwpLinuxDmabuf::NotifyRequestCreateBufferDone(
...@@ -120,8 +122,10 @@ void WaylandZwpLinuxDmabuf::Modifiers( ...@@ -120,8 +122,10 @@ void WaylandZwpLinuxDmabuf::Modifiers(
uint32_t modifier_hi, uint32_t modifier_hi,
uint32_t modifier_lo) { uint32_t modifier_lo) {
WaylandZwpLinuxDmabuf* self = static_cast<WaylandZwpLinuxDmabuf*>(data); WaylandZwpLinuxDmabuf* self = static_cast<WaylandZwpLinuxDmabuf*>(data);
if (self) if (self) {
self->AddSupportedFourCCFormat(format); uint64_t modifier = static_cast<uint64_t>(modifier_hi) << 32 | modifier_lo;
self->AddSupportedFourCCFormatAndModifier(format, {modifier});
}
} }
// static // static
...@@ -130,7 +134,7 @@ void WaylandZwpLinuxDmabuf::Format(void* data, ...@@ -130,7 +134,7 @@ void WaylandZwpLinuxDmabuf::Format(void* data,
uint32_t format) { uint32_t format) {
WaylandZwpLinuxDmabuf* self = static_cast<WaylandZwpLinuxDmabuf*>(data); WaylandZwpLinuxDmabuf* self = static_cast<WaylandZwpLinuxDmabuf*>(data);
if (self) if (self)
self->AddSupportedFourCCFormat(format); self->AddSupportedFourCCFormatAndModifier(format, base::nullopt);
} }
// static // static
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/files/scoped_file.h" #include "base/files/scoped_file.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h" #include "ui/ozone/platform/wayland/common/wayland_object.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h" #include "ui/ozone/platform/wayland/common/wayland_util.h"
...@@ -29,6 +30,9 @@ class WaylandConnection; ...@@ -29,6 +30,9 @@ class WaylandConnection;
// |wl_buffer|s backed by dmabuf |file| descriptor. // |wl_buffer|s backed by dmabuf |file| descriptor.
class WaylandZwpLinuxDmabuf { class WaylandZwpLinuxDmabuf {
public: public:
using BufferFormatsWithModifiersMap =
base::flat_map<gfx::BufferFormat, std::vector<uint64_t>>;
WaylandZwpLinuxDmabuf(zwp_linux_dmabuf_v1* zwp_linux_dmabuf, WaylandZwpLinuxDmabuf(zwp_linux_dmabuf_v1* zwp_linux_dmabuf,
WaylandConnection* connection); WaylandConnection* connection);
~WaylandZwpLinuxDmabuf(); ~WaylandZwpLinuxDmabuf();
...@@ -46,15 +50,17 @@ class WaylandZwpLinuxDmabuf { ...@@ -46,15 +50,17 @@ class WaylandZwpLinuxDmabuf {
wl::OnRequestBufferCallback callback); wl::OnRequestBufferCallback callback);
// Returns supported buffer formats received from the Wayland compositor. // Returns supported buffer formats received from the Wayland compositor.
std::vector<gfx::BufferFormat> supported_buffer_formats() const { BufferFormatsWithModifiersMap supported_buffer_formats() const {
return supported_buffer_formats_; return supported_buffer_formats_with_modifiers_;
} }
private: private:
// Receives supported |fourcc_format| from either ::Modifers or ::Format call // Receives supported |fourcc_format| from either ::Modifers or ::Format call
// (depending on the protocol version), and stores it as gfx::BufferFormat to // (depending on the protocol version), and stores it as gfx::BufferFormat to
// the |supported_buffer_formats_| container. // the |supported_buffer_formats_| container. Modifiers can also be passed to
void AddSupportedFourCCFormat(uint32_t fourcc_format); // this method to be stored as a map of the format and modifier.
void AddSupportedFourCCFormatAndModifier(uint32_t fourcc_format,
base::Optional<uint64_t> modifier);
// Finds the stored callback corresponding to the |params| created in the // Finds the stored callback corresponding to the |params| created in the
// RequestBufferAsync call, and passes the wl_buffer to the client. The // RequestBufferAsync call, and passes the wl_buffer to the client. The
...@@ -79,14 +85,16 @@ class WaylandZwpLinuxDmabuf { ...@@ -79,14 +85,16 @@ class WaylandZwpLinuxDmabuf {
static void CreateFailed(void* data, static void CreateFailed(void* data,
struct zwp_linux_buffer_params_v1* params); struct zwp_linux_buffer_params_v1* params);
// Holds pointer to the zwp_linux_dmabuf_v1 Wayland factory. // Holds pointer to the
// zwp_linux_dmabuf_v1 Wayland
// factory.
const wl::Object<zwp_linux_dmabuf_v1> zwp_linux_dmabuf_; const wl::Object<zwp_linux_dmabuf_v1> zwp_linux_dmabuf_;
// Non-owned. // Non-owned.
WaylandConnection* const connection_; WaylandConnection* const connection_;
// Holds supported DRM formats translated to gfx::BufferFormat. // Holds supported DRM formats translated to gfx::BufferFormat.
std::vector<gfx::BufferFormat> supported_buffer_formats_; BufferFormatsWithModifiersMap supported_buffer_formats_with_modifiers_;
// Contains callbacks for requests to create |wl_buffer|s using // Contains callbacks for requests to create |wl_buffer|s using
// |zwp_linux_dmabuf_| factory. // |zwp_linux_dmabuf_| factory.
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "ui/ozone/platform/wayland/host/wayland_input_method_context_factory.h" #include "ui/ozone/platform/wayland/host/wayland_input_method_context_factory.h"
#include "ui/ozone/platform/wayland/host/wayland_output_manager.h" #include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h" #include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h"
#include "ui/ozone/public/gpu_platform_support_host.h" #include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/input_controller.h" #include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h" #include "ui/ozone/public/ozone_platform.h"
...@@ -39,6 +40,8 @@ ...@@ -39,6 +40,8 @@
#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
#endif #endif
#include "ui/gfx/buffer_format_util.h"
#if defined(WAYLAND_GBM) #if defined(WAYLAND_GBM)
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#include "ui/ozone/common/linux/gbm_wrapper.h" #include "ui/ozone/common/linux/gbm_wrapper.h"
...@@ -52,10 +55,11 @@ namespace { ...@@ -52,10 +55,11 @@ namespace {
constexpr OzonePlatform::PlatformProperties kWaylandPlatformProperties = { constexpr OzonePlatform::PlatformProperties kWaylandPlatformProperties = {
/*needs_view_token=*/false, /*needs_view_token=*/false,
// Supporting server-side decorations requires a support of xdg-decorations. // Supporting server-side decorations requires a support of
// But this protocol has been accepted into the upstream recently, and it // xdg-decorations. But this protocol has been accepted into the upstream
// will take time before it is taken by compositors. For now, always use // recently, and it will take time before it is taken by compositors. For
// custom frames and disallow switching to server-side frames. // now, always use custom frames and disallow switching to server-side
// frames.
// https://github.com/wayland-project/wayland-protocols/commit/76d1ae8c65739eff3434ef219c58a913ad34e988 // https://github.com/wayland-project/wayland-protocols/commit/76d1ae8c65739eff3434ef219c58a913ad34e988
/*custom_frame_pref_default=*/true, /*custom_frame_pref_default=*/true,
/*use_system_title_bar=*/false, /*use_system_title_bar=*/false,
...@@ -113,8 +117,8 @@ class OzonePlatformWayland : public OzonePlatform { ...@@ -113,8 +117,8 @@ class OzonePlatformWayland : public OzonePlatform {
} }
std::unique_ptr<PlatformScreen> CreateScreen() override { std::unique_ptr<PlatformScreen> CreateScreen() override {
// The WaylandConnection and the WaylandOutputManager must be created before // The WaylandConnection and the WaylandOutputManager must be created
// PlatformScreen. // before PlatformScreen.
DCHECK(connection_ && connection_->wayland_output_manager()); DCHECK(connection_ && connection_->wayland_output_manager());
return connection_->wayland_output_manager()->CreateWaylandScreen( return connection_->wayland_output_manager()->CreateWaylandScreen(
connection_.get()); connection_.get());
...@@ -137,9 +141,8 @@ class OzonePlatformWayland : public OzonePlatform { ...@@ -137,9 +141,8 @@ class OzonePlatformWayland : public OzonePlatform {
if (path_finder_.GetDrmRenderNodePath().empty()) if (path_finder_.GetDrmRenderNodePath().empty())
return false; return false;
if (std::find(supported_buffer_formats_.begin(), if (supported_buffer_formats_.find(format) ==
supported_buffer_formats_.end(), supported_buffer_formats_.end()) {
format) == supported_buffer_formats_.end()) {
return false; return false;
} }
...@@ -159,13 +162,16 @@ class OzonePlatformWayland : public OzonePlatform { ...@@ -159,13 +162,16 @@ class OzonePlatformWayland : public OzonePlatform {
if (!connection_->Initialize()) if (!connection_->Initialize())
LOG(FATAL) << "Failed to initialize Wayland platform"; LOG(FATAL) << "Failed to initialize Wayland platform";
buffer_manager_connector_ = std::make_unique<WaylandBufferManagerConnector>( buffer_manager_connector_ =
connection_->buffer_manager_host()); std::make_unique<WaylandBufferManagerConnector>(connection_.get());
cursor_factory_ = std::make_unique<BitmapCursorFactoryOzone>(); cursor_factory_ = std::make_unique<BitmapCursorFactoryOzone>();
overlay_manager_ = std::make_unique<StubOverlayManager>(); overlay_manager_ = std::make_unique<StubOverlayManager>();
input_controller_ = CreateStubInputController(); input_controller_ = CreateStubInputController();
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
supported_buffer_formats_ = connection_->GetSupportedBufferFormats();
auto* zwp_dmabuf = connection_->zwp_dmabuf();
if (zwp_dmabuf)
supported_buffer_formats_ = zwp_dmabuf->supported_buffer_formats();
// Instantiate and set LinuxInputMethodContextFactory unless it is already // Instantiate and set LinuxInputMethodContextFactory unless it is already
// set (e.g: tests may have already set it). // set (e.g: tests may have already set it).
...@@ -212,8 +218,8 @@ class OzonePlatformWayland : public OzonePlatform { ...@@ -212,8 +218,8 @@ class OzonePlatformWayland : public OzonePlatform {
} }
void CreateWaylandBufferManagerGpuBinding( void CreateWaylandBufferManagerGpuBinding(
ozone::mojom::WaylandBufferManagerGpuRequest request) { mojo::PendingReceiver<ozone::mojom::WaylandBufferManagerGpu> receiver) {
buffer_manager_->AddBindingWaylandBufferManagerGpu(std::move(request)); buffer_manager_->AddBindingWaylandBufferManagerGpu(std::move(receiver));
} }
private: private:
...@@ -234,8 +240,10 @@ class OzonePlatformWayland : public OzonePlatform { ...@@ -234,8 +240,10 @@ class OzonePlatformWayland : public OzonePlatform {
// Objects, which solely live in the GPU process. // Objects, which solely live in the GPU process.
std::unique_ptr<WaylandBufferManagerGpu> buffer_manager_; std::unique_ptr<WaylandBufferManagerGpu> buffer_manager_;
// Provides supported buffer formats for native gpu memory buffers framework. // Provides supported buffer formats for native gpu memory buffers
std::vector<gfx::BufferFormat> supported_buffer_formats_; // framework.
WaylandZwpLinuxDmabuf::BufferFormatsWithModifiersMap
supported_buffer_formats_;
// This is used both in the gpu and browser processes to find out if a drm // This is used both in the gpu and browser processes to find out if a drm
// render node is available. // render node is available.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include "ui/ozone/platform/wayland/test/mock_buffer.h" #include "ui/ozone/platform/wayland/test/mock_buffer.h"
#include "ui/ozone/platform/wayland/test/mock_zwp_linux_buffer_params.h" #include "ui/ozone/platform/wayland/test/test_zwp_linux_buffer_params.h"
namespace wl { namespace wl {
...@@ -18,14 +18,14 @@ constexpr uint32_t kLinuxDmabufVersion = 1; ...@@ -18,14 +18,14 @@ constexpr uint32_t kLinuxDmabufVersion = 1;
void CreateParams(wl_client* client, wl_resource* resource, uint32_t id) { void CreateParams(wl_client* client, wl_resource* resource, uint32_t id) {
wl_resource* params_resource = wl_resource* params_resource =
CreateResourceWithImpl<::testing::NiceMock<MockZwpLinuxBufferParamsV1>>( CreateResourceWithImpl<TestZwpLinuxBufferParamsV1>(
client, &zwp_linux_buffer_params_v1_interface, client, &zwp_linux_buffer_params_v1_interface,
wl_resource_get_version(resource), &kMockZwpLinuxBufferParamsV1Impl, wl_resource_get_version(resource), &kTestZwpLinuxBufferParamsV1Impl,
id); id);
auto* zwp_linux_dmabuf = GetUserDataAs<MockZwpLinuxDmabufV1>(resource); auto* zwp_linux_dmabuf = GetUserDataAs<MockZwpLinuxDmabufV1>(resource);
auto* buffer_params = auto* buffer_params =
GetUserDataAs<MockZwpLinuxBufferParamsV1>(params_resource); GetUserDataAs<TestZwpLinuxBufferParamsV1>(params_resource);
DCHECK(buffer_params); DCHECK(buffer_params);
zwp_linux_dmabuf->StoreBufferParams(buffer_params); zwp_linux_dmabuf->StoreBufferParams(buffer_params);
...@@ -50,12 +50,12 @@ MockZwpLinuxDmabufV1::~MockZwpLinuxDmabufV1() { ...@@ -50,12 +50,12 @@ MockZwpLinuxDmabufV1::~MockZwpLinuxDmabufV1() {
} }
void MockZwpLinuxDmabufV1::StoreBufferParams( void MockZwpLinuxDmabufV1::StoreBufferParams(
MockZwpLinuxBufferParamsV1* params) { TestZwpLinuxBufferParamsV1* params) {
buffer_params_.push_back(params); buffer_params_.push_back(params);
} }
void MockZwpLinuxDmabufV1::OnBufferParamsDestroyed( void MockZwpLinuxDmabufV1::OnBufferParamsDestroyed(
MockZwpLinuxBufferParamsV1* params) { TestZwpLinuxBufferParamsV1* params) {
auto it = std::find(buffer_params_.begin(), buffer_params_.end(), params); auto it = std::find(buffer_params_.begin(), buffer_params_.end(), params);
DCHECK(it != buffer_params_.end()); DCHECK(it != buffer_params_.end());
buffer_params_.erase(it); buffer_params_.erase(it);
......
...@@ -18,7 +18,7 @@ namespace wl { ...@@ -18,7 +18,7 @@ namespace wl {
extern const struct zwp_linux_dmabuf_v1_interface kMockZwpLinuxDmabufV1Impl; extern const struct zwp_linux_dmabuf_v1_interface kMockZwpLinuxDmabufV1Impl;
class MockZwpLinuxBufferParamsV1; class TestZwpLinuxBufferParamsV1;
// Manage zwp_linux_dmabuf_v1 object. // Manage zwp_linux_dmabuf_v1 object.
class MockZwpLinuxDmabufV1 : public GlobalObject { class MockZwpLinuxDmabufV1 : public GlobalObject {
...@@ -32,16 +32,16 @@ class MockZwpLinuxDmabufV1 : public GlobalObject { ...@@ -32,16 +32,16 @@ class MockZwpLinuxDmabufV1 : public GlobalObject {
wl_resource* resource, wl_resource* resource,
uint32_t params_id)); uint32_t params_id));
const std::vector<MockZwpLinuxBufferParamsV1*>& buffer_params() const { const std::vector<TestZwpLinuxBufferParamsV1*>& buffer_params() const {
return buffer_params_; return buffer_params_;
} }
void StoreBufferParams(MockZwpLinuxBufferParamsV1* params); void StoreBufferParams(TestZwpLinuxBufferParamsV1* params);
void OnBufferParamsDestroyed(MockZwpLinuxBufferParamsV1* params); void OnBufferParamsDestroyed(TestZwpLinuxBufferParamsV1* params);
private: private:
std::vector<MockZwpLinuxBufferParamsV1*> buffer_params_; std::vector<TestZwpLinuxBufferParamsV1*> buffer_params_;
DISALLOW_COPY_AND_ASSIGN(MockZwpLinuxDmabufV1); DISALLOW_COPY_AND_ASSIGN(MockZwpLinuxDmabufV1);
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/ozone/platform/wayland/test/mock_zwp_linux_buffer_params.h" #include "ui/ozone/platform/wayland/test/test_zwp_linux_buffer_params.h"
#include "ui/ozone/platform/wayland/test/mock_buffer.h" #include "ui/ozone/platform/wayland/test/mock_buffer.h"
#include "ui/ozone/platform/wayland/test/mock_zwp_linux_dmabuf.h" #include "ui/ozone/platform/wayland/test/mock_zwp_linux_dmabuf.h"
...@@ -19,14 +19,14 @@ void Add(wl_client* client, ...@@ -19,14 +19,14 @@ void Add(wl_client* client,
uint32_t stride, uint32_t stride,
uint32_t modifier_hi, uint32_t modifier_hi,
uint32_t modifier_lo) { uint32_t modifier_lo) {
auto* buffer_params = GetUserDataAs<MockZwpLinuxBufferParamsV1>(resource); auto* buffer_params = GetUserDataAs<TestZwpLinuxBufferParamsV1>(resource);
buffer_params->fds_.emplace_back(fd); buffer_params->fds_.emplace_back(fd);
buffer_params->Add(client, resource, fd, plane_idx, offset, stride, buffer_params->modifier_lo_ = modifier_lo;
modifier_hi, modifier_lo); buffer_params->modifier_hi_ = modifier_hi;
} }
void CreateCommon(MockZwpLinuxBufferParamsV1* buffer_params, void CreateCommon(TestZwpLinuxBufferParamsV1* buffer_params,
wl_client* client, wl_client* client,
int32_t width, int32_t width,
int32_t height, int32_t height,
...@@ -47,10 +47,8 @@ void Create(wl_client* client, ...@@ -47,10 +47,8 @@ void Create(wl_client* client,
uint32_t format, uint32_t format,
uint32_t flags) { uint32_t flags) {
auto* buffer_params = auto* buffer_params =
GetUserDataAs<MockZwpLinuxBufferParamsV1>(buffer_params_resource); GetUserDataAs<TestZwpLinuxBufferParamsV1>(buffer_params_resource);
CreateCommon(buffer_params, client, width, height, format, flags); CreateCommon(buffer_params, client, width, height, format, flags);
buffer_params->Create(client, buffer_params_resource, width, height, format,
flags);
} }
void CreateImmed(wl_client* client, void CreateImmed(wl_client* client,
...@@ -61,33 +59,31 @@ void CreateImmed(wl_client* client, ...@@ -61,33 +59,31 @@ void CreateImmed(wl_client* client,
uint32_t format, uint32_t format,
uint32_t flags) { uint32_t flags) {
auto* buffer_params = auto* buffer_params =
GetUserDataAs<MockZwpLinuxBufferParamsV1>(buffer_params_resource); GetUserDataAs<TestZwpLinuxBufferParamsV1>(buffer_params_resource);
CreateCommon(buffer_params, client, width, height, format, flags); CreateCommon(buffer_params, client, width, height, format, flags);
buffer_params->CreateImmed(client, buffer_params_resource, buffer_id, width,
height, format, flags);
} }
} // namespace } // namespace
const struct zwp_linux_buffer_params_v1_interface const struct zwp_linux_buffer_params_v1_interface
kMockZwpLinuxBufferParamsV1Impl = {&DestroyResource, &Add, &Create, kTestZwpLinuxBufferParamsV1Impl = {&DestroyResource, &Add, &Create,
&CreateImmed}; &CreateImmed};
MockZwpLinuxBufferParamsV1::MockZwpLinuxBufferParamsV1(wl_resource* resource) TestZwpLinuxBufferParamsV1::TestZwpLinuxBufferParamsV1(wl_resource* resource)
: ServerObject(resource) {} : ServerObject(resource) {}
MockZwpLinuxBufferParamsV1::~MockZwpLinuxBufferParamsV1() { TestZwpLinuxBufferParamsV1::~TestZwpLinuxBufferParamsV1() {
DCHECK(linux_dmabuf_); DCHECK(linux_dmabuf_);
linux_dmabuf_->OnBufferParamsDestroyed(this); linux_dmabuf_->OnBufferParamsDestroyed(this);
} }
void MockZwpLinuxBufferParamsV1::SetZwpLinuxDmabuf( void TestZwpLinuxBufferParamsV1::SetZwpLinuxDmabuf(
MockZwpLinuxDmabufV1* linux_dmabuf) { MockZwpLinuxDmabufV1* linux_dmabuf) {
DCHECK(!linux_dmabuf_); DCHECK(!linux_dmabuf_);
linux_dmabuf_ = linux_dmabuf; linux_dmabuf_ = linux_dmabuf;
} }
void MockZwpLinuxBufferParamsV1::SetBufferResource(wl_resource* resource) { void TestZwpLinuxBufferParamsV1::SetBufferResource(wl_resource* resource) {
DCHECK(!buffer_resource_); DCHECK(!buffer_resource_);
buffer_resource_ = resource; buffer_resource_ = resource;
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_MOCK_ZWP_LINUX_BUFFER_PARAMS_H_ #ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_ZWP_LINUX_BUFFER_PARAMS_H_
#define UI_OZONE_PLATFORM_WAYLAND_TEST_MOCK_ZWP_LINUX_BUFFER_PARAMS_H_ #define UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_ZWP_LINUX_BUFFER_PARAMS_H_
#include <linux-dmabuf-unstable-v1-server-protocol.h> #include <linux-dmabuf-unstable-v1-server-protocol.h>
...@@ -18,41 +18,38 @@ struct wl_resource; ...@@ -18,41 +18,38 @@ struct wl_resource;
namespace wl { namespace wl {
extern const struct zwp_linux_buffer_params_v1_interface extern const struct zwp_linux_buffer_params_v1_interface
kMockZwpLinuxBufferParamsV1Impl; kTestZwpLinuxBufferParamsV1Impl;
class MockZwpLinuxDmabufV1; class MockZwpLinuxDmabufV1;
// Manage zwp_linux_buffer_params_v1 // Manage zwp_linux_buffer_params_v1
class MockZwpLinuxBufferParamsV1 : public ServerObject { class TestZwpLinuxBufferParamsV1 : public ServerObject {
public: public:
MockZwpLinuxBufferParamsV1(wl_resource* resource); explicit TestZwpLinuxBufferParamsV1(wl_resource* resource);
~MockZwpLinuxBufferParamsV1(); ~TestZwpLinuxBufferParamsV1() override;
MOCK_METHOD2(Destroy, void(wl_client* client, wl_resource* resource)); void Destroy(wl_client* client, wl_resource* resource);
MOCK_METHOD8(Add, void Add(wl_client* client,
void(wl_client* client, wl_resource* resource,
wl_resource* resource, int32_t fd,
int32_t fd, uint32_t plane_idx,
uint32_t plane_idx, uint32_t offset,
uint32_t offset, uint32_t stride,
uint32_t stride, uint32_t modifier_hi,
uint32_t modifier_hi, uint32_t modifier_lo);
uint32_t modifier_lo)); void Create(wl_client* client,
MOCK_METHOD6(Create, wl_resource* resource,
void(wl_client* client, int32_t width,
wl_resource* resource, int32_t height,
int32_t width, uint32_t format,
int32_t height, uint32_t flags);
uint32_t format, void CreateImmed(wl_client* client,
uint32_t flags)); wl_resource* resource,
MOCK_METHOD7(CreateImmed, uint32_t buffer_id,
void(wl_client* client, int32_t width,
wl_resource* resource, int32_t height,
uint32_t buffer_id, uint32_t format,
int32_t width, uint32_t flags);
int32_t height,
uint32_t format,
uint32_t flags));
wl_resource* buffer_resource() const { return buffer_resource_; } wl_resource* buffer_resource() const { return buffer_resource_; }
...@@ -62,6 +59,9 @@ class MockZwpLinuxBufferParamsV1 : public ServerObject { ...@@ -62,6 +59,9 @@ class MockZwpLinuxBufferParamsV1 : public ServerObject {
std::vector<base::ScopedFD> fds_; std::vector<base::ScopedFD> fds_;
uint32_t modifier_hi_ = 0;
uint32_t modifier_lo_ = 0;
private: private:
// Non-owned pointer to the linux dmabuf object, which created this params // Non-owned pointer to the linux dmabuf object, which created this params
// resource and holds a pointer to it. On destruction, must notify it about // resource and holds a pointer to it. On destruction, must notify it about
...@@ -72,9 +72,9 @@ class MockZwpLinuxBufferParamsV1 : public ServerObject { ...@@ -72,9 +72,9 @@ class MockZwpLinuxBufferParamsV1 : public ServerObject {
// null if not created/failed to be created. // null if not created/failed to be created.
wl_resource* buffer_resource_ = nullptr; wl_resource* buffer_resource_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(MockZwpLinuxBufferParamsV1); DISALLOW_COPY_AND_ASSIGN(TestZwpLinuxBufferParamsV1);
}; };
} // namespace wl } // namespace wl
#endif // UI_OZONE_PLATFORM_WAYLAND_TEST_MOCK_ZWP_LINUX_BUFFER_PARAMS_H_ #endif // UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_ZWP_LINUX_BUFFER_PARAMS_H_
...@@ -14,10 +14,13 @@ ...@@ -14,10 +14,13 @@
#include "mojo/public/cpp/system/platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/ozone/common/linux/drm_util_linux.h"
#include "ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h" #include "ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h"
#include "ui/ozone/platform/wayland/test/mock_surface.h" #include "ui/ozone/platform/wayland/test/mock_surface.h"
#include "ui/ozone/platform/wayland/test/mock_zwp_linux_buffer_params.h"
#include "ui/ozone/platform/wayland/test/mock_zwp_linux_dmabuf.h" #include "ui/ozone/platform/wayland/test/mock_zwp_linux_dmabuf.h"
#include "ui/ozone/platform/wayland/test/test_zwp_linux_buffer_params.h"
#include "ui/ozone/platform/wayland/test/wayland_test.h" #include "ui/ozone/platform/wayland/test/wayland_test.h"
using testing::_; using testing::_;
...@@ -81,7 +84,7 @@ class WaylandBufferManagerTest : public WaylandTest { ...@@ -81,7 +84,7 @@ class WaylandBufferManagerTest : public WaylandTest {
// callback and bind the interface again if the manager failed. // callback and bind the interface again if the manager failed.
manager_host_->SetTerminateGpuCallback(callback_.Get()); manager_host_->SetTerminateGpuCallback(callback_.Get());
auto interface_ptr = manager_host_->BindInterface(); auto interface_ptr = manager_host_->BindInterface();
buffer_manager_gpu_->SetWaylandBufferManagerHost(std::move(interface_ptr)); buffer_manager_gpu_->Initialize(std::move(interface_ptr), {}, false);
} }
protected: protected:
...@@ -109,11 +112,15 @@ class WaylandBufferManagerTest : public WaylandTest { ...@@ -109,11 +112,15 @@ class WaylandBufferManagerTest : public WaylandTest {
.Times(1) .Times(1)
.WillRepeatedly(::testing::Invoke([this, callback](std::string) { .WillRepeatedly(::testing::Invoke([this, callback](std::string) {
manager_host_->OnChannelDestroyed(); manager_host_->OnChannelDestroyed();
manager_host_->SetTerminateGpuCallback(callback->Get()); manager_host_->SetTerminateGpuCallback(callback->Get());
auto interface_ptr = manager_host_->BindInterface(); auto interface_ptr = manager_host_->BindInterface();
buffer_manager_gpu_->SetWaylandBufferManagerHost( // Recreate the gpu side manager (the production code does the
std::move(interface_ptr)); // same).
buffer_manager_gpu_ = std::make_unique<WaylandBufferManagerGpu>();
buffer_manager_gpu_->Initialize(std::move(interface_ptr), {},
false);
})); }));
} }
} }
...@@ -201,6 +208,54 @@ TEST_P(WaylandBufferManagerTest, CreateDmabufBasedBuffers) { ...@@ -201,6 +208,54 @@ TEST_P(WaylandBufferManagerTest, CreateDmabufBasedBuffers) {
false /*fail*/); false /*fail*/);
} }
TEST_P(WaylandBufferManagerTest, VerifyModifiers) {
constexpr uint32_t kDmabufBufferId = 1;
constexpr uint32_t kFourccFormatR8 = DRM_FORMAT_R8;
constexpr uint64_t kFormatModiferLinear = DRM_FORMAT_MOD_LINEAR;
const std::vector<uint64_t> kFormatModifiers{DRM_FORMAT_MOD_INVALID,
kFormatModiferLinear};
// Tests that fourcc format is added, but invalid modifier is ignored first.
// Then, when valid modifier comes, it is stored.
for (const auto& modifier : kFormatModifiers) {
uint32_t modifier_hi = modifier >> 32;
uint32_t modifier_lo = modifier & UINT32_MAX;
zwp_linux_dmabuf_v1_send_modifier(server_.zwp_linux_dmabuf_v1()->resource(),
kFourccFormatR8, modifier_hi,
modifier_lo);
Sync();
auto buffer_formats = connection_->zwp_dmabuf()->supported_buffer_formats();
DCHECK_EQ(buffer_formats.size(), 1u);
DCHECK_EQ(buffer_formats.begin()->first,
GetBufferFormatFromFourCCFormat(kFourccFormatR8));
auto modifiers = buffer_formats.begin()->second;
if (modifier == DRM_FORMAT_MOD_INVALID) {
DCHECK_EQ(modifiers.size(), 0u);
} else {
DCHECK_EQ(modifiers.size(), 1u);
DCHECK_EQ(modifiers[0], modifier);
}
}
EXPECT_CALL(*server_.zwp_linux_dmabuf_v1(), CreateParams(_, _, _)).Times(1);
const gfx::AcceleratedWidget widget = window_->GetWidget();
CreateDmabufBasedBufferAndSetTerminateExpecation(
false /*fail*/, widget, kDmabufBufferId, base::ScopedFD(), kDefaultSize,
{1}, {2}, {kFormatModiferLinear}, kFourccFormatR8, 1);
Sync();
auto params_vector = server_.zwp_linux_dmabuf_v1()->buffer_params();
EXPECT_EQ(params_vector.size(), 1u);
EXPECT_EQ(params_vector[0]->modifier_hi_, kFormatModiferLinear >> 32);
EXPECT_EQ(params_vector[0]->modifier_lo_, kFormatModiferLinear & UINT32_MAX);
}
TEST_P(WaylandBufferManagerTest, CreateShmBasedBuffers) { TEST_P(WaylandBufferManagerTest, CreateShmBasedBuffers) {
constexpr uint32_t kShmBufferId = 1; constexpr uint32_t kShmBufferId = 1;
......
...@@ -9,13 +9,15 @@ import "ui/gfx/geometry/mojom/geometry.mojom"; ...@@ -9,13 +9,15 @@ import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/accelerated_widget.mojom"; import "ui/gfx/mojom/accelerated_widget.mojom";
import "ui/gfx/mojom/presentation_feedback.mojom"; import "ui/gfx/mojom/presentation_feedback.mojom";
import "ui/gfx/mojom/swap_result.mojom"; import "ui/gfx/mojom/swap_result.mojom";
import "ui/gfx/mojom/buffer_types.mojom";
// Used by the GPU for communication with the WaylandBufferManagerHost in // Used by the GPU for communication with the WaylandBufferManagerHost in
// the browser process. // the browser process.
interface WaylandBufferManagerHost { interface WaylandBufferManagerHost {
// Sets up an associated pipe between the Gpu and Host. // Sets up an associated pipe between the Gpu and Host.
SetWaylandBufferManagerGpuPtr( SetWaylandBufferManagerGpu(
associated WaylandBufferManagerGpu buffer_manager_gpu_associated_ptr); pending_associated_remote<WaylandBufferManagerGpu>
buffer_manager_gpu_associated);
// The following two methods are used either for hardware accelerated // The following two methods are used either for hardware accelerated
// rendering or for the software rendering. // rendering or for the software rendering.
...@@ -69,14 +71,20 @@ interface WaylandBufferManagerHost { ...@@ -69,14 +71,20 @@ interface WaylandBufferManagerHost {
interface WaylandBufferManagerGpu { interface WaylandBufferManagerGpu {
// Used by the browser process to provide the GPU process with a mojo ptr to a // Initializes the gpu side buffer manager by passing the interface pointer of
// WaylandBufferManagerHost, which lives in the browser process. // of the WaylandBufferManagerHost that lives in the browser process to it.
SetWaylandBufferManagerHost(WaylandBufferManagerHost buffer_manager_host_ptr); // Also supplies the gpu side manager with the supported buffer formats and
// modifiers so that gpu side clients could be aware of supported modifiers
// The browser process may request the client to reset gbm device instance to // the Wayland compositor announces. The modifiers may be empty, which means
// avoid using zwp_linux_dmabuf protocol, which means using wl_egl_surface in // modifiers are not supported.
// a single process mode, and software rendering in a multiple process mode. // The browser process may also request the client to reset gbm device
ResetGbmDevice(); // instance to avoid using zwp_linux_dmabuf protocol by setting
// |supports_dma_buf| to false, which results in using wl_egl_surface in a
// single process mode, and software rendering in a multiple process mode.
Initialize(pending_remote<WaylandBufferManagerHost> remote_host,
map<gfx.mojom.BufferFormat,
array<uint64>> buffer_formats_with_modifiers,
bool supports_dma_buf);
// Signals about swap completion. // Signals about swap completion.
OnSubmission(gfx.mojom.AcceleratedWidget widget, OnSubmission(gfx.mojom.AcceleratedWidget widget,
......
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