| OLD | NEW |
| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "cc/animation/animation_curve.h" | 9 #include "cc/animation/animation_curve.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 bool has_unfinished_animation) override { | 153 bool has_unfinished_animation) override { |
| 154 EXPECT_FALSE(has_unfinished_animation); | 154 EXPECT_FALSE(has_unfinished_animation); |
| 155 update_animation_state_was_called_ = true; | 155 update_animation_state_was_called_ = true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 158 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 159 TargetProperty::Type target_property, | 159 TargetProperty::Type target_property, |
| 160 int group) override { | 160 int group) override { |
| 161 EXPECT_LT(base::TimeTicks(), monotonic_time); | 161 EXPECT_LT(base::TimeTicks(), monotonic_time); |
| 162 | 162 |
| 163 LayerAnimationController* controller = | 163 Animation* animation = |
| 164 player_->element_animations()->layer_animation_controller(); | 164 player_->element_animations()->GetAnimation(TargetProperty::OPACITY); |
| 165 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); | |
| 166 if (animation) | 165 if (animation) |
| 167 player_->RemoveAnimation(animation->id()); | 166 player_->RemoveAnimation(animation->id()); |
| 168 | 167 |
| 169 EndTest(); | 168 EndTest(); |
| 170 } | 169 } |
| 171 | 170 |
| 172 void AfterTest() override { EXPECT_TRUE(update_animation_state_was_called_); } | 171 void AfterTest() override { EXPECT_TRUE(update_animation_state_was_called_); } |
| 173 | 172 |
| 174 private: | 173 private: |
| 175 bool update_animation_state_was_called_; | 174 bool update_animation_state_was_called_; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 286 |
| 288 // Wait for the commit with the animation to happen. | 287 // Wait for the commit with the animation to happen. |
| 289 if (host_impl->sync_tree()->source_frame_number() != 0) | 288 if (host_impl->sync_tree()->source_frame_number() != 0) |
| 290 return; | 289 return; |
| 291 | 290 |
| 292 scoped_refptr<AnimationTimeline> timeline_impl = | 291 scoped_refptr<AnimationTimeline> timeline_impl = |
| 293 host_impl->animation_host()->GetTimelineById(timeline_id_); | 292 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 294 scoped_refptr<AnimationPlayer> player_child_impl = | 293 scoped_refptr<AnimationPlayer> player_child_impl = |
| 295 timeline_impl->GetPlayerById(player_child_id_); | 294 timeline_impl->GetPlayerById(player_child_id_); |
| 296 | 295 |
| 297 LayerAnimationController* controller_impl = | |
| 298 player_child_impl->element_animations()->layer_animation_controller(); | |
| 299 Animation* animation = | 296 Animation* animation = |
| 300 controller_impl->GetAnimation(TargetProperty::OPACITY); | 297 player_child_impl->element_animations()->GetAnimation( |
| 298 TargetProperty::OPACITY); |
| 301 | 299 |
| 302 const FloatAnimationCurve* curve = | 300 const FloatAnimationCurve* curve = |
| 303 animation->curve()->ToFloatAnimationCurve(); | 301 animation->curve()->ToFloatAnimationCurve(); |
| 304 float start_opacity = curve->GetValue(base::TimeDelta()); | 302 float start_opacity = curve->GetValue(base::TimeDelta()); |
| 305 float end_opacity = curve->GetValue(curve->Duration()); | 303 float end_opacity = curve->GetValue(curve->Duration()); |
| 306 float linearly_interpolated_opacity = | 304 float linearly_interpolated_opacity = |
| 307 0.25f * end_opacity + 0.75f * start_opacity; | 305 0.25f * end_opacity + 0.75f * start_opacity; |
| 308 base::TimeDelta time = TimeUtil::Scale(curve->Duration(), 0.25f); | 306 base::TimeDelta time = TimeUtil::Scale(curve->Duration(), 0.25f); |
| 309 // If the linear timing function associated with this animation was not | 307 // If the linear timing function associated with this animation was not |
| 310 // picked up, then the linearly interpolated opacity would be different | 308 // picked up, then the linearly interpolated opacity would be different |
| (...skipping 30 matching lines...) Expand all Loading... |
| 341 player_child_->AttachLayer(picture_->id()); | 339 player_child_->AttachLayer(picture_->id()); |
| 342 } | 340 } |
| 343 | 341 |
| 344 void BeginTest() override { | 342 void BeginTest() override { |
| 345 PostAddAnimationToMainThreadPlayer(player_child_.get()); | 343 PostAddAnimationToMainThreadPlayer(player_child_.get()); |
| 346 } | 344 } |
| 347 | 345 |
| 348 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 346 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 349 TargetProperty::Type target_property, | 347 TargetProperty::Type target_property, |
| 350 int group) override { | 348 int group) override { |
| 351 LayerAnimationController* controller = | 349 Animation* animation = player_child_->element_animations()->GetAnimation( |
| 352 player_child_->element_animations()->layer_animation_controller(); | 350 TargetProperty::OPACITY); |
| 353 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); | |
| 354 main_start_time_ = animation->start_time(); | 351 main_start_time_ = animation->start_time(); |
| 355 controller->RemoveAnimation(animation->id()); | 352 player_child_->element_animations()->RemoveAnimation(animation->id()); |
| 356 EndTest(); | 353 EndTest(); |
| 357 } | 354 } |
| 358 | 355 |
| 359 void UpdateAnimationState(LayerTreeHostImpl* impl_host, | 356 void UpdateAnimationState(LayerTreeHostImpl* impl_host, |
| 360 bool has_unfinished_animation) override { | 357 bool has_unfinished_animation) override { |
| 361 scoped_refptr<AnimationTimeline> timeline_impl = | 358 scoped_refptr<AnimationTimeline> timeline_impl = |
| 362 impl_host->animation_host()->GetTimelineById(timeline_id_); | 359 impl_host->animation_host()->GetTimelineById(timeline_id_); |
| 363 scoped_refptr<AnimationPlayer> player_child_impl = | 360 scoped_refptr<AnimationPlayer> player_child_impl = |
| 364 timeline_impl->GetPlayerById(player_child_id_); | 361 timeline_impl->GetPlayerById(player_child_id_); |
| 365 | 362 |
| 366 LayerAnimationController* controller = | 363 Animation* animation = |
| 367 player_child_impl->element_animations()->layer_animation_controller(); | 364 player_child_impl->element_animations()->GetAnimation( |
| 368 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); | 365 TargetProperty::OPACITY); |
| 369 if (!animation) | 366 if (!animation) |
| 370 return; | 367 return; |
| 371 | 368 |
| 372 impl_start_time_ = animation->start_time(); | 369 impl_start_time_ = animation->start_time(); |
| 373 } | 370 } |
| 374 | 371 |
| 375 void AfterTest() override { | 372 void AfterTest() override { |
| 376 EXPECT_EQ(impl_start_time_, main_start_time_); | 373 EXPECT_EQ(impl_start_time_, main_start_time_); |
| 377 EXPECT_LT(base::TimeTicks(), impl_start_time_); | 374 EXPECT_LT(base::TimeTicks(), impl_start_time_); |
| 378 } | 375 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 393 public: | 390 public: |
| 394 void BeginTest() override { | 391 void BeginTest() override { |
| 395 AttachPlayersToTimeline(); | 392 AttachPlayersToTimeline(); |
| 396 player_->AttachLayer(layer_tree_host()->root_layer()->id()); | 393 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
| 397 PostAddInstantAnimationToMainThreadPlayer(player_.get()); | 394 PostAddInstantAnimationToMainThreadPlayer(player_.get()); |
| 398 } | 395 } |
| 399 | 396 |
| 400 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 397 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
| 401 TargetProperty::Type target_property, | 398 TargetProperty::Type target_property, |
| 402 int group) override { | 399 int group) override { |
| 403 LayerAnimationController* controller = | 400 Animation* animation = |
| 404 player_->element_animations()->layer_animation_controller(); | 401 player_->element_animations()->GetAnimation(TargetProperty::OPACITY); |
| 405 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); | |
| 406 if (animation) | 402 if (animation) |
| 407 controller->RemoveAnimation(animation->id()); | 403 player_->element_animations()->RemoveAnimation(animation->id()); |
| 408 EndTest(); | 404 EndTest(); |
| 409 } | 405 } |
| 410 | 406 |
| 411 void AfterTest() override {} | 407 void AfterTest() override {} |
| 412 }; | 408 }; |
| 413 | 409 |
| 414 SINGLE_AND_MULTI_THREAD_TEST_F( | 410 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 415 LayerTreeHostAnimationTestAnimationFinishedEvents); | 411 LayerTreeHostAnimationTestAnimationFinishedEvents); |
| 416 | 412 |
| 417 // Ensures that when opacity is being animated, this value does not cause the | 413 // Ensures that when opacity is being animated, this value does not cause the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 436 void BeginTest() override { | 432 void BeginTest() override { |
| 437 PostAddAnimationToMainThreadPlayer(player_.get()); | 433 PostAddAnimationToMainThreadPlayer(player_.get()); |
| 438 } | 434 } |
| 439 | 435 |
| 440 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 436 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 441 scoped_refptr<AnimationTimeline> timeline_impl = | 437 scoped_refptr<AnimationTimeline> timeline_impl = |
| 442 host_impl->animation_host()->GetTimelineById(timeline_id_); | 438 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 443 scoped_refptr<AnimationPlayer> player_impl = | 439 scoped_refptr<AnimationPlayer> player_impl = |
| 444 timeline_impl->GetPlayerById(player_id_); | 440 timeline_impl->GetPlayerById(player_id_); |
| 445 | 441 |
| 446 LayerAnimationController* controller_impl = | 442 Animation* animation_impl = player_impl->element_animations()->GetAnimation( |
| 447 player_impl->element_animations()->layer_animation_controller(); | 443 TargetProperty::OPACITY); |
| 448 Animation* animation_impl = | 444 player_impl->element_animations()->RemoveAnimation(animation_impl->id()); |
| 449 controller_impl->GetAnimation(TargetProperty::OPACITY); | |
| 450 controller_impl->RemoveAnimation(animation_impl->id()); | |
| 451 EndTest(); | 445 EndTest(); |
| 452 } | 446 } |
| 453 | 447 |
| 454 void AfterTest() override { | 448 void AfterTest() override { |
| 455 // Update() should have been called once, proving that the layer was not | 449 // Update() should have been called once, proving that the layer was not |
| 456 // skipped. | 450 // skipped. |
| 457 EXPECT_EQ(1, update_check_layer_->update_count()); | 451 EXPECT_EQ(1, update_check_layer_->update_count()); |
| 458 | 452 |
| 459 // clear update_check_layer_ so LayerTreeHost dies. | 453 // clear update_check_layer_ so LayerTreeHost dies. |
| 460 update_check_layer_ = NULL; | 454 update_check_layer_ = NULL; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 | 788 |
| 795 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 789 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 796 | 790 |
| 797 void BeginMainFrame(const BeginFrameArgs& args) override { | 791 void BeginMainFrame(const BeginFrameArgs& args) override { |
| 798 switch (layer_tree_host()->source_frame_number()) { | 792 switch (layer_tree_host()->source_frame_number()) { |
| 799 case 0: | 793 case 0: |
| 800 break; | 794 break; |
| 801 case 1: { | 795 case 1: { |
| 802 Animation* animation = | 796 Animation* animation = |
| 803 player_child_->element_animations() | 797 player_child_->element_animations() |
| 804 ->layer_animation_controller() | |
| 805 ->GetAnimation(TargetProperty::SCROLL_OFFSET); | 798 ->GetAnimation(TargetProperty::SCROLL_OFFSET); |
| 806 player_child_->RemoveAnimation(animation->id()); | 799 player_child_->RemoveAnimation(animation->id()); |
| 807 scroll_layer_->SetScrollOffset(final_postion_); | 800 scroll_layer_->SetScrollOffset(final_postion_); |
| 808 break; | 801 break; |
| 809 } | 802 } |
| 810 default: | 803 default: |
| 811 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset()); | 804 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset()); |
| 812 } | 805 } |
| 813 } | 806 } |
| 814 | 807 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 827 } | 820 } |
| 828 | 821 |
| 829 scoped_refptr<AnimationTimeline> timeline_impl = | 822 scoped_refptr<AnimationTimeline> timeline_impl = |
| 830 host_impl->animation_host()->GetTimelineById(timeline_id_); | 823 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 831 scoped_refptr<AnimationPlayer> player_impl = | 824 scoped_refptr<AnimationPlayer> player_impl = |
| 832 timeline_impl->GetPlayerById(player_child_id_); | 825 timeline_impl->GetPlayerById(player_child_id_); |
| 833 | 826 |
| 834 LayerImpl* scroll_layer_impl = | 827 LayerImpl* scroll_layer_impl = |
| 835 host_impl->active_tree()->root_layer()->children()[0]; | 828 host_impl->active_tree()->root_layer()->children()[0]; |
| 836 Animation* animation = player_impl->element_animations() | 829 Animation* animation = player_impl->element_animations() |
| 837 ->layer_animation_controller() | |
| 838 ->GetAnimation(TargetProperty::SCROLL_OFFSET); | 830 ->GetAnimation(TargetProperty::SCROLL_OFFSET); |
| 839 | 831 |
| 840 if (!animation || animation->run_state() != Animation::RUNNING) { | 832 if (!animation || animation->run_state() != Animation::RUNNING) { |
| 841 host_impl->BlockNotifyReadyToActivateForTesting(false); | 833 host_impl->BlockNotifyReadyToActivateForTesting(false); |
| 842 return; | 834 return; |
| 843 } | 835 } |
| 844 | 836 |
| 845 // Block activation until the running animation has a chance to produce a | 837 // Block activation until the running animation has a chance to produce a |
| 846 // scroll delta. | 838 // scroll delta. |
| 847 gfx::Vector2dF scroll_delta = ScrollDelta(scroll_layer_impl); | 839 gfx::Vector2dF scroll_delta = ScrollDelta(scroll_layer_impl); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 host_impl->animation_host()->GetTimelineById(timeline_id_); | 935 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 944 scoped_refptr<AnimationPlayer> player_impl = | 936 scoped_refptr<AnimationPlayer> player_impl = |
| 945 timeline_impl->GetPlayerById(player_id_); | 937 timeline_impl->GetPlayerById(player_id_); |
| 946 scoped_refptr<AnimationPlayer> player_child_impl = | 938 scoped_refptr<AnimationPlayer> player_child_impl = |
| 947 timeline_impl->GetPlayerById(player_child_id_); | 939 timeline_impl->GetPlayerById(player_child_id_); |
| 948 | 940 |
| 949 // wait for tree activation. | 941 // wait for tree activation. |
| 950 if (!player_impl->element_animations()) | 942 if (!player_impl->element_animations()) |
| 951 return; | 943 return; |
| 952 | 944 |
| 953 LayerAnimationController* root_controller_impl = | 945 Animation* root_animation = player_impl->element_animations()->GetAnimation( |
| 954 player_impl->element_animations()->layer_animation_controller(); | 946 TargetProperty::OPACITY); |
| 955 Animation* root_animation = | |
| 956 root_controller_impl->GetAnimation(TargetProperty::OPACITY); | |
| 957 if (!root_animation || root_animation->run_state() != Animation::RUNNING) | 947 if (!root_animation || root_animation->run_state() != Animation::RUNNING) |
| 958 return; | 948 return; |
| 959 | 949 |
| 960 LayerAnimationController* child_controller_impl = | |
| 961 player_child_impl->element_animations()->layer_animation_controller(); | |
| 962 Animation* child_animation = | 950 Animation* child_animation = |
| 963 child_controller_impl->GetAnimation(TargetProperty::OPACITY); | 951 player_child_impl->element_animations()->GetAnimation( |
| 952 TargetProperty::OPACITY); |
| 964 EXPECT_EQ(Animation::RUNNING, child_animation->run_state()); | 953 EXPECT_EQ(Animation::RUNNING, child_animation->run_state()); |
| 965 EXPECT_EQ(root_animation->start_time(), child_animation->start_time()); | 954 EXPECT_EQ(root_animation->start_time(), child_animation->start_time()); |
| 966 root_controller_impl->AbortAnimations(TargetProperty::OPACITY); | 955 player_impl->element_animations()->AbortAnimations(TargetProperty::OPACITY); |
| 967 root_controller_impl->AbortAnimations(TargetProperty::TRANSFORM); | 956 player_impl->element_animations()->AbortAnimations( |
| 968 child_controller_impl->AbortAnimations(TargetProperty::OPACITY); | 957 TargetProperty::TRANSFORM); |
| 958 player_child_impl->element_animations()->AbortAnimations( |
| 959 TargetProperty::OPACITY); |
| 969 EndTest(); | 960 EndTest(); |
| 970 } | 961 } |
| 971 | 962 |
| 972 void AfterTest() override {} | 963 void AfterTest() override {} |
| 973 | 964 |
| 974 private: | 965 private: |
| 975 int frame_count_with_pending_tree_; | 966 int frame_count_with_pending_tree_; |
| 976 }; | 967 }; |
| 977 | 968 |
| 978 // This test blocks activation which is not supported for single thread mode. | 969 // This test blocks activation which is not supported for single thread mode. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 // After checking this on the sync tree, we will activate, which will cause | 1008 // After checking this on the sync tree, we will activate, which will cause |
| 1018 // PrepareTiles to happen again (which races with the test exiting). | 1009 // PrepareTiles to happen again (which races with the test exiting). |
| 1019 if (TestEnded()) | 1010 if (TestEnded()) |
| 1020 return; | 1011 return; |
| 1021 | 1012 |
| 1022 scoped_refptr<AnimationTimeline> timeline_impl = | 1013 scoped_refptr<AnimationTimeline> timeline_impl = |
| 1023 host_impl->animation_host()->GetTimelineById(timeline_id_); | 1014 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 1024 scoped_refptr<AnimationPlayer> player_impl = | 1015 scoped_refptr<AnimationPlayer> player_impl = |
| 1025 timeline_impl->GetPlayerById(player_id_); | 1016 timeline_impl->GetPlayerById(player_id_); |
| 1026 | 1017 |
| 1027 LayerAnimationController* controller_impl = | |
| 1028 player_impl->element_animations()->layer_animation_controller(); | |
| 1029 | |
| 1030 LayerImpl* root = host_impl->sync_tree()->root_layer(); | 1018 LayerImpl* root = host_impl->sync_tree()->root_layer(); |
| 1031 LayerImpl* child = root->children()[0]; | 1019 LayerImpl* child = root->children()[0]; |
| 1032 Animation* animation = | 1020 Animation* animation = player_impl->element_animations()->GetAnimation( |
| 1033 controller_impl->GetAnimation(TargetProperty::TRANSFORM); | 1021 TargetProperty::TRANSFORM); |
| 1034 | 1022 |
| 1035 // The animation should be starting for the first frame. | 1023 // The animation should be starting for the first frame. |
| 1036 EXPECT_EQ(Animation::STARTING, animation->run_state()); | 1024 EXPECT_EQ(Animation::STARTING, animation->run_state()); |
| 1037 | 1025 |
| 1038 // And the transform should be propogated to the sync tree layer, at its | 1026 // And the transform should be propogated to the sync tree layer, at its |
| 1039 // starting state which is 6,7. | 1027 // starting state which is 6,7. |
| 1040 gfx::Transform expected_transform; | 1028 gfx::Transform expected_transform; |
| 1041 expected_transform.Translate(6.0, 7.0); | 1029 expected_transform.Translate(6.0, 7.0); |
| 1042 EXPECT_EQ(expected_transform, child->DrawTransform()); | 1030 EXPECT_EQ(expected_transform, child->DrawTransform()); |
| 1043 // And the sync tree layer should know it is animating. | 1031 // And the sync tree layer should know it is animating. |
| 1044 EXPECT_TRUE(child->screen_space_transform_is_animating()); | 1032 EXPECT_TRUE(child->screen_space_transform_is_animating()); |
| 1045 | 1033 |
| 1046 controller_impl->AbortAnimations(TargetProperty::TRANSFORM); | 1034 player_impl->element_animations()->AbortAnimations( |
| 1035 TargetProperty::TRANSFORM); |
| 1047 EndTest(); | 1036 EndTest(); |
| 1048 } | 1037 } |
| 1049 | 1038 |
| 1050 void AfterTest() override {} | 1039 void AfterTest() override {} |
| 1051 | 1040 |
| 1052 FakeContentLayerClient client_; | 1041 FakeContentLayerClient client_; |
| 1053 scoped_refptr<Layer> layer_; | 1042 scoped_refptr<Layer> layer_; |
| 1054 }; | 1043 }; |
| 1055 | 1044 |
| 1056 SINGLE_AND_MULTI_THREAD_TEST_F( | 1045 SINGLE_AND_MULTI_THREAD_TEST_F( |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 } | 1207 } |
| 1219 | 1208 |
| 1220 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1209 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1221 | 1210 |
| 1222 void DidCommit() override { | 1211 void DidCommit() override { |
| 1223 switch (layer_tree_host()->source_frame_number()) { | 1212 switch (layer_tree_host()->source_frame_number()) { |
| 1224 case 1: | 1213 case 1: |
| 1225 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); | 1214 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); |
| 1226 break; | 1215 break; |
| 1227 case 2: | 1216 case 2: |
| 1228 LayerAnimationController* controller = | |
| 1229 player_child_->element_animations()->layer_animation_controller(); | |
| 1230 Animation* animation = | 1217 Animation* animation = |
| 1231 controller->GetAnimation(TargetProperty::TRANSFORM); | 1218 player_child_->element_animations()->GetAnimation( |
| 1219 TargetProperty::TRANSFORM); |
| 1232 player_child_->RemoveAnimation(animation->id()); | 1220 player_child_->RemoveAnimation(animation->id()); |
| 1233 gfx::Transform transform; | 1221 gfx::Transform transform; |
| 1234 transform.Translate(10.f, 10.f); | 1222 transform.Translate(10.f, 10.f); |
| 1235 layer_->SetTransform(transform); | 1223 layer_->SetTransform(transform); |
| 1236 | 1224 |
| 1237 // Do something that causes property trees to get rebuilt. This is | 1225 // Do something that causes property trees to get rebuilt. This is |
| 1238 // intended to simulate the conditions that caused the bug whose fix | 1226 // intended to simulate the conditions that caused the bug whose fix |
| 1239 // this is testing (the test will pass without it but won't test what | 1227 // this is testing (the test will pass without it but won't test what |
| 1240 // we want it to). We were updating the wrong transform node at the end | 1228 // we want it to). We were updating the wrong transform node at the end |
| 1241 // of an animation (we were assuming the layer with the finished | 1229 // of an animation (we were assuming the layer with the finished |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 } | 1286 } |
| 1299 | 1287 |
| 1300 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1288 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1301 | 1289 |
| 1302 void DidCommit() override { | 1290 void DidCommit() override { |
| 1303 switch (layer_tree_host()->source_frame_number()) { | 1291 switch (layer_tree_host()->source_frame_number()) { |
| 1304 case 1: | 1292 case 1: |
| 1305 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); | 1293 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); |
| 1306 break; | 1294 break; |
| 1307 case 2: | 1295 case 2: |
| 1308 LayerAnimationController* controller = | 1296 Animation* animation = player_->element_animations()->GetAnimation( |
| 1309 player_->element_animations()->layer_animation_controller(); | 1297 TargetProperty::TRANSFORM); |
| 1310 Animation* animation = | |
| 1311 controller->GetAnimation(TargetProperty::TRANSFORM); | |
| 1312 player_->RemoveAnimation(animation->id()); | 1298 player_->RemoveAnimation(animation->id()); |
| 1313 break; | 1299 break; |
| 1314 } | 1300 } |
| 1315 } | 1301 } |
| 1316 | 1302 |
| 1317 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1303 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 1318 LayerImpl* root = host_impl->sync_tree()->root_layer(); | 1304 LayerImpl* root = host_impl->sync_tree()->root_layer(); |
| 1319 LayerImpl* child = root->children()[0]; | 1305 LayerImpl* child = root->children()[0]; |
| 1320 switch (host_impl->sync_tree()->source_frame_number()) { | 1306 switch (host_impl->sync_tree()->source_frame_number()) { |
| 1321 case 0: | 1307 case 0: |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 private: | 1606 private: |
| 1621 scoped_refptr<Layer> layer_; | 1607 scoped_refptr<Layer> layer_; |
| 1622 FakeContentLayerClient client_; | 1608 FakeContentLayerClient client_; |
| 1623 }; | 1609 }; |
| 1624 | 1610 |
| 1625 MULTI_THREAD_TEST_F( | 1611 MULTI_THREAD_TEST_F( |
| 1626 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1612 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1627 | 1613 |
| 1628 } // namespace | 1614 } // namespace |
| 1629 } // namespace cc | 1615 } // namespace cc |
| OLD | NEW |