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

Side by Side Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 231133002: CC::Animations should use TimeTicks & TimeDelta to represent time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code changed as per review comments Created 6 years, 7 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | ui/compositor/layer_animation_sequence.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "cc/animation/animation_curve.h" 7 #include "cc/animation/animation_curve.h"
8 #include "cc/animation/layer_animation_controller.h" 8 #include "cc/animation/layer_animation_controller.h"
9 #include "cc/animation/scroll_offset_animation_curve.h" 9 #include "cc/animation/scroll_offset_animation_curve.h"
10 #include "cc/animation/timing_function.h" 10 #include "cc/animation/timing_function.h"
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 561 }
562 562
563 virtual void NotifyAnimationStarted( 563 virtual void NotifyAnimationStarted(
564 base::TimeTicks monotonic_time, 564 base::TimeTicks monotonic_time,
565 Animation::TargetProperty target_property) OVERRIDE { 565 Animation::TargetProperty target_property) OVERRIDE {
566 LayerAnimationController* controller = 566 LayerAnimationController* controller =
567 layer_tree_host()->root_layer()->children()[0]-> 567 layer_tree_host()->root_layer()->children()[0]->
568 layer_animation_controller(); 568 layer_animation_controller();
569 Animation* animation = 569 Animation* animation =
570 controller->GetAnimation(Animation::Opacity); 570 controller->GetAnimation(Animation::Opacity);
571 main_start_time_ = animation->start_time(); 571 main_start_time_ =
572 (animation->start_time() - base::TimeTicks()).InSecondsF();
572 controller->RemoveAnimation(animation->id()); 573 controller->RemoveAnimation(animation->id());
573 574
574 if (impl_start_time_ > 0.0) 575 if (impl_start_time_ > 0.0)
575 EndTest(); 576 EndTest();
576 } 577 }
577 578
578 virtual void UpdateAnimationState( 579 virtual void UpdateAnimationState(
579 LayerTreeHostImpl* impl_host, 580 LayerTreeHostImpl* impl_host,
580 bool has_unfinished_animation) OVERRIDE { 581 bool has_unfinished_animation) OVERRIDE {
581 LayerAnimationController* controller = 582 LayerAnimationController* controller =
582 impl_host->active_tree()->root_layer()->children()[0]-> 583 impl_host->active_tree()->root_layer()->children()[0]->
583 layer_animation_controller(); 584 layer_animation_controller();
584 Animation* animation = 585 Animation* animation =
585 controller->GetAnimation(Animation::Opacity); 586 controller->GetAnimation(Animation::Opacity);
586 if (!animation) 587 if (!animation)
587 return; 588 return;
588 589
589 impl_start_time_ = animation->start_time(); 590 impl_start_time_ =
591 (animation->start_time() - base::TimeTicks()).InSecondsF();
590 controller->RemoveAnimation(animation->id()); 592 controller->RemoveAnimation(animation->id());
591 593
592 if (main_start_time_ > 0.0) 594 if (main_start_time_ > 0.0)
593 EndTest(); 595 EndTest();
594 } 596 }
595 597
596 virtual void AfterTest() OVERRIDE { 598 virtual void AfterTest() OVERRIDE {
597 EXPECT_FLOAT_EQ(impl_start_time_, main_start_time_); 599 EXPECT_FLOAT_EQ(impl_start_time_, main_start_time_);
598 } 600 }
599 601
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 AnimationRegistrar::AnimationControllerMap copy = 1362 AnimationRegistrar::AnimationControllerMap copy =
1361 host_impl->animation_registrar()->active_animation_controllers(); 1363 host_impl->animation_registrar()->active_animation_controllers();
1362 EXPECT_EQ(2u, copy.size()); 1364 EXPECT_EQ(2u, copy.size());
1363 for (AnimationRegistrar::AnimationControllerMap::iterator iter = 1365 for (AnimationRegistrar::AnimationControllerMap::iterator iter =
1364 copy.begin(); 1366 copy.begin();
1365 iter != copy.end(); 1367 iter != copy.end();
1366 ++iter) { 1368 ++iter) {
1367 int id = ((*iter).second->id()); 1369 int id = ((*iter).second->id());
1368 if (id == host_impl->RootLayer()->id()) { 1370 if (id == host_impl->RootLayer()->id()) {
1369 Animation* anim = (*iter).second->GetAnimation(Animation::Transform); 1371 Animation* anim = (*iter).second->GetAnimation(Animation::Transform);
1370 EXPECT_GT(anim->start_time(), 0); 1372 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1371 } else if (id == host_impl->RootLayer()->children()[0]->id()) { 1373 } else if (id == host_impl->RootLayer()->children()[0]->id()) {
1372 Animation* anim = (*iter).second->GetAnimation(Animation::Opacity); 1374 Animation* anim = (*iter).second->GetAnimation(Animation::Opacity);
1373 EXPECT_GT(anim->start_time(), 0); 1375 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1374 } 1376 }
1375 } 1377 }
1376 } 1378 }
1377 } 1379 }
1378 1380
1379 virtual void AfterTest() OVERRIDE {} 1381 virtual void AfterTest() OVERRIDE {}
1380 1382
1381 private: 1383 private:
1382 scoped_refptr<Layer> content_; 1384 scoped_refptr<Layer> content_;
1383 int num_swap_buffers_; 1385 int num_swap_buffers_;
1384 }; 1386 };
1385 1387
1386 SINGLE_AND_MULTI_THREAD_TEST_F( 1388 SINGLE_AND_MULTI_THREAD_TEST_F(
1387 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1389 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
1388 1390
1389 } // namespace 1391 } // namespace
1390 } // namespace cc 1392 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | ui/compositor/layer_animation_sequence.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698