| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" | 5 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
| 11 #include "ui/display/types/display_mode.h" | 11 #include "ui/display/types/display_mode.h" |
| 12 #include "ui/display/types/display_snapshot.h" | 12 #include "ui/display/types/display_snapshot.h" |
| 13 #include "ui/ozone/common/display_util.h" | 13 #include "ui/ozone/common/display_util.h" |
| 14 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" | 14 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" |
| 15 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | 15 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
| 16 #include "ui/ozone/platform/dri/dri_helper_thread.h" | |
| 17 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" | 16 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" |
| 18 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" | 17 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" |
| 19 #include "ui/ozone/platform/dri/dri_wrapper.h" | 18 #include "ui/ozone/platform/dri/dri_wrapper.h" |
| 20 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" | 19 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" |
| 21 #include "ui/ozone/public/ozone_switches.h" | 20 #include "ui/ozone/public/ozone_switches.h" |
| 22 | 21 |
| 23 namespace ui { | 22 namespace ui { |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 27 void MessageProcessedOnMain( | 26 void MessageProcessedOnMain( |
| 28 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 27 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
| 29 const base::Closure& io_thread_task) { | 28 const base::Closure& io_thread_task) { |
| 30 io_thread_task_runner->PostTask(FROM_HERE, io_thread_task); | 29 io_thread_task_runner->PostTask(FROM_HERE, io_thread_task); |
| 31 } | 30 } |
| 32 | 31 |
| 33 class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter { | 32 class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter { |
| 34 public: | 33 public: |
| 34 typedef base::Callback<void( |
| 35 const scoped_refptr<base::SingleThreadTaskRunner>&)> |
| 36 OnFilterAddedCallback; |
| 37 |
| 35 DriGpuPlatformSupportMessageFilter( | 38 DriGpuPlatformSupportMessageFilter( |
| 36 DriWindowDelegateManager* window_manager, | 39 DriWindowDelegateManager* window_manager, |
| 37 const base::Closure& on_filter_added_callback, | 40 const OnFilterAddedCallback& on_filter_added_callback, |
| 38 IPC::Listener* main_thread_listener) | 41 IPC::Listener* main_thread_listener) |
| 39 : window_manager_(window_manager), | 42 : window_manager_(window_manager), |
| 40 on_filter_added_callback_(on_filter_added_callback), | 43 on_filter_added_callback_(on_filter_added_callback), |
| 41 main_thread_listener_(main_thread_listener), | 44 main_thread_listener_(main_thread_listener), |
| 42 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 45 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 43 pending_main_thread_operations_(0), | 46 pending_main_thread_operations_(0), |
| 44 cursor_animating_(false) {} | 47 cursor_animating_(false) {} |
| 45 | 48 |
| 46 void OnFilterAdded(IPC::Sender* sender) override { | 49 void OnFilterAdded(IPC::Sender* sender) override { |
| 47 io_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 50 io_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 48 main_thread_task_runner_->PostTask(FROM_HERE, on_filter_added_callback_); | 51 main_thread_task_runner_->PostTask( |
| 52 FROM_HERE, |
| 53 base::Bind(on_filter_added_callback_, io_thread_task_runner_)); |
| 49 } | 54 } |
| 50 | 55 |
| 51 // This code is meant to be very temporary and only as a special case to fix | 56 // This code is meant to be very temporary and only as a special case to fix |
| 52 // cursor movement jank resulting from slowdowns on the gpu main thread. | 57 // cursor movement jank resulting from slowdowns on the gpu main thread. |
| 53 // It handles cursor movement on IO thread when display config is stable | 58 // It handles cursor movement on IO thread when display config is stable |
| 54 // and returns it to main thread during transitions. | 59 // and returns it to main thread during transitions. |
| 55 bool OnMessageReceived(const IPC::Message& message) override { | 60 bool OnMessageReceived(const IPC::Message& message) override { |
| 56 // If this message affects the state needed to set cursor, handle it on | 61 // If this message affects the state needed to set cursor, handle it on |
| 57 // the main thread. If a cursor move message arrives but we haven't | 62 // the main thread. If a cursor move message arrives but we haven't |
| 58 // processed the previous main thread message, keep processing on main | 63 // processed the previous main thread message, keep processing on main |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 152 |
| 148 OzoneGpuMsg_CursorSet::Param param; | 153 OzoneGpuMsg_CursorSet::Param param; |
| 149 if (!OzoneGpuMsg_CursorSet::Read(&message, ¶m)) | 154 if (!OzoneGpuMsg_CursorSet::Read(&message, ¶m)) |
| 150 return; | 155 return; |
| 151 | 156 |
| 152 int frame_delay_ms = get<3>(param); | 157 int frame_delay_ms = get<3>(param); |
| 153 cursor_animating_ = frame_delay_ms != 0; | 158 cursor_animating_ = frame_delay_ms != 0; |
| 154 } | 159 } |
| 155 | 160 |
| 156 DriWindowDelegateManager* window_manager_; | 161 DriWindowDelegateManager* window_manager_; |
| 157 base::Closure on_filter_added_callback_; | 162 OnFilterAddedCallback on_filter_added_callback_; |
| 158 IPC::Listener* main_thread_listener_; | 163 IPC::Listener* main_thread_listener_; |
| 159 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 164 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 160 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; | 165 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; |
| 161 int32 pending_main_thread_operations_; | 166 int32 pending_main_thread_operations_; |
| 162 bool cursor_animating_; | 167 bool cursor_animating_; |
| 163 }; | 168 }; |
| 164 } | 169 } |
| 165 | 170 |
| 166 DriGpuPlatformSupport::DriGpuPlatformSupport( | 171 DriGpuPlatformSupport::DriGpuPlatformSupport( |
| 167 DriWrapper* drm, | 172 DriWrapper* drm, |
| 168 DriWindowDelegateManager* window_manager, | 173 DriWindowDelegateManager* window_manager, |
| 169 ScreenManager* screen_manager, | 174 ScreenManager* screen_manager, |
| 170 scoped_ptr<NativeDisplayDelegateDri> ndd) | 175 scoped_ptr<NativeDisplayDelegateDri> ndd) |
| 171 : sender_(NULL), | 176 : sender_(NULL), |
| 172 drm_(drm), | 177 drm_(drm), |
| 173 window_manager_(window_manager), | 178 window_manager_(window_manager), |
| 174 screen_manager_(screen_manager), | 179 screen_manager_(screen_manager), |
| 175 ndd_(ndd.Pass()) { | 180 ndd_(ndd.Pass()) { |
| 176 filter_ = new DriGpuPlatformSupportMessageFilter( | 181 filter_ = new DriGpuPlatformSupportMessageFilter( |
| 177 window_manager, | 182 window_manager, base::Bind(&DriGpuPlatformSupport::SetIOTaskRunner, |
| 178 base::Bind(&DriGpuPlatformSupport::OnFilterAdded, base::Unretained(this)), | 183 base::Unretained(this)), |
| 179 this); | 184 this); |
| 180 } | 185 } |
| 181 | 186 |
| 182 DriGpuPlatformSupport::~DriGpuPlatformSupport() { | 187 DriGpuPlatformSupport::~DriGpuPlatformSupport() { |
| 183 } | 188 } |
| 184 | 189 |
| 185 void DriGpuPlatformSupport::AddHandler(scoped_ptr<GpuPlatformSupport> handler) { | 190 void DriGpuPlatformSupport::AddHandler(scoped_ptr<GpuPlatformSupport> handler) { |
| 186 handlers_.push_back(handler.release()); | 191 handlers_.push_back(handler.release()); |
| 187 } | 192 } |
| 188 | 193 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 350 |
| 346 void DriGpuPlatformSupport::OnRemoveGraphicsDevice(const base::FilePath& path) { | 351 void DriGpuPlatformSupport::OnRemoveGraphicsDevice(const base::FilePath& path) { |
| 347 NOTIMPLEMENTED(); | 352 NOTIMPLEMENTED(); |
| 348 } | 353 } |
| 349 | 354 |
| 350 void DriGpuPlatformSupport::RelinquishGpuResources( | 355 void DriGpuPlatformSupport::RelinquishGpuResources( |
| 351 const base::Closure& callback) { | 356 const base::Closure& callback) { |
| 352 callback.Run(); | 357 callback.Run(); |
| 353 } | 358 } |
| 354 | 359 |
| 355 void DriGpuPlatformSupport::OnFilterAdded() { | 360 void DriGpuPlatformSupport::SetIOTaskRunner( |
| 361 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) { |
| 362 io_task_runner_ = io_task_runner; |
| 356 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 363 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 357 // Only surfaceless path supports async page flips. So we only initialize the | 364 // Only surfaceless path supports async page flips. |
| 358 // helper thread if we're using async page flips. | 365 if (cmd->HasSwitch(switches::kOzoneUseSurfaceless)) { |
| 359 if (!helper_thread_.IsRunning() && | 366 drm_->InitializeTaskRunner(io_task_runner_); |
| 360 cmd->HasSwitch(switches::kOzoneUseSurfaceless)) { | |
| 361 helper_thread_.Initialize(); | |
| 362 drm_->InitializeTaskRunner(helper_thread_.task_runner()); | |
| 363 } | 367 } |
| 364 } | 368 } |
| 365 | 369 |
| 366 IPC::MessageFilter* DriGpuPlatformSupport::GetMessageFilter() { | 370 IPC::MessageFilter* DriGpuPlatformSupport::GetMessageFilter() { |
| 367 return filter_.get(); | 371 return filter_.get(); |
| 368 } | 372 } |
| 369 | 373 |
| 370 } // namespace ui | 374 } // namespace ui |
| OLD | NEW |