Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 1877073006: CC Animation: Make AnimationRegistrar a private member of AnimationHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | ui/compositor/layer_animator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "cc/animation/animation_id_provider.h" 11 #include "cc/animation/animation_id_provider.h"
12 #include "cc/animation/animation_player.h" 12 #include "cc/animation/animation_player.h"
13 #include "cc/animation/animation_registrar.h"
14 #include "cc/animation/animation_timeline.h" 13 #include "cc/animation/animation_timeline.h"
15 #include "cc/animation/element_animations.h" 14 #include "cc/animation/element_animations.h"
16 #include "cc/animation/layer_animation_controller.h" 15 #include "cc/animation/layer_animation_controller.h"
17 #include "cc/animation/scroll_offset_animation_curve.h" 16 #include "cc/animation/scroll_offset_animation_curve.h"
18 #include "cc/animation/timing_function.h" 17 #include "cc/animation/timing_function.h"
19 #include "cc/animation/transform_operations.h" 18 #include "cc/animation/transform_operations.h"
20 #include "cc/base/completion_event.h" 19 #include "cc/base/completion_event.h"
21 #include "cc/base/time_util.h" 20 #include "cc/base/time_util.h"
22 #include "cc/layers/layer.h" 21 #include "cc/layers/layer.h"
23 #include "cc/layers/layer_impl.h" 22 #include "cc/layers/layer_impl.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 225
227 void BeginTest() override { 226 void BeginTest() override {
228 AttachPlayersToTimeline(); 227 AttachPlayersToTimeline();
229 player_->AttachLayer(layer_tree_host()->root_layer()->id()); 228 player_->AttachLayer(layer_tree_host()->root_layer()->id());
230 PostAddAnimationToMainThreadPlayer(player_.get()); 229 PostAddAnimationToMainThreadPlayer(player_.get());
231 } 230 }
232 231
233 void AnimateLayers(LayerTreeHostImpl* host_impl, 232 void AnimateLayers(LayerTreeHostImpl* host_impl,
234 base::TimeTicks monotonic_time) override { 233 base::TimeTicks monotonic_time) override {
235 bool have_animations = !host_impl->animation_host() 234 bool have_animations = !host_impl->animation_host()
236 ->animation_registrar()
237 ->active_animation_controllers_for_testing() 235 ->active_animation_controllers_for_testing()
238 .empty(); 236 .empty();
239 if (!started_animating_ && have_animations) { 237 if (!started_animating_ && have_animations) {
240 started_animating_ = true; 238 started_animating_ = true;
241 return; 239 return;
242 } 240 }
243 241
244 if (started_animating_ && !have_animations) 242 if (started_animating_ && !have_animations)
245 EndTest(); 243 EndTest();
246 } 244 }
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 1077
1080 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1078 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1081 1079
1082 void DidCommit() override { 1080 void DidCommit() override {
1083 switch (layer_tree_host()->source_frame_number()) { 1081 switch (layer_tree_host()->source_frame_number()) {
1084 case 0: 1082 case 0:
1085 EXPECT_TRUE(player_->element_animations() 1083 EXPECT_TRUE(player_->element_animations()
1086 ->has_active_value_observer_for_testing()); 1084 ->has_active_value_observer_for_testing());
1087 EXPECT_FALSE(player_->element_animations() 1085 EXPECT_FALSE(player_->element_animations()
1088 ->has_pending_value_observer_for_testing()); 1086 ->has_pending_value_observer_for_testing());
1089 EXPECT_TRUE(layer_tree_host() 1087 EXPECT_TRUE(layer_tree_host()->animation_host()->NeedsAnimateLayers());
1090 ->animation_host()
1091 ->animation_registrar()
1092 ->needs_animate_layers());
1093 break; 1088 break;
1094 case 1: 1089 case 1:
1095 layer_->RemoveFromParent(); 1090 layer_->RemoveFromParent();
1096 EXPECT_FALSE(player_->element_animations() 1091 EXPECT_FALSE(player_->element_animations()
1097 ->has_active_value_observer_for_testing()); 1092 ->has_active_value_observer_for_testing());
1098 EXPECT_FALSE(player_->element_animations() 1093 EXPECT_FALSE(player_->element_animations()
1099 ->has_pending_value_observer_for_testing()); 1094 ->has_pending_value_observer_for_testing());
1100 EXPECT_TRUE(layer_tree_host() 1095 EXPECT_TRUE(layer_tree_host()->animation_host()->NeedsAnimateLayers());
1101 ->animation_host()
1102 ->animation_registrar()
1103 ->needs_animate_layers());
1104 break; 1096 break;
1105 case 2: 1097 case 2:
1106 layer_tree_host()->root_layer()->AddChild(layer_); 1098 layer_tree_host()->root_layer()->AddChild(layer_);
1107 EXPECT_TRUE(player_->element_animations() 1099 EXPECT_TRUE(player_->element_animations()
1108 ->has_active_value_observer_for_testing()); 1100 ->has_active_value_observer_for_testing());
1109 EXPECT_FALSE(player_->element_animations() 1101 EXPECT_FALSE(player_->element_animations()
1110 ->has_pending_value_observer_for_testing()); 1102 ->has_pending_value_observer_for_testing());
1111 EXPECT_TRUE(layer_tree_host() 1103 EXPECT_TRUE(layer_tree_host()->animation_host()->NeedsAnimateLayers());
1112 ->animation_host()
1113 ->animation_registrar()
1114 ->needs_animate_layers());
1115 break; 1104 break;
1116 } 1105 }
1117 } 1106 }
1118 1107
1119 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1108 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1120 scoped_refptr<AnimationTimeline> timeline_impl = 1109 scoped_refptr<AnimationTimeline> timeline_impl =
1121 host_impl->animation_host()->GetTimelineById(timeline_id_); 1110 host_impl->animation_host()->GetTimelineById(timeline_id_);
1122 scoped_refptr<AnimationPlayer> player_impl = 1111 scoped_refptr<AnimationPlayer> player_impl =
1123 timeline_impl->GetPlayerById(player_id_); 1112 timeline_impl->GetPlayerById(player_id_);
1124 1113
1125 switch (host_impl->active_tree()->source_frame_number()) { 1114 switch (host_impl->active_tree()->source_frame_number()) {
1126 case 0: 1115 case 0:
1127 EXPECT_TRUE(player_impl->element_animations() 1116 EXPECT_TRUE(player_impl->element_animations()
1128 ->has_active_value_observer_for_testing()); 1117 ->has_active_value_observer_for_testing());
1129 EXPECT_TRUE(host_impl->animation_host() 1118 EXPECT_TRUE(host_impl->animation_host()->NeedsAnimateLayers());
1130 ->animation_registrar()
1131 ->needs_animate_layers());
1132 break; 1119 break;
1133 case 1: 1120 case 1:
1134 EXPECT_FALSE(player_impl->element_animations() 1121 EXPECT_FALSE(player_impl->element_animations()
1135 ->has_active_value_observer_for_testing()); 1122 ->has_active_value_observer_for_testing());
1136 EXPECT_TRUE(host_impl->animation_host() 1123 EXPECT_TRUE(host_impl->animation_host()->NeedsAnimateLayers());
1137 ->animation_registrar()
1138 ->needs_animate_layers());
1139 break; 1124 break;
1140 case 2: 1125 case 2:
1141 EXPECT_TRUE(player_impl->element_animations() 1126 EXPECT_TRUE(player_impl->element_animations()
1142 ->has_active_value_observer_for_testing()); 1127 ->has_active_value_observer_for_testing());
1143 EXPECT_TRUE(host_impl->animation_host() 1128 EXPECT_TRUE(host_impl->animation_host()->NeedsAnimateLayers());
1144 ->animation_registrar()
1145 ->needs_animate_layers());
1146 EndTest(); 1129 EndTest();
1147 break; 1130 break;
1148 } 1131 }
1149 } 1132 }
1150 1133
1151 void AfterTest() override {} 1134 void AfterTest() override {}
1152 1135
1153 private: 1136 private:
1154 scoped_refptr<Layer> layer_; 1137 scoped_refptr<Layer> layer_;
1155 }; 1138 };
(...skipping 30 matching lines...) Expand all
1186 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false); 1169 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false);
1187 break; 1170 break;
1188 } 1171 }
1189 } 1172 }
1190 1173
1191 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { 1174 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
1192 // After both animations have started, verify that they have valid 1175 // After both animations have started, verify that they have valid
1193 // start times. 1176 // start times.
1194 if (host_impl->active_tree()->source_frame_number() < 2) 1177 if (host_impl->active_tree()->source_frame_number() < 2)
1195 return; 1178 return;
1196 AnimationRegistrar::AnimationControllerMap controllers_copy = 1179 AnimationHost::AnimationControllerMap controllers_copy =
1197 host_impl->animation_host() 1180 host_impl->animation_host()->active_animation_controllers_for_testing();
1198 ->animation_registrar()
1199 ->active_animation_controllers_for_testing();
1200 EXPECT_EQ(2u, controllers_copy.size()); 1181 EXPECT_EQ(2u, controllers_copy.size());
1201 for (auto& it : controllers_copy) { 1182 for (auto& it : controllers_copy) {
1202 int id = it.first; 1183 int id = it.first;
1203 if (id == host_impl->RootLayer()->id()) { 1184 if (id == host_impl->RootLayer()->id()) {
1204 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM); 1185 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM);
1205 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); 1186 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1206 } else if (id == host_impl->RootLayer()->children()[0]->id()) { 1187 } else if (id == host_impl->RootLayer()->children()[0]->id()) {
1207 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY); 1188 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY);
1208 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); 1189 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1209 } 1190 }
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 private: 1620 private:
1640 scoped_refptr<Layer> layer_; 1621 scoped_refptr<Layer> layer_;
1641 FakeContentLayerClient client_; 1622 FakeContentLayerClient client_;
1642 }; 1623 };
1643 1624
1644 MULTI_THREAD_TEST_F( 1625 MULTI_THREAD_TEST_F(
1645 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); 1626 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit);
1646 1627
1647 } // namespace 1628 } // namespace
1648 } // namespace cc 1629 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | ui/compositor/layer_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698