| 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(42lu)); |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 void SetupTree() override { | 766 void SetupTree() override { |
| 765 LayerTreeHostAnimationTest::SetupTree(); | 767 LayerTreeHostAnimationTest::SetupTree(); |
| 766 | 768 |
| 767 scroll_layer_ = FakePictureLayer::Create(&client_); | 769 scroll_layer_ = FakePictureLayer::Create(&client_); |
| 768 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); | 770 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); |
| 769 client_.set_bounds(scroll_layer_->bounds()); | 771 client_.set_bounds(scroll_layer_->bounds()); |
| 770 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 772 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 771 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 773 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 772 | 774 |
| 773 AttachPlayersToTimeline(); | 775 AttachPlayersToTimeline(); |
| 774 player_child_->AttachElement(scroll_layer_->id()); | 776 player_child_->AttachElement(scroll_layer_->element_id()); |
| 775 // Allows NotifyAnimationTakeover to get called. | 777 // Allows NotifyAnimationTakeover to get called. |
| 776 player_child_->set_animation_delegate(this); | 778 player_child_->set_animation_delegate(this); |
| 777 } | 779 } |
| 778 | 780 |
| 779 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 781 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 780 | 782 |
| 781 void DidCommit() override { | 783 void DidCommit() override { |
| 782 if (layer_tree_host()->source_frame_number() == 1) { | 784 if (layer_tree_host()->source_frame_number() == 1) { |
| 783 // Add an update after the first commit to trigger the animation takeover | 785 // Add an update after the first commit to trigger the animation takeover |
| 784 // path. | 786 // path. |
| 785 layer_tree_host() | 787 layer_tree_host() |
| 786 ->animation_host() | 788 ->animation_host() |
| 787 ->scroll_offset_animations() | 789 ->scroll_offset_animations() |
| 788 .AddTakeoverUpdate(scroll_layer_->id()); | 790 .AddTakeoverUpdate(scroll_layer_->element_id()); |
| 789 EXPECT_TRUE(layer_tree_host() | 791 EXPECT_TRUE(layer_tree_host() |
| 790 ->animation_host() | 792 ->animation_host() |
| 791 ->scroll_offset_animations() | 793 ->scroll_offset_animations() |
| 792 .HasUpdatesForTesting()); | 794 .HasUpdatesForTesting()); |
| 793 } | 795 } |
| 794 } | 796 } |
| 795 | 797 |
| 796 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 798 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 797 if (host_impl->sync_tree()->source_frame_number() == 0) { | 799 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 798 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( | 800 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( |
| 799 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), | 801 scroll_layer_->element_id(), gfx::ScrollOffset(650.f, 750.f), |
| 800 gfx::ScrollOffset(10, 20)); | 802 gfx::ScrollOffset(10, 20)); |
| 801 } | 803 } |
| 802 } | 804 } |
| 803 | 805 |
| 804 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, | 806 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, |
| 805 TargetProperty::Type target_property, | 807 TargetProperty::Type target_property, |
| 806 double animation_start_time, | 808 double animation_start_time, |
| 807 std::unique_ptr<AnimationCurve> curve) override { | 809 std::unique_ptr<AnimationCurve> curve) override { |
| 808 EndTest(); | 810 EndTest(); |
| 809 } | 811 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 827 void SetupTree() override { | 829 void SetupTree() override { |
| 828 LayerTreeHostAnimationTest::SetupTree(); | 830 LayerTreeHostAnimationTest::SetupTree(); |
| 829 | 831 |
| 830 scroll_layer_ = FakePictureLayer::Create(&client_); | 832 scroll_layer_ = FakePictureLayer::Create(&client_); |
| 831 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); | 833 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); |
| 832 client_.set_bounds(scroll_layer_->bounds()); | 834 client_.set_bounds(scroll_layer_->bounds()); |
| 833 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 835 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 834 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 836 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 835 | 837 |
| 836 AttachPlayersToTimeline(); | 838 AttachPlayersToTimeline(); |
| 837 player_child_->AttachElement(scroll_layer_->id()); | 839 player_child_->AttachElement(scroll_layer_->element_id()); |
| 838 } | 840 } |
| 839 | 841 |
| 840 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 842 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 841 | 843 |
| 842 void DidCommit() override { | 844 void DidCommit() override { |
| 843 if (layer_tree_host()->source_frame_number() == 1) { | 845 if (layer_tree_host()->source_frame_number() == 1) { |
| 844 // Add an update after the first commit to trigger the animation update | 846 // Add an update after the first commit to trigger the animation update |
| 845 // path. | 847 // path. |
| 846 layer_tree_host() | 848 layer_tree_host() |
| 847 ->animation_host() | 849 ->animation_host() |
| 848 ->scroll_offset_animations() | 850 ->scroll_offset_animations() |
| 849 .AddAdjustmentUpdate(scroll_layer_->id(), | 851 .AddAdjustmentUpdate(scroll_layer_->element_id(), |
| 850 gfx::Vector2dF(100.f, 100.f)); | 852 gfx::Vector2dF(100.f, 100.f)); |
| 851 EXPECT_TRUE(layer_tree_host() | 853 EXPECT_TRUE(layer_tree_host() |
| 852 ->animation_host() | 854 ->animation_host() |
| 853 ->scroll_offset_animations() | 855 ->scroll_offset_animations() |
| 854 .HasUpdatesForTesting()); | 856 .HasUpdatesForTesting()); |
| 855 } else if (layer_tree_host()->source_frame_number() == 2) { | 857 } else if (layer_tree_host()->source_frame_number() == 2) { |
| 856 // Verify that the update queue is cleared after the update is applied. | 858 // Verify that the update queue is cleared after the update is applied. |
| 857 EXPECT_FALSE(layer_tree_host() | 859 EXPECT_FALSE(layer_tree_host() |
| 858 ->animation_host() | 860 ->animation_host() |
| 859 ->scroll_offset_animations() | 861 ->scroll_offset_animations() |
| 860 .HasUpdatesForTesting()); | 862 .HasUpdatesForTesting()); |
| 861 } | 863 } |
| 862 } | 864 } |
| 863 | 865 |
| 864 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | 866 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
| 865 // Note that the frame number gets incremented after BeginCommitOnThread but | 867 // Note that the frame number gets incremented after BeginCommitOnThread but |
| 866 // before WillCommitCompleteOnThread and CommitCompleteOnThread. | 868 // before WillCommitCompleteOnThread and CommitCompleteOnThread. |
| 867 if (host_impl->sync_tree()->source_frame_number() == 0) { | 869 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 868 // This happens after the impl-only animation is added in | 870 // This happens after the impl-only animation is added in |
| 869 // WillCommitCompleteOnThread. | 871 // WillCommitCompleteOnThread. |
| 870 Animation* animation = | 872 Animation* animation = |
| 871 host_impl->animation_host() | 873 host_impl->animation_host() |
| 872 ->GetElementAnimationsForElementId(scroll_layer_->id()) | 874 ->GetElementAnimationsForElementId(scroll_layer_->element_id()) |
| 873 ->GetAnimation(TargetProperty::SCROLL_OFFSET); | 875 ->GetAnimation(TargetProperty::SCROLL_OFFSET); |
| 874 ScrollOffsetAnimationCurve* curve = | 876 ScrollOffsetAnimationCurve* curve = |
| 875 animation->curve()->ToScrollOffsetAnimationCurve(); | 877 animation->curve()->ToScrollOffsetAnimationCurve(); |
| 876 | 878 |
| 877 // Verifiy the initial and target position before the scroll offset | 879 // Verifiy the initial and target position before the scroll offset |
| 878 // update from MT. | 880 // update from MT. |
| 879 EXPECT_EQ(Animation::RunState::RUNNING, animation->run_state()); | 881 EXPECT_EQ(Animation::RunState::RUNNING, animation->run_state()); |
| 880 EXPECT_EQ(gfx::ScrollOffset(10.f, 20.f), | 882 EXPECT_EQ(gfx::ScrollOffset(10.f, 20.f), |
| 881 curve->GetValue(base::TimeDelta())); | 883 curve->GetValue(base::TimeDelta())); |
| 882 EXPECT_EQ(gfx::ScrollOffset(650.f, 750.f), curve->target_value()); | 884 EXPECT_EQ(gfx::ScrollOffset(650.f, 750.f), curve->target_value()); |
| 883 } | 885 } |
| 884 } | 886 } |
| 885 | 887 |
| 886 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 888 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 887 if (host_impl->sync_tree()->source_frame_number() == 0) { | 889 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 888 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( | 890 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( |
| 889 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), | 891 scroll_layer_->element_id(), gfx::ScrollOffset(650.f, 750.f), |
| 890 gfx::ScrollOffset(10, 20)); | 892 gfx::ScrollOffset(10, 20)); |
| 891 } | 893 } |
| 892 } | 894 } |
| 893 | 895 |
| 894 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 896 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 895 if (host_impl->sync_tree()->source_frame_number() == 1) { | 897 if (host_impl->sync_tree()->source_frame_number() == 1) { |
| 896 Animation* animation = | 898 Animation* animation = |
| 897 host_impl->animation_host() | 899 host_impl->animation_host() |
| 898 ->GetElementAnimationsForElementId(scroll_layer_->id()) | 900 ->GetElementAnimationsForElementId(scroll_layer_->element_id()) |
| 899 ->GetAnimation(TargetProperty::SCROLL_OFFSET); | 901 ->GetAnimation(TargetProperty::SCROLL_OFFSET); |
| 900 ScrollOffsetAnimationCurve* curve = | 902 ScrollOffsetAnimationCurve* curve = |
| 901 animation->curve()->ToScrollOffsetAnimationCurve(); | 903 animation->curve()->ToScrollOffsetAnimationCurve(); |
| 902 // Verifiy the initial and target position after the scroll offset | 904 // Verifiy the initial and target position after the scroll offset |
| 903 // update from MT | 905 // update from MT |
| 904 EXPECT_EQ(Animation::RunState::STARTING, animation->run_state()); | 906 EXPECT_EQ(Animation::RunState::STARTING, animation->run_state()); |
| 905 EXPECT_EQ(gfx::ScrollOffset(110.f, 120.f), | 907 EXPECT_EQ(gfx::ScrollOffset(110.f, 120.f), |
| 906 curve->GetValue(base::TimeDelta())); | 908 curve->GetValue(base::TimeDelta())); |
| 907 EXPECT_EQ(gfx::ScrollOffset(750.f, 850.f), curve->target_value()); | 909 EXPECT_EQ(gfx::ScrollOffset(750.f, 850.f), curve->target_value()); |
| 908 | 910 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 942 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 941 | 943 |
| 942 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 944 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 943 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f), | 945 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f), |
| 944 EaseInOutTimingFunction::Create())); | 946 EaseInOutTimingFunction::Create())); |
| 945 std::unique_ptr<Animation> animation(Animation::Create( | 947 std::unique_ptr<Animation> animation(Animation::Create( |
| 946 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 948 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 947 animation->set_needs_synchronized_start_time(true); | 949 animation->set_needs_synchronized_start_time(true); |
| 948 | 950 |
| 949 AttachPlayersToTimeline(); | 951 AttachPlayersToTimeline(); |
| 950 player_child_->AttachElement(scroll_layer_->id()); | 952 player_child_->AttachElement(scroll_layer_->element_id()); |
| 951 player_child_->AddAnimation(std::move(animation)); | 953 player_child_->AddAnimation(std::move(animation)); |
| 952 } | 954 } |
| 953 | 955 |
| 954 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 956 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 955 | 957 |
| 956 void BeginMainFrame(const BeginFrameArgs& args) override { | 958 void BeginMainFrame(const BeginFrameArgs& args) override { |
| 957 switch (layer_tree_host()->source_frame_number()) { | 959 switch (layer_tree_host()->source_frame_number()) { |
| 958 case 0: | 960 case 0: |
| 959 break; | 961 break; |
| 960 case 1: { | 962 case 1: { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() | 1050 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() |
| 1049 : frame_count_with_pending_tree_(0) {} | 1051 : frame_count_with_pending_tree_(0) {} |
| 1050 | 1052 |
| 1051 void BeginTest() override { | 1053 void BeginTest() override { |
| 1052 AttachPlayersToTimeline(); | 1054 AttachPlayersToTimeline(); |
| 1053 PostSetNeedsCommitToMainThread(); | 1055 PostSetNeedsCommitToMainThread(); |
| 1054 } | 1056 } |
| 1055 | 1057 |
| 1056 void DidCommit() override { | 1058 void DidCommit() override { |
| 1057 if (layer_tree_host()->source_frame_number() == 1) { | 1059 if (layer_tree_host()->source_frame_number() == 1) { |
| 1058 player_->AttachElement(layer_tree_host()->root_layer()->id()); | 1060 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
| 1059 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); | 1061 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); |
| 1060 } else if (layer_tree_host()->source_frame_number() == 2) { | 1062 } else if (layer_tree_host()->source_frame_number() == 2) { |
| 1061 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); | 1063 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); |
| 1062 | 1064 |
| 1063 scoped_refptr<Layer> layer = Layer::Create(); | 1065 scoped_refptr<Layer> layer = Layer::Create(); |
| 1064 layer_tree_host()->root_layer()->AddChild(layer); | 1066 layer_tree_host()->root_layer()->AddChild(layer); |
| 1067 |
| 1068 layer_tree_host()->SetElementIdsForTesting(); |
| 1065 layer->SetBounds(gfx::Size(4, 4)); | 1069 layer->SetBounds(gfx::Size(4, 4)); |
| 1066 | 1070 |
| 1067 player_child_->AttachElement(layer->id()); | 1071 player_child_->AttachElement(layer->element_id()); |
| 1068 player_child_->set_animation_delegate(this); | 1072 player_child_->set_animation_delegate(this); |
| 1069 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); | 1073 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); |
| 1070 } | 1074 } |
| 1071 } | 1075 } |
| 1072 | 1076 |
| 1073 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | 1077 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
| 1074 host_impl->BlockNotifyReadyToActivateForTesting(true); | 1078 host_impl->BlockNotifyReadyToActivateForTesting(true); |
| 1075 } | 1079 } |
| 1076 | 1080 |
| 1077 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1081 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 | 1149 |
| 1146 layer_ = FakePictureLayer::Create(&client_); | 1150 layer_ = FakePictureLayer::Create(&client_); |
| 1147 layer_->SetBounds(gfx::Size(2, 2)); | 1151 layer_->SetBounds(gfx::Size(2, 2)); |
| 1148 client_.set_bounds(layer_->bounds()); | 1152 client_.set_bounds(layer_->bounds()); |
| 1149 // Transform the layer to 4,4 to start. | 1153 // Transform the layer to 4,4 to start. |
| 1150 gfx::Transform start_transform; | 1154 gfx::Transform start_transform; |
| 1151 start_transform.Translate(4.0, 4.0); | 1155 start_transform.Translate(4.0, 4.0); |
| 1152 layer_->SetTransform(start_transform); | 1156 layer_->SetTransform(start_transform); |
| 1153 | 1157 |
| 1154 layer_tree_host()->root_layer()->AddChild(layer_); | 1158 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1155 player_->AttachElement(layer_->id()); | 1159 layer_tree_host()->SetElementIdsForTesting(); |
| 1160 |
| 1161 player_->AttachElement(layer_->element_id()); |
| 1156 | 1162 |
| 1157 AttachPlayersToTimeline(); | 1163 AttachPlayersToTimeline(); |
| 1158 } | 1164 } |
| 1159 | 1165 |
| 1160 void BeginTest() override { | 1166 void BeginTest() override { |
| 1161 // Add a translate from 6,7 to 8,9. | 1167 // Add a translate from 6,7 to 8,9. |
| 1162 TransformOperations start; | 1168 TransformOperations start; |
| 1163 start.AppendTranslate(6.f, 7.f, 0.f); | 1169 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1164 TransformOperations end; | 1170 TransformOperations end; |
| 1165 end.AppendTranslate(8.f, 9.f, 0.f); | 1171 end.AppendTranslate(8.f, 9.f, 0.f); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 // the animation should resume. | 1221 // the animation should resume. |
| 1216 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded | 1222 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded |
| 1217 : public LayerTreeHostAnimationTest { | 1223 : public LayerTreeHostAnimationTest { |
| 1218 public: | 1224 public: |
| 1219 void SetupTree() override { | 1225 void SetupTree() override { |
| 1220 LayerTreeHostAnimationTest::SetupTree(); | 1226 LayerTreeHostAnimationTest::SetupTree(); |
| 1221 layer_ = Layer::Create(); | 1227 layer_ = Layer::Create(); |
| 1222 layer_->SetBounds(gfx::Size(4, 4)); | 1228 layer_->SetBounds(gfx::Size(4, 4)); |
| 1223 layer_tree_host()->root_layer()->AddChild(layer_); | 1229 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1224 | 1230 |
| 1231 layer_tree_host()->SetElementIdsForTesting(); |
| 1232 |
| 1225 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); | 1233 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); |
| 1226 timeline_->AttachPlayer(player_.get()); | 1234 timeline_->AttachPlayer(player_.get()); |
| 1227 player_->AttachElement(layer_->id()); | 1235 player_->AttachElement(layer_->element_id()); |
| 1228 DCHECK(player_->element_animations()); | 1236 DCHECK(player_->element_animations()); |
| 1229 | 1237 |
| 1230 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); | 1238 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); |
| 1231 } | 1239 } |
| 1232 | 1240 |
| 1233 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1241 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1234 | 1242 |
| 1235 void DidCommit() override { | 1243 void DidCommit() override { |
| 1236 switch (layer_tree_host()->source_frame_number()) { | 1244 switch (layer_tree_host()->source_frame_number()) { |
| 1237 case 0: | 1245 case 0: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 : public LayerTreeHostAnimationTest { | 1307 : public LayerTreeHostAnimationTest { |
| 1300 public: | 1308 public: |
| 1301 void SetupTree() override { | 1309 void SetupTree() override { |
| 1302 LayerTreeHostAnimationTest::SetupTree(); | 1310 LayerTreeHostAnimationTest::SetupTree(); |
| 1303 layer_ = Layer::Create(); | 1311 layer_ = Layer::Create(); |
| 1304 layer_->SetBounds(gfx::Size(4, 4)); | 1312 layer_->SetBounds(gfx::Size(4, 4)); |
| 1305 layer_tree_host()->root_layer()->AddChild(layer_); | 1313 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1306 | 1314 |
| 1307 AttachPlayersToTimeline(); | 1315 AttachPlayersToTimeline(); |
| 1308 | 1316 |
| 1309 player_->AttachElement(layer_tree_host()->root_layer()->id()); | 1317 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
| 1310 player_child_->AttachElement(layer_->id()); | 1318 player_child_->AttachElement(layer_->element_id()); |
| 1311 } | 1319 } |
| 1312 | 1320 |
| 1313 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1321 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1314 | 1322 |
| 1315 void DidCommit() override { | 1323 void DidCommit() override { |
| 1316 switch (layer_tree_host()->source_frame_number()) { | 1324 switch (layer_tree_host()->source_frame_number()) { |
| 1317 case 1: | 1325 case 1: |
| 1318 // First frame: add an animation to the root layer. | 1326 // First frame: add an animation to the root layer. |
| 1319 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5); | 1327 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5); |
| 1320 break; | 1328 break; |
| 1321 case 2: | 1329 case 2: |
| 1322 // Second frame: add an animation to the content layer. The root layer | 1330 // Second frame: add an animation to the content layer. The root layer |
| 1323 // animation has caused us to animate already during this frame. | 1331 // animation has caused us to animate already during this frame. |
| 1324 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false); | 1332 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false); |
| 1325 break; | 1333 break; |
| 1326 } | 1334 } |
| 1327 } | 1335 } |
| 1328 | 1336 |
| 1329 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { | 1337 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { |
| 1330 // After both animations have started, verify that they have valid | 1338 // After both animations have started, verify that they have valid |
| 1331 // start times. | 1339 // start times. |
| 1332 if (host_impl->active_tree()->source_frame_number() < 2) | 1340 if (host_impl->active_tree()->source_frame_number() < 2) |
| 1333 return; | 1341 return; |
| 1334 AnimationHost::ElementToAnimationsMap element_animations_copy = | 1342 AnimationHost::ElementToAnimationsMap element_animations_copy = |
| 1335 host_impl->animation_host()->active_element_animations_for_testing(); | 1343 host_impl->animation_host()->active_element_animations_for_testing(); |
| 1336 EXPECT_EQ(2u, element_animations_copy.size()); | 1344 EXPECT_EQ(2u, element_animations_copy.size()); |
| 1337 for (auto& it : element_animations_copy) { | 1345 for (auto& it : element_animations_copy) { |
| 1338 int id = it.first; | 1346 ElementId id = it.first; |
| 1339 if (id == host_impl->RootLayer()->id()) { | 1347 if (id == host_impl->RootLayer()->element_id()) { |
| 1340 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM); | 1348 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM); |
| 1341 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 1349 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
| 1342 } else if (id == layer_->id()) { | 1350 } else if (id == layer_->element_id()) { |
| 1343 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY); | 1351 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY); |
| 1344 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 1352 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
| 1345 } | 1353 } |
| 1346 EndTest(); | 1354 EndTest(); |
| 1347 } | 1355 } |
| 1348 } | 1356 } |
| 1349 | 1357 |
| 1350 void AfterTest() override {} | 1358 void AfterTest() override {} |
| 1351 | 1359 |
| 1352 private: | 1360 private: |
| 1353 scoped_refptr<Layer> layer_; | 1361 scoped_refptr<Layer> layer_; |
| 1354 }; | 1362 }; |
| 1355 | 1363 |
| 1356 SINGLE_AND_MULTI_THREAD_TEST_F( | 1364 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1357 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1365 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
| 1358 | 1366 |
| 1359 class LayerTreeHostAnimationTestRemoveAnimation | 1367 class LayerTreeHostAnimationTestRemoveAnimation |
| 1360 : public LayerTreeHostAnimationTest { | 1368 : public LayerTreeHostAnimationTest { |
| 1361 public: | 1369 public: |
| 1362 void SetupTree() override { | 1370 void SetupTree() override { |
| 1363 LayerTreeHostAnimationTest::SetupTree(); | 1371 LayerTreeHostAnimationTest::SetupTree(); |
| 1364 layer_ = FakePictureLayer::Create(&client_); | 1372 layer_ = FakePictureLayer::Create(&client_); |
| 1365 layer_->SetBounds(gfx::Size(4, 4)); | 1373 layer_->SetBounds(gfx::Size(4, 4)); |
| 1366 client_.set_bounds(layer_->bounds()); | 1374 client_.set_bounds(layer_->bounds()); |
| 1367 layer_tree_host()->root_layer()->AddChild(layer_); | 1375 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1368 | 1376 |
| 1369 AttachPlayersToTimeline(); | 1377 AttachPlayersToTimeline(); |
| 1370 | 1378 |
| 1371 player_->AttachElement(layer_tree_host()->root_layer()->id()); | 1379 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
| 1372 player_child_->AttachElement(layer_->id()); | 1380 player_child_->AttachElement(layer_->element_id()); |
| 1373 } | 1381 } |
| 1374 | 1382 |
| 1375 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1383 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1376 | 1384 |
| 1377 void DidCommit() override { | 1385 void DidCommit() override { |
| 1378 switch (layer_tree_host()->source_frame_number()) { | 1386 switch (layer_tree_host()->source_frame_number()) { |
| 1379 case 1: | 1387 case 1: |
| 1380 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); | 1388 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); |
| 1381 break; | 1389 break; |
| 1382 case 2: | 1390 case 2: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 : public LayerTreeHostAnimationTest { | 1448 : public LayerTreeHostAnimationTest { |
| 1441 public: | 1449 public: |
| 1442 void SetupTree() override { | 1450 void SetupTree() override { |
| 1443 LayerTreeHostAnimationTest::SetupTree(); | 1451 LayerTreeHostAnimationTest::SetupTree(); |
| 1444 layer_ = FakePictureLayer::Create(&client_); | 1452 layer_ = FakePictureLayer::Create(&client_); |
| 1445 layer_->SetBounds(gfx::Size(4, 4)); | 1453 layer_->SetBounds(gfx::Size(4, 4)); |
| 1446 client_.set_bounds(layer_->bounds()); | 1454 client_.set_bounds(layer_->bounds()); |
| 1447 layer_tree_host()->root_layer()->AddChild(layer_); | 1455 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1448 | 1456 |
| 1449 AttachPlayersToTimeline(); | 1457 AttachPlayersToTimeline(); |
| 1450 player_->AttachElement(layer_->id()); | 1458 player_->AttachElement(layer_->element_id()); |
| 1451 } | 1459 } |
| 1452 | 1460 |
| 1453 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1461 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1454 | 1462 |
| 1455 void DidCommit() override { | 1463 void DidCommit() override { |
| 1456 switch (layer_tree_host()->source_frame_number()) { | 1464 switch (layer_tree_host()->source_frame_number()) { |
| 1457 case 1: | 1465 case 1: |
| 1458 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); | 1466 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); |
| 1459 break; | 1467 break; |
| 1460 case 2: | 1468 case 2: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 | 1530 |
| 1523 void SetupTree() override { | 1531 void SetupTree() override { |
| 1524 LayerTreeHostAnimationTest::SetupTree(); | 1532 LayerTreeHostAnimationTest::SetupTree(); |
| 1525 layer_ = FakePictureLayer::Create(&client_); | 1533 layer_ = FakePictureLayer::Create(&client_); |
| 1526 layer_->SetBounds(gfx::Size(4, 4)); | 1534 layer_->SetBounds(gfx::Size(4, 4)); |
| 1527 client_.set_bounds(layer_->bounds()); | 1535 client_.set_bounds(layer_->bounds()); |
| 1528 layer_tree_host()->root_layer()->AddChild(layer_); | 1536 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1529 | 1537 |
| 1530 AttachPlayersToTimeline(); | 1538 AttachPlayersToTimeline(); |
| 1531 | 1539 |
| 1532 player_->AttachElement(layer_tree_host()->root_layer()->id()); | 1540 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
| 1533 player_child_->AttachElement(layer_->id()); | 1541 player_child_->AttachElement(layer_->element_id()); |
| 1534 } | 1542 } |
| 1535 | 1543 |
| 1536 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1544 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1537 | 1545 |
| 1538 void DidCommit() override { | 1546 void DidCommit() override { |
| 1539 if (layer_tree_host()->source_frame_number() == 1) | 1547 if (layer_tree_host()->source_frame_number() == 1) |
| 1540 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5); | 1548 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5); |
| 1541 } | 1549 } |
| 1542 | 1550 |
| 1543 void WillCommit() override { | 1551 void WillCommit() override { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 : called_animation_started_(false), called_animation_finished_(false) {} | 1604 : called_animation_started_(false), called_animation_finished_(false) {} |
| 1597 | 1605 |
| 1598 void SetupTree() override { | 1606 void SetupTree() override { |
| 1599 LayerTreeHostAnimationTest::SetupTree(); | 1607 LayerTreeHostAnimationTest::SetupTree(); |
| 1600 picture_ = FakePictureLayer::Create(&client_); | 1608 picture_ = FakePictureLayer::Create(&client_); |
| 1601 picture_->SetBounds(gfx::Size(4, 4)); | 1609 picture_->SetBounds(gfx::Size(4, 4)); |
| 1602 client_.set_bounds(picture_->bounds()); | 1610 client_.set_bounds(picture_->bounds()); |
| 1603 layer_tree_host()->root_layer()->AddChild(picture_); | 1611 layer_tree_host()->root_layer()->AddChild(picture_); |
| 1604 | 1612 |
| 1605 AttachPlayersToTimeline(); | 1613 AttachPlayersToTimeline(); |
| 1606 player_->AttachElement(picture_->id()); | 1614 player_->AttachElement(picture_->element_id()); |
| 1607 player_->set_animation_delegate(this); | 1615 player_->set_animation_delegate(this); |
| 1608 } | 1616 } |
| 1609 | 1617 |
| 1610 void BeginTest() override { | 1618 void BeginTest() override { |
| 1611 PostAddLongAnimationToMainThreadPlayer(player_.get()); | 1619 PostAddLongAnimationToMainThreadPlayer(player_.get()); |
| 1612 } | 1620 } |
| 1613 | 1621 |
| 1614 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 1622 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 1615 TargetProperty::Type target_property, | 1623 TargetProperty::Type target_property, |
| 1616 int group) override { | 1624 int group) override { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1646 // if we destroy ElementAnimations. | 1654 // if we destroy ElementAnimations. |
| 1647 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction | 1655 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction |
| 1648 : public LayerTreeHostAnimationTest { | 1656 : public LayerTreeHostAnimationTest { |
| 1649 public: | 1657 public: |
| 1650 void SetupTree() override { | 1658 void SetupTree() override { |
| 1651 prev_screen_space_transform_is_animating_ = true; | 1659 prev_screen_space_transform_is_animating_ = true; |
| 1652 screen_space_transform_animation_stopped_ = false; | 1660 screen_space_transform_animation_stopped_ = false; |
| 1653 | 1661 |
| 1654 LayerTreeHostAnimationTest::SetupTree(); | 1662 LayerTreeHostAnimationTest::SetupTree(); |
| 1655 AttachPlayersToTimeline(); | 1663 AttachPlayersToTimeline(); |
| 1656 player_->AttachElement(layer_tree_host()->root_layer()->id()); | 1664 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
| 1657 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); | 1665 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); |
| 1658 } | 1666 } |
| 1659 | 1667 |
| 1660 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1668 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1661 | 1669 |
| 1662 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1670 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 1663 if (host_impl->pending_tree()->source_frame_number() <= 1) { | 1671 if (host_impl->pending_tree()->source_frame_number() <= 1) { |
| 1664 EXPECT_TRUE(host_impl->pending_tree() | 1672 EXPECT_TRUE(host_impl->pending_tree() |
| 1665 ->root_layer() | 1673 ->root_layer() |
| 1666 ->screen_space_transform_is_animating()); | 1674 ->screen_space_transform_is_animating()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 public: | 1738 public: |
| 1731 void SetupTree() override { | 1739 void SetupTree() override { |
| 1732 LayerTreeHostAnimationTest::SetupTree(); | 1740 LayerTreeHostAnimationTest::SetupTree(); |
| 1733 layer_ = FakePictureLayer::Create(&client_); | 1741 layer_ = FakePictureLayer::Create(&client_); |
| 1734 layer_->SetBounds(gfx::Size(4, 4)); | 1742 layer_->SetBounds(gfx::Size(4, 4)); |
| 1735 client_.set_bounds(layer_->bounds()); | 1743 client_.set_bounds(layer_->bounds()); |
| 1736 layer_tree_host()->root_layer()->AddChild(layer_); | 1744 layer_tree_host()->root_layer()->AddChild(layer_); |
| 1737 | 1745 |
| 1738 AttachPlayersToTimeline(); | 1746 AttachPlayersToTimeline(); |
| 1739 | 1747 |
| 1740 player_->AttachElement(layer_tree_host()->root_layer()->id()); | 1748 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
| 1741 player_child_->AttachElement(layer_->id()); | 1749 player_child_->AttachElement(layer_->element_id()); |
| 1742 } | 1750 } |
| 1743 | 1751 |
| 1744 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1752 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1745 | 1753 |
| 1746 void DidCommit() override { | 1754 void DidCommit() override { |
| 1747 if (layer_tree_host()->source_frame_number() == 1 || | 1755 if (layer_tree_host()->source_frame_number() == 1 || |
| 1748 layer_tree_host()->source_frame_number() == 2) | 1756 layer_tree_host()->source_frame_number() == 2) |
| 1749 PostSetNeedsCommitToMainThread(); | 1757 PostSetNeedsCommitToMainThread(); |
| 1750 } | 1758 } |
| 1751 | 1759 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1768 private: | 1776 private: |
| 1769 scoped_refptr<Layer> layer_; | 1777 scoped_refptr<Layer> layer_; |
| 1770 FakeContentLayerClient client_; | 1778 FakeContentLayerClient client_; |
| 1771 }; | 1779 }; |
| 1772 | 1780 |
| 1773 MULTI_THREAD_TEST_F( | 1781 MULTI_THREAD_TEST_F( |
| 1774 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1782 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1775 | 1783 |
| 1776 } // namespace | 1784 } // namespace |
| 1777 } // namespace cc | 1785 } // namespace cc |
| OLD | NEW |