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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 // An animation finishing during commit can only happen when we have a separate | 997 // An animation finishing during commit can only happen when we have a separate |
998 // compositor thread. | 998 // compositor thread. |
999 MULTI_THREAD_TEST_F(LayerTreeHostTimelinesTestAnimationFinishesDuringCommit); | 999 MULTI_THREAD_TEST_F(LayerTreeHostTimelinesTestAnimationFinishesDuringCommit); |
1000 | 1000 |
1001 // Check that SetTransformIsPotentiallyAnimatingChanged is called | 1001 // Check that SetTransformIsPotentiallyAnimatingChanged is called |
1002 // if we destroy LayerAnimationController and ElementAnimations. | 1002 // if we destroy LayerAnimationController and ElementAnimations. |
1003 class LayerTreeHostTimelinesTestSetPotentiallyAnimatingOnLacDestruction | 1003 class LayerTreeHostTimelinesTestSetPotentiallyAnimatingOnLacDestruction |
1004 : public LayerTreeHostTimelinesTest { | 1004 : public LayerTreeHostTimelinesTest { |
1005 public: | 1005 public: |
1006 void SetupTree() override { | 1006 void SetupTree() override { |
| 1007 prev_screen_space_transform_is_animating_ = true; |
| 1008 screen_space_transform_animation_stopped_ = false; |
| 1009 |
1007 LayerTreeHostTimelinesTest::SetupTree(); | 1010 LayerTreeHostTimelinesTest::SetupTree(); |
1008 AttachPlayersToTimeline(); | 1011 AttachPlayersToTimeline(); |
1009 player_->AttachLayer(layer_tree_host()->root_layer()->id()); | 1012 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
1010 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); | 1013 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); |
1011 } | 1014 } |
1012 | 1015 |
1013 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1016 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1014 | 1017 |
1015 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1018 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
1016 if (host_impl->active_tree()->source_frame_number() == 1) { | 1019 if (host_impl->pending_tree()->source_frame_number() <= 1) { |
1017 EXPECT_TRUE(host_impl->active_tree()); | 1020 EXPECT_TRUE(host_impl->pending_tree() |
1018 EXPECT_TRUE(host_impl->active_tree()->root_layer()); | |
1019 EXPECT_TRUE(host_impl->pending_tree()); | |
1020 EXPECT_TRUE(host_impl->pending_tree()->root_layer()); | |
1021 | |
1022 EXPECT_EQ(2, host_impl->pending_tree()->source_frame_number()); | |
1023 | |
1024 EXPECT_TRUE(host_impl->active_tree() | |
1025 ->root_layer() | 1021 ->root_layer() |
1026 ->screen_space_transform_is_animating()); | 1022 ->screen_space_transform_is_animating()); |
| 1023 } else { |
1027 EXPECT_FALSE(host_impl->pending_tree() | 1024 EXPECT_FALSE(host_impl->pending_tree() |
1028 ->root_layer() | 1025 ->root_layer() |
1029 ->screen_space_transform_is_animating()); | 1026 ->screen_space_transform_is_animating()); |
1030 } else if (host_impl->active_tree()->source_frame_number() == 2) { | |
1031 EXPECT_FALSE(host_impl->active_tree() | |
1032 ->root_layer() | |
1033 ->screen_space_transform_is_animating()); | |
1034 EXPECT_FALSE(host_impl->pending_tree() | |
1035 ->root_layer() | |
1036 ->screen_space_transform_is_animating()); | |
1037 } | 1027 } |
1038 } | 1028 } |
1039 | 1029 |
1040 void DidCommit() override { PostSetNeedsCommitToMainThread(); } | 1030 void DidCommit() override { PostSetNeedsCommitToMainThread(); } |
1041 | 1031 |
1042 void UpdateLayerTreeHost() override { | 1032 void UpdateLayerTreeHost() override { |
1043 if (layer_tree_host()->source_frame_number() == 2) { | 1033 if (layer_tree_host()->source_frame_number() == 2) { |
1044 // Destroy player. | 1034 // Destroy player. |
1045 timeline_->DetachPlayer(player_.get()); | 1035 timeline_->DetachPlayer(player_.get()); |
1046 player_ = nullptr; | 1036 player_ = nullptr; |
1047 } | 1037 } |
1048 } | 1038 } |
1049 | 1039 |
| 1040 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 1041 LayerTreeHostImpl::FrameData* frame_data, |
| 1042 DrawResult draw_result) override { |
| 1043 const bool screen_space_transform_is_animating = |
| 1044 host_impl->active_tree() |
| 1045 ->root_layer() |
| 1046 ->screen_space_transform_is_animating(); |
| 1047 |
| 1048 // Check that screen_space_transform_is_animating changes only once. |
| 1049 if (screen_space_transform_is_animating && |
| 1050 prev_screen_space_transform_is_animating_) |
| 1051 EXPECT_FALSE(screen_space_transform_animation_stopped_); |
| 1052 if (!screen_space_transform_is_animating && |
| 1053 prev_screen_space_transform_is_animating_) { |
| 1054 EXPECT_FALSE(screen_space_transform_animation_stopped_); |
| 1055 screen_space_transform_animation_stopped_ = true; |
| 1056 } |
| 1057 if (!screen_space_transform_is_animating && |
| 1058 !prev_screen_space_transform_is_animating_) |
| 1059 EXPECT_TRUE(screen_space_transform_animation_stopped_); |
| 1060 |
| 1061 prev_screen_space_transform_is_animating_ = |
| 1062 screen_space_transform_is_animating; |
| 1063 |
| 1064 return draw_result; |
| 1065 } |
| 1066 |
1050 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 1067 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
1051 if (host_impl->active_tree()->source_frame_number() >= 2) | 1068 if (host_impl->active_tree()->source_frame_number() >= 2) |
1052 EndTest(); | 1069 EndTest(); |
1053 } | 1070 } |
1054 | 1071 |
1055 void AfterTest() override {} | 1072 void AfterTest() override { |
| 1073 EXPECT_TRUE(screen_space_transform_animation_stopped_); |
| 1074 } |
| 1075 |
| 1076 bool prev_screen_space_transform_is_animating_; |
| 1077 bool screen_space_transform_animation_stopped_; |
1056 }; | 1078 }; |
1057 | 1079 |
1058 MULTI_THREAD_TEST_F( | 1080 MULTI_THREAD_TEST_F( |
1059 LayerTreeHostTimelinesTestSetPotentiallyAnimatingOnLacDestruction); | 1081 LayerTreeHostTimelinesTestSetPotentiallyAnimatingOnLacDestruction); |
1060 | 1082 |
1061 // Check that we invalidate property trees on AnimationPlayer::SetNeedsCommit. | 1083 // Check that we invalidate property trees on AnimationPlayer::SetNeedsCommit. |
1062 class LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit | 1084 class LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit |
1063 : public LayerTreeHostTimelinesTest { | 1085 : public LayerTreeHostTimelinesTest { |
1064 public: | 1086 public: |
1065 void SetupTree() override { | 1087 void SetupTree() override { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 private: | 1123 private: |
1102 scoped_refptr<Layer> layer_; | 1124 scoped_refptr<Layer> layer_; |
1103 FakeContentLayerClient client_; | 1125 FakeContentLayerClient client_; |
1104 }; | 1126 }; |
1105 | 1127 |
1106 MULTI_THREAD_TEST_F( | 1128 MULTI_THREAD_TEST_F( |
1107 LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1129 LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
1108 | 1130 |
1109 } // namespace | 1131 } // namespace |
1110 } // namespace cc | 1132 } // namespace cc |
OLD | NEW |