| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 host_impl->BlockNotifyReadyToActivateForTesting(false); | 651 host_impl->BlockNotifyReadyToActivateForTesting(false); |
| 652 return; | 652 return; |
| 653 } | 653 } |
| 654 | 654 |
| 655 scoped_refptr<AnimationTimeline> timeline_impl = | 655 scoped_refptr<AnimationTimeline> timeline_impl = |
| 656 host_impl->animation_host()->GetTimelineById(timeline_id_); | 656 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 657 scoped_refptr<AnimationPlayer> player_impl = | 657 scoped_refptr<AnimationPlayer> player_impl = |
| 658 timeline_impl->GetPlayerById(player_child_id_); | 658 timeline_impl->GetPlayerById(player_child_id_); |
| 659 | 659 |
| 660 LayerImpl* scroll_layer_impl = | 660 LayerImpl* scroll_layer_impl = |
| 661 host_impl->active_tree()->root_layer()->children()[0]; | 661 host_impl->active_tree()->root_layer()->children()[0].get(); |
| 662 Animation* animation = player_impl->element_animations() | 662 Animation* animation = player_impl->element_animations() |
| 663 ->layer_animation_controller() | 663 ->layer_animation_controller() |
| 664 ->GetAnimation(Animation::SCROLL_OFFSET); | 664 ->GetAnimation(Animation::SCROLL_OFFSET); |
| 665 | 665 |
| 666 if (!animation || animation->run_state() != Animation::RUNNING) { | 666 if (!animation || animation->run_state() != Animation::RUNNING) { |
| 667 host_impl->BlockNotifyReadyToActivateForTesting(false); | 667 host_impl->BlockNotifyReadyToActivateForTesting(false); |
| 668 return; | 668 return; |
| 669 } | 669 } |
| 670 | 670 |
| 671 // Block activation until the running animation has a chance to produce a | 671 // Block activation until the running animation has a chance to produce a |
| 672 // scroll delta. | 672 // scroll delta. |
| 673 gfx::Vector2dF scroll_delta = scroll_layer_impl->ScrollDelta(); | 673 gfx::Vector2dF scroll_delta = scroll_layer_impl->ScrollDelta(); |
| 674 if (scroll_delta.x() < 1.f || scroll_delta.y() < 1.f) | 674 if (scroll_delta.x() < 1.f || scroll_delta.y() < 1.f) |
| 675 return; | 675 return; |
| 676 | 676 |
| 677 host_impl->BlockNotifyReadyToActivateForTesting(false); | 677 host_impl->BlockNotifyReadyToActivateForTesting(false); |
| 678 } | 678 } |
| 679 | 679 |
| 680 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 680 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 681 if (host_impl->pending_tree()->source_frame_number() != 1) | 681 if (host_impl->pending_tree()->source_frame_number() != 1) |
| 682 return; | 682 return; |
| 683 LayerImpl* scroll_layer_impl = | 683 LayerImpl* scroll_layer_impl = |
| 684 host_impl->pending_tree()->root_layer()->children()[0]; | 684 host_impl->pending_tree()->root_layer()->children()[0].get(); |
| 685 EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset()); | 685 EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset()); |
| 686 } | 686 } |
| 687 | 687 |
| 688 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 688 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 689 if (host_impl->active_tree()->source_frame_number() != 1) | 689 if (host_impl->active_tree()->source_frame_number() != 1) |
| 690 return; | 690 return; |
| 691 LayerImpl* scroll_layer_impl = | 691 LayerImpl* scroll_layer_impl = |
| 692 host_impl->active_tree()->root_layer()->children()[0]; | 692 host_impl->active_tree()->root_layer()->children()[0].get(); |
| 693 EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset()); | 693 EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset()); |
| 694 EndTest(); | 694 EndTest(); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void AfterTest() override { | 697 void AfterTest() override { |
| 698 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset()); | 698 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset()); |
| 699 } | 699 } |
| 700 | 700 |
| 701 private: | 701 private: |
| 702 FakeContentLayerClient client_; | 702 FakeContentLayerClient client_; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 963 |
| 964 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 964 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 965 switch (host_impl->sync_tree()->source_frame_number()) { | 965 switch (host_impl->sync_tree()->source_frame_number()) { |
| 966 case 1: | 966 case 1: |
| 967 PostSetNeedsCommitToMainThread(); | 967 PostSetNeedsCommitToMainThread(); |
| 968 break; | 968 break; |
| 969 case 2: | 969 case 2: |
| 970 gfx::Transform expected_transform; | 970 gfx::Transform expected_transform; |
| 971 expected_transform.Translate(5.f, 5.f); | 971 expected_transform.Translate(5.f, 5.f); |
| 972 LayerImpl* layer_impl = | 972 LayerImpl* layer_impl = |
| 973 host_impl->sync_tree()->root_layer()->children()[0]; | 973 host_impl->sync_tree()->root_layer()->children()[0].get(); |
| 974 EXPECT_EQ(expected_transform, layer_impl->draw_transform()); | 974 EXPECT_EQ(expected_transform, layer_impl->draw_transform()); |
| 975 EndTest(); | 975 EndTest(); |
| 976 break; | 976 break; |
| 977 } | 977 } |
| 978 } | 978 } |
| 979 | 979 |
| 980 void UpdateAnimationState(LayerTreeHostImpl* host_impl, | 980 void UpdateAnimationState(LayerTreeHostImpl* host_impl, |
| 981 bool has_unfinished_animation) override { | 981 bool has_unfinished_animation) override { |
| 982 if (host_impl->active_tree()->source_frame_number() == 1 && | 982 if (host_impl->active_tree()->source_frame_number() == 1 && |
| 983 !has_unfinished_animation) { | 983 !has_unfinished_animation) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 private: | 1094 private: |
| 1095 scoped_refptr<Layer> layer_; | 1095 scoped_refptr<Layer> layer_; |
| 1096 FakeContentLayerClient client_; | 1096 FakeContentLayerClient client_; |
| 1097 }; | 1097 }; |
| 1098 | 1098 |
| 1099 MULTI_THREAD_TEST_F( | 1099 MULTI_THREAD_TEST_F( |
| 1100 LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1100 LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1101 | 1101 |
| 1102 } // namespace | 1102 } // namespace |
| 1103 } // namespace cc | 1103 } // namespace cc |
| OLD | NEW |