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

[ozone/wayland] Fix broken software rendering path.

The "[Ozone/Wayland] Manager: make mojo calls on IO thread." CL:
https://crrev.com/c/1640398 broke the software rendering path,
which results in a DCHECK now.

It turned out that when software rendering is used, the buffers
are committed on the VizCompositorThread, whereas hw accelerated
rendering uses GpuMainThread instead.

To resolve the conflict, rename the |gpu_thread_runner_| to
the |commit_thread_runner_|, and use it when OnSubmission
and OnPresentation calls come.

Bug: 969603
Change-Id: I3600e35fdc9d4fd0817ce9948316a2af86108bdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1642558Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#666629}
parent b1077e4b
......@@ -17,8 +17,7 @@
namespace ui {
WaylandBufferManagerGpu::WaylandBufferManagerGpu()
: associated_binding_(this),
gpu_thread_runner_(base::ThreadTaskRunnerHandle::Get()) {}
: associated_binding_(this) {}
WaylandBufferManagerGpu::~WaylandBufferManagerGpu() = default;
......@@ -50,9 +49,9 @@ void WaylandBufferManagerGpu::OnSubmission(gfx::AcceleratedWidget widget,
// a buffer, and is able to call the OnSubmission for that specific buffer.
if (surface) {
// As long as mojo calls rerouted to the IO child thread, we have to reroute
// them back to the gpu main thread, where the original commit buffer call
// came from.
gpu_thread_runner_->PostTask(
// them back to the same thread, where the original commit buffer call came
// from.
commit_thread_runner_->PostTask(
FROM_HERE,
base::Bind(&WaylandSurfaceGpu::OnSubmission, base::Unretained(surface),
buffer_id, swap_result));
......@@ -71,9 +70,9 @@ void WaylandBufferManagerGpu::OnPresentation(
// a buffer, and is able to call the OnPresentation for that specific buffer.
if (surface) {
// As long as mojo calls rerouted to the IO child thread, we have to reroute
// them back to the gpu main thread, where the original commit buffer call
// came from.
gpu_thread_runner_->PostTask(
// them back to the same thread, where the original commit buffer call came
// from.
commit_thread_runner_->PostTask(
FROM_HERE, base::Bind(&WaylandSurfaceGpu::OnPresentation,
base::Unretained(surface), buffer_id, feedback));
}
......@@ -138,9 +137,11 @@ void WaylandBufferManagerGpu::CreateShmBasedBuffer(
void WaylandBufferManagerGpu::CommitBuffer(gfx::AcceleratedWidget widget,
uint32_t buffer_id,
const gfx::Rect& damage_region) {
DCHECK(gpu_thread_runner_ && gpu_thread_runner_->BelongsToCurrentThread());
DCHECK(io_thread_runner_);
if (!commit_thread_runner_)
commit_thread_runner_ = base::ThreadTaskRunnerHandle::Get();
// Do the mojo call on the IO child thread.
io_thread_runner_->PostTask(
FROM_HERE,
......
......@@ -158,12 +158,13 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*> widget_to_surface_map_;
// This task runner can be used to pass messages back to the GpuMainThread.
// For example, swap requests come from the GpuMainThread, but rerouted to the
// IOChildThread and then mojo calls happen. However, when the manager
// receives mojo calls, it has to reroute calls back to the same thread
// where the calls came from to ensure correct sequence.
scoped_refptr<base::SingleThreadTaskRunner> gpu_thread_runner_;
// 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
// from the GpuMainThread, but rerouted to the IOChildThread and then mojo
// calls happen. However, when the manager receives mojo calls, it has to
// reroute calls back to the same thread where the calls came from to ensure
// correct sequence.
scoped_refptr<base::SingleThreadTaskRunner> commit_thread_runner_;
// A task runner, which is initialized in a multi-process mode. It is used to
// ensure all the methods of this class are run on IOChildThread. This is
......
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