Commit d818104f authored by dnicoara's avatar dnicoara Committed by Commit bot

[Ozone-Drm] Notify cursor of channel established last

The cursor is special since movements don't need to be routed to
the UI thread, instead they are directly dispatched to the GPU
process from the IO-thread. During the recovery of a crashed GPU
process, the windowing state needs to be re-created on the new GPU. As
such we need to make sure that the windows are re-created on the GPU
before the cursor can send targeted events (to a specific window).

BUG=468485

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

Cr-Commit-Position: refs/heads/master@{#321645}
parent d317e89d
......@@ -10,7 +10,6 @@
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/ozone/common/gpu/ozone_gpu_messages.h"
#include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
#include "ui/ozone/platform/drm/host/drm_window_host.h"
#include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
......@@ -20,18 +19,11 @@
namespace ui {
DrmCursor::DrmCursor(DrmWindowHostManager* window_manager,
DrmGpuPlatformSupportHost* gpu_platform_support_host)
: window_manager_(window_manager),
gpu_platform_support_host_(gpu_platform_support_host) {
DrmCursor::DrmCursor(DrmWindowHostManager* window_manager)
: window_manager_(window_manager) {
}
DrmCursor::~DrmCursor() {
gpu_platform_support_host_->UnregisterHandler(this);
}
void DrmCursor::Init() {
gpu_platform_support_host_->RegisterHandler(this);
}
void DrmCursor::SetCursor(gfx::AcceleratedWidget window,
......
......@@ -31,12 +31,9 @@ class DrmWindowHostManager;
class DrmCursor : public CursorDelegateEvdev, public GpuPlatformSupportHost {
public:
explicit DrmCursor(DrmWindowHostManager* window_manager,
DrmGpuPlatformSupportHost* sender);
explicit DrmCursor(DrmWindowHostManager* window_manager);
~DrmCursor() override;
void Init();
// Change the cursor over the specifed window.
void SetCursor(gfx::AcceleratedWidget window, PlatformCursor platform_cursor);
......@@ -90,7 +87,6 @@ class DrmCursor : public CursorDelegateEvdev, public GpuPlatformSupportHost {
void SendLocked(IPC::Message* message);
DrmWindowHostManager* window_manager_; // Not owned.
DrmGpuPlatformSupportHost* gpu_platform_support_host_; // Not owned.
// Task runner for main thread.
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
......
......@@ -8,10 +8,12 @@
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/common/gpu/ozone_gpu_messages.h"
#include "ui/ozone/platform/drm/host/channel_observer.h"
#include "ui/ozone/platform/drm/host/drm_cursor.h"
namespace ui {
DrmGpuPlatformSupportHost::DrmGpuPlatformSupportHost() : host_id_(-1) {
DrmGpuPlatformSupportHost::DrmGpuPlatformSupportHost(DrmCursor* cursor)
: host_id_(-1), cursor_(cursor) {
}
DrmGpuPlatformSupportHost::~DrmGpuPlatformSupportHost() {
......@@ -64,11 +66,20 @@ void DrmGpuPlatformSupportHost::OnChannelEstablished(
FOR_EACH_OBSERVER(ChannelObserver, channel_observers_,
OnChannelEstablished());
// The cursor is special since it will process input events on the IO thread
// and can by-pass the UI thread. This means that we need to special case it
// and notify it after all other observers/handlers are notified such that the
// (windowing) state on the GPU can be initialized before the cursor is
// allowed to IPC messages (which are targeted to a specific window).
cursor_->OnChannelEstablished(host_id, send_runner_, send_callback_);
}
void DrmGpuPlatformSupportHost::OnChannelDestroyed(int host_id) {
TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnChannelDestroyed",
"host_id", host_id);
cursor_->OnChannelDestroyed(host_id);
if (host_id_ == host_id) {
host_id_ = -1;
send_runner_ = nullptr;
......
......@@ -21,11 +21,12 @@ class Point;
namespace ui {
class ChannelObserver;
class DrmCursor;
class DrmGpuPlatformSupportHost : public GpuPlatformSupportHost,
public IPC::Sender {
public:
DrmGpuPlatformSupportHost();
DrmGpuPlatformSupportHost(DrmCursor* cursor);
~DrmGpuPlatformSupportHost() override;
void RegisterHandler(GpuPlatformSupportHost* handler);
......@@ -55,7 +56,8 @@ class DrmGpuPlatformSupportHost : public GpuPlatformSupportHost,
scoped_refptr<base::SingleThreadTaskRunner> send_runner_;
base::Callback<void(IPC::Message*)> send_callback_;
std::vector<GpuPlatformSupportHost*> handlers_;
std::vector<GpuPlatformSupportHost*> handlers_; // Not owned.
DrmCursor* cursor_; // Not owned.
ObserverList<ChannelObserver> channel_observers_;
};
......
......@@ -103,6 +103,7 @@ class OzonePlatformDrm : public OzonePlatform {
ForceInitializationOfPrimaryDisplay(drm_, screen_manager_.get());
drm_device_manager_.reset(new DrmDeviceManager(drm_));
display_manager_.reset(new DisplayManager());
cursor_.reset(new DrmCursor(window_manager_.get()));
surface_factory_ozone_.reset(
new DrmSurfaceFactory(&window_delegate_manager_));
scoped_ptr<DrmGpuDisplayManager> ndd(new DrmGpuDisplayManager(
......@@ -111,12 +112,10 @@ class OzonePlatformDrm : public OzonePlatform {
gpu_platform_support_.reset(new DrmGpuPlatformSupport(
drm_device_manager_.get(), &window_delegate_manager_,
screen_manager_.get(), ndd.Pass()));
gpu_platform_support_host_.reset(new DrmGpuPlatformSupportHost());
gpu_platform_support_host_.reset(
new DrmGpuPlatformSupportHost(cursor_.get()));
window_manager_.reset(new DrmWindowHostManager());
cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
cursor_.reset(
new DrmCursor(window_manager_.get(), gpu_platform_support_host_.get()));
cursor_->Init();
#if defined(USE_XKBCOMMON)
KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(make_scoped_ptr(
new XkbKeyboardLayoutEngine(xkb_evdev_code_converter_)));
......@@ -148,8 +147,8 @@ class OzonePlatformDrm : public OzonePlatform {
// Objects in the "Browser" process.
scoped_ptr<DeviceManager> device_manager_;
scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
scoped_ptr<DrmCursor> cursor_;
scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
scoped_ptr<DrmWindowHostManager> window_manager_;
scoped_ptr<DisplayManager> display_manager_;
scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_;
......
......@@ -154,12 +154,11 @@ class OzonePlatformGbm : public OzonePlatform {
if (!surface_factory_ozone_)
surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_));
device_manager_ = CreateDeviceManager();
gpu_platform_support_host_.reset(new DrmGpuPlatformSupportHost());
cursor_.reset(new DrmCursor(window_manager_.get()));
gpu_platform_support_host_.reset(
new DrmGpuPlatformSupportHost(cursor_.get()));
window_manager_.reset(new DrmWindowHostManager());
cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
cursor_.reset(
new DrmCursor(window_manager_.get(), gpu_platform_support_host_.get()));
cursor_->Init();
#if defined(USE_XKBCOMMON)
KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(make_scoped_ptr(
new XkbKeyboardLayoutEngine(xkb_evdev_code_converter_)));
......@@ -218,13 +217,13 @@ class OzonePlatformGbm : public OzonePlatform {
scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_;
scoped_ptr<DrmWindowManager> window_delegate_manager_;
// Obejcts in the Browser process.
// Objects in the Browser process.
base::FilePath primary_graphics_card_path_;
scoped_ptr<DeviceManager> device_manager_;
scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
scoped_ptr<DrmCursor> cursor_;
scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_;
scoped_ptr<DrmCursor> cursor_;
scoped_ptr<DrmWindowHostManager> window_manager_;
scoped_ptr<DisplayManager> display_manager_;
......
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