summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/animation/animation.h3
-rw-r--r--cc/animation/layer_animation_controller.cc8
-rw-r--r--cc/animation/layer_animation_controller_unittest.cc26
-rw-r--r--cc/trees/layer_tree_host_unittest_animation.cc50
4 files changed, 79 insertions, 8 deletions
diff --git a/cc/animation/animation.h b/cc/animation/animation.h
index 2677fde..153e4ef 100644
--- a/cc/animation/animation.h
+++ b/cc/animation/animation.h
@@ -151,6 +151,9 @@ class CC_EXPORT Animation {
scoped_ptr<Animation> CloneAndInitialize(RunState initial_run_state) const;
+ void set_is_controlling_instance_for_test(bool is_controlling_instance) {
+ is_controlling_instance_ = is_controlling_instance;
+ }
bool is_controlling_instance() const { return is_controlling_instance_; }
void PushPropertiesTo(Animation* other) const;
diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc
index 82f27ca..54b1a71 100644
--- a/cc/animation/layer_animation_controller.cc
+++ b/cc/animation/layer_animation_controller.cc
@@ -815,7 +815,9 @@ void LayerAnimationController::MarkAnimationsForDeletion(
// on the impl thread, we only mark a FINISHED main thread animation for
// deletion once it has received a FINISHED event from the impl thread.
bool animation_i_will_send_or_has_received_finish_event =
- events || animations_[i]->received_finished_event();
+ animations_[i]->is_controlling_instance() ||
+ animations_[i]->is_impl_only() ||
+ animations_[i]->received_finished_event();
// If an animation is finished, and not already marked for deletion,
// find out if all other animations in the same group are also finished.
if (animations_[i]->run_state() == Animation::FINISHED &&
@@ -827,7 +829,9 @@ void LayerAnimationController::MarkAnimationsForDeletion(
all_anims_with_same_id_are_finished = true;
for (size_t j = 0; j < animations_.size(); ++j) {
bool animation_j_will_send_or_has_received_finish_event =
- events || animations_[j]->received_finished_event();
+ animations_[j]->is_controlling_instance() ||
+ animations_[j]->is_impl_only() ||
+ animations_[j]->received_finished_event();
if (group_id == animations_[j]->group()) {
if (!animations_[j]->is_finished() ||
(animations_[j]->run_state() == Animation::FINISHED &&
diff --git a/cc/animation/layer_animation_controller_unittest.cc b/cc/animation/layer_animation_controller_unittest.cc
index dade5aa..e267eea 100644
--- a/cc/animation/layer_animation_controller_unittest.cc
+++ b/cc/animation/layer_animation_controller_unittest.cc
@@ -1527,16 +1527,20 @@ TEST(LayerAnimationControllerTest, SkipUpdateState) {
LayerAnimationController::Create(0));
controller->AddValueObserver(&dummy);
- controller->AddAnimation(CreateAnimation(
+ scoped_ptr<Animation> first_animation(CreateAnimation(
scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 1,
Animation::TRANSFORM));
+ first_animation->set_is_controlling_instance_for_test(true);
+ controller->AddAnimation(first_animation.Pass());
controller->Animate(kInitialTickTime);
controller->UpdateState(true, events.get());
- controller->AddAnimation(CreateAnimation(
+ scoped_ptr<Animation> second_animation(CreateAnimation(
scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
2, Animation::OPACITY));
+ second_animation->set_is_controlling_instance_for_test(true);
+ controller->AddAnimation(second_animation.Pass());
// Animate but don't UpdateState.
controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
@@ -1838,12 +1842,17 @@ TEST(LayerAnimationControllerTest, FinishedEventsForGroup) {
const int group_id = 1;
// Add two animations with the same group id but different durations.
- controller_impl->AddAnimation(Animation::Create(
+ scoped_ptr<Animation> first_animation(Animation::Create(
scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 1,
group_id, Animation::TRANSFORM));
- controller_impl->AddAnimation(Animation::Create(
+ first_animation->set_is_controlling_instance_for_test(true);
+ controller_impl->AddAnimation(first_animation.Pass());
+
+ scoped_ptr<Animation> second_animation(Animation::Create(
scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
2, group_id, Animation::OPACITY));
+ second_animation->set_is_controlling_instance_for_test(true);
+ controller_impl->AddAnimation(second_animation.Pass());
controller_impl->Animate(kInitialTickTime);
controller_impl->UpdateState(true, events.get());
@@ -1888,12 +1897,17 @@ TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) {
controller_impl->AddValueObserver(&dummy_impl);
// Add two animations with the same group id.
- controller_impl->AddAnimation(CreateAnimation(
+ scoped_ptr<Animation> first_animation(CreateAnimation(
scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), 1,
Animation::TRANSFORM));
- controller_impl->AddAnimation(CreateAnimation(
+ first_animation->set_is_controlling_instance_for_test(true);
+ controller_impl->AddAnimation(first_animation.Pass());
+
+ scoped_ptr<Animation> second_animation(CreateAnimation(
scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1, Animation::OPACITY));
+ second_animation->set_is_controlling_instance_for_test(true);
+ controller_impl->AddAnimation(second_animation.Pass());
controller_impl->Animate(kInitialTickTime);
controller_impl->UpdateState(true, events.get());
diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc
index b1287d3..45e3456 100644
--- a/cc/trees/layer_tree_host_unittest_animation.cc
+++ b/cc/trees/layer_tree_host_unittest_animation.cc
@@ -1035,5 +1035,55 @@ class LayerTreeHostAnimationTestAddAnimationAfterAnimating
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostAnimationTestAddAnimationAfterAnimating);
+class LayerTreeHostAnimationTestNotifyAnimationFinished
+ : public LayerTreeHostAnimationTest {
+ public:
+ LayerTreeHostAnimationTestNotifyAnimationFinished()
+ : called_animation_started_(false), called_animation_finished_(false) {}
+
+ void SetupTree() override {
+ LayerTreeHostAnimationTest::SetupTree();
+ picture_ = FakePictureLayer::Create(layer_settings(), &client_);
+ picture_->SetBounds(gfx::Size(4, 4));
+ picture_->set_layer_animation_delegate(this);
+ layer_tree_host()->root_layer()->AddChild(picture_);
+ }
+
+ void BeginTest() override {
+ layer_tree_host()->SetViewportSize(gfx::Size());
+ PostAddLongAnimationToMainThread(picture_.get());
+ }
+
+ void NotifyAnimationStarted(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ called_animation_started_ = true;
+ layer_tree_host()->AnimateLayers(
+ base::TimeTicks::FromInternalValue(std::numeric_limits<int64>::max()));
+ PostSetNeedsCommitToMainThread();
+ }
+
+ void NotifyAnimationFinished(base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property,
+ int group) override {
+ called_animation_finished_ = true;
+ EndTest();
+ }
+
+ void AfterTest() override {
+ EXPECT_TRUE(called_animation_started_);
+ EXPECT_TRUE(called_animation_finished_);
+ }
+
+ private:
+ bool called_animation_started_;
+ bool called_animation_finished_;
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> picture_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostAnimationTestNotifyAnimationFinished);
+
} // namespace
} // namespace cc