| 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 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 private: | 991 private: |
| 992 scoped_refptr<Layer> layer_; | 992 scoped_refptr<Layer> layer_; |
| 993 FakeContentLayerClient client_; | 993 FakeContentLayerClient client_; |
| 994 CompletionEvent completion_; | 994 CompletionEvent completion_; |
| 995 }; | 995 }; |
| 996 | 996 |
| 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 |
| 1002 // if we destroy LayerAnimationController and ElementAnimations. |
| 1003 class LayerTreeHostTimelinesTestSetPotentiallyAnimatingOnLacDestruction |
| 1004 : public LayerTreeHostTimelinesTest { |
| 1005 public: |
| 1006 void SetupTree() override { |
| 1007 LayerTreeHostTimelinesTest::SetupTree(); |
| 1008 AttachPlayersToTimeline(); |
| 1009 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
| 1010 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); |
| 1011 } |
| 1012 |
| 1013 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1014 |
| 1015 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 1016 if (host_impl->active_tree()->source_frame_number() == 2) { |
| 1017 EXPECT_TRUE(host_impl->active_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_TRUE(host_impl->active_tree() |
| 1023 ->root_layer() |
| 1024 ->screen_space_transform_is_animating()); |
| 1025 EXPECT_FALSE(host_impl->pending_tree() |
| 1026 ->root_layer() |
| 1027 ->screen_space_transform_is_animating()); |
| 1028 } |
| 1029 } |
| 1030 |
| 1031 void WillCommit() override {} |
| 1032 |
| 1033 void DidCommit() override { PostSetNeedsCommitToMainThread(); } |
| 1034 |
| 1035 void Layout() override { |
| 1036 if (layer_tree_host()->source_frame_number() == 2) { |
| 1037 // Destroy player. |
| 1038 timeline_->DetachPlayer(player_.get()); |
| 1039 player_ = nullptr; |
| 1040 } |
| 1041 } |
| 1042 |
| 1043 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 1044 if (host_impl->active_tree()->source_frame_number() >= 2) |
| 1045 EndTest(); |
| 1046 } |
| 1047 |
| 1048 void AfterTest() override {} |
| 1049 }; |
| 1050 |
| 1051 MULTI_THREAD_TEST_F( |
| 1052 LayerTreeHostTimelinesTestSetPotentiallyAnimatingOnLacDestruction); |
| 1053 |
| 1054 // Check that we invalidate property trees on AnimationPlayer::SetNeedsCommit. |
| 1055 class LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit |
| 1056 : public LayerTreeHostTimelinesTest { |
| 1057 public: |
| 1058 void SetupTree() override { |
| 1059 LayerTreeHostTimelinesTest::SetupTree(); |
| 1060 layer_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 1061 layer_->SetBounds(gfx::Size(4, 4)); |
| 1062 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1063 |
| 1064 AttachPlayersToTimeline(); |
| 1065 |
| 1066 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
| 1067 player_child_->AttachLayer(layer_->id()); |
| 1068 } |
| 1069 |
| 1070 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1071 |
| 1072 void DidCommit() override { |
| 1073 if (layer_tree_host()->source_frame_number() == 1 || |
| 1074 layer_tree_host()->source_frame_number() == 2) |
| 1075 PostSetNeedsCommitToMainThread(); |
| 1076 } |
| 1077 |
| 1078 void Layout() override { |
| 1079 if (layer_tree_host()->source_frame_number() == 1) { |
| 1080 EXPECT_FALSE(layer_tree_host()->property_trees()->needs_rebuild); |
| 1081 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); |
| 1082 } |
| 1083 |
| 1084 EXPECT_TRUE(layer_tree_host()->property_trees()->needs_rebuild); |
| 1085 } |
| 1086 |
| 1087 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 1088 if (host_impl->active_tree()->source_frame_number() >= 2) |
| 1089 EndTest(); |
| 1090 } |
| 1091 |
| 1092 void AfterTest() override {} |
| 1093 |
| 1094 private: |
| 1095 scoped_refptr<Layer> layer_; |
| 1096 FakeContentLayerClient client_; |
| 1097 }; |
| 1098 |
| 1099 MULTI_THREAD_TEST_F( |
| 1100 LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1101 |
| 1001 } // namespace | 1102 } // namespace |
| 1002 } // namespace cc | 1103 } // namespace cc |
| OLD | NEW |