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/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "ipc/ipc_message_macros.h" | 9 #include "ipc/ipc_message_macros.h" |
10 #include "ui/display/types/display_mode.h" | 10 #include "ui/display/types/display_mode.h" |
11 #include "ui/display/types/display_snapshot.h" | 11 #include "ui/display/types/display_snapshot.h" |
12 #include "ui/ozone/common/display_util.h" | 12 #include "ui/ozone/common/display_util.h" |
13 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" | 13 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" |
14 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | 14 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
15 #include "ui/ozone/platform/dri/dri_helper_thread.h" | |
15 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" | 16 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" |
16 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" | 17 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" |
17 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" | 18 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" |
18 | 19 |
19 namespace ui { | 20 namespace ui { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 void MessageProcessedOnMain( | 24 void MessageProcessedOnMain( |
24 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 25 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
25 const base::Closure& io_thread_task) { | 26 const base::Closure& io_thread_task) { |
26 io_thread_task_runner->PostTask(FROM_HERE, io_thread_task); | 27 io_thread_task_runner->PostTask(FROM_HERE, io_thread_task); |
27 } | 28 } |
28 | 29 |
29 class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter { | 30 class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter { |
30 public: | 31 public: |
31 DriGpuPlatformSupportMessageFilter(DriWindowDelegateManager* window_manager, | 32 DriGpuPlatformSupportMessageFilter(DriWindowDelegateManager* window_manager, |
33 DriHelperThread* helper_thread, | |
32 IPC::Listener* main_thread_listener) | 34 IPC::Listener* main_thread_listener) |
33 : window_manager_(window_manager), | 35 : window_manager_(window_manager), |
36 helper_thread_(helper_thread), | |
34 main_thread_listener_(main_thread_listener), | 37 main_thread_listener_(main_thread_listener), |
35 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 38 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
36 pending_main_thread_operations_(0), | 39 pending_main_thread_operations_(0), |
37 cursor_animating_(false), | 40 cursor_animating_(false), |
38 start_on_main_(true) {} | 41 start_on_main_(true) {} |
39 | 42 |
40 void OnFilterAdded(IPC::Sender* sender) override { | 43 void OnFilterAdded(IPC::Sender* sender) override { |
41 io_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 44 io_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
45 if (helper_thread_) | |
alexst (slow to review)
2015/01/22 23:09:24
So it occurred to me, we shouldn't be passing the
dnicoara
2015/01/23 17:13:06
Done.
I've moved the helper thread in here and In
| |
46 helper_thread_->Initialize(); | |
42 } | 47 } |
43 | 48 |
44 // This code is meant to be very temporary and only as a special case to fix | 49 // This code is meant to be very temporary and only as a special case to fix |
45 // cursor movement jank resulting from slowdowns on the gpu main thread. | 50 // cursor movement jank resulting from slowdowns on the gpu main thread. |
46 // It handles cursor movement on IO thread when display config is stable | 51 // It handles cursor movement on IO thread when display config is stable |
47 // and returns it to main thread during transitions. | 52 // and returns it to main thread during transitions. |
48 bool OnMessageReceived(const IPC::Message& message) override { | 53 bool OnMessageReceived(const IPC::Message& message) override { |
49 // If this message affects the state needed to set cursor, handle it on | 54 // If this message affects the state needed to set cursor, handle it on |
50 // the main thread. If a cursor move message arrives but we haven't | 55 // the main thread. If a cursor move message arrives but we haven't |
51 // processed the previous main thread message, keep processing on main | 56 // processed the previous main thread message, keep processing on main |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 | 146 |
142 OzoneGpuMsg_CursorSet::Param param; | 147 OzoneGpuMsg_CursorSet::Param param; |
143 if (!OzoneGpuMsg_CursorSet::Read(&message, ¶m)) | 148 if (!OzoneGpuMsg_CursorSet::Read(&message, ¶m)) |
144 return; | 149 return; |
145 | 150 |
146 int frame_delay_ms = get<3>(param); | 151 int frame_delay_ms = get<3>(param); |
147 cursor_animating_ = frame_delay_ms != 0; | 152 cursor_animating_ = frame_delay_ms != 0; |
148 } | 153 } |
149 | 154 |
150 DriWindowDelegateManager* window_manager_; | 155 DriWindowDelegateManager* window_manager_; |
156 DriHelperThread* helper_thread_; | |
151 IPC::Listener* main_thread_listener_; | 157 IPC::Listener* main_thread_listener_; |
152 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 158 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
153 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; | 159 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; |
154 int32 pending_main_thread_operations_; | 160 int32 pending_main_thread_operations_; |
155 bool cursor_animating_; | 161 bool cursor_animating_; |
156 // The filter is not installed early enough, so some messages may | 162 // The filter is not installed early enough, so some messages may |
157 // get routed to main thread. Once we get our first message on io, send it | 163 // get routed to main thread. Once we get our first message on io, send it |
158 // to main to ensure all prior main thread operations are finished before we | 164 // to main to ensure all prior main thread operations are finished before we |
159 // continue on io. | 165 // continue on io. |
160 // TODO: remove this once filter is properly installed. | 166 // TODO: remove this once filter is properly installed. |
161 bool start_on_main_; | 167 bool start_on_main_; |
162 }; | 168 }; |
163 } | 169 } |
164 | 170 |
165 DriGpuPlatformSupport::DriGpuPlatformSupport( | 171 DriGpuPlatformSupport::DriGpuPlatformSupport( |
166 DriWrapper* drm, | 172 DriWrapper* drm, |
167 DriWindowDelegateManager* window_manager, | 173 DriWindowDelegateManager* window_manager, |
168 ScreenManager* screen_manager, | 174 ScreenManager* screen_manager, |
175 DriHelperThread* helper_thread, | |
169 scoped_ptr<NativeDisplayDelegateDri> ndd) | 176 scoped_ptr<NativeDisplayDelegateDri> ndd) |
170 : sender_(NULL), | 177 : sender_(NULL), |
171 drm_(drm), | 178 drm_(drm), |
172 window_manager_(window_manager), | 179 window_manager_(window_manager), |
173 screen_manager_(screen_manager), | 180 screen_manager_(screen_manager), |
174 ndd_(ndd.Pass()) { | 181 ndd_(ndd.Pass()) { |
175 filter_ = new DriGpuPlatformSupportMessageFilter(window_manager, this); | 182 filter_ = new DriGpuPlatformSupportMessageFilter(window_manager, |
183 helper_thread, this); | |
176 } | 184 } |
177 | 185 |
178 DriGpuPlatformSupport::~DriGpuPlatformSupport() { | 186 DriGpuPlatformSupport::~DriGpuPlatformSupport() { |
179 } | 187 } |
180 | 188 |
181 void DriGpuPlatformSupport::AddHandler(scoped_ptr<GpuPlatformSupport> handler) { | 189 void DriGpuPlatformSupport::AddHandler(scoped_ptr<GpuPlatformSupport> handler) { |
182 handlers_.push_back(handler.release()); | 190 handlers_.push_back(handler.release()); |
183 } | 191 } |
184 | 192 |
185 void DriGpuPlatformSupport::OnChannelEstablished(IPC::Sender* sender) { | 193 void DriGpuPlatformSupport::OnChannelEstablished(IPC::Sender* sender) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 void DriGpuPlatformSupport::RelinquishGpuResources( | 360 void DriGpuPlatformSupport::RelinquishGpuResources( |
353 const base::Closure& callback) { | 361 const base::Closure& callback) { |
354 callback.Run(); | 362 callback.Run(); |
355 } | 363 } |
356 | 364 |
357 IPC::MessageFilter* DriGpuPlatformSupport::GetMessageFilter() { | 365 IPC::MessageFilter* DriGpuPlatformSupport::GetMessageFilter() { |
358 return filter_.get(); | 366 return filter_.get(); |
359 } | 367 } |
360 | 368 |
361 } // namespace ui | 369 } // namespace ui |
OLD | NEW |