Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 2317753002: cc: Abstract the LayerTreeHost. (Closed)
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity); 465 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity);
466 466
467 // Layers added to tree with existing active animations should have the 467 // Layers added to tree with existing active animations should have the
468 // animation correctly recognized. 468 // animation correctly recognized.
469 class LayerTreeHostAnimationTestLayerAddedWithAnimation 469 class LayerTreeHostAnimationTestLayerAddedWithAnimation
470 : public LayerTreeHostAnimationTest { 470 : public LayerTreeHostAnimationTest {
471 public: 471 public:
472 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 472 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
473 473
474 void DidCommit() override { 474 void DidCommit() override {
475 if (layer_tree_host()->source_frame_number() == 1) { 475 if (layer_tree_host()->SourceFrameNumber() == 1) {
476 AttachPlayersToTimeline(); 476 AttachPlayersToTimeline();
477 477
478 scoped_refptr<Layer> layer = Layer::Create(); 478 scoped_refptr<Layer> layer = Layer::Create();
479 layer->SetElementId(ElementId(42, 0)); 479 layer->SetElementId(ElementId(42, 0));
480 player_->AttachElement(layer->element_id()); 480 player_->AttachElement(layer->element_id());
481 player_->set_animation_delegate(this); 481 player_->set_animation_delegate(this);
482 482
483 // Any valid AnimationCurve will do here. 483 // Any valid AnimationCurve will do here.
484 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); 484 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve());
485 std::unique_ptr<Animation> animation( 485 std::unique_ptr<Animation> animation(
(...skipping 20 matching lines...) Expand all
506 : public LayerTreeHostAnimationTest { 506 : public LayerTreeHostAnimationTest {
507 public: 507 public:
508 LayerTreeHostAnimationTestCancelAnimateCommit() 508 LayerTreeHostAnimationTestCancelAnimateCommit()
509 : num_begin_frames_(0), num_commit_calls_(0), num_draw_calls_(0) {} 509 : num_begin_frames_(0), num_commit_calls_(0), num_draw_calls_(0) {}
510 510
511 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 511 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
512 512
513 void BeginMainFrame(const BeginFrameArgs& args) override { 513 void BeginMainFrame(const BeginFrameArgs& args) override {
514 num_begin_frames_++; 514 num_begin_frames_++;
515 // No-op animate will cancel the commit. 515 // No-op animate will cancel the commit.
516 if (layer_tree_host()->source_frame_number() == 1) { 516 if (layer_tree_host()->SourceFrameNumber() == 1) {
517 EndTest(); 517 EndTest();
518 return; 518 return;
519 } 519 }
520 layer_tree_host()->SetNeedsAnimate(); 520 layer_tree_host()->SetNeedsAnimate();
521 } 521 }
522 522
523 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { 523 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
524 num_commit_calls_++; 524 num_commit_calls_++;
525 if (impl->active_tree()->source_frame_number() > 1) 525 if (impl->active_tree()->source_frame_number() > 1)
526 FAIL() << "Commit should have been canceled."; 526 FAIL() << "Commit should have been canceled.";
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 if (TestEnded()) 655 if (TestEnded())
656 return draw_result; 656 return draw_result;
657 // Act like there is checkerboard when the second animation wants to draw. 657 // Act like there is checkerboard when the second animation wants to draw.
658 ++prevented_draw_; 658 ++prevented_draw_;
659 if (prevented_draw_ > 2) 659 if (prevented_draw_ > 2)
660 EndTest(); 660 EndTest();
661 return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; 661 return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
662 } 662 }
663 663
664 void DidCommitAndDrawFrame() override { 664 void DidCommitAndDrawFrame() override {
665 switch (layer_tree_host()->source_frame_number()) { 665 switch (layer_tree_host()->SourceFrameNumber()) {
666 case 1: 666 case 1:
667 // The animation is longer than 1 BeginFrame interval. 667 // The animation is longer than 1 BeginFrame interval.
668 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 0.2f, 0.8f, 668 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 0.2f, 0.8f,
669 false); 669 false);
670 break; 670 break;
671 case 2: 671 case 2:
672 // This second animation will not be drawn so it should not start. 672 // This second animation will not be drawn so it should not start.
673 AddAnimatedTransformToPlayer(player_child_.get(), 0.1, 5, 5); 673 AddAnimatedTransformToPlayer(player_child_.get(), 0.1, 5, 5);
674 break; 674 break;
675 } 675 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 716 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
717 layer_tree()->root_layer()->AddChild(scroll_layer_); 717 layer_tree()->root_layer()->AddChild(scroll_layer_);
718 718
719 AttachPlayersToTimeline(); 719 AttachPlayersToTimeline();
720 player_child_->AttachElement(scroll_layer_->element_id()); 720 player_child_->AttachElement(scroll_layer_->element_id());
721 } 721 }
722 722
723 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 723 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
724 724
725 void DidCommit() override { 725 void DidCommit() override {
726 switch (layer_tree_host()->source_frame_number()) { 726 switch (layer_tree_host()->SourceFrameNumber()) {
727 case 1: { 727 case 1: {
728 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 728 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
729 ScrollOffsetAnimationCurve::Create( 729 ScrollOffsetAnimationCurve::Create(
730 gfx::ScrollOffset(500.f, 550.f), 730 gfx::ScrollOffset(500.f, 550.f),
731 CubicBezierTimingFunction::CreatePreset( 731 CubicBezierTimingFunction::CreatePreset(
732 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); 732 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
733 std::unique_ptr<Animation> animation(Animation::Create( 733 std::unique_ptr<Animation> animation(Animation::Create(
734 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 734 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
735 animation->set_needs_synchronized_start_time(true); 735 animation->set_needs_synchronized_start_time(true);
736 bool impl_scrolling_supported = 736 bool impl_scrolling_supported =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 776
777 AttachPlayersToTimeline(); 777 AttachPlayersToTimeline();
778 player_child_->AttachElement(scroll_layer_->element_id()); 778 player_child_->AttachElement(scroll_layer_->element_id());
779 // Allows NotifyAnimationTakeover to get called. 779 // Allows NotifyAnimationTakeover to get called.
780 player_child_->set_animation_delegate(this); 780 player_child_->set_animation_delegate(this);
781 } 781 }
782 782
783 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 783 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
784 784
785 void DidCommit() override { 785 void DidCommit() override {
786 if (layer_tree_host()->source_frame_number() == 1) { 786 if (layer_tree_host()->SourceFrameNumber() == 1) {
787 // Add an update after the first commit to trigger the animation takeover 787 // Add an update after the first commit to trigger the animation takeover
788 // path. 788 // path.
789 layer_tree() 789 layer_tree()
790 ->animation_host() 790 ->animation_host()
791 ->scroll_offset_animations() 791 ->scroll_offset_animations()
792 .AddTakeoverUpdate(scroll_layer_->element_id()); 792 .AddTakeoverUpdate(scroll_layer_->element_id());
793 EXPECT_TRUE(layer_tree() 793 EXPECT_TRUE(layer_tree()
794 ->animation_host() 794 ->animation_host()
795 ->scroll_offset_animations() 795 ->scroll_offset_animations()
796 .HasUpdatesForTesting()); 796 .HasUpdatesForTesting());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 837 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
838 layer_tree()->root_layer()->AddChild(scroll_layer_); 838 layer_tree()->root_layer()->AddChild(scroll_layer_);
839 839
840 AttachPlayersToTimeline(); 840 AttachPlayersToTimeline();
841 player_child_->AttachElement(scroll_layer_->element_id()); 841 player_child_->AttachElement(scroll_layer_->element_id());
842 } 842 }
843 843
844 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 844 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
845 845
846 void DidCommit() override { 846 void DidCommit() override {
847 if (layer_tree_host()->source_frame_number() == 1) { 847 if (layer_tree_host()->SourceFrameNumber() == 1) {
848 // Add an update after the first commit to trigger the animation update 848 // Add an update after the first commit to trigger the animation update
849 // path. 849 // path.
850 layer_tree() 850 layer_tree()
851 ->animation_host() 851 ->animation_host()
852 ->scroll_offset_animations() 852 ->scroll_offset_animations()
853 .AddAdjustmentUpdate(scroll_layer_->element_id(), 853 .AddAdjustmentUpdate(scroll_layer_->element_id(),
854 gfx::Vector2dF(100.f, 100.f)); 854 gfx::Vector2dF(100.f, 100.f));
855 EXPECT_TRUE(layer_tree() 855 EXPECT_TRUE(layer_tree()
856 ->animation_host() 856 ->animation_host()
857 ->scroll_offset_animations() 857 ->scroll_offset_animations()
858 .HasUpdatesForTesting()); 858 .HasUpdatesForTesting());
859 } else if (layer_tree_host()->source_frame_number() == 2) { 859 } else if (layer_tree_host()->SourceFrameNumber() == 2) {
860 // Verify that the update queue is cleared after the update is applied. 860 // Verify that the update queue is cleared after the update is applied.
861 EXPECT_FALSE(layer_tree() 861 EXPECT_FALSE(layer_tree()
862 ->animation_host() 862 ->animation_host()
863 ->scroll_offset_animations() 863 ->scroll_offset_animations()
864 .HasUpdatesForTesting()); 864 .HasUpdatesForTesting());
865 } 865 }
866 } 866 }
867 867
868 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { 868 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
869 // Note that the frame number gets incremented after BeginCommitOnThread but 869 // Note that the frame number gets incremented after BeginCommitOnThread but
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 animation->set_needs_synchronized_start_time(true); 953 animation->set_needs_synchronized_start_time(true);
954 954
955 AttachPlayersToTimeline(); 955 AttachPlayersToTimeline();
956 player_child_->AttachElement(scroll_layer_->element_id()); 956 player_child_->AttachElement(scroll_layer_->element_id());
957 player_child_->AddAnimation(std::move(animation)); 957 player_child_->AddAnimation(std::move(animation));
958 } 958 }
959 959
960 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 960 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
961 961
962 void BeginMainFrame(const BeginFrameArgs& args) override { 962 void BeginMainFrame(const BeginFrameArgs& args) override {
963 switch (layer_tree_host()->source_frame_number()) { 963 switch (layer_tree_host()->SourceFrameNumber()) {
964 case 0: 964 case 0:
965 break; 965 break;
966 case 1: { 966 case 1: {
967 Animation* animation = 967 Animation* animation =
968 player_child_->element_animations() 968 player_child_->element_animations()
969 ->GetAnimation(TargetProperty::SCROLL_OFFSET); 969 ->GetAnimation(TargetProperty::SCROLL_OFFSET);
970 player_child_->RemoveAnimation(animation->id()); 970 player_child_->RemoveAnimation(animation->id());
971 scroll_layer_->SetScrollOffset(final_postion_); 971 scroll_layer_->SetScrollOffset(final_postion_);
972 break; 972 break;
973 } 973 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 public: 1053 public:
1054 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() 1054 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers()
1055 : frame_count_with_pending_tree_(0) {} 1055 : frame_count_with_pending_tree_(0) {}
1056 1056
1057 void BeginTest() override { 1057 void BeginTest() override {
1058 AttachPlayersToTimeline(); 1058 AttachPlayersToTimeline();
1059 PostSetNeedsCommitToMainThread(); 1059 PostSetNeedsCommitToMainThread();
1060 } 1060 }
1061 1061
1062 void DidCommit() override { 1062 void DidCommit() override {
1063 if (layer_tree_host()->source_frame_number() == 1) { 1063 if (layer_tree_host()->SourceFrameNumber() == 1) {
1064 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1064 player_->AttachElement(layer_tree()->root_layer()->element_id());
1065 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); 1065 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1);
1066 } else if (layer_tree_host()->source_frame_number() == 2) { 1066 } else if (layer_tree_host()->SourceFrameNumber() == 2) {
1067 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); 1067 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true);
1068 1068
1069 scoped_refptr<Layer> layer = Layer::Create(); 1069 scoped_refptr<Layer> layer = Layer::Create();
1070 layer_tree()->root_layer()->AddChild(layer); 1070 layer_tree()->root_layer()->AddChild(layer);
1071 1071
1072 layer_tree()->SetElementIdsForTesting(); 1072 layer_tree()->SetElementIdsForTesting();
1073 layer->SetBounds(gfx::Size(4, 4)); 1073 layer->SetBounds(gfx::Size(4, 4));
1074 1074
1075 player_child_->AttachElement(layer->element_id()); 1075 player_child_->AttachElement(layer->element_id());
1076 player_child_->set_animation_delegate(this); 1076 player_child_->set_animation_delegate(this);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 timeline_->AttachPlayer(player_.get()); 1238 timeline_->AttachPlayer(player_.get());
1239 player_->AttachElement(layer_->element_id()); 1239 player_->AttachElement(layer_->element_id());
1240 DCHECK(player_->element_animations()); 1240 DCHECK(player_->element_animations());
1241 1241
1242 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); 1242 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true);
1243 } 1243 }
1244 1244
1245 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1245 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1246 1246
1247 void DidCommit() override { 1247 void DidCommit() override {
1248 switch (layer_tree_host()->source_frame_number()) { 1248 switch (layer_tree_host()->SourceFrameNumber()) {
1249 case 0: 1249 case 0:
1250 EXPECT_TRUE( 1250 EXPECT_TRUE(
1251 player_->element_animations()->has_element_in_active_list()); 1251 player_->element_animations()->has_element_in_active_list());
1252 EXPECT_FALSE( 1252 EXPECT_FALSE(
1253 player_->element_animations()->has_element_in_pending_list()); 1253 player_->element_animations()->has_element_in_pending_list());
1254 EXPECT_TRUE(layer_tree()->animation_host()->NeedsAnimateLayers()); 1254 EXPECT_TRUE(layer_tree()->animation_host()->NeedsAnimateLayers());
1255 break; 1255 break;
1256 case 1: 1256 case 1:
1257 layer_->RemoveFromParent(); 1257 layer_->RemoveFromParent();
1258 EXPECT_FALSE( 1258 EXPECT_FALSE(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 1318
1319 AttachPlayersToTimeline(); 1319 AttachPlayersToTimeline();
1320 1320
1321 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1321 player_->AttachElement(layer_tree()->root_layer()->element_id());
1322 player_child_->AttachElement(layer_->element_id()); 1322 player_child_->AttachElement(layer_->element_id());
1323 } 1323 }
1324 1324
1325 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1325 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1326 1326
1327 void DidCommit() override { 1327 void DidCommit() override {
1328 switch (layer_tree_host()->source_frame_number()) { 1328 switch (layer_tree_host()->SourceFrameNumber()) {
1329 case 1: 1329 case 1:
1330 // First frame: add an animation to the root layer. 1330 // First frame: add an animation to the root layer.
1331 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5); 1331 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5);
1332 break; 1332 break;
1333 case 2: 1333 case 2:
1334 // Second frame: add an animation to the content layer. The root layer 1334 // Second frame: add an animation to the content layer. The root layer
1335 // animation has caused us to animate already during this frame. 1335 // animation has caused us to animate already during this frame.
1336 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false); 1336 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false);
1337 break; 1337 break;
1338 } 1338 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 1393
1394 AttachPlayersToTimeline(); 1394 AttachPlayersToTimeline();
1395 1395
1396 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1396 player_->AttachElement(layer_tree()->root_layer()->element_id());
1397 player_child_->AttachElement(layer_->element_id()); 1397 player_child_->AttachElement(layer_->element_id());
1398 } 1398 }
1399 1399
1400 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1400 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1401 1401
1402 void DidCommit() override { 1402 void DidCommit() override {
1403 switch (layer_tree_host()->source_frame_number()) { 1403 switch (layer_tree_host()->SourceFrameNumber()) {
1404 case 1: 1404 case 1:
1405 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); 1405 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5);
1406 break; 1406 break;
1407 case 2: 1407 case 2:
1408 Animation* animation = 1408 Animation* animation =
1409 player_child_->element_animations()->GetAnimation( 1409 player_child_->element_animations()->GetAnimation(
1410 TargetProperty::TRANSFORM); 1410 TargetProperty::TRANSFORM);
1411 player_child_->RemoveAnimation(animation->id()); 1411 player_child_->RemoveAnimation(animation->id());
1412 gfx::Transform transform; 1412 gfx::Transform transform;
1413 transform.Translate(10.f, 10.f); 1413 transform.Translate(10.f, 10.f);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 client_.set_bounds(layer_->bounds()); 1472 client_.set_bounds(layer_->bounds());
1473 layer_tree()->root_layer()->AddChild(layer_); 1473 layer_tree()->root_layer()->AddChild(layer_);
1474 1474
1475 AttachPlayersToTimeline(); 1475 AttachPlayersToTimeline();
1476 player_->AttachElement(layer_->element_id()); 1476 player_->AttachElement(layer_->element_id());
1477 } 1477 }
1478 1478
1479 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1479 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1480 1480
1481 void DidCommit() override { 1481 void DidCommit() override {
1482 switch (layer_tree_host()->source_frame_number()) { 1482 switch (layer_tree_host()->SourceFrameNumber()) {
1483 case 1: 1483 case 1:
1484 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); 1484 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5);
1485 break; 1485 break;
1486 case 2: 1486 case 2:
1487 Animation* animation = player_->element_animations()->GetAnimation( 1487 Animation* animation = player_->element_animations()->GetAnimation(
1488 TargetProperty::TRANSFORM); 1488 TargetProperty::TRANSFORM);
1489 player_->RemoveAnimation(animation->id()); 1489 player_->RemoveAnimation(animation->id());
1490 break; 1490 break;
1491 } 1491 }
1492 } 1492 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 1555
1556 AttachPlayersToTimeline(); 1556 AttachPlayersToTimeline();
1557 1557
1558 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1558 player_->AttachElement(layer_tree()->root_layer()->element_id());
1559 player_child_->AttachElement(layer_->element_id()); 1559 player_child_->AttachElement(layer_->element_id());
1560 } 1560 }
1561 1561
1562 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1562 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1563 1563
1564 void DidCommit() override { 1564 void DidCommit() override {
1565 if (layer_tree_host()->source_frame_number() == 1) 1565 if (layer_tree_host()->SourceFrameNumber() == 1)
1566 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5); 1566 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5);
1567 } 1567 }
1568 1568
1569 void WillCommit() override { 1569 void WillCommit() override {
1570 if (layer_tree_host()->source_frame_number() == 2) { 1570 if (layer_tree_host()->SourceFrameNumber() == 2) {
1571 // Block until the animation finishes on the compositor thread. Since 1571 // Block until the animation finishes on the compositor thread. Since
1572 // animations have already been ticked on the main thread, when the commit 1572 // animations have already been ticked on the main thread, when the commit
1573 // happens the state on the main thread will be consistent with having a 1573 // happens the state on the main thread will be consistent with having a
1574 // running animation but the state on the compositor thread will be 1574 // running animation but the state on the compositor thread will be
1575 // consistent with having only a finished animation. 1575 // consistent with having only a finished animation.
1576 completion_.Wait(); 1576 completion_.Wait();
1577 } 1577 }
1578 } 1578 }
1579 1579
1580 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1580 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 EndTest(); 1703 EndTest();
1704 break; 1704 break;
1705 default: 1705 default:
1706 break; 1706 break;
1707 } 1707 }
1708 } 1708 }
1709 1709
1710 void DidCommit() override { PostSetNeedsCommitToMainThread(); } 1710 void DidCommit() override { PostSetNeedsCommitToMainThread(); }
1711 1711
1712 void WillBeginMainFrame() override { 1712 void WillBeginMainFrame() override {
1713 if (layer_tree_host()->source_frame_number() == 2) { 1713 if (layer_tree_host()->SourceFrameNumber() == 2) {
1714 // Destroy player. 1714 // Destroy player.
1715 timeline_->DetachPlayer(player_.get()); 1715 timeline_->DetachPlayer(player_.get());
1716 player_ = nullptr; 1716 player_ = nullptr;
1717 timeline_->AttachPlayer(player_child_.get()); 1717 timeline_->AttachPlayer(player_child_.get());
1718 player_child_->AttachElement(layer_tree()->root_layer()->element_id()); 1718 player_child_->AttachElement(layer_tree()->root_layer()->element_id());
1719 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10); 1719 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10);
1720 Animation* animation = player_child_->element_animations()->GetAnimation( 1720 Animation* animation = player_child_->element_animations()->GetAnimation(
1721 TargetProperty::TRANSFORM); 1721 TargetProperty::TRANSFORM);
1722 animation->set_start_time(base::TimeTicks::Now() + 1722 animation->set_start_time(base::TimeTicks::Now() +
1723 base::TimeDelta::FromSecondsD(1000)); 1723 base::TimeDelta::FromSecondsD(1000));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 } else { 1755 } else {
1756 EXPECT_FALSE(host_impl->pending_tree() 1756 EXPECT_FALSE(host_impl->pending_tree()
1757 ->root_layer_for_testing() 1757 ->root_layer_for_testing()
1758 ->screen_space_transform_is_animating()); 1758 ->screen_space_transform_is_animating());
1759 } 1759 }
1760 } 1760 }
1761 1761
1762 void DidCommit() override { PostSetNeedsCommitToMainThread(); } 1762 void DidCommit() override { PostSetNeedsCommitToMainThread(); }
1763 1763
1764 void UpdateLayerTreeHost() override { 1764 void UpdateLayerTreeHost() override {
1765 if (layer_tree_host()->source_frame_number() == 2) { 1765 if (layer_tree_host()->SourceFrameNumber() == 2) {
1766 // Destroy player. 1766 // Destroy player.
1767 timeline_->DetachPlayer(player_.get()); 1767 timeline_->DetachPlayer(player_.get());
1768 player_ = nullptr; 1768 player_ = nullptr;
1769 } 1769 }
1770 } 1770 }
1771 1771
1772 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 1772 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
1773 LayerTreeHostImpl::FrameData* frame_data, 1773 LayerTreeHostImpl::FrameData* frame_data,
1774 DrawResult draw_result) override { 1774 DrawResult draw_result) override {
1775 const bool screen_space_transform_is_animating = 1775 const bool screen_space_transform_is_animating =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 1825
1826 AttachPlayersToTimeline(); 1826 AttachPlayersToTimeline();
1827 1827
1828 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1828 player_->AttachElement(layer_tree()->root_layer()->element_id());
1829 player_child_->AttachElement(layer_->element_id()); 1829 player_child_->AttachElement(layer_->element_id());
1830 } 1830 }
1831 1831
1832 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1832 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1833 1833
1834 void DidCommit() override { 1834 void DidCommit() override {
1835 if (layer_tree_host()->source_frame_number() == 1 || 1835 if (layer_tree_host()->SourceFrameNumber() == 1 ||
1836 layer_tree_host()->source_frame_number() == 2) 1836 layer_tree_host()->SourceFrameNumber() == 2)
1837 PostSetNeedsCommitToMainThread(); 1837 PostSetNeedsCommitToMainThread();
1838 } 1838 }
1839 1839
1840 void UpdateLayerTreeHost() override { 1840 void UpdateLayerTreeHost() override {
1841 if (layer_tree_host()->source_frame_number() == 1) { 1841 if (layer_tree_host()->SourceFrameNumber() == 1) {
1842 EXPECT_FALSE(layer_tree()->property_trees()->needs_rebuild); 1842 EXPECT_FALSE(layer_tree()->property_trees()->needs_rebuild);
1843 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); 1843 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5);
1844 } 1844 }
1845 1845
1846 EXPECT_TRUE(layer_tree()->property_trees()->needs_rebuild); 1846 EXPECT_TRUE(layer_tree()->property_trees()->needs_rebuild);
1847 } 1847 }
1848 1848
1849 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 1849 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
1850 if (host_impl->active_tree()->source_frame_number() >= 2) 1850 if (host_impl->active_tree()->source_frame_number() >= 2)
1851 EndTest(); 1851 EndTest();
1852 } 1852 }
1853 1853
1854 void AfterTest() override {} 1854 void AfterTest() override {}
1855 1855
1856 private: 1856 private:
1857 scoped_refptr<Layer> layer_; 1857 scoped_refptr<Layer> layer_;
1858 FakeContentLayerClient client_; 1858 FakeContentLayerClient client_;
1859 }; 1859 };
1860 1860
1861 MULTI_THREAD_TEST_F( 1861 MULTI_THREAD_TEST_F(
1862 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); 1862 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit);
1863 1863
1864 } // namespace 1864 } // namespace
1865 } // namespace cc 1865 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698