summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-22 16:28:55 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-22 16:28:55 +0000
commitfb7425a2a146e2686a389c38278882e4e89e5531 (patch)
tree4ef17f6722e831ecb80fd3725b4119241cb1499b /cc
parent1870aea2c5499f3f2f596f5c1e00a0c4511ca5a0 (diff)
downloadchromium_src-fb7425a2a146e2686a389c38278882e4e89e5531.zip
chromium_src-fb7425a2a146e2686a389c38278882e4e89e5531.tar.gz
chromium_src-fb7425a2a146e2686a389c38278882e4e89e5531.tar.bz2
cc: Animate with the CurrentFrameTime
Instead of calling Now() when animating, use the LayerTreeHostImpl's notion of the current frame time, so that it is consistent with the values used in UpdateTilePriorities and everything else that wants to do things based on the time of each frame. BUG=187366 Review URL: https://chromiumcodereview.appspot.com/12450018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195531 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/layers/heads_up_display_layer_impl.cc2
-rw-r--r--cc/layers/layer_impl.cc2
-rw-r--r--cc/layers/picture_layer_impl.cc4
-rw-r--r--cc/trees/layer_tree_host_impl.cc27
-rw-r--r--cc/trees/layer_tree_host_impl.h11
-rw-r--r--cc/trees/layer_tree_impl.cc8
-rw-r--r--cc/trees/layer_tree_impl.h3
-rw-r--r--cc/trees/single_thread_proxy.cc4
-rw-r--r--cc/trees/thread_proxy.cc9
9 files changed, 45 insertions, 25 deletions
diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc
index 4ff96a5..f8ab6ae 100644
--- a/cc/layers/heads_up_display_layer_impl.cc
+++ b/cc/layers/heads_up_display_layer_impl.cc
@@ -185,7 +185,7 @@ void HeadsUpDisplayLayerImpl::UpdateHudContents() {
const LayerTreeDebugState& debug_state = layer_tree_impl()->debug_state();
// Don't update numbers every frame so text is readable.
- base::TimeTicks now = layer_tree_impl()->CurrentFrameTime();
+ base::TimeTicks now = layer_tree_impl()->CurrentFrameTimeTicks();
if (base::TimeDelta(now - time_of_last_graph_update_).InSecondsF() > 0.25f) {
time_of_last_graph_update_ = now;
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index ab32cb8..aec8cd2 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -826,7 +826,7 @@ void LayerImpl::UpdateScrollbarPositions() {
if (scrollbar_animation_controller_ &&
!scrollbar_animation_controller_->IsScrollGestureInProgress()) {
scrollbar_animation_controller_->DidProgrammaticallyUpdateScroll(
- base::TimeTicks::Now());
+ layer_tree_impl()->CurrentFrameTimeTicks());
}
// Get the current_offset_.y() value for a sanity-check on scrolling
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 83576d4..3f1c322 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -268,8 +268,8 @@ void PictureLayerImpl::UpdateTilePriorities() {
UpdateLCDTextStatus();
int current_source_frame_number = layer_tree_impl()->source_frame_number();
- double current_frame_time =
- (layer_tree_impl()->CurrentFrameTime() - base::TimeTicks()).InSecondsF();
+ double current_frame_time = (layer_tree_impl()->CurrentFrameTimeTicks() -
+ base::TimeTicks()).InSecondsF();
gfx::Transform current_screen_space_transform = screen_space_transform();
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index faa7612..657e72f 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -111,7 +111,9 @@ class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient {
}
layer_tree_host_impl_->ActivatePendingTreeIfNeeded();
- layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now());
+ layer_tree_host_impl_->Animate(
+ layer_tree_host_impl_->CurrentFrameTimeTicks(),
+ layer_tree_host_impl_->CurrentFrameTime());
layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
bool start_ready_animations = true;
layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
@@ -1742,7 +1744,7 @@ void LayerTreeHostImpl::ScrollEnd() {
top_controls_manager_->ScrollEnd();
ClearCurrentlyScrollingLayer();
active_tree()->DidEndScroll();
- StartScrollbarAnimation(base::TimeTicks::Now());
+ StartScrollbarAnimation(CurrentFrameTimeTicks());
}
void LayerTreeHostImpl::PinchGestureBegin() {
@@ -2038,12 +2040,25 @@ void LayerTreeHostImpl::SetTreePriority(TreePriority priority) {
}
void LayerTreeHostImpl::BeginNextFrame() {
- current_frame_time_ = base::TimeTicks();
+ current_frame_timeticks_ = base::TimeTicks();
+ current_frame_time_ = base::Time();
}
-base::TimeTicks LayerTreeHostImpl::CurrentFrameTime() {
- if (current_frame_time_.is_null())
- current_frame_time_ = base::TimeTicks::Now();
+static void UpdateCurrentFrameTime(base::TimeTicks* ticks, base::Time* now) {
+ if (ticks->is_null()) {
+ DCHECK(now->is_null());
+ *ticks = base::TimeTicks::Now();
+ *now = base::Time::Now();
+ }
+}
+
+base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() {
+ UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_);
+ return current_frame_timeticks_;
+}
+
+base::Time LayerTreeHostImpl::CurrentFrameTime() {
+ UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_);
return current_frame_time_;
}
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index 3b7c791..c31fba1 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -252,11 +252,6 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
- void StartPageScaleAnimation(gfx::Vector2d target_offset,
- bool use_anchor,
- float scale,
- base::TimeDelta duration);
-
bool needs_animate_layers() const {
return !animation_registrar_->active_animation_controllers().empty();
}
@@ -342,7 +337,8 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
void SetTreePriority(TreePriority priority);
void BeginNextFrame();
- base::TimeTicks CurrentFrameTime();
+ base::TimeTicks CurrentFrameTimeTicks();
+ base::Time CurrentFrameTime();
scoped_ptr<base::Value> AsValue() const;
scoped_ptr<base::Value> ActivationStateAsValue() const;
@@ -466,7 +462,8 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
gfx::Rect viewport_damage_rect_;
- base::TimeTicks current_frame_time_;
+ base::TimeTicks current_frame_timeticks_;
+ base::Time current_frame_time_;
scoped_ptr<AnimationRegistrar> animation_registrar_;
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index cbc9124..141dc06 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -156,7 +156,7 @@ void LayerTreeImpl::SetCurrentlyScrollingLayer(LayerImpl* layer) {
if (currently_scrolling_layer_ &&
currently_scrolling_layer_->scrollbar_animation_controller())
currently_scrolling_layer_->scrollbar_animation_controller()->
- DidScrollGestureEnd(base::TimeTicks::Now());
+ DidScrollGestureEnd(CurrentFrameTimeTicks());
currently_scrolling_layer_ = layer;
if (layer && layer->scrollbar_animation_controller())
layer->scrollbar_animation_controller()->DidScrollGestureBegin();
@@ -501,7 +501,11 @@ bool LayerTreeImpl::PinchGestureActive() const {
return layer_tree_host_impl_->pinch_gesture_active();
}
-base::TimeTicks LayerTreeImpl::CurrentFrameTime() const {
+base::TimeTicks LayerTreeImpl::CurrentFrameTimeTicks() const {
+ return layer_tree_host_impl_->CurrentFrameTimeTicks();
+}
+
+base::Time LayerTreeImpl::CurrentFrameTime() const {
return layer_tree_host_impl_->CurrentFrameTime();
}
diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h
index 2db5cfa..fdda05d 100644
--- a/cc/trees/layer_tree_impl.h
+++ b/cc/trees/layer_tree_impl.h
@@ -67,7 +67,8 @@ class CC_EXPORT LayerTreeImpl {
LayerImpl* FindPendingTreeLayerById(int id);
int MaxTextureSize() const;
bool PinchGestureActive() const;
- base::TimeTicks CurrentFrameTime() const;
+ base::TimeTicks CurrentFrameTimeTicks() const;
+ base::Time CurrentFrameTime() const;
void SetNeedsCommit();
// Tree specific methods exposed to layer-impl tree.
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index 24bfae8..1ebb2fd 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -432,7 +432,9 @@ bool SingleThreadProxy::DoComposite(
return false;
}
- layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now());
+ layer_tree_host_impl_->Animate(
+ layer_tree_host_impl_->CurrentFrameTimeTicks(),
+ layer_tree_host_impl_->CurrentFrameTime());
layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false);
layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect);
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
index 3cc54e6..7f0f275 100644
--- a/cc/trees/thread_proxy.cc
+++ b/cc/trees/thread_proxy.cc
@@ -873,9 +873,9 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) {
if (!layer_tree_host_impl_->renderer())
return result;
- // FIXME: compute the frame display time more intelligently
- base::TimeTicks monotonic_time = base::TimeTicks::Now();
- base::Time wall_clock_time = base::Time::Now();
+ base::TimeTicks monotonic_time =
+ layer_tree_host_impl_->CurrentFrameTimeTicks();
+ base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime();
if (input_handler_on_impl_thread_)
input_handler_on_impl_thread_->Animate(monotonic_time);
@@ -1343,7 +1343,8 @@ void ThreadProxy::RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) {
}
void ThreadProxy::StartScrollbarAnimationOnImplThread() {
- layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now());
+ layer_tree_host_impl_->StartScrollbarAnimation(
+ layer_tree_host_impl_->CurrentFrameTimeTicks());
}
} // namespace cc