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