Commit 6d8301a5 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

[ozone/wayland] Shm: Proxy: make mojo calls on the gpu thread

This is a prerequisite to unite the buffer managers and
share most of the buffer management APIs between software and
hardware paths.

When software compositing is used, make sure that the calls to mojo
happen on the gpu thread. Otherwise, OnSubmission and OnPresentation
may happen on a completely different thread and hit the DCHECK.

Bug: 963853
Change-Id: I537b7734f88dab23a9f97897ffd48e07bc36a537
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1617502Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#661180}
parent ae179176
......@@ -150,6 +150,22 @@ void WaylandConnectionProxy::CreateShmBufferForWidget(
base::File file,
size_t length,
const gfx::Size size) {
DCHECK(gpu_thread_runner_);
// Do a mojo call on the GpuMainThread instead of the io child thread to
// ensure proper functionality.
gpu_thread_runner_->PostTask(
FROM_HERE,
base::BindOnce(&WaylandConnectionProxy::CreateShmBufferInternal,
base::Unretained(this), widget, std::move(file), length,
std::move(size)));
}
void WaylandConnectionProxy::CreateShmBufferInternal(
gfx::AcceleratedWidget widget,
base::File file,
size_t length,
const gfx::Size size) {
DCHECK(gpu_thread_runner_->BelongsToCurrentThread());
if (!wc_ptr_.is_bound())
BindHostInterface();
......@@ -160,11 +176,36 @@ void WaylandConnectionProxy::CreateShmBufferForWidget(
void WaylandConnectionProxy::PresentShmBufferForWidget(
gfx::AcceleratedWidget widget,
const gfx::Rect& damage) {
DCHECK(gpu_thread_runner_);
// Do a mojo call on the GpuMainThread instead of the io child thread to
// ensure proper functionality.
gpu_thread_runner_->PostTask(
FROM_HERE,
base::BindOnce(&WaylandConnectionProxy::PresentShmBufferForWidgetInternal,
base::Unretained(this), widget, damage));
}
void WaylandConnectionProxy::PresentShmBufferForWidgetInternal(
gfx::AcceleratedWidget widget,
const gfx::Rect& damage) {
DCHECK(gpu_thread_runner_->BelongsToCurrentThread());
DCHECK(wc_ptr_);
wc_ptr_->PresentShmBufferForWidget(widget, damage);
}
void WaylandConnectionProxy::DestroyShmBuffer(gfx::AcceleratedWidget widget) {
DCHECK(gpu_thread_runner_);
// Do a mojo call on the GpuMainThread instead of the io child thread to
// ensure proper functionality.
gpu_thread_runner_->PostTask(
FROM_HERE,
base::BindOnce(&WaylandConnectionProxy::DestroyShmBufferInternal,
base::Unretained(this), widget));
}
void WaylandConnectionProxy::DestroyShmBufferInternal(
gfx::AcceleratedWidget widget) {
DCHECK(gpu_thread_runner_->BelongsToCurrentThread());
DCHECK(wc_ptr_);
wc_ptr_->DestroyShmBuffer(widget);
}
......
......@@ -150,6 +150,14 @@ class WaylandConnectionProxy : public ozone::mojom::WaylandConnectionClient {
void DestroyZwpLinuxDmabufInternal(gfx::AcceleratedWidget widget,
uint32_t buffer_id);
void CreateShmBufferInternal(gfx::AcceleratedWidget widget,
base::File file,
size_t length,
const gfx::Size size);
void PresentShmBufferForWidgetInternal(gfx::AcceleratedWidget widget,
const gfx::Rect& damage);
void DestroyShmBufferInternal(gfx::AcceleratedWidget widget);
void BindHostInterface();
// Non-owned pointer to a WaylandConnection. It is only used in a single
......
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