| 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 26 matching lines...) Expand all Loading... |
| 37 player_child_id_(AnimationIdProvider::NextPlayerId()) { | 37 player_child_id_(AnimationIdProvider::NextPlayerId()) { |
| 38 timeline_ = AnimationTimeline::Create(timeline_id_); | 38 timeline_ = AnimationTimeline::Create(timeline_id_); |
| 39 player_ = AnimationPlayer::Create(player_id_); | 39 player_ = AnimationPlayer::Create(player_id_); |
| 40 player_child_ = AnimationPlayer::Create(player_child_id_); | 40 player_child_ = AnimationPlayer::Create(player_child_id_); |
| 41 | 41 |
| 42 player_->set_animation_delegate(this); | 42 player_->set_animation_delegate(this); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void AttachPlayersToTimeline() { | 45 void AttachPlayersToTimeline() { |
| 46 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); | 46 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); |
| 47 layer_tree_host()->SetElementIdsForTesting(); | |
| 48 timeline_->AttachPlayer(player_.get()); | 47 timeline_->AttachPlayer(player_.get()); |
| 49 timeline_->AttachPlayer(player_child_.get()); | 48 timeline_->AttachPlayer(player_child_.get()); |
| 50 } | 49 } |
| 51 | 50 |
| 52 protected: | 51 protected: |
| 53 scoped_refptr<AnimationTimeline> timeline_; | 52 scoped_refptr<AnimationTimeline> timeline_; |
| 54 scoped_refptr<AnimationPlayer> player_; | 53 scoped_refptr<AnimationPlayer> player_; |
| 55 scoped_refptr<AnimationPlayer> player_child_; | 54 scoped_refptr<AnimationPlayer> player_child_; |
| 56 | 55 |
| 57 const int timeline_id_; | 56 const int timeline_id_; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Add a layer animation and confirm that | 138 // Add a layer animation and confirm that |
| 140 // LayerTreeHostImpl::UpdateAnimationState does get called. | 139 // LayerTreeHostImpl::UpdateAnimationState does get called. |
| 141 class LayerTreeHostAnimationTestAddAnimation | 140 class LayerTreeHostAnimationTestAddAnimation |
| 142 : public LayerTreeHostAnimationTest { | 141 : public LayerTreeHostAnimationTest { |
| 143 public: | 142 public: |
| 144 LayerTreeHostAnimationTestAddAnimation() | 143 LayerTreeHostAnimationTestAddAnimation() |
| 145 : update_animation_state_was_called_(false) {} | 144 : update_animation_state_was_called_(false) {} |
| 146 | 145 |
| 147 void BeginTest() override { | 146 void BeginTest() override { |
| 148 AttachPlayersToTimeline(); | 147 AttachPlayersToTimeline(); |
| 149 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 148 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 150 PostAddInstantAnimationToMainThreadPlayer(player_.get()); | 149 PostAddInstantAnimationToMainThreadPlayer(player_.get()); |
| 151 } | 150 } |
| 152 | 151 |
| 153 void UpdateAnimationState(LayerTreeHostImpl* host_impl, | 152 void UpdateAnimationState(LayerTreeHostImpl* host_impl, |
| 154 bool has_unfinished_animation) override { | 153 bool has_unfinished_animation) override { |
| 155 EXPECT_FALSE(has_unfinished_animation); | 154 EXPECT_FALSE(has_unfinished_animation); |
| 156 update_animation_state_was_called_ = true; | 155 update_animation_state_was_called_ = true; |
| 157 } | 156 } |
| 158 | 157 |
| 159 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 158 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 180 // Add a layer animation to a layer, but continually fail to draw. Confirm that | 179 // Add a layer animation to a layer, but continually fail to draw. Confirm that |
| 181 // after a while, we do eventually force a draw. | 180 // after a while, we do eventually force a draw. |
| 182 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws | 181 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws |
| 183 : public LayerTreeHostAnimationTest { | 182 : public LayerTreeHostAnimationTest { |
| 184 public: | 183 public: |
| 185 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws() | 184 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws() |
| 186 : started_animating_(false) {} | 185 : started_animating_(false) {} |
| 187 | 186 |
| 188 void BeginTest() override { | 187 void BeginTest() override { |
| 189 AttachPlayersToTimeline(); | 188 AttachPlayersToTimeline(); |
| 190 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 189 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 191 PostAddAnimationToMainThreadPlayer(player_.get()); | 190 PostAddAnimationToMainThreadPlayer(player_.get()); |
| 192 } | 191 } |
| 193 | 192 |
| 194 void AnimateLayers(LayerTreeHostImpl* host_impl, | 193 void AnimateLayers(LayerTreeHostImpl* host_impl, |
| 195 base::TimeTicks monotonic_time) override { | 194 base::TimeTicks monotonic_time) override { |
| 196 started_animating_ = true; | 195 started_animating_ = true; |
| 197 } | 196 } |
| 198 | 197 |
| 199 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 198 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 200 if (started_animating_) | 199 if (started_animating_) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 218 | 217 |
| 219 // Ensures that animations eventually get deleted. | 218 // Ensures that animations eventually get deleted. |
| 220 class LayerTreeHostAnimationTestAnimationsGetDeleted | 219 class LayerTreeHostAnimationTestAnimationsGetDeleted |
| 221 : public LayerTreeHostAnimationTest { | 220 : public LayerTreeHostAnimationTest { |
| 222 public: | 221 public: |
| 223 LayerTreeHostAnimationTestAnimationsGetDeleted() | 222 LayerTreeHostAnimationTestAnimationsGetDeleted() |
| 224 : started_animating_(false) {} | 223 : started_animating_(false) {} |
| 225 | 224 |
| 226 void BeginTest() override { | 225 void BeginTest() override { |
| 227 AttachPlayersToTimeline(); | 226 AttachPlayersToTimeline(); |
| 228 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 227 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 229 PostAddAnimationToMainThreadPlayer(player_.get()); | 228 PostAddAnimationToMainThreadPlayer(player_.get()); |
| 230 } | 229 } |
| 231 | 230 |
| 232 void AnimateLayers(LayerTreeHostImpl* host_impl, | 231 void AnimateLayers(LayerTreeHostImpl* host_impl, |
| 233 base::TimeTicks monotonic_time) override { | 232 base::TimeTicks monotonic_time) override { |
| 234 bool have_animations = !host_impl->animation_host() | 233 bool have_animations = !host_impl->animation_host() |
| 235 ->active_element_animations_for_testing() | 234 ->active_element_animations_for_testing() |
| 236 .empty(); | 235 .empty(); |
| 237 if (!started_animating_ && have_animations) { | 236 if (!started_animating_ && have_animations) { |
| 238 started_animating_ = true; | 237 started_animating_ = true; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 264 : public LayerTreeHostAnimationTest { | 263 : public LayerTreeHostAnimationTest { |
| 265 public: | 264 public: |
| 266 void SetupTree() override { | 265 void SetupTree() override { |
| 267 LayerTreeHostAnimationTest::SetupTree(); | 266 LayerTreeHostAnimationTest::SetupTree(); |
| 268 picture_ = FakePictureLayer::Create(&client_); | 267 picture_ = FakePictureLayer::Create(&client_); |
| 269 picture_->SetBounds(gfx::Size(4, 4)); | 268 picture_->SetBounds(gfx::Size(4, 4)); |
| 270 client_.set_bounds(picture_->bounds()); | 269 client_.set_bounds(picture_->bounds()); |
| 271 layer_tree_host()->root_layer()->AddChild(picture_); | 270 layer_tree_host()->root_layer()->AddChild(picture_); |
| 272 | 271 |
| 273 AttachPlayersToTimeline(); | 272 AttachPlayersToTimeline(); |
| 274 player_child_->AttachElement(picture_->element_id()); | 273 player_child_->AttachElement(picture_->id()); |
| 275 } | 274 } |
| 276 | 275 |
| 277 void BeginTest() override { | 276 void BeginTest() override { |
| 278 PostAddAnimationToMainThreadPlayer(player_child_.get()); | 277 PostAddAnimationToMainThreadPlayer(player_child_.get()); |
| 279 } | 278 } |
| 280 | 279 |
| 281 void AnimateLayers(LayerTreeHostImpl* host_impl, | 280 void AnimateLayers(LayerTreeHostImpl* host_impl, |
| 282 base::TimeTicks monotonic_time) override { | 281 base::TimeTicks monotonic_time) override { |
| 283 // TODO(ajuma): This test only checks the active tree. Add checks for | 282 // TODO(ajuma): This test only checks the active tree. Add checks for |
| 284 // pending tree too. | 283 // pending tree too. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 void SetupTree() override { | 329 void SetupTree() override { |
| 331 LayerTreeHostAnimationTest::SetupTree(); | 330 LayerTreeHostAnimationTest::SetupTree(); |
| 332 picture_ = FakePictureLayer::Create(&client_); | 331 picture_ = FakePictureLayer::Create(&client_); |
| 333 picture_->SetBounds(gfx::Size(4, 4)); | 332 picture_->SetBounds(gfx::Size(4, 4)); |
| 334 client_.set_bounds(picture_->bounds()); | 333 client_.set_bounds(picture_->bounds()); |
| 335 | 334 |
| 336 layer_tree_host()->root_layer()->AddChild(picture_); | 335 layer_tree_host()->root_layer()->AddChild(picture_); |
| 337 | 336 |
| 338 AttachPlayersToTimeline(); | 337 AttachPlayersToTimeline(); |
| 339 player_child_->set_animation_delegate(this); | 338 player_child_->set_animation_delegate(this); |
| 340 player_child_->AttachElement(picture_->element_id()); | 339 player_child_->AttachElement(picture_->id()); |
| 341 } | 340 } |
| 342 | 341 |
| 343 void BeginTest() override { | 342 void BeginTest() override { |
| 344 PostAddAnimationToMainThreadPlayer(player_child_.get()); | 343 PostAddAnimationToMainThreadPlayer(player_child_.get()); |
| 345 } | 344 } |
| 346 | 345 |
| 347 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 346 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 348 TargetProperty::Type target_property, | 347 TargetProperty::Type target_property, |
| 349 int group) override { | 348 int group) override { |
| 350 Animation* animation = player_child_->element_animations()->GetAnimation( | 349 Animation* animation = player_child_->element_animations()->GetAnimation( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 383 |
| 385 SINGLE_AND_MULTI_THREAD_TEST_F( | 384 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 386 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes); | 385 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes); |
| 387 | 386 |
| 388 // Ensures that notify animation finished is called. | 387 // Ensures that notify animation finished is called. |
| 389 class LayerTreeHostAnimationTestAnimationFinishedEvents | 388 class LayerTreeHostAnimationTestAnimationFinishedEvents |
| 390 : public LayerTreeHostAnimationTest { | 389 : public LayerTreeHostAnimationTest { |
| 391 public: | 390 public: |
| 392 void BeginTest() override { | 391 void BeginTest() override { |
| 393 AttachPlayersToTimeline(); | 392 AttachPlayersToTimeline(); |
| 394 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 393 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 395 PostAddInstantAnimationToMainThreadPlayer(player_.get()); | 394 PostAddInstantAnimationToMainThreadPlayer(player_.get()); |
| 396 } | 395 } |
| 397 | 396 |
| 398 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 397 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
| 399 TargetProperty::Type target_property, | 398 TargetProperty::Type target_property, |
| 400 int group) override { | 399 int group) override { |
| 401 Animation* animation = | 400 Animation* animation = |
| 402 player_->element_animations()->GetAnimation(TargetProperty::OPACITY); | 401 player_->element_animations()->GetAnimation(TargetProperty::OPACITY); |
| 403 if (animation) | 402 if (animation) |
| 404 player_->element_animations()->RemoveAnimation(animation->id()); | 403 player_->element_animations()->RemoveAnimation(animation->id()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 420 : update_check_layer_() {} | 419 : update_check_layer_() {} |
| 421 | 420 |
| 422 void SetupTree() override { | 421 void SetupTree() override { |
| 423 update_check_layer_ = FakePictureLayer::Create(&client_); | 422 update_check_layer_ = FakePictureLayer::Create(&client_); |
| 424 update_check_layer_->SetOpacity(0.f); | 423 update_check_layer_->SetOpacity(0.f); |
| 425 layer_tree_host()->SetRootLayer(update_check_layer_); | 424 layer_tree_host()->SetRootLayer(update_check_layer_); |
| 426 client_.set_bounds(update_check_layer_->bounds()); | 425 client_.set_bounds(update_check_layer_->bounds()); |
| 427 LayerTreeHostAnimationTest::SetupTree(); | 426 LayerTreeHostAnimationTest::SetupTree(); |
| 428 | 427 |
| 429 AttachPlayersToTimeline(); | 428 AttachPlayersToTimeline(); |
| 430 player_->AttachElement(update_check_layer_->element_id()); | 429 player_->AttachElement(update_check_layer_->id()); |
| 431 } | 430 } |
| 432 | 431 |
| 433 void BeginTest() override { | 432 void BeginTest() override { |
| 434 PostAddAnimationToMainThreadPlayer(player_.get()); | 433 PostAddAnimationToMainThreadPlayer(player_.get()); |
| 435 } | 434 } |
| 436 | 435 |
| 437 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 436 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 438 scoped_refptr<AnimationTimeline> timeline_impl = | 437 scoped_refptr<AnimationTimeline> timeline_impl = |
| 439 host_impl->animation_host()->GetTimelineById(timeline_id_); | 438 host_impl->animation_host()->GetTimelineById(timeline_id_); |
| 440 scoped_refptr<AnimationPlayer> player_impl = | 439 scoped_refptr<AnimationPlayer> player_impl = |
| (...skipping 27 matching lines...) Expand all Loading... |
| 468 class LayerTreeHostAnimationTestLayerAddedWithAnimation | 467 class LayerTreeHostAnimationTestLayerAddedWithAnimation |
| 469 : public LayerTreeHostAnimationTest { | 468 : public LayerTreeHostAnimationTest { |
| 470 public: | 469 public: |
| 471 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 470 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 472 | 471 |
| 473 void DidCommit() override { | 472 void DidCommit() override { |
| 474 if (layer_tree_host()->source_frame_number() == 1) { | 473 if (layer_tree_host()->source_frame_number() == 1) { |
| 475 AttachPlayersToTimeline(); | 474 AttachPlayersToTimeline(); |
| 476 | 475 |
| 477 scoped_refptr<Layer> layer = Layer::Create(); | 476 scoped_refptr<Layer> layer = Layer::Create(); |
| 478 layer->SetElementId(ElementId(42, 0)); | 477 player_->AttachElement(layer->id()); |
| 479 player_->AttachElement(layer->element_id()); | |
| 480 player_->set_animation_delegate(this); | 478 player_->set_animation_delegate(this); |
| 481 | 479 |
| 482 // Any valid AnimationCurve will do here. | 480 // Any valid AnimationCurve will do here. |
| 483 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); | 481 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); |
| 484 std::unique_ptr<Animation> animation( | 482 std::unique_ptr<Animation> animation( |
| 485 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY)); | 483 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY)); |
| 486 player_->AddAnimation(std::move(animation)); | 484 player_->AddAnimation(std::move(animation)); |
| 487 | 485 |
| 488 // We add the animation *before* attaching the layer to the tree. | 486 // We add the animation *before* attaching the layer to the tree. |
| 489 layer_tree_host()->root_layer()->AddChild(layer); | 487 layer_tree_host()->root_layer()->AddChild(layer); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations | 618 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations |
| 621 : public LayerTreeHostAnimationTest { | 619 : public LayerTreeHostAnimationTest { |
| 622 void SetupTree() override { | 620 void SetupTree() override { |
| 623 LayerTreeHostAnimationTest::SetupTree(); | 621 LayerTreeHostAnimationTest::SetupTree(); |
| 624 picture_ = FakePictureLayer::Create(&client_); | 622 picture_ = FakePictureLayer::Create(&client_); |
| 625 picture_->SetBounds(gfx::Size(4, 4)); | 623 picture_->SetBounds(gfx::Size(4, 4)); |
| 626 client_.set_bounds(picture_->bounds()); | 624 client_.set_bounds(picture_->bounds()); |
| 627 layer_tree_host()->root_layer()->AddChild(picture_); | 625 layer_tree_host()->root_layer()->AddChild(picture_); |
| 628 | 626 |
| 629 AttachPlayersToTimeline(); | 627 AttachPlayersToTimeline(); |
| 630 player_child_->AttachElement(picture_->element_id()); | 628 player_child_->AttachElement(picture_->id()); |
| 631 player_child_->set_animation_delegate(this); | 629 player_child_->set_animation_delegate(this); |
| 632 } | 630 } |
| 633 | 631 |
| 634 void InitializeSettings(LayerTreeSettings* settings) override { | 632 void InitializeSettings(LayerTreeSettings* settings) override { |
| 635 // Make sure that drawing many times doesn't cause a checkerboarded | 633 // Make sure that drawing many times doesn't cause a checkerboarded |
| 636 // animation to start so we avoid flake in this test. | 634 // animation to start so we avoid flake in this test. |
| 637 settings->timeout_and_draw_when_animation_checkerboards = false; | 635 settings->timeout_and_draw_when_animation_checkerboards = false; |
| 638 LayerTreeHostAnimationTest::InitializeSettings(settings); | 636 LayerTreeHostAnimationTest::InitializeSettings(settings); |
| 639 } | 637 } |
| 640 | 638 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 LayerTreeHostAnimationTest::SetupTree(); | 707 LayerTreeHostAnimationTest::SetupTree(); |
| 710 | 708 |
| 711 scroll_layer_ = FakePictureLayer::Create(&client_); | 709 scroll_layer_ = FakePictureLayer::Create(&client_); |
| 712 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); | 710 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); |
| 713 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); | 711 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); |
| 714 client_.set_bounds(scroll_layer_->bounds()); | 712 client_.set_bounds(scroll_layer_->bounds()); |
| 715 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 713 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 716 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 714 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 717 | 715 |
| 718 AttachPlayersToTimeline(); | 716 AttachPlayersToTimeline(); |
| 719 player_child_->AttachElement(scroll_layer_->element_id()); | 717 player_child_->AttachElement(scroll_layer_->id()); |
| 720 } | 718 } |
| 721 | 719 |
| 722 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 720 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 723 | 721 |
| 724 void DidCommit() override { | 722 void DidCommit() override { |
| 725 switch (layer_tree_host()->source_frame_number()) { | 723 switch (layer_tree_host()->source_frame_number()) { |
| 726 case 1: { | 724 case 1: { |
| 727 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 725 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 728 ScrollOffsetAnimationCurve::Create( | 726 ScrollOffsetAnimationCurve::Create( |
| 729 gfx::ScrollOffset(500.f, 550.f), | 727 gfx::ScrollOffset(500.f, 550.f), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 void SetupTree() override { | 765 void SetupTree() override { |
| 768 LayerTreeHostAnimationTest::SetupTree(); | 766 LayerTreeHostAnimationTest::SetupTree(); |
| 769 | 767 |
| 770 scroll_layer_ = FakePictureLayer::Create(&client_); | 768 scroll_layer_ = FakePictureLayer::Create(&client_); |
| 771 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); | 769 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); |
| 772 client_.set_bounds(scroll_layer_->bounds()); | 770 client_.set_bounds(scroll_layer_->bounds()); |
| 773 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 771 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 774 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 772 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 775 | 773 |
| 776 AttachPlayersToTimeline(); | 774 AttachPlayersToTimeline(); |
| 777 player_child_->AttachElement(scroll_layer_->element_id()); | 775 player_child_->AttachElement(scroll_layer_->id()); |
| 778 // Allows NotifyAnimationTakeover to get called. | 776 // Allows NotifyAnimationTakeover to get called. |
| 779 player_child_->set_animation_delegate(this); | 777 player_child_->set_animation_delegate(this); |
| 780 } | 778 } |
| 781 | 779 |
| 782 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 780 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 783 | 781 |
| 784 void DidCommit() override { | 782 void DidCommit() override { |
| 785 if (layer_tree_host()->source_frame_number() == 1) { | 783 if (layer_tree_host()->source_frame_number() == 1) { |
| 786 // Add an update after the first commit to trigger the animation takeover | 784 // Add an update after the first commit to trigger the animation takeover |
| 787 // path. | 785 // path. |
| 788 layer_tree_host() | 786 layer_tree_host() |
| 789 ->animation_host() | 787 ->animation_host() |
| 790 ->scroll_offset_animations() | 788 ->scroll_offset_animations() |
| 791 .AddTakeoverUpdate(scroll_layer_->element_id()); | 789 .AddTakeoverUpdate(scroll_layer_->id()); |
| 792 EXPECT_TRUE(layer_tree_host() | 790 EXPECT_TRUE(layer_tree_host() |
| 793 ->animation_host() | 791 ->animation_host() |
| 794 ->scroll_offset_animations() | 792 ->scroll_offset_animations() |
| 795 .HasUpdatesForTesting()); | 793 .HasUpdatesForTesting()); |
| 796 } | 794 } |
| 797 } | 795 } |
| 798 | 796 |
| 799 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 797 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 800 if (host_impl->sync_tree()->source_frame_number() == 0) { | 798 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 801 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( | 799 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( |
| 802 scroll_layer_->element_id(), gfx::ScrollOffset(650.f, 750.f), | 800 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), |
| 803 gfx::ScrollOffset(10, 20)); | 801 gfx::ScrollOffset(10, 20)); |
| 804 } | 802 } |
| 805 } | 803 } |
| 806 | 804 |
| 807 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, | 805 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, |
| 808 TargetProperty::Type target_property, | 806 TargetProperty::Type target_property, |
| 809 double animation_start_time, | 807 double animation_start_time, |
| 810 std::unique_ptr<AnimationCurve> curve) override { | 808 std::unique_ptr<AnimationCurve> curve) override { |
| 811 EndTest(); | 809 EndTest(); |
| 812 } | 810 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 830 void SetupTree() override { | 828 void SetupTree() override { |
| 831 LayerTreeHostAnimationTest::SetupTree(); | 829 LayerTreeHostAnimationTest::SetupTree(); |
| 832 | 830 |
| 833 scroll_layer_ = FakePictureLayer::Create(&client_); | 831 scroll_layer_ = FakePictureLayer::Create(&client_); |
| 834 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); | 832 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); |
| 835 client_.set_bounds(scroll_layer_->bounds()); | 833 client_.set_bounds(scroll_layer_->bounds()); |
| 836 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 834 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 837 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 835 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 838 | 836 |
| 839 AttachPlayersToTimeline(); | 837 AttachPlayersToTimeline(); |
| 840 player_child_->AttachElement(scroll_layer_->element_id()); | 838 player_child_->AttachElement(scroll_layer_->id()); |
| 841 } | 839 } |
| 842 | 840 |
| 843 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 841 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 844 | 842 |
| 845 void DidCommit() override { | 843 void DidCommit() override { |
| 846 if (layer_tree_host()->source_frame_number() == 1) { | 844 if (layer_tree_host()->source_frame_number() == 1) { |
| 847 // Add an update after the first commit to trigger the animation update | 845 // Add an update after the first commit to trigger the animation update |
| 848 // path. | 846 // path. |
| 849 layer_tree_host() | 847 layer_tree_host() |
| 850 ->animation_host() | 848 ->animation_host() |
| 851 ->scroll_offset_animations() | 849 ->scroll_offset_animations() |
| 852 .AddAdjustmentUpdate(scroll_layer_->element_id(), | 850 .AddAdjustmentUpdate(scroll_layer_->id(), |
| 853 gfx::Vector2dF(100.f, 100.f)); | 851 gfx::Vector2dF(100.f, 100.f)); |
| 854 EXPECT_TRUE(layer_tree_host() | 852 EXPECT_TRUE(layer_tree_host() |
| 855 ->animation_host() | 853 ->animation_host() |
| 856 ->scroll_offset_animations() | 854 ->scroll_offset_animations() |
| 857 .HasUpdatesForTesting()); | 855 .HasUpdatesForTesting()); |
| 858 } else if (layer_tree_host()->source_frame_number() == 2) { | 856 } else if (layer_tree_host()->source_frame_number() == 2) { |
| 859 // Verify that the update queue is cleared after the update is applied. | 857 // Verify that the update queue is cleared after the update is applied. |
| 860 EXPECT_FALSE(layer_tree_host() | 858 EXPECT_FALSE(layer_tree_host() |
| 861 ->animation_host() | 859 ->animation_host() |
| 862 ->scroll_offset_animations() | 860 ->scroll_offset_animations() |
| 863 .HasUpdatesForTesting()); | 861 .HasUpdatesForTesting()); |
| 864 } | 862 } |
| 865 } | 863 } |
| 866 | 864 |
| 867 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | 865 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
| 868 // Note that the frame number gets incremented after BeginCommitOnThread but | 866 // Note that the frame number gets incremented after BeginCommitOnThread but |
| 869 // before WillCommitCompleteOnThread and CommitCompleteOnThread. | 867 // before WillCommitCompleteOnThread and CommitCompleteOnThread. |
| 870 if (host_impl->sync_tree()->source_frame_number() == 0) { | 868 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 871 // This happens after the impl-only animation is added in | 869 // This happens after the impl-only animation is added in |
| 872 // WillCommitCompleteOnThread. | 870 // WillCommitCompleteOnThread. |
| 873 Animation* animation = | 871 Animation* animation = |
| 874 host_impl->animation_host() | 872 host_impl->animation_host() |
| 875 ->GetElementAnimationsForElementId(scroll_layer_->element_id()) | 873 ->GetElementAnimationsForElementId(scroll_layer_->id()) |
| 876 ->GetAnimation(TargetProperty::SCROLL_OFFSET); | 874 ->GetAnimation(TargetProperty::SCROLL_OFFSET); |
| 877 ScrollOffsetAnimationCurve* curve = | 875 ScrollOffsetAnimationCurve* curve = |
| 878 animation->curve()->ToScrollOffsetAnimationCurve(); | 876 animation->curve()->ToScrollOffsetAnimationCurve(); |
| 879 | 877 |
| 880 // Verifiy the initial and target position before the scroll offset | 878 // Verifiy the initial and target position before the scroll offset |
| 881 // update from MT. | 879 // update from MT. |
| 882 EXPECT_EQ(Animation::RunState::RUNNING, animation->run_state()); | 880 EXPECT_EQ(Animation::RunState::RUNNING, animation->run_state()); |
| 883 EXPECT_EQ(gfx::ScrollOffset(10.f, 20.f), | 881 EXPECT_EQ(gfx::ScrollOffset(10.f, 20.f), |
| 884 curve->GetValue(base::TimeDelta())); | 882 curve->GetValue(base::TimeDelta())); |
| 885 EXPECT_EQ(gfx::ScrollOffset(650.f, 750.f), curve->target_value()); | 883 EXPECT_EQ(gfx::ScrollOffset(650.f, 750.f), curve->target_value()); |
| 886 } | 884 } |
| 887 } | 885 } |
| 888 | 886 |
| 889 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 887 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 890 if (host_impl->sync_tree()->source_frame_number() == 0) { | 888 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 891 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( | 889 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( |
| 892 scroll_layer_->element_id(), gfx::ScrollOffset(650.f, 750.f), | 890 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), |
| 893 gfx::ScrollOffset(10, 20)); | 891 gfx::ScrollOffset(10, 20)); |
| 894 } | 892 } |
| 895 } | 893 } |
| 896 | 894 |
| 897 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 895 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 898 if (host_impl->sync_tree()->source_frame_number() == 1) { | 896 if (host_impl->sync_tree()->source_frame_number() == 1) { |
| 899 Animation* animation = | 897 Animation* animation = |
| 900 host_impl->animation_host() | 898 host_impl->animation_host() |
| 901 ->GetElementAnimationsForElementId(scroll_layer_->element_id()) | 899 ->GetElementAnimationsForElementId(scroll_layer_->id()) |
| 902 ->GetAnimation(TargetProperty::SCROLL_OFFSET); | 900 ->GetAnimation(TargetProperty::SCROLL_OFFSET); |
| 903 ScrollOffsetAnimationCurve* curve = | 901 ScrollOffsetAnimationCurve* curve = |
| 904 animation->curve()->ToScrollOffsetAnimationCurve(); | 902 animation->curve()->ToScrollOffsetAnimationCurve(); |
| 905 // Verifiy the initial and target position after the scroll offset | 903 // Verifiy the initial and target position after the scroll offset |
| 906 // update from MT | 904 // update from MT |
| 907 EXPECT_EQ(Animation::RunState::STARTING, animation->run_state()); | 905 EXPECT_EQ(Animation::RunState::STARTING, animation->run_state()); |
| 908 EXPECT_EQ(gfx::ScrollOffset(110.f, 120.f), | 906 EXPECT_EQ(gfx::ScrollOffset(110.f, 120.f), |
| 909 curve->GetValue(base::TimeDelta())); | 907 curve->GetValue(base::TimeDelta())); |
| 910 EXPECT_EQ(gfx::ScrollOffset(750.f, 850.f), curve->target_value()); | 908 EXPECT_EQ(gfx::ScrollOffset(750.f, 850.f), curve->target_value()); |
| 911 | 909 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 943 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 946 ScrollOffsetAnimationCurve::Create( | 944 ScrollOffsetAnimationCurve::Create( |
| 947 gfx::ScrollOffset(6500.f, 7500.f), | 945 gfx::ScrollOffset(6500.f, 7500.f), |
| 948 CubicBezierTimingFunction::CreatePreset( | 946 CubicBezierTimingFunction::CreatePreset( |
| 949 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 947 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 950 std::unique_ptr<Animation> animation(Animation::Create( | 948 std::unique_ptr<Animation> animation(Animation::Create( |
| 951 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 949 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 952 animation->set_needs_synchronized_start_time(true); | 950 animation->set_needs_synchronized_start_time(true); |
| 953 | 951 |
| 954 AttachPlayersToTimeline(); | 952 AttachPlayersToTimeline(); |
| 955 player_child_->AttachElement(scroll_layer_->element_id()); | 953 player_child_->AttachElement(scroll_layer_->id()); |
| 956 player_child_->AddAnimation(std::move(animation)); | 954 player_child_->AddAnimation(std::move(animation)); |
| 957 } | 955 } |
| 958 | 956 |
| 959 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 957 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 960 | 958 |
| 961 void BeginMainFrame(const BeginFrameArgs& args) override { | 959 void BeginMainFrame(const BeginFrameArgs& args) override { |
| 962 switch (layer_tree_host()->source_frame_number()) { | 960 switch (layer_tree_host()->source_frame_number()) { |
| 963 case 0: | 961 case 0: |
| 964 break; | 962 break; |
| 965 case 1: { | 963 case 1: { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() | 1051 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() |
| 1054 : frame_count_with_pending_tree_(0) {} | 1052 : frame_count_with_pending_tree_(0) {} |
| 1055 | 1053 |
| 1056 void BeginTest() override { | 1054 void BeginTest() override { |
| 1057 AttachPlayersToTimeline(); | 1055 AttachPlayersToTimeline(); |
| 1058 PostSetNeedsCommitToMainThread(); | 1056 PostSetNeedsCommitToMainThread(); |
| 1059 } | 1057 } |
| 1060 | 1058 |
| 1061 void DidCommit() override { | 1059 void DidCommit() override { |
| 1062 if (layer_tree_host()->source_frame_number() == 1) { | 1060 if (layer_tree_host()->source_frame_number() == 1) { |
| 1063 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 1061 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 1064 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); | 1062 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); |
| 1065 } else if (layer_tree_host()->source_frame_number() == 2) { | 1063 } else if (layer_tree_host()->source_frame_number() == 2) { |
| 1066 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); | 1064 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); |
| 1067 | 1065 |
| 1068 scoped_refptr<Layer> layer = Layer::Create(); | 1066 scoped_refptr<Layer> layer = Layer::Create(); |
| 1069 layer_tree_host()->root_layer()->AddChild(layer); | 1067 layer_tree_host()->root_layer()->AddChild(layer); |
| 1070 | |
| 1071 layer_tree_host()->SetElementIdsForTesting(); | |
| 1072 layer->SetBounds(gfx::Size(4, 4)); | 1068 layer->SetBounds(gfx::Size(4, 4)); |
| 1073 | 1069 |
| 1074 player_child_->AttachElement(layer->element_id()); | 1070 player_child_->AttachElement(layer->id()); |
| 1075 player_child_->set_animation_delegate(this); | 1071 player_child_->set_animation_delegate(this); |
| 1076 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); | 1072 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); |
| 1077 } | 1073 } |
| 1078 } | 1074 } |
| 1079 | 1075 |
| 1080 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | 1076 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
| 1081 host_impl->BlockNotifyReadyToActivateForTesting(true); | 1077 host_impl->BlockNotifyReadyToActivateForTesting(true); |
| 1082 } | 1078 } |
| 1083 | 1079 |
| 1084 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1080 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 | 1148 |
| 1153 layer_ = FakePictureLayer::Create(&client_); | 1149 layer_ = FakePictureLayer::Create(&client_); |
| 1154 layer_->SetBounds(gfx::Size(2, 2)); | 1150 layer_->SetBounds(gfx::Size(2, 2)); |
| 1155 client_.set_bounds(layer_->bounds()); | 1151 client_.set_bounds(layer_->bounds()); |
| 1156 // Transform the layer to 4,4 to start. | 1152 // Transform the layer to 4,4 to start. |
| 1157 gfx::Transform start_transform; | 1153 gfx::Transform start_transform; |
| 1158 start_transform.Translate(4.0, 4.0); | 1154 start_transform.Translate(4.0, 4.0); |
| 1159 layer_->SetTransform(start_transform); | 1155 layer_->SetTransform(start_transform); |
| 1160 | 1156 |
| 1161 layer_tree_host()->root_layer()->AddChild(layer_); | 1157 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1162 layer_tree_host()->SetElementIdsForTesting(); | 1158 player_->AttachElement(layer_->id()); |
| 1163 | |
| 1164 player_->AttachElement(layer_->element_id()); | |
| 1165 | 1159 |
| 1166 AttachPlayersToTimeline(); | 1160 AttachPlayersToTimeline(); |
| 1167 } | 1161 } |
| 1168 | 1162 |
| 1169 void BeginTest() override { | 1163 void BeginTest() override { |
| 1170 // Add a translate from 6,7 to 8,9. | 1164 // Add a translate from 6,7 to 8,9. |
| 1171 TransformOperations start; | 1165 TransformOperations start; |
| 1172 start.AppendTranslate(6.f, 7.f, 0.f); | 1166 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1173 TransformOperations end; | 1167 TransformOperations end; |
| 1174 end.AppendTranslate(8.f, 9.f, 0.f); | 1168 end.AppendTranslate(8.f, 9.f, 0.f); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 // the animation should resume. | 1218 // the animation should resume. |
| 1225 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded | 1219 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded |
| 1226 : public LayerTreeHostAnimationTest { | 1220 : public LayerTreeHostAnimationTest { |
| 1227 public: | 1221 public: |
| 1228 void SetupTree() override { | 1222 void SetupTree() override { |
| 1229 LayerTreeHostAnimationTest::SetupTree(); | 1223 LayerTreeHostAnimationTest::SetupTree(); |
| 1230 layer_ = Layer::Create(); | 1224 layer_ = Layer::Create(); |
| 1231 layer_->SetBounds(gfx::Size(4, 4)); | 1225 layer_->SetBounds(gfx::Size(4, 4)); |
| 1232 layer_tree_host()->root_layer()->AddChild(layer_); | 1226 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1233 | 1227 |
| 1234 layer_tree_host()->SetElementIdsForTesting(); | |
| 1235 | |
| 1236 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); | 1228 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); |
| 1237 timeline_->AttachPlayer(player_.get()); | 1229 timeline_->AttachPlayer(player_.get()); |
| 1238 player_->AttachElement(layer_->element_id()); | 1230 player_->AttachElement(layer_->id()); |
| 1239 DCHECK(player_->element_animations()); | 1231 DCHECK(player_->element_animations()); |
| 1240 | 1232 |
| 1241 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); | 1233 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); |
| 1242 } | 1234 } |
| 1243 | 1235 |
| 1244 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1236 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1245 | 1237 |
| 1246 void DidCommit() override { | 1238 void DidCommit() override { |
| 1247 switch (layer_tree_host()->source_frame_number()) { | 1239 switch (layer_tree_host()->source_frame_number()) { |
| 1248 case 0: | 1240 case 0: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 : public LayerTreeHostAnimationTest { | 1302 : public LayerTreeHostAnimationTest { |
| 1311 public: | 1303 public: |
| 1312 void SetupTree() override { | 1304 void SetupTree() override { |
| 1313 LayerTreeHostAnimationTest::SetupTree(); | 1305 LayerTreeHostAnimationTest::SetupTree(); |
| 1314 layer_ = Layer::Create(); | 1306 layer_ = Layer::Create(); |
| 1315 layer_->SetBounds(gfx::Size(4, 4)); | 1307 layer_->SetBounds(gfx::Size(4, 4)); |
| 1316 layer_tree_host()->root_layer()->AddChild(layer_); | 1308 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1317 | 1309 |
| 1318 AttachPlayersToTimeline(); | 1310 AttachPlayersToTimeline(); |
| 1319 | 1311 |
| 1320 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 1312 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 1321 player_child_->AttachElement(layer_->element_id()); | 1313 player_child_->AttachElement(layer_->id()); |
| 1322 } | 1314 } |
| 1323 | 1315 |
| 1324 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1316 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1325 | 1317 |
| 1326 void DidCommit() override { | 1318 void DidCommit() override { |
| 1327 switch (layer_tree_host()->source_frame_number()) { | 1319 switch (layer_tree_host()->source_frame_number()) { |
| 1328 case 1: | 1320 case 1: |
| 1329 // First frame: add an animation to the root layer. | 1321 // First frame: add an animation to the root layer. |
| 1330 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5); | 1322 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5); |
| 1331 break; | 1323 break; |
| 1332 case 2: | 1324 case 2: |
| 1333 // Second frame: add an animation to the content layer. The root layer | 1325 // Second frame: add an animation to the content layer. The root layer |
| 1334 // animation has caused us to animate already during this frame. | 1326 // animation has caused us to animate already during this frame. |
| 1335 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false); | 1327 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false); |
| 1336 break; | 1328 break; |
| 1337 } | 1329 } |
| 1338 } | 1330 } |
| 1339 | 1331 |
| 1340 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { | 1332 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { |
| 1341 // After both animations have started, verify that they have valid | 1333 // After both animations have started, verify that they have valid |
| 1342 // start times. | 1334 // start times. |
| 1343 if (host_impl->active_tree()->source_frame_number() < 2) | 1335 if (host_impl->active_tree()->source_frame_number() < 2) |
| 1344 return; | 1336 return; |
| 1345 AnimationHost::ElementToAnimationsMap element_animations_copy = | 1337 AnimationHost::ElementToAnimationsMap element_animations_copy = |
| 1346 host_impl->animation_host()->active_element_animations_for_testing(); | 1338 host_impl->animation_host()->active_element_animations_for_testing(); |
| 1347 EXPECT_EQ(2u, element_animations_copy.size()); | 1339 EXPECT_EQ(2u, element_animations_copy.size()); |
| 1348 for (auto& it : element_animations_copy) { | 1340 for (auto& it : element_animations_copy) { |
| 1349 ElementId id = it.first; | 1341 int id = it.first; |
| 1350 if (id == host_impl->RootLayer()->element_id()) { | 1342 if (id == host_impl->RootLayer()->id()) { |
| 1351 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM); | 1343 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM); |
| 1352 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 1344 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
| 1353 } else if (id == layer_->element_id()) { | 1345 } else if (id == layer_->id()) { |
| 1354 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY); | 1346 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY); |
| 1355 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 1347 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
| 1356 } | 1348 } |
| 1357 EndTest(); | 1349 EndTest(); |
| 1358 } | 1350 } |
| 1359 } | 1351 } |
| 1360 | 1352 |
| 1361 void AfterTest() override {} | 1353 void AfterTest() override {} |
| 1362 | 1354 |
| 1363 private: | 1355 private: |
| 1364 scoped_refptr<Layer> layer_; | 1356 scoped_refptr<Layer> layer_; |
| 1365 }; | 1357 }; |
| 1366 | 1358 |
| 1367 SINGLE_AND_MULTI_THREAD_TEST_F( | 1359 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1368 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1360 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
| 1369 | 1361 |
| 1370 class LayerTreeHostAnimationTestRemoveAnimation | 1362 class LayerTreeHostAnimationTestRemoveAnimation |
| 1371 : public LayerTreeHostAnimationTest { | 1363 : public LayerTreeHostAnimationTest { |
| 1372 public: | 1364 public: |
| 1373 void SetupTree() override { | 1365 void SetupTree() override { |
| 1374 LayerTreeHostAnimationTest::SetupTree(); | 1366 LayerTreeHostAnimationTest::SetupTree(); |
| 1375 layer_ = FakePictureLayer::Create(&client_); | 1367 layer_ = FakePictureLayer::Create(&client_); |
| 1376 layer_->SetBounds(gfx::Size(4, 4)); | 1368 layer_->SetBounds(gfx::Size(4, 4)); |
| 1377 client_.set_bounds(layer_->bounds()); | 1369 client_.set_bounds(layer_->bounds()); |
| 1378 layer_tree_host()->root_layer()->AddChild(layer_); | 1370 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1379 | 1371 |
| 1380 AttachPlayersToTimeline(); | 1372 AttachPlayersToTimeline(); |
| 1381 | 1373 |
| 1382 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 1374 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 1383 player_child_->AttachElement(layer_->element_id()); | 1375 player_child_->AttachElement(layer_->id()); |
| 1384 } | 1376 } |
| 1385 | 1377 |
| 1386 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1378 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1387 | 1379 |
| 1388 void DidCommit() override { | 1380 void DidCommit() override { |
| 1389 switch (layer_tree_host()->source_frame_number()) { | 1381 switch (layer_tree_host()->source_frame_number()) { |
| 1390 case 1: | 1382 case 1: |
| 1391 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); | 1383 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); |
| 1392 break; | 1384 break; |
| 1393 case 2: | 1385 case 2: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 : public LayerTreeHostAnimationTest { | 1443 : public LayerTreeHostAnimationTest { |
| 1452 public: | 1444 public: |
| 1453 void SetupTree() override { | 1445 void SetupTree() override { |
| 1454 LayerTreeHostAnimationTest::SetupTree(); | 1446 LayerTreeHostAnimationTest::SetupTree(); |
| 1455 layer_ = FakePictureLayer::Create(&client_); | 1447 layer_ = FakePictureLayer::Create(&client_); |
| 1456 layer_->SetBounds(gfx::Size(4, 4)); | 1448 layer_->SetBounds(gfx::Size(4, 4)); |
| 1457 client_.set_bounds(layer_->bounds()); | 1449 client_.set_bounds(layer_->bounds()); |
| 1458 layer_tree_host()->root_layer()->AddChild(layer_); | 1450 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1459 | 1451 |
| 1460 AttachPlayersToTimeline(); | 1452 AttachPlayersToTimeline(); |
| 1461 player_->AttachElement(layer_->element_id()); | 1453 player_->AttachElement(layer_->id()); |
| 1462 } | 1454 } |
| 1463 | 1455 |
| 1464 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1456 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1465 | 1457 |
| 1466 void DidCommit() override { | 1458 void DidCommit() override { |
| 1467 switch (layer_tree_host()->source_frame_number()) { | 1459 switch (layer_tree_host()->source_frame_number()) { |
| 1468 case 1: | 1460 case 1: |
| 1469 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); | 1461 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); |
| 1470 break; | 1462 break; |
| 1471 case 2: | 1463 case 2: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 | 1525 |
| 1534 void SetupTree() override { | 1526 void SetupTree() override { |
| 1535 LayerTreeHostAnimationTest::SetupTree(); | 1527 LayerTreeHostAnimationTest::SetupTree(); |
| 1536 layer_ = FakePictureLayer::Create(&client_); | 1528 layer_ = FakePictureLayer::Create(&client_); |
| 1537 layer_->SetBounds(gfx::Size(4, 4)); | 1529 layer_->SetBounds(gfx::Size(4, 4)); |
| 1538 client_.set_bounds(layer_->bounds()); | 1530 client_.set_bounds(layer_->bounds()); |
| 1539 layer_tree_host()->root_layer()->AddChild(layer_); | 1531 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1540 | 1532 |
| 1541 AttachPlayersToTimeline(); | 1533 AttachPlayersToTimeline(); |
| 1542 | 1534 |
| 1543 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 1535 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 1544 player_child_->AttachElement(layer_->element_id()); | 1536 player_child_->AttachElement(layer_->id()); |
| 1545 } | 1537 } |
| 1546 | 1538 |
| 1547 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1539 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1548 | 1540 |
| 1549 void DidCommit() override { | 1541 void DidCommit() override { |
| 1550 if (layer_tree_host()->source_frame_number() == 1) | 1542 if (layer_tree_host()->source_frame_number() == 1) |
| 1551 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5); | 1543 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5); |
| 1552 } | 1544 } |
| 1553 | 1545 |
| 1554 void WillCommit() override { | 1546 void WillCommit() override { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 : called_animation_started_(false), called_animation_finished_(false) {} | 1599 : called_animation_started_(false), called_animation_finished_(false) {} |
| 1608 | 1600 |
| 1609 void SetupTree() override { | 1601 void SetupTree() override { |
| 1610 LayerTreeHostAnimationTest::SetupTree(); | 1602 LayerTreeHostAnimationTest::SetupTree(); |
| 1611 picture_ = FakePictureLayer::Create(&client_); | 1603 picture_ = FakePictureLayer::Create(&client_); |
| 1612 picture_->SetBounds(gfx::Size(4, 4)); | 1604 picture_->SetBounds(gfx::Size(4, 4)); |
| 1613 client_.set_bounds(picture_->bounds()); | 1605 client_.set_bounds(picture_->bounds()); |
| 1614 layer_tree_host()->root_layer()->AddChild(picture_); | 1606 layer_tree_host()->root_layer()->AddChild(picture_); |
| 1615 | 1607 |
| 1616 AttachPlayersToTimeline(); | 1608 AttachPlayersToTimeline(); |
| 1617 player_->AttachElement(picture_->element_id()); | 1609 player_->AttachElement(picture_->id()); |
| 1618 player_->set_animation_delegate(this); | 1610 player_->set_animation_delegate(this); |
| 1619 } | 1611 } |
| 1620 | 1612 |
| 1621 void BeginTest() override { | 1613 void BeginTest() override { |
| 1622 PostAddLongAnimationToMainThreadPlayer(player_.get()); | 1614 PostAddLongAnimationToMainThreadPlayer(player_.get()); |
| 1623 } | 1615 } |
| 1624 | 1616 |
| 1625 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 1617 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 1626 TargetProperty::Type target_property, | 1618 TargetProperty::Type target_property, |
| 1627 int group) override { | 1619 int group) override { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1657 // if we destroy ElementAnimations. | 1649 // if we destroy ElementAnimations. |
| 1658 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction | 1650 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction |
| 1659 : public LayerTreeHostAnimationTest { | 1651 : public LayerTreeHostAnimationTest { |
| 1660 public: | 1652 public: |
| 1661 void SetupTree() override { | 1653 void SetupTree() override { |
| 1662 prev_screen_space_transform_is_animating_ = true; | 1654 prev_screen_space_transform_is_animating_ = true; |
| 1663 screen_space_transform_animation_stopped_ = false; | 1655 screen_space_transform_animation_stopped_ = false; |
| 1664 | 1656 |
| 1665 LayerTreeHostAnimationTest::SetupTree(); | 1657 LayerTreeHostAnimationTest::SetupTree(); |
| 1666 AttachPlayersToTimeline(); | 1658 AttachPlayersToTimeline(); |
| 1667 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 1659 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 1668 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); | 1660 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); |
| 1669 } | 1661 } |
| 1670 | 1662 |
| 1671 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1663 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1672 | 1664 |
| 1673 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1665 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 1674 if (host_impl->pending_tree()->source_frame_number() <= 1) { | 1666 if (host_impl->pending_tree()->source_frame_number() <= 1) { |
| 1675 EXPECT_TRUE(host_impl->pending_tree() | 1667 EXPECT_TRUE(host_impl->pending_tree() |
| 1676 ->root_layer() | 1668 ->root_layer() |
| 1677 ->screen_space_transform_is_animating()); | 1669 ->screen_space_transform_is_animating()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1741 public: | 1733 public: |
| 1742 void SetupTree() override { | 1734 void SetupTree() override { |
| 1743 LayerTreeHostAnimationTest::SetupTree(); | 1735 LayerTreeHostAnimationTest::SetupTree(); |
| 1744 layer_ = FakePictureLayer::Create(&client_); | 1736 layer_ = FakePictureLayer::Create(&client_); |
| 1745 layer_->SetBounds(gfx::Size(4, 4)); | 1737 layer_->SetBounds(gfx::Size(4, 4)); |
| 1746 client_.set_bounds(layer_->bounds()); | 1738 client_.set_bounds(layer_->bounds()); |
| 1747 layer_tree_host()->root_layer()->AddChild(layer_); | 1739 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1748 | 1740 |
| 1749 AttachPlayersToTimeline(); | 1741 AttachPlayersToTimeline(); |
| 1750 | 1742 |
| 1751 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); | 1743 player_->AttachElement(layer_tree_host()->root_layer()->id()); |
| 1752 player_child_->AttachElement(layer_->element_id()); | 1744 player_child_->AttachElement(layer_->id()); |
| 1753 } | 1745 } |
| 1754 | 1746 |
| 1755 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1747 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1756 | 1748 |
| 1757 void DidCommit() override { | 1749 void DidCommit() override { |
| 1758 if (layer_tree_host()->source_frame_number() == 1 || | 1750 if (layer_tree_host()->source_frame_number() == 1 || |
| 1759 layer_tree_host()->source_frame_number() == 2) | 1751 layer_tree_host()->source_frame_number() == 2) |
| 1760 PostSetNeedsCommitToMainThread(); | 1752 PostSetNeedsCommitToMainThread(); |
| 1761 } | 1753 } |
| 1762 | 1754 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1779 private: | 1771 private: |
| 1780 scoped_refptr<Layer> layer_; | 1772 scoped_refptr<Layer> layer_; |
| 1781 FakeContentLayerClient client_; | 1773 FakeContentLayerClient client_; |
| 1782 }; | 1774 }; |
| 1783 | 1775 |
| 1784 MULTI_THREAD_TEST_F( | 1776 MULTI_THREAD_TEST_F( |
| 1785 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1777 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1786 | 1778 |
| 1787 } // namespace | 1779 } // namespace |
| 1788 } // namespace cc | 1780 } // namespace cc |
| OLD | NEW |