| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/gpu/compositor_thread.h" | 5 #include "content/renderer/gpu/compositor_thread.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "content/renderer/gpu/input_event_filter.h" | 9 #include "content/renderer/gpu/input_event_filter.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingPa
rameters.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingPa
rameters.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 namespace { | 93 namespace { |
| 94 void SetHighThreadPriority() { | 94 void SetHighThreadPriority() { |
| 95 int nice_value = -6; // High priority. | 95 int nice_value = -6; // High priority. |
| 96 setpriority(PRIO_PROCESS, base::PlatformThread::CurrentId(), nice_value); | 96 setpriority(PRIO_PROCESS, base::PlatformThread::CurrentId(), nice_value); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 #endif | 99 #endif |
| 100 | 100 |
| 101 CompositorThread::CompositorThread(IPC::Listener* main_listener) | 101 CompositorThread::CompositorThread(IPC::Listener* main_listener) |
| 102 : thread_("Compositor") { | 102 : thread_("Compositor") { |
| 103 thread_.Start(); |
| 103 filter_ = | 104 filter_ = |
| 104 new InputEventFilter(main_listener, | 105 new InputEventFilter(main_listener, |
| 105 thread_.message_loop()->message_loop_proxy(), | 106 thread_.message_loop()->message_loop_proxy(), |
| 106 base::Bind(&CompositorThread::HandleInputEvent, | 107 base::Bind(&CompositorThread::HandleInputEvent, |
| 107 base::Unretained(this))); | 108 base::Unretained(this))); |
| 108 #if defined(OS_ANDROID) | 109 #if defined(OS_ANDROID) |
| 109 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) | 110 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| 110 thread_.message_loop()->PostTask(FROM_HERE, | 111 thread_.message_loop()->PostTask(FROM_HERE, |
| 111 base::Bind(&SetHighThreadPriority)); | 112 base::Bind(&SetHighThreadPriority)); |
| 112 #endif | 113 #endif |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return; | 155 return; |
| 155 } | 156 } |
| 156 | 157 |
| 157 TRACE_EVENT0("CompositorThread::AddInputHandler", "AddingRoute"); | 158 TRACE_EVENT0("CompositorThread::AddInputHandler", "AddingRoute"); |
| 158 filter_->AddRoute(routing_id); | 159 filter_->AddRoute(routing_id); |
| 159 input_handlers_[routing_id] = | 160 input_handlers_[routing_id] = |
| 160 make_scoped_refptr(new InputHandlerWrapper(this, | 161 make_scoped_refptr(new InputHandlerWrapper(this, |
| 161 routing_id, input_handler, main_loop, render_view_impl)); | 162 routing_id, input_handler, main_loop, render_view_impl)); |
| 162 } | 163 } |
| 163 | 164 |
| 165 |
| 166 base::MessageLoopProxy* CompositorThread::message_loop_proxy() const { |
| 167 return thread_.message_loop()->message_loop_proxy(); |
| 168 } |
| 169 |
| 164 void CompositorThread::RemoveInputHandler(int routing_id) { | 170 void CompositorThread::RemoveInputHandler(int routing_id) { |
| 165 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 171 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 166 | 172 |
| 167 TRACE_EVENT0("CompositorThread::RemoveInputHandler", "RemovingRoute"); | 173 TRACE_EVENT0("CompositorThread::RemoveInputHandler", "RemovingRoute"); |
| 168 | 174 |
| 169 filter_->RemoveRoute(routing_id); | 175 filter_->RemoveRoute(routing_id); |
| 170 input_handlers_.erase(routing_id); | 176 input_handlers_.erase(routing_id); |
| 171 } | 177 } |
| 172 | 178 |
| 173 void CompositorThread::HandleInputEvent( | 179 void CompositorThread::HandleInputEvent( |
| 174 int routing_id, | 180 int routing_id, |
| 175 const WebInputEvent* input_event) { | 181 const WebInputEvent* input_event) { |
| 176 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 182 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 177 | 183 |
| 178 InputHandlerMap::iterator it = input_handlers_.find(routing_id); | 184 InputHandlerMap::iterator it = input_handlers_.find(routing_id); |
| 179 if (it == input_handlers_.end()) { | 185 if (it == input_handlers_.end()) { |
| 180 TRACE_EVENT0("CompositorThread::HandleInputEvent", "NoInputHandlerFound"); | 186 TRACE_EVENT0("CompositorThread::HandleInputEvent", "NoInputHandlerFound"); |
| 181 // Oops, we no longer have an interested input handler.. | 187 // Oops, we no longer have an interested input handler.. |
| 182 filter_->DidNotHandleInputEvent(true); | 188 filter_->DidNotHandleInputEvent(true); |
| 183 return; | 189 return; |
| 184 } | 190 } |
| 185 | 191 |
| 186 it->second->input_handler()->handleInputEvent(*input_event); | 192 it->second->input_handler()->handleInputEvent(*input_event); |
| 187 } | 193 } |
| 188 | 194 |
| 189 } // namespace content | 195 } // namespace content |
| OLD | NEW |