| 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 25 matching lines...) Expand all Loading... |
| 36 : timeline_id_(AnimationIdProvider::NextTimelineId()), | 36 : timeline_id_(AnimationIdProvider::NextTimelineId()), |
| 37 player_id_(AnimationIdProvider::NextPlayerId()), | 37 player_id_(AnimationIdProvider::NextPlayerId()), |
| 38 player_child_id_(AnimationIdProvider::NextPlayerId()) { | 38 player_child_id_(AnimationIdProvider::NextPlayerId()) { |
| 39 timeline_ = AnimationTimeline::Create(timeline_id_); | 39 timeline_ = AnimationTimeline::Create(timeline_id_); |
| 40 player_ = AnimationPlayer::Create(player_id_); | 40 player_ = AnimationPlayer::Create(player_id_); |
| 41 player_child_ = AnimationPlayer::Create(player_child_id_); | 41 player_child_ = AnimationPlayer::Create(player_child_id_); |
| 42 | 42 |
| 43 player_->set_layer_animation_delegate(this); | 43 player_->set_layer_animation_delegate(this); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void InitializeSettings(LayerTreeSettings* settings) override { | |
| 47 settings->use_compositor_animation_timelines = true; | |
| 48 } | |
| 49 | |
| 50 void InitializeLayerSettings(LayerSettings* layer_settings) override { | |
| 51 layer_settings->use_compositor_animation_timelines = true; | |
| 52 } | |
| 53 | |
| 54 void AttachPlayersToTimeline() { | 46 void AttachPlayersToTimeline() { |
| 55 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); | 47 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); |
| 56 timeline_->AttachPlayer(player_.get()); | 48 timeline_->AttachPlayer(player_.get()); |
| 57 timeline_->AttachPlayer(player_child_.get()); | 49 timeline_->AttachPlayer(player_child_.get()); |
| 58 } | 50 } |
| 59 | 51 |
| 60 protected: | 52 protected: |
| 61 scoped_refptr<AnimationTimeline> timeline_; | 53 scoped_refptr<AnimationTimeline> timeline_; |
| 62 scoped_refptr<AnimationPlayer> player_; | 54 scoped_refptr<AnimationPlayer> player_; |
| 63 scoped_refptr<AnimationPlayer> player_child_; | 55 scoped_refptr<AnimationPlayer> player_child_; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 }; | 260 }; |
| 269 | 261 |
| 270 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimationsGetDeleted); | 262 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimationsGetDeleted); |
| 271 | 263 |
| 272 // Ensure that an animation's timing function is respected. | 264 // Ensure that an animation's timing function is respected. |
| 273 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction | 265 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction |
| 274 : public LayerTreeHostAnimationTest { | 266 : public LayerTreeHostAnimationTest { |
| 275 public: | 267 public: |
| 276 void SetupTree() override { | 268 void SetupTree() override { |
| 277 LayerTreeHostAnimationTest::SetupTree(); | 269 LayerTreeHostAnimationTest::SetupTree(); |
| 278 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 270 picture_ = FakePictureLayer::Create(&client_); |
| 279 picture_->SetBounds(gfx::Size(4, 4)); | 271 picture_->SetBounds(gfx::Size(4, 4)); |
| 280 client_.set_bounds(picture_->bounds()); | 272 client_.set_bounds(picture_->bounds()); |
| 281 layer_tree_host()->root_layer()->AddChild(picture_); | 273 layer_tree_host()->root_layer()->AddChild(picture_); |
| 282 | 274 |
| 283 AttachPlayersToTimeline(); | 275 AttachPlayersToTimeline(); |
| 284 player_child_->AttachLayer(picture_->id()); | 276 player_child_->AttachLayer(picture_->id()); |
| 285 } | 277 } |
| 286 | 278 |
| 287 void BeginTest() override { | 279 void BeginTest() override { |
| 288 PostAddAnimationToMainThreadPlayer(player_child_.get()); | 280 PostAddAnimationToMainThreadPlayer(player_child_.get()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 SINGLE_AND_MULTI_THREAD_TEST_F( | 325 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 334 LayerTreeHostAnimationTestAddAnimationWithTimingFunction); | 326 LayerTreeHostAnimationTestAddAnimationWithTimingFunction); |
| 335 | 327 |
| 336 // Ensures that main thread animations have their start times synchronized with | 328 // Ensures that main thread animations have their start times synchronized with |
| 337 // impl thread animations. | 329 // impl thread animations. |
| 338 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes | 330 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes |
| 339 : public LayerTreeHostAnimationTest { | 331 : public LayerTreeHostAnimationTest { |
| 340 public: | 332 public: |
| 341 void SetupTree() override { | 333 void SetupTree() override { |
| 342 LayerTreeHostAnimationTest::SetupTree(); | 334 LayerTreeHostAnimationTest::SetupTree(); |
| 343 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 335 picture_ = FakePictureLayer::Create(&client_); |
| 344 picture_->SetBounds(gfx::Size(4, 4)); | 336 picture_->SetBounds(gfx::Size(4, 4)); |
| 345 client_.set_bounds(picture_->bounds()); | 337 client_.set_bounds(picture_->bounds()); |
| 346 | 338 |
| 347 layer_tree_host()->root_layer()->AddChild(picture_); | 339 layer_tree_host()->root_layer()->AddChild(picture_); |
| 348 | 340 |
| 349 AttachPlayersToTimeline(); | 341 AttachPlayersToTimeline(); |
| 350 player_child_->set_layer_animation_delegate(this); | 342 player_child_->set_layer_animation_delegate(this); |
| 351 player_child_->AttachLayer(picture_->id()); | 343 player_child_->AttachLayer(picture_->id()); |
| 352 } | 344 } |
| 353 | 345 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 418 |
| 427 // Ensures that when opacity is being animated, this value does not cause the | 419 // Ensures that when opacity is being animated, this value does not cause the |
| 428 // subtree to be skipped. | 420 // subtree to be skipped. |
| 429 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity | 421 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity |
| 430 : public LayerTreeHostAnimationTest { | 422 : public LayerTreeHostAnimationTest { |
| 431 public: | 423 public: |
| 432 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity() | 424 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity() |
| 433 : update_check_layer_() {} | 425 : update_check_layer_() {} |
| 434 | 426 |
| 435 void SetupTree() override { | 427 void SetupTree() override { |
| 436 update_check_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 428 update_check_layer_ = FakePictureLayer::Create(&client_); |
| 437 update_check_layer_->SetOpacity(0.f); | 429 update_check_layer_->SetOpacity(0.f); |
| 438 layer_tree_host()->SetRootLayer(update_check_layer_); | 430 layer_tree_host()->SetRootLayer(update_check_layer_); |
| 439 client_.set_bounds(update_check_layer_->bounds()); | 431 client_.set_bounds(update_check_layer_->bounds()); |
| 440 LayerTreeHostAnimationTest::SetupTree(); | 432 LayerTreeHostAnimationTest::SetupTree(); |
| 441 | 433 |
| 442 AttachPlayersToTimeline(); | 434 AttachPlayersToTimeline(); |
| 443 player_->AttachLayer(update_check_layer_->id()); | 435 player_->AttachLayer(update_check_layer_->id()); |
| 444 } | 436 } |
| 445 | 437 |
| 446 void BeginTest() override { | 438 void BeginTest() override { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 // animation correctly recognized. | 474 // animation correctly recognized. |
| 483 class LayerTreeHostAnimationTestLayerAddedWithAnimation | 475 class LayerTreeHostAnimationTestLayerAddedWithAnimation |
| 484 : public LayerTreeHostAnimationTest { | 476 : public LayerTreeHostAnimationTest { |
| 485 public: | 477 public: |
| 486 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 478 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 487 | 479 |
| 488 void DidCommit() override { | 480 void DidCommit() override { |
| 489 if (layer_tree_host()->source_frame_number() == 1) { | 481 if (layer_tree_host()->source_frame_number() == 1) { |
| 490 AttachPlayersToTimeline(); | 482 AttachPlayersToTimeline(); |
| 491 | 483 |
| 492 scoped_refptr<Layer> layer = Layer::Create(layer_settings()); | 484 scoped_refptr<Layer> layer = Layer::Create(); |
| 493 player_->AttachLayer(layer->id()); | 485 player_->AttachLayer(layer->id()); |
| 494 player_->set_layer_animation_delegate(this); | 486 player_->set_layer_animation_delegate(this); |
| 495 | 487 |
| 496 // Any valid AnimationCurve will do here. | 488 // Any valid AnimationCurve will do here. |
| 497 scoped_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); | 489 scoped_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); |
| 498 scoped_ptr<Animation> animation( | 490 scoped_ptr<Animation> animation( |
| 499 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY)); | 491 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY)); |
| 500 player_->AddAnimation(std::move(animation)); | 492 player_->AddAnimation(std::move(animation)); |
| 501 | 493 |
| 502 // We add the animation *before* attaching the layer to the tree. | 494 // We add the animation *before* attaching the layer to the tree. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 }; | 620 }; |
| 629 | 621 |
| 630 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimateAfterSetNeedsCommit); | 622 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimateAfterSetNeedsCommit); |
| 631 | 623 |
| 632 // Animations should not be started when frames are being skipped due to | 624 // Animations should not be started when frames are being skipped due to |
| 633 // checkerboard. | 625 // checkerboard. |
| 634 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations | 626 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations |
| 635 : public LayerTreeHostAnimationTest { | 627 : public LayerTreeHostAnimationTest { |
| 636 void SetupTree() override { | 628 void SetupTree() override { |
| 637 LayerTreeHostAnimationTest::SetupTree(); | 629 LayerTreeHostAnimationTest::SetupTree(); |
| 638 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 630 picture_ = FakePictureLayer::Create(&client_); |
| 639 picture_->SetBounds(gfx::Size(4, 4)); | 631 picture_->SetBounds(gfx::Size(4, 4)); |
| 640 client_.set_bounds(picture_->bounds()); | 632 client_.set_bounds(picture_->bounds()); |
| 641 layer_tree_host()->root_layer()->AddChild(picture_); | 633 layer_tree_host()->root_layer()->AddChild(picture_); |
| 642 | 634 |
| 643 AttachPlayersToTimeline(); | 635 AttachPlayersToTimeline(); |
| 644 player_child_->AttachLayer(picture_->id()); | 636 player_child_->AttachLayer(picture_->id()); |
| 645 player_child_->set_layer_animation_delegate(this); | 637 player_child_->set_layer_animation_delegate(this); |
| 646 } | 638 } |
| 647 | 639 |
| 648 void InitializeSettings(LayerTreeSettings* settings) override { | 640 void InitializeSettings(LayerTreeSettings* settings) override { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 | 707 |
| 716 // Verifies that scroll offset animations are only accepted when impl-scrolling | 708 // Verifies that scroll offset animations are only accepted when impl-scrolling |
| 717 // is supported, and that when scroll offset animations are accepted, | 709 // is supported, and that when scroll offset animations are accepted, |
| 718 // scroll offset updates are sent back to the main thread. | 710 // scroll offset updates are sent back to the main thread. |
| 719 class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated | 711 class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated |
| 720 : public LayerTreeHostAnimationTest { | 712 : public LayerTreeHostAnimationTest { |
| 721 public: | 713 public: |
| 722 void SetupTree() override { | 714 void SetupTree() override { |
| 723 LayerTreeHostAnimationTest::SetupTree(); | 715 LayerTreeHostAnimationTest::SetupTree(); |
| 724 | 716 |
| 725 scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 717 scroll_layer_ = FakePictureLayer::Create(&client_); |
| 726 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); | 718 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); |
| 727 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); | 719 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); |
| 728 client_.set_bounds(scroll_layer_->bounds()); | 720 client_.set_bounds(scroll_layer_->bounds()); |
| 729 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 721 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 730 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 722 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 731 | 723 |
| 732 AttachPlayersToTimeline(); | 724 AttachPlayersToTimeline(); |
| 733 player_child_->AttachLayer(scroll_layer_->id()); | 725 player_child_->AttachLayer(scroll_layer_->id()); |
| 734 } | 726 } |
| 735 | 727 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 // delta. | 768 // delta. |
| 777 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval | 769 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval |
| 778 : public LayerTreeHostAnimationTest { | 770 : public LayerTreeHostAnimationTest { |
| 779 public: | 771 public: |
| 780 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval() | 772 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval() |
| 781 : final_postion_(50.0, 100.0) {} | 773 : final_postion_(50.0, 100.0) {} |
| 782 | 774 |
| 783 void SetupTree() override { | 775 void SetupTree() override { |
| 784 LayerTreeHostAnimationTest::SetupTree(); | 776 LayerTreeHostAnimationTest::SetupTree(); |
| 785 | 777 |
| 786 scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 778 scroll_layer_ = FakePictureLayer::Create(&client_); |
| 787 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); | 779 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); |
| 788 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); | 780 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); |
| 789 client_.set_bounds(scroll_layer_->bounds()); | 781 client_.set_bounds(scroll_layer_->bounds()); |
| 790 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0)); | 782 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0)); |
| 791 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 783 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 792 | 784 |
| 793 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 785 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 794 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f), | 786 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f), |
| 795 EaseInOutTimingFunction::Create())); | 787 EaseInOutTimingFunction::Create())); |
| 796 scoped_ptr<Animation> animation(Animation::Create( | 788 scoped_ptr<Animation> animation(Animation::Create( |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 PostSetNeedsCommitToMainThread(); | 896 PostSetNeedsCommitToMainThread(); |
| 905 } | 897 } |
| 906 | 898 |
| 907 void DidCommit() override { | 899 void DidCommit() override { |
| 908 if (layer_tree_host()->source_frame_number() == 1) { | 900 if (layer_tree_host()->source_frame_number() == 1) { |
| 909 player_->AttachLayer(layer_tree_host()->root_layer()->id()); | 901 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
| 910 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); | 902 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); |
| 911 } else if (layer_tree_host()->source_frame_number() == 2) { | 903 } else if (layer_tree_host()->source_frame_number() == 2) { |
| 912 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); | 904 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); |
| 913 | 905 |
| 914 scoped_refptr<Layer> layer = Layer::Create(layer_settings()); | 906 scoped_refptr<Layer> layer = Layer::Create(); |
| 915 layer_tree_host()->root_layer()->AddChild(layer); | 907 layer_tree_host()->root_layer()->AddChild(layer); |
| 916 layer->SetBounds(gfx::Size(4, 4)); | 908 layer->SetBounds(gfx::Size(4, 4)); |
| 917 | 909 |
| 918 player_child_->AttachLayer(layer->id()); | 910 player_child_->AttachLayer(layer->id()); |
| 919 player_child_->set_layer_animation_delegate(this); | 911 player_child_->set_layer_animation_delegate(this); |
| 920 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); | 912 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); |
| 921 } | 913 } |
| 922 } | 914 } |
| 923 | 915 |
| 924 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | 916 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 // This test blocks activation which is not supported for single thread mode. | 980 // This test blocks activation which is not supported for single thread mode. |
| 989 MULTI_THREAD_BLOCKNOTIFY_TEST_F( | 981 MULTI_THREAD_BLOCKNOTIFY_TEST_F( |
| 990 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers); | 982 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers); |
| 991 | 983 |
| 992 class LayerTreeHostAnimationTestPendingTreeAnimatesFirstCommit | 984 class LayerTreeHostAnimationTestPendingTreeAnimatesFirstCommit |
| 993 : public LayerTreeHostAnimationTest { | 985 : public LayerTreeHostAnimationTest { |
| 994 public: | 986 public: |
| 995 void SetupTree() override { | 987 void SetupTree() override { |
| 996 LayerTreeHostAnimationTest::SetupTree(); | 988 LayerTreeHostAnimationTest::SetupTree(); |
| 997 | 989 |
| 998 layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 990 layer_ = FakePictureLayer::Create(&client_); |
| 999 layer_->SetBounds(gfx::Size(2, 2)); | 991 layer_->SetBounds(gfx::Size(2, 2)); |
| 1000 client_.set_bounds(layer_->bounds()); | 992 client_.set_bounds(layer_->bounds()); |
| 1001 // Transform the layer to 4,4 to start. | 993 // Transform the layer to 4,4 to start. |
| 1002 gfx::Transform start_transform; | 994 gfx::Transform start_transform; |
| 1003 start_transform.Translate(4.0, 4.0); | 995 start_transform.Translate(4.0, 4.0); |
| 1004 layer_->SetTransform(start_transform); | 996 layer_->SetTransform(start_transform); |
| 1005 | 997 |
| 1006 layer_tree_host()->root_layer()->AddChild(layer_); | 998 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1007 player_->AttachLayer(layer_->id()); | 999 player_->AttachLayer(layer_->id()); |
| 1008 | 1000 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 SINGLE_AND_MULTI_THREAD_TEST_F( | 1058 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1067 LayerTreeHostAnimationTestPendingTreeAnimatesFirstCommit); | 1059 LayerTreeHostAnimationTestPendingTreeAnimatesFirstCommit); |
| 1068 | 1060 |
| 1069 // When a layer with an animation is removed from the tree and later re-added, | 1061 // When a layer with an animation is removed from the tree and later re-added, |
| 1070 // the animation should resume. | 1062 // the animation should resume. |
| 1071 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded | 1063 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded |
| 1072 : public LayerTreeHostAnimationTest { | 1064 : public LayerTreeHostAnimationTest { |
| 1073 public: | 1065 public: |
| 1074 void SetupTree() override { | 1066 void SetupTree() override { |
| 1075 LayerTreeHostAnimationTest::SetupTree(); | 1067 LayerTreeHostAnimationTest::SetupTree(); |
| 1076 layer_ = Layer::Create(layer_settings()); | 1068 layer_ = Layer::Create(); |
| 1077 layer_->SetBounds(gfx::Size(4, 4)); | 1069 layer_->SetBounds(gfx::Size(4, 4)); |
| 1078 layer_tree_host()->root_layer()->AddChild(layer_); | 1070 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1079 | 1071 |
| 1080 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); | 1072 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); |
| 1081 timeline_->AttachPlayer(player_.get()); | 1073 timeline_->AttachPlayer(player_.get()); |
| 1082 player_->AttachLayer(layer_->id()); | 1074 player_->AttachLayer(layer_->id()); |
| 1083 DCHECK(player_->element_animations()); | 1075 DCHECK(player_->element_animations()); |
| 1084 | 1076 |
| 1085 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); | 1077 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); |
| 1086 } | 1078 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 }; | 1155 }; |
| 1164 | 1156 |
| 1165 SINGLE_AND_MULTI_THREAD_TEST_F( | 1157 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1166 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded); | 1158 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded); |
| 1167 | 1159 |
| 1168 class LayerTreeHostAnimationTestAddAnimationAfterAnimating | 1160 class LayerTreeHostAnimationTestAddAnimationAfterAnimating |
| 1169 : public LayerTreeHostAnimationTest { | 1161 : public LayerTreeHostAnimationTest { |
| 1170 public: | 1162 public: |
| 1171 void SetupTree() override { | 1163 void SetupTree() override { |
| 1172 LayerTreeHostAnimationTest::SetupTree(); | 1164 LayerTreeHostAnimationTest::SetupTree(); |
| 1173 layer_ = Layer::Create(layer_settings()); | 1165 layer_ = Layer::Create(); |
| 1174 layer_->SetBounds(gfx::Size(4, 4)); | 1166 layer_->SetBounds(gfx::Size(4, 4)); |
| 1175 layer_tree_host()->root_layer()->AddChild(layer_); | 1167 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1176 | 1168 |
| 1177 AttachPlayersToTimeline(); | 1169 AttachPlayersToTimeline(); |
| 1178 | 1170 |
| 1179 player_->AttachLayer(layer_tree_host()->root_layer()->id()); | 1171 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
| 1180 player_child_->AttachLayer(layer_->id()); | 1172 player_child_->AttachLayer(layer_->id()); |
| 1181 } | 1173 } |
| 1182 | 1174 |
| 1183 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1175 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 }; | 1218 }; |
| 1227 | 1219 |
| 1228 SINGLE_AND_MULTI_THREAD_TEST_F( | 1220 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1229 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1221 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
| 1230 | 1222 |
| 1231 class LayerTreeHostAnimationTestRemoveAnimation | 1223 class LayerTreeHostAnimationTestRemoveAnimation |
| 1232 : public LayerTreeHostAnimationTest { | 1224 : public LayerTreeHostAnimationTest { |
| 1233 public: | 1225 public: |
| 1234 void SetupTree() override { | 1226 void SetupTree() override { |
| 1235 LayerTreeHostAnimationTest::SetupTree(); | 1227 LayerTreeHostAnimationTest::SetupTree(); |
| 1236 layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 1228 layer_ = FakePictureLayer::Create(&client_); |
| 1237 layer_->SetBounds(gfx::Size(4, 4)); | 1229 layer_->SetBounds(gfx::Size(4, 4)); |
| 1238 client_.set_bounds(layer_->bounds()); | 1230 client_.set_bounds(layer_->bounds()); |
| 1239 layer_tree_host()->root_layer()->AddChild(layer_); | 1231 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1240 | 1232 |
| 1241 AttachPlayersToTimeline(); | 1233 AttachPlayersToTimeline(); |
| 1242 | 1234 |
| 1243 player_->AttachLayer(layer_tree_host()->root_layer()->id()); | 1235 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
| 1244 player_child_->AttachLayer(layer_->id()); | 1236 player_child_->AttachLayer(layer_->id()); |
| 1245 } | 1237 } |
| 1246 | 1238 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1263 | 1255 |
| 1264 // Do something that causes property trees to get rebuilt. This is | 1256 // Do something that causes property trees to get rebuilt. This is |
| 1265 // intended to simulate the conditions that caused the bug whose fix | 1257 // intended to simulate the conditions that caused the bug whose fix |
| 1266 // this is testing (the test will pass without it but won't test what | 1258 // this is testing (the test will pass without it but won't test what |
| 1267 // we want it to). We were updating the wrong transform node at the end | 1259 // we want it to). We were updating the wrong transform node at the end |
| 1268 // of an animation (we were assuming the layer with the finished | 1260 // of an animation (we were assuming the layer with the finished |
| 1269 // animation still had its own transform node). But nodes can only get | 1261 // animation still had its own transform node). But nodes can only get |
| 1270 // added/deleted when something triggers a rebuild. Adding a layer | 1262 // added/deleted when something triggers a rebuild. Adding a layer |
| 1271 // triggers a rebuild, and since the layer that had an animation before | 1263 // triggers a rebuild, and since the layer that had an animation before |
| 1272 // no longer has one, it doesn't get a transform node in the rebuild. | 1264 // no longer has one, it doesn't get a transform node in the rebuild. |
| 1273 layer_->AddChild(Layer::Create(layer_settings())); | 1265 layer_->AddChild(Layer::Create()); |
| 1274 break; | 1266 break; |
| 1275 } | 1267 } |
| 1276 } | 1268 } |
| 1277 | 1269 |
| 1278 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 1270 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 1279 LayerImpl* root = host_impl->active_tree()->root_layer(); | 1271 LayerImpl* root = host_impl->active_tree()->root_layer(); |
| 1280 LayerImpl* child = root->children()[0].get(); | 1272 LayerImpl* child = root->children()[0].get(); |
| 1281 switch (host_impl->active_tree()->source_frame_number()) { | 1273 switch (host_impl->active_tree()->source_frame_number()) { |
| 1282 case 0: | 1274 case 0: |
| 1283 // No animation yet. | 1275 // No animation yet. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1308 FakeContentLayerClient client_; | 1300 FakeContentLayerClient client_; |
| 1309 }; | 1301 }; |
| 1310 | 1302 |
| 1311 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestRemoveAnimation); | 1303 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestRemoveAnimation); |
| 1312 | 1304 |
| 1313 class LayerTreeHostAnimationTestIsAnimating | 1305 class LayerTreeHostAnimationTestIsAnimating |
| 1314 : public LayerTreeHostAnimationTest { | 1306 : public LayerTreeHostAnimationTest { |
| 1315 public: | 1307 public: |
| 1316 void SetupTree() override { | 1308 void SetupTree() override { |
| 1317 LayerTreeHostAnimationTest::SetupTree(); | 1309 LayerTreeHostAnimationTest::SetupTree(); |
| 1318 layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 1310 layer_ = FakePictureLayer::Create(&client_); |
| 1319 layer_->SetBounds(gfx::Size(4, 4)); | 1311 layer_->SetBounds(gfx::Size(4, 4)); |
| 1320 client_.set_bounds(layer_->bounds()); | 1312 client_.set_bounds(layer_->bounds()); |
| 1321 layer_tree_host()->root_layer()->AddChild(layer_); | 1313 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1322 | 1314 |
| 1323 AttachPlayersToTimeline(); | 1315 AttachPlayersToTimeline(); |
| 1324 player_->AttachLayer(layer_->id()); | 1316 player_->AttachLayer(layer_->id()); |
| 1325 } | 1317 } |
| 1326 | 1318 |
| 1327 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1319 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1328 | 1320 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestIsAnimating); | 1385 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestIsAnimating); |
| 1394 | 1386 |
| 1395 class LayerTreeHostAnimationTestAnimationFinishesDuringCommit | 1387 class LayerTreeHostAnimationTestAnimationFinishesDuringCommit |
| 1396 : public LayerTreeHostAnimationTest { | 1388 : public LayerTreeHostAnimationTest { |
| 1397 public: | 1389 public: |
| 1398 LayerTreeHostAnimationTestAnimationFinishesDuringCommit() | 1390 LayerTreeHostAnimationTestAnimationFinishesDuringCommit() |
| 1399 : signalled_(false) {} | 1391 : signalled_(false) {} |
| 1400 | 1392 |
| 1401 void SetupTree() override { | 1393 void SetupTree() override { |
| 1402 LayerTreeHostAnimationTest::SetupTree(); | 1394 LayerTreeHostAnimationTest::SetupTree(); |
| 1403 layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 1395 layer_ = FakePictureLayer::Create(&client_); |
| 1404 layer_->SetBounds(gfx::Size(4, 4)); | 1396 layer_->SetBounds(gfx::Size(4, 4)); |
| 1405 client_.set_bounds(layer_->bounds()); | 1397 client_.set_bounds(layer_->bounds()); |
| 1406 layer_tree_host()->root_layer()->AddChild(layer_); | 1398 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1407 | 1399 |
| 1408 AttachPlayersToTimeline(); | 1400 AttachPlayersToTimeline(); |
| 1409 | 1401 |
| 1410 player_->AttachLayer(layer_tree_host()->root_layer()->id()); | 1402 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
| 1411 player_child_->AttachLayer(layer_->id()); | 1403 player_child_->AttachLayer(layer_->id()); |
| 1412 } | 1404 } |
| 1413 | 1405 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimationFinishesDuringCommit); | 1461 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimationFinishesDuringCommit); |
| 1470 | 1462 |
| 1471 class LayerTreeHostAnimationTestNotifyAnimationFinished | 1463 class LayerTreeHostAnimationTestNotifyAnimationFinished |
| 1472 : public LayerTreeHostAnimationTest { | 1464 : public LayerTreeHostAnimationTest { |
| 1473 public: | 1465 public: |
| 1474 LayerTreeHostAnimationTestNotifyAnimationFinished() | 1466 LayerTreeHostAnimationTestNotifyAnimationFinished() |
| 1475 : called_animation_started_(false), called_animation_finished_(false) {} | 1467 : called_animation_started_(false), called_animation_finished_(false) {} |
| 1476 | 1468 |
| 1477 void SetupTree() override { | 1469 void SetupTree() override { |
| 1478 LayerTreeHostAnimationTest::SetupTree(); | 1470 LayerTreeHostAnimationTest::SetupTree(); |
| 1479 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 1471 picture_ = FakePictureLayer::Create(&client_); |
| 1480 picture_->SetBounds(gfx::Size(4, 4)); | 1472 picture_->SetBounds(gfx::Size(4, 4)); |
| 1481 client_.set_bounds(picture_->bounds()); | 1473 client_.set_bounds(picture_->bounds()); |
| 1482 layer_tree_host()->root_layer()->AddChild(picture_); | 1474 layer_tree_host()->root_layer()->AddChild(picture_); |
| 1483 | 1475 |
| 1484 AttachPlayersToTimeline(); | 1476 AttachPlayersToTimeline(); |
| 1485 player_->AttachLayer(picture_->id()); | 1477 player_->AttachLayer(picture_->id()); |
| 1486 player_->set_layer_animation_delegate(this); | 1478 player_->set_layer_animation_delegate(this); |
| 1487 } | 1479 } |
| 1488 | 1480 |
| 1489 void BeginTest() override { | 1481 void BeginTest() override { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 | 1594 |
| 1603 MULTI_THREAD_TEST_F( | 1595 MULTI_THREAD_TEST_F( |
| 1604 LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction); | 1596 LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction); |
| 1605 | 1597 |
| 1606 // Check that we invalidate property trees on AnimationPlayer::SetNeedsCommit. | 1598 // Check that we invalidate property trees on AnimationPlayer::SetNeedsCommit. |
| 1607 class LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit | 1599 class LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit |
| 1608 : public LayerTreeHostAnimationTest { | 1600 : public LayerTreeHostAnimationTest { |
| 1609 public: | 1601 public: |
| 1610 void SetupTree() override { | 1602 void SetupTree() override { |
| 1611 LayerTreeHostAnimationTest::SetupTree(); | 1603 LayerTreeHostAnimationTest::SetupTree(); |
| 1612 layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 1604 layer_ = FakePictureLayer::Create(&client_); |
| 1613 layer_->SetBounds(gfx::Size(4, 4)); | 1605 layer_->SetBounds(gfx::Size(4, 4)); |
| 1614 client_.set_bounds(layer_->bounds()); | 1606 client_.set_bounds(layer_->bounds()); |
| 1615 layer_tree_host()->root_layer()->AddChild(layer_); | 1607 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1616 | 1608 |
| 1617 AttachPlayersToTimeline(); | 1609 AttachPlayersToTimeline(); |
| 1618 | 1610 |
| 1619 player_->AttachLayer(layer_tree_host()->root_layer()->id()); | 1611 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
| 1620 player_child_->AttachLayer(layer_->id()); | 1612 player_child_->AttachLayer(layer_->id()); |
| 1621 } | 1613 } |
| 1622 | 1614 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1647 private: | 1639 private: |
| 1648 scoped_refptr<Layer> layer_; | 1640 scoped_refptr<Layer> layer_; |
| 1649 FakeContentLayerClient client_; | 1641 FakeContentLayerClient client_; |
| 1650 }; | 1642 }; |
| 1651 | 1643 |
| 1652 MULTI_THREAD_TEST_F( | 1644 MULTI_THREAD_TEST_F( |
| 1653 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1645 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1654 | 1646 |
| 1655 } // namespace | 1647 } // namespace |
| 1656 } // namespace cc | 1648 } // namespace cc |
| OLD | NEW |