diff options
author | sivagunturi@chromium.org <sivagunturi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-15 17:31:36 +0000 |
---|---|---|
committer | sivagunturi@chromium.org <sivagunturi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-15 17:31:36 +0000 |
commit | ac22516a1df6e674ca7c730eee4d22286f96a257 (patch) | |
tree | 96fb2af51d9b501840c7018d9cd38a9921b803cf /cc/trees | |
parent | 2590cbb39144fec19f67e86493392123ea67d90f (diff) | |
download | chromium_src-ac22516a1df6e674ca7c730eee4d22286f96a257.zip chromium_src-ac22516a1df6e674ca7c730eee4d22286f96a257.tar.gz chromium_src-ac22516a1df6e674ca7c730eee4d22286f96a257.tar.bz2 |
CC::LayerAnimationController should use TimeTicks and
TimeDelta to represent time.
As of now complete CC/animation code uses double type
for time durations. This patch replaces double with
TimeTicks where time stamps is used and TimeDeltas
where offset is used.
BUG=178171
Review URL: https://codereview.chromium.org/231133002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees')
-rw-r--r-- | cc/trees/layer_tree_host.cc | 4 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 26 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_animation.cc | 10 |
3 files changed, 15 insertions, 25 deletions
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index d9cab33..e284014 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -1150,15 +1150,13 @@ scoped_ptr<base::Value> LayerTreeHost::AsValue() const { return state.PassAs<base::Value>(); } -void LayerTreeHost::AnimateLayers(base::TimeTicks time) { +void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { if (!settings_.accelerated_animation_enabled || animation_registrar_->active_animation_controllers().empty()) return; TRACE_EVENT0("cc", "LayerTreeHost::AnimateLayers"); - double monotonic_time = (time - base::TimeTicks()).InSecondsF(); - AnimationRegistrar::AnimationControllerMap copy = animation_registrar_->active_animation_controllers(); for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 4a846ec..b51d6f9 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -2770,26 +2770,21 @@ void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { if (!page_scale_animation_) return; - // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic - // time. - double monotonic_time_for_cc_animations = - (monotonic_time - base::TimeTicks()).InSecondsF(); gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); if (!page_scale_animation_->IsAnimationStarted()) - page_scale_animation_->StartAnimation(monotonic_time_for_cc_animations); + page_scale_animation_->StartAnimation(monotonic_time); - active_tree_->SetPageScaleDelta(page_scale_animation_->PageScaleFactorAtTime( - monotonic_time_for_cc_animations) / - active_tree_->page_scale_factor()); - gfx::Vector2dF next_scroll = page_scale_animation_->ScrollOffsetAtTime( - monotonic_time_for_cc_animations); + active_tree_->SetPageScaleDelta( + page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / + active_tree_->page_scale_factor()); + gfx::Vector2dF next_scroll = + page_scale_animation_->ScrollOffsetAtTime(monotonic_time); ScrollViewportBy(next_scroll - scroll_total); SetNeedsRedraw(); - if (page_scale_animation_->IsAnimationCompleteAtTime( - monotonic_time_for_cc_animations)) { + if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { page_scale_animation_.reset(); client_->SetNeedsCommitOnImplThread(); client_->RenewTreePriority(); @@ -2819,17 +2814,12 @@ void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { return; TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); - - // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic - // time. - double monotonic_time_for_cc_animations = - (monotonic_time - base::TimeTicks()).InSecondsF(); AnimationRegistrar::AnimationControllerMap copy = animation_registrar_->active_animation_controllers(); for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); iter != copy.end(); ++iter) - (*iter).second->Animate(monotonic_time_for_cc_animations); + (*iter).second->Animate(monotonic_time); SetNeedsAnimate(); } diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc index 8e11556..9e02822 100644 --- a/cc/trees/layer_tree_host_unittest_animation.cc +++ b/cc/trees/layer_tree_host_unittest_animation.cc @@ -568,7 +568,8 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes layer_animation_controller(); Animation* animation = controller->GetAnimation(Animation::Opacity); - main_start_time_ = animation->start_time(); + main_start_time_ = + (animation->start_time() - base::TimeTicks()).InSecondsF(); controller->RemoveAnimation(animation->id()); if (impl_start_time_ > 0.0) @@ -586,7 +587,8 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes if (!animation) return; - impl_start_time_ = animation->start_time(); + impl_start_time_ = + (animation->start_time() - base::TimeTicks()).InSecondsF(); controller->RemoveAnimation(animation->id()); if (main_start_time_ > 0.0) @@ -1367,10 +1369,10 @@ class LayerTreeHostAnimationTestAddAnimationAfterAnimating int id = ((*iter).second->id()); if (id == host_impl->RootLayer()->id()) { Animation* anim = (*iter).second->GetAnimation(Animation::Transform); - EXPECT_GT(anim->start_time(), 0); + EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); } else if (id == host_impl->RootLayer()->children()[0]->id()) { Animation* anim = (*iter).second->GetAnimation(Animation::Opacity); - EXPECT_GT(anim->start_time(), 0); + EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); } } } |