| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 PostAddInstantAnimationToMainThreadPlayer(player_.get()); | 80 PostAddInstantAnimationToMainThreadPlayer(player_.get()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void UpdateAnimationState(LayerTreeHostImpl* host_impl, | 83 void UpdateAnimationState(LayerTreeHostImpl* host_impl, |
| 84 bool has_unfinished_animation) override { | 84 bool has_unfinished_animation) override { |
| 85 EXPECT_FALSE(has_unfinished_animation); | 85 EXPECT_FALSE(has_unfinished_animation); |
| 86 update_animation_state_was_called_ = true; | 86 update_animation_state_was_called_ = true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 89 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 90 Animation::TargetProperty target_property, | 90 TargetProperty::Type target_property, |
| 91 int group) override { | 91 int group) override { |
| 92 EXPECT_LT(base::TimeTicks(), monotonic_time); | 92 EXPECT_LT(base::TimeTicks(), monotonic_time); |
| 93 | 93 |
| 94 LayerAnimationController* controller = | 94 LayerAnimationController* controller = |
| 95 player_->element_animations()->layer_animation_controller(); | 95 player_->element_animations()->layer_animation_controller(); |
| 96 Animation* animation = controller->GetAnimation(Animation::OPACITY); | 96 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); |
| 97 if (animation) | 97 if (animation) |
| 98 player_->RemoveAnimation(animation->id()); | 98 player_->RemoveAnimation(animation->id()); |
| 99 | 99 |
| 100 EndTest(); | 100 EndTest(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void AfterTest() override { EXPECT_TRUE(update_animation_state_was_called_); } | 103 void AfterTest() override { EXPECT_TRUE(update_animation_state_was_called_); } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 bool update_animation_state_was_called_; | 106 bool update_animation_state_was_called_; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (!started_animating_ && have_animations) { | 171 if (!started_animating_ && have_animations) { |
| 172 started_animating_ = true; | 172 started_animating_ = true; |
| 173 return; | 173 return; |
| 174 } | 174 } |
| 175 | 175 |
| 176 if (started_animating_ && !have_animations) | 176 if (started_animating_ && !have_animations) |
| 177 EndTest(); | 177 EndTest(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 180 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
| 181 Animation::TargetProperty target_property, | 181 TargetProperty::Type target_property, |
| 182 int group) override { | 182 int group) override { |
| 183 // Animations on the impl-side controller only get deleted during a commit, | 183 // Animations on the impl-side controller only get deleted during a commit, |
| 184 // so we need to schedule a commit. | 184 // so we need to schedule a commit. |
| 185 layer_tree_host()->SetNeedsCommit(); | 185 layer_tree_host()->SetNeedsCommit(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void AfterTest() override {} | 188 void AfterTest() override {} |
| 189 | 189 |
| 190 private: | 190 private: |
| 191 bool started_animating_; | 191 bool started_animating_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 221 if (host_impl->sync_tree()->source_frame_number() != 0) | 221 if (host_impl->sync_tree()->source_frame_number() != 0) |
| 222 return; | 222 return; |
| 223 | 223 |
| 224 scoped_refptr<AnimationTimeline> timeline_impl = | 224 scoped_refptr<AnimationTimeline> timeline_impl = |
| 225 host_impl->animation_host()->GetTimelineById(timeline_id_); | 225 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 226 scoped_refptr<AnimationPlayer> player_child_impl = | 226 scoped_refptr<AnimationPlayer> player_child_impl = |
| 227 timeline_impl->GetPlayerById(player_child_id_); | 227 timeline_impl->GetPlayerById(player_child_id_); |
| 228 | 228 |
| 229 LayerAnimationController* controller_impl = | 229 LayerAnimationController* controller_impl = |
| 230 player_child_impl->element_animations()->layer_animation_controller(); | 230 player_child_impl->element_animations()->layer_animation_controller(); |
| 231 Animation* animation = controller_impl->GetAnimation(Animation::OPACITY); | 231 Animation* animation = |
| 232 controller_impl->GetAnimation(TargetProperty::OPACITY); |
| 232 | 233 |
| 233 const FloatAnimationCurve* curve = | 234 const FloatAnimationCurve* curve = |
| 234 animation->curve()->ToFloatAnimationCurve(); | 235 animation->curve()->ToFloatAnimationCurve(); |
| 235 float start_opacity = curve->GetValue(base::TimeDelta()); | 236 float start_opacity = curve->GetValue(base::TimeDelta()); |
| 236 float end_opacity = curve->GetValue(curve->Duration()); | 237 float end_opacity = curve->GetValue(curve->Duration()); |
| 237 float linearly_interpolated_opacity = | 238 float linearly_interpolated_opacity = |
| 238 0.25f * end_opacity + 0.75f * start_opacity; | 239 0.25f * end_opacity + 0.75f * start_opacity; |
| 239 base::TimeDelta time = TimeUtil::Scale(curve->Duration(), 0.25f); | 240 base::TimeDelta time = TimeUtil::Scale(curve->Duration(), 0.25f); |
| 240 // If the linear timing function associated with this animation was not | 241 // If the linear timing function associated with this animation was not |
| 241 // picked up, then the linearly interpolated opacity would be different | 242 // picked up, then the linearly interpolated opacity would be different |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 AttachPlayersToTimeline(); | 274 AttachPlayersToTimeline(); |
| 274 player_child_->set_layer_animation_delegate(this); | 275 player_child_->set_layer_animation_delegate(this); |
| 275 player_child_->AttachLayer(picture_->id()); | 276 player_child_->AttachLayer(picture_->id()); |
| 276 } | 277 } |
| 277 | 278 |
| 278 void BeginTest() override { | 279 void BeginTest() override { |
| 279 PostAddAnimationToMainThreadPlayer(player_child_.get()); | 280 PostAddAnimationToMainThreadPlayer(player_child_.get()); |
| 280 } | 281 } |
| 281 | 282 |
| 282 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 283 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 283 Animation::TargetProperty target_property, | 284 TargetProperty::Type target_property, |
| 284 int group) override { | 285 int group) override { |
| 285 LayerAnimationController* controller = | 286 LayerAnimationController* controller = |
| 286 player_child_->element_animations()->layer_animation_controller(); | 287 player_child_->element_animations()->layer_animation_controller(); |
| 287 Animation* animation = controller->GetAnimation(Animation::OPACITY); | 288 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); |
| 288 main_start_time_ = animation->start_time(); | 289 main_start_time_ = animation->start_time(); |
| 289 controller->RemoveAnimation(animation->id()); | 290 controller->RemoveAnimation(animation->id()); |
| 290 EndTest(); | 291 EndTest(); |
| 291 } | 292 } |
| 292 | 293 |
| 293 void UpdateAnimationState(LayerTreeHostImpl* impl_host, | 294 void UpdateAnimationState(LayerTreeHostImpl* impl_host, |
| 294 bool has_unfinished_animation) override { | 295 bool has_unfinished_animation) override { |
| 295 scoped_refptr<AnimationTimeline> timeline_impl = | 296 scoped_refptr<AnimationTimeline> timeline_impl = |
| 296 impl_host->animation_host()->GetTimelineById(timeline_id_); | 297 impl_host->animation_host()->GetTimelineById(timeline_id_); |
| 297 scoped_refptr<AnimationPlayer> player_child_impl = | 298 scoped_refptr<AnimationPlayer> player_child_impl = |
| 298 timeline_impl->GetPlayerById(player_child_id_); | 299 timeline_impl->GetPlayerById(player_child_id_); |
| 299 | 300 |
| 300 LayerAnimationController* controller = | 301 LayerAnimationController* controller = |
| 301 player_child_impl->element_animations()->layer_animation_controller(); | 302 player_child_impl->element_animations()->layer_animation_controller(); |
| 302 Animation* animation = controller->GetAnimation(Animation::OPACITY); | 303 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); |
| 303 if (!animation) | 304 if (!animation) |
| 304 return; | 305 return; |
| 305 | 306 |
| 306 impl_start_time_ = animation->start_time(); | 307 impl_start_time_ = animation->start_time(); |
| 307 } | 308 } |
| 308 | 309 |
| 309 void AfterTest() override { | 310 void AfterTest() override { |
| 310 EXPECT_EQ(impl_start_time_, main_start_time_); | 311 EXPECT_EQ(impl_start_time_, main_start_time_); |
| 311 EXPECT_LT(base::TimeTicks(), impl_start_time_); | 312 EXPECT_LT(base::TimeTicks(), impl_start_time_); |
| 312 } | 313 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 328 public: | 329 public: |
| 329 LayerTreeHostTimelinesTestAnimationFinishedEvents() {} | 330 LayerTreeHostTimelinesTestAnimationFinishedEvents() {} |
| 330 | 331 |
| 331 void BeginTest() override { | 332 void BeginTest() override { |
| 332 AttachPlayersToTimeline(); | 333 AttachPlayersToTimeline(); |
| 333 player_->AttachLayer(layer_tree_host()->root_layer()->id()); | 334 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
| 334 PostAddInstantAnimationToMainThreadPlayer(player_.get()); | 335 PostAddInstantAnimationToMainThreadPlayer(player_.get()); |
| 335 } | 336 } |
| 336 | 337 |
| 337 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 338 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
| 338 Animation::TargetProperty target_property, | 339 TargetProperty::Type target_property, |
| 339 int group) override { | 340 int group) override { |
| 340 LayerAnimationController* controller = | 341 LayerAnimationController* controller = |
| 341 player_->element_animations()->layer_animation_controller(); | 342 player_->element_animations()->layer_animation_controller(); |
| 342 Animation* animation = controller->GetAnimation(Animation::OPACITY); | 343 Animation* animation = controller->GetAnimation(TargetProperty::OPACITY); |
| 343 if (animation) | 344 if (animation) |
| 344 controller->RemoveAnimation(animation->id()); | 345 controller->RemoveAnimation(animation->id()); |
| 345 EndTest(); | 346 EndTest(); |
| 346 } | 347 } |
| 347 | 348 |
| 348 void AfterTest() override {} | 349 void AfterTest() override {} |
| 349 }; | 350 }; |
| 350 | 351 |
| 351 SINGLE_AND_MULTI_THREAD_TEST_F( | 352 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 352 LayerTreeHostTimelinesTestAnimationFinishedEvents); | 353 LayerTreeHostTimelinesTestAnimationFinishedEvents); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 377 | 378 |
| 378 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 379 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 379 scoped_refptr<AnimationTimeline> timeline_impl = | 380 scoped_refptr<AnimationTimeline> timeline_impl = |
| 380 host_impl->animation_host()->GetTimelineById(timeline_id_); | 381 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 381 scoped_refptr<AnimationPlayer> player_impl = | 382 scoped_refptr<AnimationPlayer> player_impl = |
| 382 timeline_impl->GetPlayerById(player_id_); | 383 timeline_impl->GetPlayerById(player_id_); |
| 383 | 384 |
| 384 LayerAnimationController* controller_impl = | 385 LayerAnimationController* controller_impl = |
| 385 player_impl->element_animations()->layer_animation_controller(); | 386 player_impl->element_animations()->layer_animation_controller(); |
| 386 Animation* animation_impl = | 387 Animation* animation_impl = |
| 387 controller_impl->GetAnimation(Animation::OPACITY); | 388 controller_impl->GetAnimation(TargetProperty::OPACITY); |
| 388 controller_impl->RemoveAnimation(animation_impl->id()); | 389 controller_impl->RemoveAnimation(animation_impl->id()); |
| 389 EndTest(); | 390 EndTest(); |
| 390 } | 391 } |
| 391 | 392 |
| 392 void AfterTest() override { | 393 void AfterTest() override { |
| 393 // Update() should have been called once, proving that the layer was not | 394 // Update() should have been called once, proving that the layer was not |
| 394 // skipped. | 395 // skipped. |
| 395 EXPECT_EQ(1, update_check_layer_->update_count()); | 396 EXPECT_EQ(1, update_check_layer_->update_count()); |
| 396 | 397 |
| 397 // clear update_check_layer_ so LayerTreeHost dies. | 398 // clear update_check_layer_ so LayerTreeHost dies. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 420 if (layer_tree_host()->source_frame_number() == 1) { | 421 if (layer_tree_host()->source_frame_number() == 1) { |
| 421 AttachPlayersToTimeline(); | 422 AttachPlayersToTimeline(); |
| 422 | 423 |
| 423 scoped_refptr<Layer> layer = Layer::Create(layer_settings()); | 424 scoped_refptr<Layer> layer = Layer::Create(layer_settings()); |
| 424 player_->AttachLayer(layer->id()); | 425 player_->AttachLayer(layer->id()); |
| 425 player_->set_layer_animation_delegate(this); | 426 player_->set_layer_animation_delegate(this); |
| 426 | 427 |
| 427 // Any valid AnimationCurve will do here. | 428 // Any valid AnimationCurve will do here. |
| 428 scoped_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); | 429 scoped_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); |
| 429 scoped_ptr<Animation> animation( | 430 scoped_ptr<Animation> animation( |
| 430 Animation::Create(std::move(curve), 1, 1, Animation::OPACITY)); | 431 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY)); |
| 431 player_->AddAnimation(std::move(animation)); | 432 player_->AddAnimation(std::move(animation)); |
| 432 | 433 |
| 433 // We add the animation *before* attaching the layer to the tree. | 434 // We add the animation *before* attaching the layer to the tree. |
| 434 layer_tree_host()->root_layer()->AddChild(layer); | 435 layer_tree_host()->root_layer()->AddChild(layer); |
| 435 } | 436 } |
| 436 } | 437 } |
| 437 | 438 |
| 438 void AnimateLayers(LayerTreeHostImpl* impl_host, | 439 void AnimateLayers(LayerTreeHostImpl* impl_host, |
| 439 base::TimeTicks monotonic_time) override { | 440 base::TimeTicks monotonic_time) override { |
| 440 EndTest(); | 441 EndTest(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 false); | 501 false); |
| 501 break; | 502 break; |
| 502 case 2: | 503 case 2: |
| 503 // This second animation will not be drawn so it should not start. | 504 // This second animation will not be drawn so it should not start. |
| 504 AddAnimatedTransformToPlayer(player_child_.get(), 0.1, 5, 5); | 505 AddAnimatedTransformToPlayer(player_child_.get(), 0.1, 5, 5); |
| 505 break; | 506 break; |
| 506 } | 507 } |
| 507 } | 508 } |
| 508 | 509 |
| 509 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 510 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 510 Animation::TargetProperty target_property, | 511 TargetProperty::Type target_property, |
| 511 int group) override { | 512 int group) override { |
| 512 if (TestEnded()) | 513 if (TestEnded()) |
| 513 return; | 514 return; |
| 514 started_times_++; | 515 started_times_++; |
| 515 } | 516 } |
| 516 | 517 |
| 517 void AfterTest() override { | 518 void AfterTest() override { |
| 518 // Make sure we tried to draw the second animation but failed. | 519 // Make sure we tried to draw the second animation but failed. |
| 519 EXPECT_LT(0, prevented_draw_); | 520 EXPECT_LT(0, prevented_draw_); |
| 520 // The first animation should be started, but the second should not because | 521 // The first animation should be started, but the second should not because |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 558 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 558 | 559 |
| 559 void DidCommit() override { | 560 void DidCommit() override { |
| 560 switch (layer_tree_host()->source_frame_number()) { | 561 switch (layer_tree_host()->source_frame_number()) { |
| 561 case 1: { | 562 case 1: { |
| 562 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 563 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 563 ScrollOffsetAnimationCurve::Create( | 564 ScrollOffsetAnimationCurve::Create( |
| 564 gfx::ScrollOffset(500.f, 550.f), | 565 gfx::ScrollOffset(500.f, 550.f), |
| 565 EaseInOutTimingFunction::Create())); | 566 EaseInOutTimingFunction::Create())); |
| 566 scoped_ptr<Animation> animation(Animation::Create( | 567 scoped_ptr<Animation> animation(Animation::Create( |
| 567 std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); | 568 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 568 animation->set_needs_synchronized_start_time(true); | 569 animation->set_needs_synchronized_start_time(true); |
| 569 bool impl_scrolling_supported = | 570 bool impl_scrolling_supported = |
| 570 layer_tree_host()->proxy()->SupportsImplScrolling(); | 571 layer_tree_host()->proxy()->SupportsImplScrolling(); |
| 571 if (impl_scrolling_supported) | 572 if (impl_scrolling_supported) |
| 572 player_child_->AddAnimation(std::move(animation)); | 573 player_child_->AddAnimation(std::move(animation)); |
| 573 else | 574 else |
| 574 EndTest(); | 575 EndTest(); |
| 575 break; | 576 break; |
| 576 } | 577 } |
| 577 default: | 578 default: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 608 scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 609 scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 609 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); | 610 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); |
| 610 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); | 611 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); |
| 611 client_.set_bounds(scroll_layer_->bounds()); | 612 client_.set_bounds(scroll_layer_->bounds()); |
| 612 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0)); | 613 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0)); |
| 613 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 614 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 614 | 615 |
| 615 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 616 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 616 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f), | 617 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f), |
| 617 EaseInOutTimingFunction::Create())); | 618 EaseInOutTimingFunction::Create())); |
| 618 scoped_ptr<Animation> animation( | 619 scoped_ptr<Animation> animation(Animation::Create( |
| 619 Animation::Create(std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); | 620 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 620 animation->set_needs_synchronized_start_time(true); | 621 animation->set_needs_synchronized_start_time(true); |
| 621 | 622 |
| 622 AttachPlayersToTimeline(); | 623 AttachPlayersToTimeline(); |
| 623 player_child_->AttachLayer(scroll_layer_->id()); | 624 player_child_->AttachLayer(scroll_layer_->id()); |
| 624 player_child_->AddAnimation(std::move(animation)); | 625 player_child_->AddAnimation(std::move(animation)); |
| 625 } | 626 } |
| 626 | 627 |
| 627 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 628 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 628 | 629 |
| 629 void BeginMainFrame(const BeginFrameArgs& args) override { | 630 void BeginMainFrame(const BeginFrameArgs& args) override { |
| 630 switch (layer_tree_host()->source_frame_number()) { | 631 switch (layer_tree_host()->source_frame_number()) { |
| 631 case 0: | 632 case 0: |
| 632 break; | 633 break; |
| 633 case 1: { | 634 case 1: { |
| 634 Animation* animation = player_child_->element_animations() | 635 Animation* animation = |
| 635 ->layer_animation_controller() | 636 player_child_->element_animations() |
| 636 ->GetAnimation(Animation::SCROLL_OFFSET); | 637 ->layer_animation_controller() |
| 638 ->GetAnimation(TargetProperty::SCROLL_OFFSET); |
| 637 player_child_->RemoveAnimation(animation->id()); | 639 player_child_->RemoveAnimation(animation->id()); |
| 638 scroll_layer_->SetScrollOffset(final_postion_); | 640 scroll_layer_->SetScrollOffset(final_postion_); |
| 639 break; | 641 break; |
| 640 } | 642 } |
| 641 default: | 643 default: |
| 642 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset()); | 644 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset()); |
| 643 } | 645 } |
| 644 } | 646 } |
| 645 | 647 |
| 646 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | 648 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 659 | 661 |
| 660 scoped_refptr<AnimationTimeline> timeline_impl = | 662 scoped_refptr<AnimationTimeline> timeline_impl = |
| 661 host_impl->animation_host()->GetTimelineById(timeline_id_); | 663 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 662 scoped_refptr<AnimationPlayer> player_impl = | 664 scoped_refptr<AnimationPlayer> player_impl = |
| 663 timeline_impl->GetPlayerById(player_child_id_); | 665 timeline_impl->GetPlayerById(player_child_id_); |
| 664 | 666 |
| 665 LayerImpl* scroll_layer_impl = | 667 LayerImpl* scroll_layer_impl = |
| 666 host_impl->active_tree()->root_layer()->children()[0].get(); | 668 host_impl->active_tree()->root_layer()->children()[0].get(); |
| 667 Animation* animation = player_impl->element_animations() | 669 Animation* animation = player_impl->element_animations() |
| 668 ->layer_animation_controller() | 670 ->layer_animation_controller() |
| 669 ->GetAnimation(Animation::SCROLL_OFFSET); | 671 ->GetAnimation(TargetProperty::SCROLL_OFFSET); |
| 670 | 672 |
| 671 if (!animation || animation->run_state() != Animation::RUNNING) { | 673 if (!animation || animation->run_state() != Animation::RUNNING) { |
| 672 host_impl->BlockNotifyReadyToActivateForTesting(false); | 674 host_impl->BlockNotifyReadyToActivateForTesting(false); |
| 673 return; | 675 return; |
| 674 } | 676 } |
| 675 | 677 |
| 676 // Block activation until the running animation has a chance to produce a | 678 // Block activation until the running animation has a chance to produce a |
| 677 // scroll delta. | 679 // scroll delta. |
| 678 gfx::Vector2dF scroll_delta = scroll_layer_impl->ScrollDelta(); | 680 gfx::Vector2dF scroll_delta = scroll_layer_impl->ScrollDelta(); |
| 679 if (scroll_delta.x() < 1.f || scroll_delta.y() < 1.f) | 681 if (scroll_delta.x() < 1.f || scroll_delta.y() < 1.f) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 scoped_refptr<AnimationPlayer> player_child_impl = | 780 scoped_refptr<AnimationPlayer> player_child_impl = |
| 779 timeline_impl->GetPlayerById(player_child_id_); | 781 timeline_impl->GetPlayerById(player_child_id_); |
| 780 | 782 |
| 781 // wait for tree activation. | 783 // wait for tree activation. |
| 782 if (!player_impl->element_animations()) | 784 if (!player_impl->element_animations()) |
| 783 return; | 785 return; |
| 784 | 786 |
| 785 LayerAnimationController* root_controller_impl = | 787 LayerAnimationController* root_controller_impl = |
| 786 player_impl->element_animations()->layer_animation_controller(); | 788 player_impl->element_animations()->layer_animation_controller(); |
| 787 Animation* root_animation = | 789 Animation* root_animation = |
| 788 root_controller_impl->GetAnimation(Animation::OPACITY); | 790 root_controller_impl->GetAnimation(TargetProperty::OPACITY); |
| 789 if (!root_animation || root_animation->run_state() != Animation::RUNNING) | 791 if (!root_animation || root_animation->run_state() != Animation::RUNNING) |
| 790 return; | 792 return; |
| 791 | 793 |
| 792 LayerAnimationController* child_controller_impl = | 794 LayerAnimationController* child_controller_impl = |
| 793 player_child_impl->element_animations()->layer_animation_controller(); | 795 player_child_impl->element_animations()->layer_animation_controller(); |
| 794 Animation* child_animation = | 796 Animation* child_animation = |
| 795 child_controller_impl->GetAnimation(Animation::OPACITY); | 797 child_controller_impl->GetAnimation(TargetProperty::OPACITY); |
| 796 EXPECT_EQ(Animation::RUNNING, child_animation->run_state()); | 798 EXPECT_EQ(Animation::RUNNING, child_animation->run_state()); |
| 797 EXPECT_EQ(root_animation->start_time(), child_animation->start_time()); | 799 EXPECT_EQ(root_animation->start_time(), child_animation->start_time()); |
| 798 root_controller_impl->AbortAnimations(Animation::OPACITY); | 800 root_controller_impl->AbortAnimations(TargetProperty::OPACITY); |
| 799 root_controller_impl->AbortAnimations(Animation::TRANSFORM); | 801 root_controller_impl->AbortAnimations(TargetProperty::TRANSFORM); |
| 800 child_controller_impl->AbortAnimations(Animation::OPACITY); | 802 child_controller_impl->AbortAnimations(TargetProperty::OPACITY); |
| 801 EndTest(); | 803 EndTest(); |
| 802 } | 804 } |
| 803 | 805 |
| 804 void AfterTest() override {} | 806 void AfterTest() override {} |
| 805 | 807 |
| 806 private: | 808 private: |
| 807 int frame_count_with_pending_tree_; | 809 int frame_count_with_pending_tree_; |
| 808 }; | 810 }; |
| 809 | 811 |
| 810 // This test blocks activation which is not supported for single thread mode. | 812 // This test blocks activation which is not supported for single thread mode. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 if (host_impl->active_tree()->source_frame_number() < 2) | 851 if (host_impl->active_tree()->source_frame_number() < 2) |
| 850 return; | 852 return; |
| 851 AnimationRegistrar::AnimationControllerMap controllers_copy = | 853 AnimationRegistrar::AnimationControllerMap controllers_copy = |
| 852 host_impl->animation_host() | 854 host_impl->animation_host() |
| 853 ->animation_registrar() | 855 ->animation_registrar() |
| 854 ->active_animation_controllers_for_testing(); | 856 ->active_animation_controllers_for_testing(); |
| 855 EXPECT_EQ(2u, controllers_copy.size()); | 857 EXPECT_EQ(2u, controllers_copy.size()); |
| 856 for (auto& it : controllers_copy) { | 858 for (auto& it : controllers_copy) { |
| 857 int id = it.first; | 859 int id = it.first; |
| 858 if (id == host_impl->RootLayer()->id()) { | 860 if (id == host_impl->RootLayer()->id()) { |
| 859 Animation* anim = it.second->GetAnimation(Animation::TRANSFORM); | 861 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM); |
| 860 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 862 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
| 861 } else if (id == host_impl->RootLayer()->children()[0]->id()) { | 863 } else if (id == host_impl->RootLayer()->children()[0]->id()) { |
| 862 Animation* anim = it.second->GetAnimation(Animation::OPACITY); | 864 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY); |
| 863 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 865 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
| 864 } | 866 } |
| 865 EndTest(); | 867 EndTest(); |
| 866 } | 868 } |
| 867 } | 869 } |
| 868 | 870 |
| 869 void AfterTest() override {} | 871 void AfterTest() override {} |
| 870 | 872 |
| 871 private: | 873 private: |
| 872 scoped_refptr<Layer> content_; | 874 scoped_refptr<Layer> content_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 894 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 896 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 895 | 897 |
| 896 void DidCommit() override { | 898 void DidCommit() override { |
| 897 switch (layer_tree_host()->source_frame_number()) { | 899 switch (layer_tree_host()->source_frame_number()) { |
| 898 case 1: | 900 case 1: |
| 899 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); | 901 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); |
| 900 break; | 902 break; |
| 901 case 2: | 903 case 2: |
| 902 LayerAnimationController* controller = | 904 LayerAnimationController* controller = |
| 903 player_child_->element_animations()->layer_animation_controller(); | 905 player_child_->element_animations()->layer_animation_controller(); |
| 904 Animation* animation = controller->GetAnimation(Animation::TRANSFORM); | 906 Animation* animation = |
| 907 controller->GetAnimation(TargetProperty::TRANSFORM); |
| 905 player_child_->RemoveAnimation(animation->id()); | 908 player_child_->RemoveAnimation(animation->id()); |
| 906 gfx::Transform transform; | 909 gfx::Transform transform; |
| 907 transform.Translate(10.f, 10.f); | 910 transform.Translate(10.f, 10.f); |
| 908 layer_->SetTransform(transform); | 911 layer_->SetTransform(transform); |
| 909 | 912 |
| 910 // Do something that causes property trees to get rebuilt. | 913 // Do something that causes property trees to get rebuilt. |
| 911 layer_->AddChild(Layer::Create(layer_settings())); | 914 layer_->AddChild(Layer::Create(layer_settings())); |
| 912 break; | 915 break; |
| 913 } | 916 } |
| 914 } | 917 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 private: | 1133 private: |
| 1131 scoped_refptr<Layer> layer_; | 1134 scoped_refptr<Layer> layer_; |
| 1132 FakeContentLayerClient client_; | 1135 FakeContentLayerClient client_; |
| 1133 }; | 1136 }; |
| 1134 | 1137 |
| 1135 MULTI_THREAD_TEST_F( | 1138 MULTI_THREAD_TEST_F( |
| 1136 LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1139 LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1137 | 1140 |
| 1138 } // namespace | 1141 } // namespace |
| 1139 } // namespace cc | 1142 } // namespace cc |
| OLD | NEW |