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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 210793002: Replace CurrentPhysicalTimeTicks with a fallback in CurrentFrameTimeTicks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(&current_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();
}
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698