Commit 910bac36 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

[ozone/wayland] Add possibility to create wl buffer immediately.

zwp_linux_dmabuf protocol is able to create the wl_buffer both
synchronously and asynchronously. This feature depends on the
protocol version.

Thus, if the protocol corresponds to the version, when the buffer
can be created immediately, utilize it and do not wait for the
answer from the Wayland compositor.

Bug: 939794
Change-Id: I14fcad5eae8bcce3b24b662867c13948eb7e4ae6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1572344
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654800}
parent d4239fb5
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
namespace ui { namespace ui {
namespace {
constexpr uint32_t kImmedVerstion = 3;
}
WaylandZwpLinuxDmabuf::WaylandZwpLinuxDmabuf( WaylandZwpLinuxDmabuf::WaylandZwpLinuxDmabuf(
zwp_linux_dmabuf_v1* zwp_linux_dmabuf, zwp_linux_dmabuf_v1* zwp_linux_dmabuf,
WaylandConnection* connection) WaylandConnection* connection)
...@@ -45,10 +49,6 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::File file, ...@@ -45,10 +49,6 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::File file,
struct zwp_linux_buffer_params_v1* params = struct zwp_linux_buffer_params_v1* params =
zwp_linux_dmabuf_v1_create_params(zwp_linux_dmabuf_.get()); zwp_linux_dmabuf_v1_create_params(zwp_linux_dmabuf_.get());
// Store the |params| with the corresponding |callback| to identify newly
// created buffer and notify the client about it via the |callback|.
pending_params_.insert(std::make_pair(params, std::move(callback)));
base::ScopedFD fd(file.TakePlatformFile()); base::ScopedFD fd(file.TakePlatformFile());
for (size_t i = 0; i < planes_count; i++) { for (size_t i = 0; i < planes_count; i++) {
...@@ -65,10 +65,23 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::File file, ...@@ -65,10 +65,23 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::File file,
offsets[i], strides[i], modifier_hi, offsets[i], strides[i], modifier_hi,
modifier_lo); modifier_lo);
} }
zwp_linux_buffer_params_v1_add_listener(params, &params_listener, this);
zwp_linux_buffer_params_v1_create(params, size.width(), size.height(), format,
0);
// It's possible to avoid waiting until the buffer is created and have it
// immediately. This method is only available since the protocol version 3.
if (zwp_linux_dmabuf_v1_get_version(zwp_linux_dmabuf_.get()) >=
kImmedVerstion) {
wl::Object<wl_buffer> buffer(zwp_linux_buffer_params_v1_create_immed(
params, size.width(), size.height(), format, 0));
std::move(callback).Run(std::move(buffer));
} else {
// Store the |params| with the corresponding |callback| to identify newly
// created buffer and notify the client about it via the |callback|.
pending_params_.insert(std::make_pair(params, std::move(callback)));
zwp_linux_buffer_params_v1_add_listener(params, &params_listener, this);
zwp_linux_buffer_params_v1_create(params, size.width(), size.height(),
format, 0);
}
connection_->ScheduleFlush(); connection_->ScheduleFlush();
} }
......
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