Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: ui/ozone/platform/dri/dri_gpu_platform_support.cc

Issue 801233003: [ozone] Temporary workaround for GPU support message filter not being installed early enough. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 28
29 class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter { 29 class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter {
30 public: 30 public:
31 DriGpuPlatformSupportMessageFilter(DriWindowDelegateManager* window_manager, 31 DriGpuPlatformSupportMessageFilter(DriWindowDelegateManager* window_manager,
32 IPC::Listener* main_thread_listener) 32 IPC::Listener* main_thread_listener)
33 : window_manager_(window_manager), 33 : window_manager_(window_manager),
34 main_thread_listener_(main_thread_listener), 34 main_thread_listener_(main_thread_listener),
35 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), 35 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
36 pending_main_thread_operations_(0), 36 pending_main_thread_operations_(0),
37 cursor_animating_(false) {} 37 cursor_animating_(false),
38 start_on_main_(true) {}
38 39
39 void OnFilterAdded(IPC::Sender* sender) override { 40 void OnFilterAdded(IPC::Sender* sender) override {
40 io_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 41 io_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
41 } 42 }
42 43
43 // This code is meant to be very temporary and only as a special case to fix 44 // This code is meant to be very temporary and only as a special case to fix
44 // cursor movement jank resulting from slowdowns on the gpu main thread. 45 // cursor movement jank resulting from slowdowns on the gpu main thread.
45 // It handles cursor movement on IO thread when display config is stable 46 // It handles cursor movement on IO thread when display config is stable
46 // and returns it to main thread during transitions. 47 // and returns it to main thread during transitions.
47 bool OnMessageReceived(const IPC::Message& message) override { 48 bool OnMessageReceived(const IPC::Message& message) override {
48 // If this message affects the state needed to set cursor, handle it on 49 // If this message affects the state needed to set cursor, handle it on
49 // the main thread. If a cursor move message arrives but we haven't 50 // the main thread. If a cursor move message arrives but we haven't
50 // processed the previous main thread message, keep processing on main 51 // processed the previous main thread message, keep processing on main
51 // until nothing is pending. 52 // until nothing is pending.
52 bool cursor_position_message = MessageAffectsCursorPosition(message.type()); 53 bool cursor_position_message = MessageAffectsCursorPosition(message.type());
53 bool cursor_state_message = MessageAffectsCursorState(message.type()); 54 bool cursor_state_message = MessageAffectsCursorState(message.type());
54 55
55 // Only handle cursor related messages here. 56 // Only handle cursor related messages here.
56 if (!cursor_position_message && !cursor_state_message) 57 if (!cursor_position_message && !cursor_state_message)
57 return false; 58 return false;
58 59
59 bool cursor_was_animating = cursor_animating_; 60 bool cursor_was_animating = cursor_animating_;
60 UpdateAnimationState(message); 61 UpdateAnimationState(message);
61 if (cursor_state_message || pending_main_thread_operations_ || 62 if (cursor_state_message || pending_main_thread_operations_ ||
62 cursor_animating_ || cursor_was_animating) { 63 cursor_animating_ || cursor_was_animating || start_on_main_) {
64 start_on_main_ = false;
63 pending_main_thread_operations_++; 65 pending_main_thread_operations_++;
64 66
65 base::Closure main_thread_message_handler = 67 base::Closure main_thread_message_handler =
66 base::Bind(base::IgnoreResult(&IPC::Listener::OnMessageReceived), 68 base::Bind(base::IgnoreResult(&IPC::Listener::OnMessageReceived),
67 base::Unretained(main_thread_listener_), message); 69 base::Unretained(main_thread_listener_), message);
68 main_thread_task_runner_->PostTask(FROM_HERE, 70 main_thread_task_runner_->PostTask(FROM_HERE,
69 main_thread_message_handler); 71 main_thread_message_handler);
70 72
71 // This is an echo from the main thread to decrement pending ops. 73 // This is an echo from the main thread to decrement pending ops.
72 // When the main thread is done with the task, it posts back to IO to 74 // When the main thread is done with the task, it posts back to IO to
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 int frame_delay_ms = get<3>(param); 146 int frame_delay_ms = get<3>(param);
145 cursor_animating_ = frame_delay_ms != 0; 147 cursor_animating_ = frame_delay_ms != 0;
146 } 148 }
147 149
148 DriWindowDelegateManager* window_manager_; 150 DriWindowDelegateManager* window_manager_;
149 IPC::Listener* main_thread_listener_; 151 IPC::Listener* main_thread_listener_;
150 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 152 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
151 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; 153 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
152 int32 pending_main_thread_operations_; 154 int32 pending_main_thread_operations_;
153 bool cursor_animating_; 155 bool cursor_animating_;
156 // 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
158 // to main to ensure all prior main thread operations are finished before we
159 // continue on io.
160 // TODO: remove this once filter is properly installed.
161 bool start_on_main_;
154 }; 162 };
155 } 163 }
156 164
157 DriGpuPlatformSupport::DriGpuPlatformSupport( 165 DriGpuPlatformSupport::DriGpuPlatformSupport(
158 DriWrapper* drm, 166 DriWrapper* drm,
159 DriWindowDelegateManager* window_manager, 167 DriWindowDelegateManager* window_manager,
160 ScreenManager* screen_manager, 168 ScreenManager* screen_manager,
161 scoped_ptr<NativeDisplayDelegateDri> ndd) 169 scoped_ptr<NativeDisplayDelegateDri> ndd)
162 : sender_(NULL), 170 : sender_(NULL),
163 drm_(drm), 171 drm_(drm),
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 void DriGpuPlatformSupport::RelinquishGpuResources( 347 void DriGpuPlatformSupport::RelinquishGpuResources(
340 const base::Closure& callback) { 348 const base::Closure& callback) {
341 callback.Run(); 349 callback.Run();
342 } 350 }
343 351
344 IPC::MessageFilter* DriGpuPlatformSupport::GetMessageFilter() { 352 IPC::MessageFilter* DriGpuPlatformSupport::GetMessageFilter() {
345 return filter_.get(); 353 return filter_.get();
346 } 354 }
347 355
348 } // namespace ui 356 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698