Commit 1e5b1c35 authored by dnicoara's avatar dnicoara Committed by Commit bot

[Ozone-DRI] Remove the extra helper thread and reuse the IO one

Now that we have access to the IO thread, pass the IO task runner to
the main thread and use that to register and listen for page flip
events.

BUG=none

Review URL: https://codereview.chromium.org/891703006

Cr-Commit-Position: refs/heads/master@{#314341}
parent ba000d27
......@@ -35,8 +35,6 @@ source_set("dri_common") {
"dri_gpu_platform_support_.h",
"dri_gpu_platform_support_host.cc",
"dri_gpu_platform_support_host.h",
"dri_helper_thread.cc",
"dri_helper_thread.h",
"dri_surface.cc",
"dri_surface.h",
"dri_surface_factory.cc",
......
......@@ -55,8 +55,6 @@
'dri_gpu_platform_support.h',
'dri_gpu_platform_support_host.cc',
'dri_gpu_platform_support_host.h',
'dri_helper_thread.cc',
'dri_helper_thread.h',
'dri_surface.cc',
'dri_surface.h',
'dri_surface_factory.cc',
......
......@@ -13,7 +13,6 @@
#include "ui/ozone/common/display_util.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/common/gpu/ozone_gpu_messages.h"
#include "ui/ozone/platform/dri/dri_helper_thread.h"
#include "ui/ozone/platform/dri/dri_window_delegate_impl.h"
#include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
#include "ui/ozone/platform/dri/dri_wrapper.h"
......@@ -32,9 +31,13 @@ void MessageProcessedOnMain(
class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter {
public:
typedef base::Callback<void(
const scoped_refptr<base::SingleThreadTaskRunner>&)>
OnFilterAddedCallback;
DriGpuPlatformSupportMessageFilter(
DriWindowDelegateManager* window_manager,
const base::Closure& on_filter_added_callback,
const OnFilterAddedCallback& on_filter_added_callback,
IPC::Listener* main_thread_listener)
: window_manager_(window_manager),
on_filter_added_callback_(on_filter_added_callback),
......@@ -45,7 +48,9 @@ class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter {
void OnFilterAdded(IPC::Sender* sender) override {
io_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
main_thread_task_runner_->PostTask(FROM_HERE, on_filter_added_callback_);
main_thread_task_runner_->PostTask(
FROM_HERE,
base::Bind(on_filter_added_callback_, io_thread_task_runner_));
}
// This code is meant to be very temporary and only as a special case to fix
......@@ -154,7 +159,7 @@ class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter {
}
DriWindowDelegateManager* window_manager_;
base::Closure on_filter_added_callback_;
OnFilterAddedCallback on_filter_added_callback_;
IPC::Listener* main_thread_listener_;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
......@@ -174,8 +179,8 @@ DriGpuPlatformSupport::DriGpuPlatformSupport(
screen_manager_(screen_manager),
ndd_(ndd.Pass()) {
filter_ = new DriGpuPlatformSupportMessageFilter(
window_manager,
base::Bind(&DriGpuPlatformSupport::OnFilterAdded, base::Unretained(this)),
window_manager, base::Bind(&DriGpuPlatformSupport::SetIOTaskRunner,
base::Unretained(this)),
this);
}
......@@ -352,14 +357,13 @@ void DriGpuPlatformSupport::RelinquishGpuResources(
callback.Run();
}
void DriGpuPlatformSupport::OnFilterAdded() {
void DriGpuPlatformSupport::SetIOTaskRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) {
io_task_runner_ = io_task_runner;
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
// Only surfaceless path supports async page flips. So we only initialize the
// helper thread if we're using async page flips.
if (!helper_thread_.IsRunning() &&
cmd->HasSwitch(switches::kOzoneUseSurfaceless)) {
helper_thread_.Initialize();
drm_->InitializeTaskRunner(helper_thread_.task_runner());
// Only surfaceless path supports async page flips.
if (cmd->HasSwitch(switches::kOzoneUseSurfaceless)) {
drm_->InitializeTaskRunner(io_task_runner_);
}
}
......
......@@ -10,13 +10,13 @@
#include "base/memory/scoped_vector.h"
#include "ipc/message_filter.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/dri/dri_helper_thread.h"
#include "ui/ozone/public/gpu_platform_support.h"
class SkBitmap;
namespace base {
class FilePath;
class SingleThreadTaskRunner;
}
namespace gfx {
......@@ -77,17 +77,18 @@ class DriGpuPlatformSupport : public GpuPlatformSupport {
void OnAddGraphicsDevice(const base::FilePath& path);
void OnRemoveGraphicsDevice(const base::FilePath& path);
void OnFilterAdded();
void SetIOTaskRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
IPC::Sender* sender_; // Not owned.
DriWrapper* drm_; // Not owned.
DriWindowDelegateManager* window_manager_; // Not owned.
ScreenManager* screen_manager_; // Not owned.
DriHelperThread helper_thread_;
scoped_ptr<NativeDisplayDelegateDri> ndd_;
ScopedVector<GpuPlatformSupport> handlers_;
scoped_refptr<IPC::MessageFilter> filter_;
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
};
} // namespace ui
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/platform/dri/dri_helper_thread.h"
namespace ui {
DriHelperThread::DriHelperThread() : Thread("DriHelperThread") {
}
DriHelperThread::~DriHelperThread() {
Stop();
}
void DriHelperThread::Initialize() {
DCHECK(!IsRunning());
if (!StartWithOptions(base::Thread::Options(base::MessageLoop::TYPE_IO, 0)))
LOG(FATAL) << "Failed to start the IO helper thread";
}
} // namespace ui
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_DRI_DRI_HELPER_THREAD_H_
#define UI_OZONE_PLATFORM_DRI_DRI_HELPER_THREAD_H_
#include "base/threading/thread.h"
namespace ui {
class DriHelperThread : public base::Thread {
public:
DriHelperThread();
~DriHelperThread() override;
// Call to start the thread. This needs to be called after the GPU entered the
// sandbox.
void Initialize();
private:
DISALLOW_COPY_AND_ASSIGN(DriHelperThread);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRI_DRI_HELPER_THREAD_H_
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