| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 void BeginTest() override { | 245 void BeginTest() override { |
| 246 AttachPlayersToTimeline(); | 246 AttachPlayersToTimeline(); |
| 247 player_->AttachElement(layer_tree()->root_layer()->element_id()); | 247 player_->AttachElement(layer_tree()->root_layer()->element_id()); |
| 248 PostAddAnimationToMainThreadPlayer(player_.get()); | 248 PostAddAnimationToMainThreadPlayer(player_.get()); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void AnimateLayers(LayerTreeHostImpl* host_impl, | 251 void AnimateLayers(LayerTreeHostImpl* host_impl, |
| 252 base::TimeTicks monotonic_time) override { | 252 base::TimeTicks monotonic_time) override { |
| 253 bool have_animations = | 253 bool have_animations = |
| 254 !GetImplAnimationHost(host_impl)->active_players_for_testing().empty(); | 254 !GetImplAnimationHost(host_impl)->ticking_players_for_testing().empty(); |
| 255 if (!started_animating_ && have_animations) { | 255 if (!started_animating_ && have_animations) { |
| 256 started_animating_ = true; | 256 started_animating_ = true; |
| 257 return; | 257 return; |
| 258 } | 258 } |
| 259 | 259 |
| 260 if (started_animating_ && !have_animations) | 260 if (started_animating_ && !have_animations) |
| 261 EndTest(); | 261 EndTest(); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 264 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 | 1252 |
| 1253 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1253 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1254 | 1254 |
| 1255 void DidCommit() override { | 1255 void DidCommit() override { |
| 1256 switch (layer_tree_host()->SourceFrameNumber()) { | 1256 switch (layer_tree_host()->SourceFrameNumber()) { |
| 1257 case 0: | 1257 case 0: |
| 1258 EXPECT_TRUE( | 1258 EXPECT_TRUE( |
| 1259 player_->element_animations()->has_element_in_active_list()); | 1259 player_->element_animations()->has_element_in_active_list()); |
| 1260 EXPECT_FALSE( | 1260 EXPECT_FALSE( |
| 1261 player_->element_animations()->has_element_in_pending_list()); | 1261 player_->element_animations()->has_element_in_pending_list()); |
| 1262 EXPECT_TRUE(animation_host()->NeedsAnimateLayers()); | 1262 EXPECT_TRUE(animation_host()->NeedsTickAnimations()); |
| 1263 break; | 1263 break; |
| 1264 case 1: | 1264 case 1: |
| 1265 layer_->RemoveFromParent(); | 1265 layer_->RemoveFromParent(); |
| 1266 EXPECT_FALSE( | 1266 EXPECT_FALSE( |
| 1267 player_->element_animations()->has_element_in_active_list()); | 1267 player_->element_animations()->has_element_in_active_list()); |
| 1268 EXPECT_FALSE( | 1268 EXPECT_FALSE( |
| 1269 player_->element_animations()->has_element_in_pending_list()); | 1269 player_->element_animations()->has_element_in_pending_list()); |
| 1270 EXPECT_FALSE(animation_host()->NeedsAnimateLayers()); | 1270 EXPECT_FALSE(animation_host()->NeedsTickAnimations()); |
| 1271 break; | 1271 break; |
| 1272 case 2: | 1272 case 2: |
| 1273 layer_tree()->root_layer()->AddChild(layer_); | 1273 layer_tree()->root_layer()->AddChild(layer_); |
| 1274 EXPECT_TRUE( | 1274 EXPECT_TRUE( |
| 1275 player_->element_animations()->has_element_in_active_list()); | 1275 player_->element_animations()->has_element_in_active_list()); |
| 1276 EXPECT_FALSE( | 1276 EXPECT_FALSE( |
| 1277 player_->element_animations()->has_element_in_pending_list()); | 1277 player_->element_animations()->has_element_in_pending_list()); |
| 1278 EXPECT_TRUE(animation_host()->NeedsAnimateLayers()); | 1278 EXPECT_TRUE(animation_host()->NeedsTickAnimations()); |
| 1279 break; | 1279 break; |
| 1280 } | 1280 } |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 1283 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 1284 scoped_refptr<AnimationTimeline> timeline_impl = | 1284 scoped_refptr<AnimationTimeline> timeline_impl = |
| 1285 GetImplAnimationHost(host_impl)->GetTimelineById(timeline_id_); | 1285 GetImplAnimationHost(host_impl)->GetTimelineById(timeline_id_); |
| 1286 scoped_refptr<AnimationPlayer> player_impl = | 1286 scoped_refptr<AnimationPlayer> player_impl = |
| 1287 timeline_impl->GetPlayerById(player_id_); | 1287 timeline_impl->GetPlayerById(player_id_); |
| 1288 | 1288 |
| 1289 switch (host_impl->active_tree()->source_frame_number()) { | 1289 switch (host_impl->active_tree()->source_frame_number()) { |
| 1290 case 0: | 1290 case 0: |
| 1291 EXPECT_TRUE( | 1291 EXPECT_TRUE( |
| 1292 player_impl->element_animations()->has_element_in_active_list()); | 1292 player_impl->element_animations()->has_element_in_active_list()); |
| 1293 EXPECT_TRUE(GetImplAnimationHost(host_impl)->NeedsAnimateLayers()); | 1293 EXPECT_TRUE(GetImplAnimationHost(host_impl)->NeedsTickAnimations()); |
| 1294 break; | 1294 break; |
| 1295 case 1: | 1295 case 1: |
| 1296 EXPECT_FALSE( | 1296 EXPECT_FALSE( |
| 1297 player_impl->element_animations()->has_element_in_active_list()); | 1297 player_impl->element_animations()->has_element_in_active_list()); |
| 1298 EXPECT_FALSE(GetImplAnimationHost(host_impl)->NeedsAnimateLayers()); | 1298 EXPECT_FALSE(GetImplAnimationHost(host_impl)->NeedsTickAnimations()); |
| 1299 break; | 1299 break; |
| 1300 case 2: | 1300 case 2: |
| 1301 EXPECT_TRUE( | 1301 EXPECT_TRUE( |
| 1302 player_impl->element_animations()->has_element_in_active_list()); | 1302 player_impl->element_animations()->has_element_in_active_list()); |
| 1303 EXPECT_TRUE(GetImplAnimationHost(host_impl)->NeedsAnimateLayers()); | 1303 EXPECT_TRUE(GetImplAnimationHost(host_impl)->NeedsTickAnimations()); |
| 1304 EndTest(); | 1304 EndTest(); |
| 1305 break; | 1305 break; |
| 1306 } | 1306 } |
| 1307 } | 1307 } |
| 1308 | 1308 |
| 1309 void AfterTest() override {} | 1309 void AfterTest() override {} |
| 1310 | 1310 |
| 1311 private: | 1311 private: |
| 1312 scoped_refptr<Layer> layer_; | 1312 scoped_refptr<Layer> layer_; |
| 1313 }; | 1313 }; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 CheckAnimations, | 1360 CheckAnimations, |
| 1361 base::Unretained(this), host_impl)); | 1361 base::Unretained(this), host_impl)); |
| 1362 } | 1362 } |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 void CheckAnimations(LayerTreeHostImpl* host_impl) { | 1365 void CheckAnimations(LayerTreeHostImpl* host_impl) { |
| 1366 GetImplTimelineAndPlayerByID(*host_impl); | 1366 GetImplTimelineAndPlayerByID(*host_impl); |
| 1367 | 1367 |
| 1368 EXPECT_EQ( | 1368 EXPECT_EQ( |
| 1369 2u, | 1369 2u, |
| 1370 GetImplAnimationHost(host_impl)->active_players_for_testing().size()); | 1370 GetImplAnimationHost(host_impl)->ticking_players_for_testing().size()); |
| 1371 | 1371 |
| 1372 Animation* root_anim = | 1372 Animation* root_anim = |
| 1373 player_impl_->GetAnimation(TargetProperty::TRANSFORM); | 1373 player_impl_->GetAnimation(TargetProperty::TRANSFORM); |
| 1374 EXPECT_GT((root_anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 1374 EXPECT_GT((root_anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
| 1375 | 1375 |
| 1376 Animation* anim = player_child_impl_->GetAnimation(TargetProperty::OPACITY); | 1376 Animation* anim = player_child_impl_->GetAnimation(TargetProperty::OPACITY); |
| 1377 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 1377 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
| 1378 | 1378 |
| 1379 EndTest(); | 1379 EndTest(); |
| 1380 } | 1380 } |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 private: | 1862 private: |
| 1863 scoped_refptr<Layer> layer_; | 1863 scoped_refptr<Layer> layer_; |
| 1864 FakeContentLayerClient client_; | 1864 FakeContentLayerClient client_; |
| 1865 }; | 1865 }; |
| 1866 | 1866 |
| 1867 MULTI_THREAD_TEST_F( | 1867 MULTI_THREAD_TEST_F( |
| 1868 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1868 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1869 | 1869 |
| 1870 } // namespace | 1870 } // namespace |
| 1871 } // namespace cc | 1871 } // namespace cc |
| OLD | NEW |