Index: cc/trees/layer_tree_host_impl.cc |
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc |
index 958419eb306af5bcd1bc1b8a0b022095b9941ee5..67eb458b3c2cb4383c99c989061b2a739de185f4 100644 |
--- a/cc/trees/layer_tree_host_impl.cc |
+++ b/cc/trees/layer_tree_host_impl.cc |
@@ -2460,8 +2460,7 @@ void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { |
scroll_layer_impl ? scroll_layer_impl->scrollbar_animation_controller() |
: NULL; |
if (animation_controller) { |
- animation_controller->DidMouseMoveOffScrollbar( |
- CurrentPhysicalTimeTicks()); |
+ animation_controller->DidMouseMoveOffScrollbar(CurrentFrameTimeTicks()); |
StartScrollbarAnimation(); |
} |
scroll_layer_id_when_mouse_over_scrollbar_ = 0; |
@@ -2490,7 +2489,7 @@ void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { |
DeviceSpaceDistanceToLayer(device_viewport_point, *it)); |
bool should_animate = animation_controller->DidMouseMoveNear( |
- CurrentPhysicalTimeTicks(), distance_to_scrollbar / device_scale_factor_); |
+ CurrentFrameTimeTicks(), distance_to_scrollbar / device_scale_factor_); |
if (should_animate) |
StartScrollbarAnimation(); |
} |
@@ -2504,7 +2503,7 @@ bool LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl, |
scroll_layer_id_when_mouse_over_scrollbar_ = scroll_layer_id; |
bool should_animate = |
layer_impl->scrollbar_animation_controller()->DidMouseMoveNear( |
- CurrentPhysicalTimeTicks(), 0); |
+ CurrentFrameTimeTicks(), 0); |
if (should_animate) |
StartScrollbarAnimation(); |
} else { |
@@ -2820,7 +2819,7 @@ void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, |
void LayerTreeHostImpl::StartScrollbarAnimation() { |
TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); |
- StartScrollbarAnimationRecursive(RootLayer(), CurrentPhysicalTimeTicks()); |
+ StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks()); |
} |
void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, |
@@ -2852,22 +2851,21 @@ void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { |
DidModifyTilePriorities(); |
} |
-void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { |
- current_frame_timeticks_ = base::TimeTicks(); |
+void LayerTreeHostImpl::UpdateCurrentFrameTime() { |
+ DCHECK(current_frame_timeticks_.is_null()); |
+ current_frame_timeticks_ = gfx::FrameTime::Now(); |
} |
-void LayerTreeHostImpl::UpdateCurrentFrameTime(base::TimeTicks* ticks) const { |
- if (ticks->is_null()) { |
- *ticks = CurrentPhysicalTimeTicks(); |
- } |
+void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { |
+ current_frame_timeticks_ = base::TimeTicks(); |
} |
base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { |
- UpdateCurrentFrameTime(¤t_frame_timeticks_); |
- return current_frame_timeticks_; |
-} |
- |
-base::TimeTicks LayerTreeHostImpl::CurrentPhysicalTimeTicks() const { |
+ // Try to use the current frame time to keep animations non-jittery. But if |
+ // we're not in a frame (because this is during an input event or a delayed |
+ // task), fall back to physical time. This should still be monotonic. |
+ if (!current_frame_timeticks_.is_null()) |
+ return current_frame_timeticks_; |
return gfx::FrameTime::Now(); |
} |