| Index: ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
|
| diff --git a/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc b/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
|
| index e87bdcd55dece76dafb9adbdd39d997cbce311d0..9aaab828097c3fd23994dd6bbc6a6c698e249cbf 100644
|
| --- a/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
|
| +++ b/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/bind.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "ipc/ipc_message_macros.h"
|
| +#include "ipc/ipc_sender.h"
|
| #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
|
| #include "ui/ozone/common/gpu/ozone_gpu_messages.h"
|
| #include "ui/ozone/platform/drm/gpu/drm_device.h"
|
| @@ -18,151 +19,6 @@
|
|
|
| namespace ui {
|
|
|
| -namespace {
|
| -
|
| -void MessageProcessedOnMain(
|
| - scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
|
| - const base::Closure& io_thread_task) {
|
| - io_thread_task_runner->PostTask(FROM_HERE, io_thread_task);
|
| -}
|
| -
|
| -class DrmGpuPlatformSupportMessageFilter : public IPC::MessageFilter {
|
| - public:
|
| - typedef base::Callback<void(
|
| - const scoped_refptr<base::SingleThreadTaskRunner>&)>
|
| - OnFilterAddedCallback;
|
| -
|
| - DrmGpuPlatformSupportMessageFilter(
|
| - ScreenManager* screen_manager,
|
| - const OnFilterAddedCallback& on_filter_added_callback,
|
| - IPC::Listener* main_thread_listener)
|
| - : screen_manager_(screen_manager),
|
| - on_filter_added_callback_(on_filter_added_callback),
|
| - main_thread_listener_(main_thread_listener),
|
| - main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
|
| -
|
| - void OnFilterAdded(IPC::Sender* sender) override {
|
| - io_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
|
| - 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
|
| - // cursor movement jank resulting from slowdowns on the gpu main thread.
|
| - // It handles cursor movement on IO thread when display config is stable
|
| - // and returns it to main thread during transitions.
|
| - bool OnMessageReceived(const IPC::Message& message) override {
|
| - // If this message affects the state needed to set cursor, handle it on
|
| - // the main thread. If a cursor move message arrives but we haven't
|
| - // processed the previous main thread message, keep processing on main
|
| - // until nothing is pending.
|
| - bool cursor_position_message = MessageAffectsCursorPosition(message.type());
|
| - bool cursor_state_message = MessageAffectsCursorState(message.type());
|
| -
|
| - // Only handle cursor related messages here.
|
| - if (!cursor_position_message && !cursor_state_message)
|
| - return false;
|
| -
|
| - bool cursor_was_animating = cursor_animating_;
|
| - UpdateAnimationState(message);
|
| - if (cursor_state_message || pending_main_thread_operations_ ||
|
| - cursor_animating_ || cursor_was_animating) {
|
| - pending_main_thread_operations_++;
|
| -
|
| - base::Closure main_thread_message_handler =
|
| - base::Bind(base::IgnoreResult(&IPC::Listener::OnMessageReceived),
|
| - base::Unretained(main_thread_listener_), message);
|
| - main_thread_task_runner_->PostTask(FROM_HERE,
|
| - main_thread_message_handler);
|
| -
|
| - // This is an echo from the main thread to decrement pending ops.
|
| - // When the main thread is done with the task, it posts back to IO to
|
| - // signal completion.
|
| - base::Closure io_thread_task = base::Bind(
|
| - &DrmGpuPlatformSupportMessageFilter::DecrementPendingOperationsOnIO,
|
| - this);
|
| -
|
| - base::Closure message_processed_callback = base::Bind(
|
| - &MessageProcessedOnMain, io_thread_task_runner_, io_thread_task);
|
| - main_thread_task_runner_->PostTask(FROM_HERE, message_processed_callback);
|
| -
|
| - return true;
|
| - }
|
| -
|
| - // Otherwise, we are in a steady state and it's safe to move cursor on IO.
|
| - bool handled = true;
|
| - IPC_BEGIN_MESSAGE_MAP(DrmGpuPlatformSupportMessageFilter, message)
|
| - IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove)
|
| - IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet)
|
| - IPC_MESSAGE_UNHANDLED(handled = false);
|
| - IPC_END_MESSAGE_MAP()
|
| -
|
| - return handled;
|
| - }
|
| -
|
| - protected:
|
| - ~DrmGpuPlatformSupportMessageFilter() override {}
|
| -
|
| - void OnCursorMove(gfx::AcceleratedWidget widget, const gfx::Point& location) {
|
| - screen_manager_->GetWindow(widget)->MoveCursor(location);
|
| - }
|
| -
|
| - void OnCursorSet(gfx::AcceleratedWidget widget,
|
| - const std::vector<SkBitmap>& bitmaps,
|
| - const gfx::Point& location,
|
| - int frame_delay_ms) {
|
| - screen_manager_->GetWindow(widget)
|
| - ->SetCursorWithoutAnimations(bitmaps, location);
|
| - }
|
| -
|
| - void DecrementPendingOperationsOnIO() { pending_main_thread_operations_--; }
|
| -
|
| - bool MessageAffectsCursorState(uint32 message_type) {
|
| - switch (message_type) {
|
| - case OzoneGpuMsg_CreateWindow::ID:
|
| - case OzoneGpuMsg_DestroyWindow::ID:
|
| - case OzoneGpuMsg_WindowBoundsChanged::ID:
|
| - case OzoneGpuMsg_ConfigureNativeDisplay::ID:
|
| - case OzoneGpuMsg_DisableNativeDisplay::ID:
|
| - return true;
|
| - default:
|
| - return false;
|
| - }
|
| - }
|
| -
|
| - bool MessageAffectsCursorPosition(uint32 message_type) {
|
| - switch (message_type) {
|
| - case OzoneGpuMsg_CursorMove::ID:
|
| - case OzoneGpuMsg_CursorSet::ID:
|
| - return true;
|
| - default:
|
| - return false;
|
| - }
|
| - }
|
| -
|
| - void UpdateAnimationState(const IPC::Message& message) {
|
| - if (message.type() != OzoneGpuMsg_CursorSet::ID)
|
| - return;
|
| -
|
| - OzoneGpuMsg_CursorSet::Param param;
|
| - if (!OzoneGpuMsg_CursorSet::Read(&message, ¶m))
|
| - return;
|
| -
|
| - int frame_delay_ms = base::get<3>(param);
|
| - cursor_animating_ = frame_delay_ms != 0;
|
| - }
|
| -
|
| - ScreenManager* screen_manager_;
|
| - 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_;
|
| - int32 pending_main_thread_operations_ = 0;
|
| - bool cursor_animating_ = false;
|
| -};
|
| -}
|
| -
|
| DrmGpuPlatformSupport::DrmGpuPlatformSupport(
|
| DrmDeviceManager* drm_device_manager,
|
| ScreenManager* screen_manager,
|
| @@ -172,16 +28,12 @@ DrmGpuPlatformSupport::DrmGpuPlatformSupport(
|
| screen_manager_(screen_manager),
|
| buffer_generator_(buffer_generator),
|
| display_manager_(display_manager.Pass()) {
|
| - filter_ = new DrmGpuPlatformSupportMessageFilter(
|
| - screen_manager, base::Bind(&DrmGpuPlatformSupport::SetIOTaskRunner,
|
| - base::Unretained(this)),
|
| - this);
|
| }
|
|
|
| DrmGpuPlatformSupport::~DrmGpuPlatformSupport() {
|
| }
|
|
|
| -void DrmGpuPlatformSupport::OnChannelEstablished(IPC::Sender* sender) {
|
| +void DrmGpuPlatformSupport::RegisterSender(const IPCSender& sender) {
|
| sender_ = sender;
|
| }
|
|
|
| @@ -250,13 +102,13 @@ void DrmGpuPlatformSupport::OnCursorMove(gfx::AcceleratedWidget widget,
|
| void DrmGpuPlatformSupport::OnCheckOverlayCapabilities(
|
| gfx::AcceleratedWidget widget,
|
| const std::vector<OverlayCheck_Params>& overlays) {
|
| - sender_->Send(new OzoneHostMsg_OverlayCapabilitiesReceived(
|
| + sender_.Run(new OzoneHostMsg_OverlayCapabilitiesReceived(
|
| widget, screen_manager_->GetWindow(widget)
|
| ->TestPageFlip(overlays, buffer_generator_)));
|
| }
|
|
|
| void DrmGpuPlatformSupport::OnRefreshNativeDisplays() {
|
| - sender_->Send(
|
| + sender_.Run(
|
| new OzoneHostMsg_UpdateNativeDisplays(display_manager_->GetDisplays()));
|
| }
|
|
|
| @@ -264,23 +116,23 @@ void DrmGpuPlatformSupport::OnConfigureNativeDisplay(
|
| int64_t id,
|
| const DisplayMode_Params& mode_param,
|
| const gfx::Point& origin) {
|
| - sender_->Send(new OzoneHostMsg_DisplayConfigured(
|
| + sender_.Run(new OzoneHostMsg_DisplayConfigured(
|
| id, display_manager_->ConfigureDisplay(id, mode_param, origin)));
|
| }
|
|
|
| void DrmGpuPlatformSupport::OnDisableNativeDisplay(int64_t id) {
|
| - sender_->Send(new OzoneHostMsg_DisplayConfigured(
|
| + sender_.Run(new OzoneHostMsg_DisplayConfigured(
|
| id, display_manager_->DisableDisplay(id)));
|
| }
|
|
|
| void DrmGpuPlatformSupport::OnTakeDisplayControl() {
|
| - sender_->Send(new OzoneHostMsg_DisplayControlTaken(
|
| + sender_.Run(new OzoneHostMsg_DisplayControlTaken(
|
| display_manager_->TakeDisplayControl()));
|
| }
|
|
|
| void DrmGpuPlatformSupport::OnRelinquishDisplayControl() {
|
| display_manager_->RelinquishDisplayControl();
|
| - sender_->Send(new OzoneHostMsg_DisplayControlRelinquished(true));
|
| + sender_.Run(new OzoneHostMsg_DisplayControlRelinquished(true));
|
| }
|
|
|
| void DrmGpuPlatformSupport::OnAddGraphicsDevice(
|
| @@ -302,22 +154,13 @@ void DrmGpuPlatformSupport::OnSetGammaRamp(
|
| void DrmGpuPlatformSupport::OnGetHDCPState(int64_t display_id) {
|
| HDCPState state = HDCP_STATE_UNDESIRED;
|
| bool success = display_manager_->GetHDCPState(display_id, &state);
|
| - sender_->Send(new OzoneHostMsg_HDCPStateReceived(display_id, success, state));
|
| + sender_.Run(new OzoneHostMsg_HDCPStateReceived(display_id, success, state));
|
| }
|
|
|
| void DrmGpuPlatformSupport::OnSetHDCPState(int64_t display_id,
|
| HDCPState state) {
|
| - sender_->Send(new OzoneHostMsg_HDCPStateUpdated(
|
| + sender_.Run(new OzoneHostMsg_HDCPStateUpdated(
|
| display_id, display_manager_->SetHDCPState(display_id, state)));
|
| }
|
|
|
| -void DrmGpuPlatformSupport::SetIOTaskRunner(
|
| - const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) {
|
| - drm_device_manager_->InitializeIOTaskRunner(io_task_runner);
|
| -}
|
| -
|
| -IPC::MessageFilter* DrmGpuPlatformSupport::GetMessageFilter() {
|
| - return filter_.get();
|
| -}
|
| -
|
| } // namespace ui
|
|
|