| 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 "content/renderer/scheduler/renderer_scheduler_impl.h" | 5 #include "content/renderer/scheduler/renderer_scheduler_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 base::TimeTicks now(Now()); | 113 base::TimeTicks now(Now()); |
| 114 if (now < estimated_next_frame_begin_) { | 114 if (now < estimated_next_frame_begin_) { |
| 115 StartIdlePeriod(); | 115 StartIdlePeriod(); |
| 116 control_task_runner_->PostDelayedTask(FROM_HERE, | 116 control_task_runner_->PostDelayedTask(FROM_HERE, |
| 117 end_idle_period_closure_.callback(), | 117 end_idle_period_closure_.callback(), |
| 118 estimated_next_frame_begin_ - now); | 118 estimated_next_frame_begin_ - now); |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 void RendererSchedulerImpl::DidReceiveInputEventOnCompositorThread( | 122 void RendererSchedulerImpl::DidReceiveInputEventOnCompositorThread( |
| 123 blink::WebInputEvent::Type type) { | 123 const blink::WebInputEvent& web_input_event) { |
| 124 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 124 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 125 "RendererSchedulerImpl::DidReceiveInputEventOnCompositorThread"); | 125 "RendererSchedulerImpl::DidReceiveInputEventOnCompositorThread"); |
| 126 // Ignore mouse events because on windows these can very frequent. | 126 // We regard MouseMove events with the left mouse button down as a signal |
| 127 // that the user is doing something requiring a smooth frame rate. |
| 128 if (web_input_event.type == blink::WebInputEvent::MouseMove && |
| 129 (web_input_event.modifiers & blink::WebInputEvent::LeftButtonDown)) { |
| 130 UpdateForInputEvent(); |
| 131 return; |
| 132 } |
| 133 // Ignore all other mouse events because they probably don't signal user |
| 134 // interaction needing a smooth framerate. NOTE isMouseEventType returns false |
| 135 // for mouse wheel events, hence we regard them as user input. |
| 127 // Ignore keyboard events because it doesn't really make sense to enter | 136 // Ignore keyboard events because it doesn't really make sense to enter |
| 128 // compositor priority for them. | 137 // compositor priority for them. |
| 129 if (blink::WebInputEvent::isMouseEventType(type) || | 138 if (blink::WebInputEvent::isMouseEventType(web_input_event.type) || |
| 130 blink::WebInputEvent::isKeyboardEventType(type)) { | 139 blink::WebInputEvent::isKeyboardEventType(web_input_event.type)) { |
| 131 return; | 140 return; |
| 132 } | 141 } |
| 133 UpdateForInputEvent(); | 142 UpdateForInputEvent(); |
| 134 } | 143 } |
| 135 | 144 |
| 136 void RendererSchedulerImpl::DidAnimateForInputOnCompositorThread() { | 145 void RendererSchedulerImpl::DidAnimateForInputOnCompositorThread() { |
| 137 UpdateForInputEvent(); | 146 UpdateForInputEvent(); |
| 138 } | 147 } |
| 139 | 148 |
| 140 void RendererSchedulerImpl::UpdateForInputEvent() { | 149 void RendererSchedulerImpl::UpdateForInputEvent() { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 state->SetDouble("last_input_time", | 352 state->SetDouble("last_input_time", |
| 344 (last_input_time_ - base::TimeTicks()).InMillisecondsF()); | 353 (last_input_time_ - base::TimeTicks()).InMillisecondsF()); |
| 345 state->SetDouble( | 354 state->SetDouble( |
| 346 "estimated_next_frame_begin", | 355 "estimated_next_frame_begin", |
| 347 (estimated_next_frame_begin_ - base::TimeTicks()).InMillisecondsF()); | 356 (estimated_next_frame_begin_ - base::TimeTicks()).InMillisecondsF()); |
| 348 | 357 |
| 349 return state; | 358 return state; |
| 350 } | 359 } |
| 351 | 360 |
| 352 } // namespace content | 361 } // namespace content |
| OLD | NEW |