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

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

Issue 1944623002: CC Animation: Use ElementId to attach CC animation players. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erasedomids
Patch Set: Let CC clients generate their own ElementIds locally. Created 4 years, 7 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
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Add a layer animation and confirm that 137 // Add a layer animation and confirm that
138 // LayerTreeHostImpl::UpdateAnimationState does get called. 138 // LayerTreeHostImpl::UpdateAnimationState does get called.
139 class LayerTreeHostAnimationTestAddAnimation 139 class LayerTreeHostAnimationTestAddAnimation
140 : public LayerTreeHostAnimationTest { 140 : public LayerTreeHostAnimationTest {
141 public: 141 public:
142 LayerTreeHostAnimationTestAddAnimation() 142 LayerTreeHostAnimationTestAddAnimation()
143 : update_animation_state_was_called_(false) {} 143 : update_animation_state_was_called_(false) {}
144 144
145 void BeginTest() override { 145 void BeginTest() override {
146 AttachPlayersToTimeline(); 146 AttachPlayersToTimeline();
147 player_->AttachElement(layer_tree_host()->root_layer()->id()); 147 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
148 PostAddInstantAnimationToMainThreadPlayer(player_.get()); 148 PostAddInstantAnimationToMainThreadPlayer(player_.get());
149 } 149 }
150 150
151 void UpdateAnimationState(LayerTreeHostImpl* host_impl, 151 void UpdateAnimationState(LayerTreeHostImpl* host_impl,
152 bool has_unfinished_animation) override { 152 bool has_unfinished_animation) override {
153 EXPECT_FALSE(has_unfinished_animation); 153 EXPECT_FALSE(has_unfinished_animation);
154 update_animation_state_was_called_ = true; 154 update_animation_state_was_called_ = true;
155 } 155 }
156 156
157 void NotifyAnimationStarted(base::TimeTicks monotonic_time, 157 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
(...skipping 20 matching lines...) Expand all
178 // Add a layer animation to a layer, but continually fail to draw. Confirm that 178 // Add a layer animation to a layer, but continually fail to draw. Confirm that
179 // after a while, we do eventually force a draw. 179 // after a while, we do eventually force a draw.
180 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws 180 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws
181 : public LayerTreeHostAnimationTest { 181 : public LayerTreeHostAnimationTest {
182 public: 182 public:
183 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws() 183 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws()
184 : started_animating_(false) {} 184 : started_animating_(false) {}
185 185
186 void BeginTest() override { 186 void BeginTest() override {
187 AttachPlayersToTimeline(); 187 AttachPlayersToTimeline();
188 player_->AttachElement(layer_tree_host()->root_layer()->id()); 188 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
189 PostAddAnimationToMainThreadPlayer(player_.get()); 189 PostAddAnimationToMainThreadPlayer(player_.get());
190 } 190 }
191 191
192 void AnimateLayers(LayerTreeHostImpl* host_impl, 192 void AnimateLayers(LayerTreeHostImpl* host_impl,
193 base::TimeTicks monotonic_time) override { 193 base::TimeTicks monotonic_time) override {
194 started_animating_ = true; 194 started_animating_ = true;
195 } 195 }
196 196
197 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 197 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
198 if (started_animating_) 198 if (started_animating_)
(...skipping 17 matching lines...) Expand all
216 216
217 // Ensures that animations eventually get deleted. 217 // Ensures that animations eventually get deleted.
218 class LayerTreeHostAnimationTestAnimationsGetDeleted 218 class LayerTreeHostAnimationTestAnimationsGetDeleted
219 : public LayerTreeHostAnimationTest { 219 : public LayerTreeHostAnimationTest {
220 public: 220 public:
221 LayerTreeHostAnimationTestAnimationsGetDeleted() 221 LayerTreeHostAnimationTestAnimationsGetDeleted()
222 : started_animating_(false) {} 222 : started_animating_(false) {}
223 223
224 void BeginTest() override { 224 void BeginTest() override {
225 AttachPlayersToTimeline(); 225 AttachPlayersToTimeline();
226 player_->AttachElement(layer_tree_host()->root_layer()->id()); 226 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
227 PostAddAnimationToMainThreadPlayer(player_.get()); 227 PostAddAnimationToMainThreadPlayer(player_.get());
228 } 228 }
229 229
230 void AnimateLayers(LayerTreeHostImpl* host_impl, 230 void AnimateLayers(LayerTreeHostImpl* host_impl,
231 base::TimeTicks monotonic_time) override { 231 base::TimeTicks monotonic_time) override {
232 bool have_animations = !host_impl->animation_host() 232 bool have_animations = !host_impl->animation_host()
233 ->active_element_animations_for_testing() 233 ->active_element_animations_for_testing()
234 .empty(); 234 .empty();
235 if (!started_animating_ && have_animations) { 235 if (!started_animating_ && have_animations) {
236 started_animating_ = true; 236 started_animating_ = true;
(...skipping 25 matching lines...) Expand all
262 : public LayerTreeHostAnimationTest { 262 : public LayerTreeHostAnimationTest {
263 public: 263 public:
264 void SetupTree() override { 264 void SetupTree() override {
265 LayerTreeHostAnimationTest::SetupTree(); 265 LayerTreeHostAnimationTest::SetupTree();
266 picture_ = FakePictureLayer::Create(&client_); 266 picture_ = FakePictureLayer::Create(&client_);
267 picture_->SetBounds(gfx::Size(4, 4)); 267 picture_->SetBounds(gfx::Size(4, 4));
268 client_.set_bounds(picture_->bounds()); 268 client_.set_bounds(picture_->bounds());
269 layer_tree_host()->root_layer()->AddChild(picture_); 269 layer_tree_host()->root_layer()->AddChild(picture_);
270 270
271 AttachPlayersToTimeline(); 271 AttachPlayersToTimeline();
272 player_child_->AttachElement(picture_->id()); 272 player_child_->AttachElement(picture_->element_id());
273 } 273 }
274 274
275 void BeginTest() override { 275 void BeginTest() override {
276 PostAddAnimationToMainThreadPlayer(player_child_.get()); 276 PostAddAnimationToMainThreadPlayer(player_child_.get());
277 } 277 }
278 278
279 void AnimateLayers(LayerTreeHostImpl* host_impl, 279 void AnimateLayers(LayerTreeHostImpl* host_impl,
280 base::TimeTicks monotonic_time) override { 280 base::TimeTicks monotonic_time) override {
281 // TODO(ajuma): This test only checks the active tree. Add checks for 281 // TODO(ajuma): This test only checks the active tree. Add checks for
282 // pending tree too. 282 // pending tree too.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 void SetupTree() override { 328 void SetupTree() override {
329 LayerTreeHostAnimationTest::SetupTree(); 329 LayerTreeHostAnimationTest::SetupTree();
330 picture_ = FakePictureLayer::Create(&client_); 330 picture_ = FakePictureLayer::Create(&client_);
331 picture_->SetBounds(gfx::Size(4, 4)); 331 picture_->SetBounds(gfx::Size(4, 4));
332 client_.set_bounds(picture_->bounds()); 332 client_.set_bounds(picture_->bounds());
333 333
334 layer_tree_host()->root_layer()->AddChild(picture_); 334 layer_tree_host()->root_layer()->AddChild(picture_);
335 335
336 AttachPlayersToTimeline(); 336 AttachPlayersToTimeline();
337 player_child_->set_animation_delegate(this); 337 player_child_->set_animation_delegate(this);
338 player_child_->AttachElement(picture_->id()); 338 player_child_->AttachElement(picture_->element_id());
339 } 339 }
340 340
341 void BeginTest() override { 341 void BeginTest() override {
342 PostAddAnimationToMainThreadPlayer(player_child_.get()); 342 PostAddAnimationToMainThreadPlayer(player_child_.get());
343 } 343 }
344 344
345 void NotifyAnimationStarted(base::TimeTicks monotonic_time, 345 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
346 TargetProperty::Type target_property, 346 TargetProperty::Type target_property,
347 int group) override { 347 int group) override {
348 Animation* animation = player_child_->element_animations()->GetAnimation( 348 Animation* animation = player_child_->element_animations()->GetAnimation(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 SINGLE_AND_MULTI_THREAD_TEST_F( 383 SINGLE_AND_MULTI_THREAD_TEST_F(
384 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes); 384 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes);
385 385
386 // Ensures that notify animation finished is called. 386 // Ensures that notify animation finished is called.
387 class LayerTreeHostAnimationTestAnimationFinishedEvents 387 class LayerTreeHostAnimationTestAnimationFinishedEvents
388 : public LayerTreeHostAnimationTest { 388 : public LayerTreeHostAnimationTest {
389 public: 389 public:
390 void BeginTest() override { 390 void BeginTest() override {
391 AttachPlayersToTimeline(); 391 AttachPlayersToTimeline();
392 player_->AttachElement(layer_tree_host()->root_layer()->id()); 392 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
393 PostAddInstantAnimationToMainThreadPlayer(player_.get()); 393 PostAddInstantAnimationToMainThreadPlayer(player_.get());
394 } 394 }
395 395
396 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 396 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
397 TargetProperty::Type target_property, 397 TargetProperty::Type target_property,
398 int group) override { 398 int group) override {
399 Animation* animation = 399 Animation* animation =
400 player_->element_animations()->GetAnimation(TargetProperty::OPACITY); 400 player_->element_animations()->GetAnimation(TargetProperty::OPACITY);
401 if (animation) 401 if (animation)
402 player_->element_animations()->RemoveAnimation(animation->id()); 402 player_->element_animations()->RemoveAnimation(animation->id());
(...skipping 15 matching lines...) Expand all
418 : update_check_layer_() {} 418 : update_check_layer_() {}
419 419
420 void SetupTree() override { 420 void SetupTree() override {
421 update_check_layer_ = FakePictureLayer::Create(&client_); 421 update_check_layer_ = FakePictureLayer::Create(&client_);
422 update_check_layer_->SetOpacity(0.f); 422 update_check_layer_->SetOpacity(0.f);
423 layer_tree_host()->SetRootLayer(update_check_layer_); 423 layer_tree_host()->SetRootLayer(update_check_layer_);
424 client_.set_bounds(update_check_layer_->bounds()); 424 client_.set_bounds(update_check_layer_->bounds());
425 LayerTreeHostAnimationTest::SetupTree(); 425 LayerTreeHostAnimationTest::SetupTree();
426 426
427 AttachPlayersToTimeline(); 427 AttachPlayersToTimeline();
428 player_->AttachElement(update_check_layer_->id()); 428 player_->AttachElement(update_check_layer_->element_id());
429 } 429 }
430 430
431 void BeginTest() override { 431 void BeginTest() override {
432 PostAddAnimationToMainThreadPlayer(player_.get()); 432 PostAddAnimationToMainThreadPlayer(player_.get());
433 } 433 }
434 434
435 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 435 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
436 scoped_refptr<AnimationTimeline> timeline_impl = 436 scoped_refptr<AnimationTimeline> timeline_impl =
437 host_impl->animation_host()->GetTimelineById(timeline_id_); 437 host_impl->animation_host()->GetTimelineById(timeline_id_);
438 scoped_refptr<AnimationPlayer> player_impl = 438 scoped_refptr<AnimationPlayer> player_impl =
(...skipping 26 matching lines...) Expand all
465 // animation correctly recognized. 465 // animation correctly recognized.
466 class LayerTreeHostAnimationTestLayerAddedWithAnimation 466 class LayerTreeHostAnimationTestLayerAddedWithAnimation
467 : public LayerTreeHostAnimationTest { 467 : public LayerTreeHostAnimationTest {
468 public: 468 public:
469 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 469 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
470 470
471 void DidCommit() override { 471 void DidCommit() override {
472 if (layer_tree_host()->source_frame_number() == 1) { 472 if (layer_tree_host()->source_frame_number() == 1) {
473 AttachPlayersToTimeline(); 473 AttachPlayersToTimeline();
474 474
475 scoped_refptr<Layer> layer = Layer::Create(); 475 scoped_refptr<Layer> layer = CreateTestLayer();
476 player_->AttachElement(layer->id()); 476 player_->AttachElement(layer->element_id());
477 player_->set_animation_delegate(this); 477 player_->set_animation_delegate(this);
478 478
479 // Any valid AnimationCurve will do here. 479 // Any valid AnimationCurve will do here.
480 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); 480 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve());
481 std::unique_ptr<Animation> animation( 481 std::unique_ptr<Animation> animation(
482 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY)); 482 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY));
483 player_->AddAnimation(std::move(animation)); 483 player_->AddAnimation(std::move(animation));
484 484
485 // We add the animation *before* attaching the layer to the tree. 485 // We add the animation *before* attaching the layer to the tree.
486 layer_tree_host()->root_layer()->AddChild(layer); 486 layer_tree_host()->root_layer()->AddChild(layer);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations 617 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
618 : public LayerTreeHostAnimationTest { 618 : public LayerTreeHostAnimationTest {
619 void SetupTree() override { 619 void SetupTree() override {
620 LayerTreeHostAnimationTest::SetupTree(); 620 LayerTreeHostAnimationTest::SetupTree();
621 picture_ = FakePictureLayer::Create(&client_); 621 picture_ = FakePictureLayer::Create(&client_);
622 picture_->SetBounds(gfx::Size(4, 4)); 622 picture_->SetBounds(gfx::Size(4, 4));
623 client_.set_bounds(picture_->bounds()); 623 client_.set_bounds(picture_->bounds());
624 layer_tree_host()->root_layer()->AddChild(picture_); 624 layer_tree_host()->root_layer()->AddChild(picture_);
625 625
626 AttachPlayersToTimeline(); 626 AttachPlayersToTimeline();
627 player_child_->AttachElement(picture_->id()); 627 player_child_->AttachElement(picture_->element_id());
628 player_child_->set_animation_delegate(this); 628 player_child_->set_animation_delegate(this);
629 } 629 }
630 630
631 void InitializeSettings(LayerTreeSettings* settings) override { 631 void InitializeSettings(LayerTreeSettings* settings) override {
632 // Make sure that drawing many times doesn't cause a checkerboarded 632 // Make sure that drawing many times doesn't cause a checkerboarded
633 // animation to start so we avoid flake in this test. 633 // animation to start so we avoid flake in this test.
634 settings->timeout_and_draw_when_animation_checkerboards = false; 634 settings->timeout_and_draw_when_animation_checkerboards = false;
635 LayerTreeHostAnimationTest::InitializeSettings(settings); 635 LayerTreeHostAnimationTest::InitializeSettings(settings);
636 } 636 }
637 637
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 LayerTreeHostAnimationTest::SetupTree(); 706 LayerTreeHostAnimationTest::SetupTree();
707 707
708 scroll_layer_ = FakePictureLayer::Create(&client_); 708 scroll_layer_ = FakePictureLayer::Create(&client_);
709 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); 709 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
710 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); 710 scroll_layer_->SetBounds(gfx::Size(1000, 1000));
711 client_.set_bounds(scroll_layer_->bounds()); 711 client_.set_bounds(scroll_layer_->bounds());
712 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 712 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
713 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 713 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
714 714
715 AttachPlayersToTimeline(); 715 AttachPlayersToTimeline();
716 player_child_->AttachElement(scroll_layer_->id()); 716 player_child_->AttachElement(scroll_layer_->element_id());
717 } 717 }
718 718
719 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 719 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
720 720
721 void DidCommit() override { 721 void DidCommit() override {
722 switch (layer_tree_host()->source_frame_number()) { 722 switch (layer_tree_host()->source_frame_number()) {
723 case 1: { 723 case 1: {
724 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 724 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
725 ScrollOffsetAnimationCurve::Create( 725 ScrollOffsetAnimationCurve::Create(
726 gfx::ScrollOffset(500.f, 550.f), 726 gfx::ScrollOffset(500.f, 550.f),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 void SetupTree() override { 763 void SetupTree() override {
764 LayerTreeHostAnimationTest::SetupTree(); 764 LayerTreeHostAnimationTest::SetupTree();
765 765
766 scroll_layer_ = FakePictureLayer::Create(&client_); 766 scroll_layer_ = FakePictureLayer::Create(&client_);
767 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); 767 scroll_layer_->SetBounds(gfx::Size(10000, 10000));
768 client_.set_bounds(scroll_layer_->bounds()); 768 client_.set_bounds(scroll_layer_->bounds());
769 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 769 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
770 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 770 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
771 771
772 AttachPlayersToTimeline(); 772 AttachPlayersToTimeline();
773 player_child_->AttachElement(scroll_layer_->id()); 773 player_child_->AttachElement(scroll_layer_->element_id());
774 // Allows NotifyAnimationTakeover to get called. 774 // Allows NotifyAnimationTakeover to get called.
775 player_child_->set_animation_delegate(this); 775 player_child_->set_animation_delegate(this);
776 } 776 }
777 777
778 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 778 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
779 779
780 void DidCommit() override { 780 void DidCommit() override {
781 // Add a main thread scrolling reason after the first commit to trigger 781 // Add a main thread scrolling reason after the first commit to trigger
782 // the takeover path. 782 // the takeover path.
783 if (layer_tree_host()->source_frame_number() == 1) { 783 if (layer_tree_host()->source_frame_number() == 1) {
784 scroll_layer_->AddMainThreadScrollingReasons( 784 scroll_layer_->AddMainThreadScrollingReasons(
785 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); 785 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects);
786 } 786 }
787 } 787 }
788 788
789 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 789 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
790 if (host_impl->sync_tree()->source_frame_number() == 0) { 790 if (host_impl->sync_tree()->source_frame_number() == 0) {
791 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( 791 host_impl->animation_host()->ImplOnlyScrollAnimationCreate(
792 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), 792 scroll_layer_->element_id(), gfx::ScrollOffset(650.f, 750.f),
793 gfx::ScrollOffset(10, 20)); 793 gfx::ScrollOffset(10, 20));
794 } 794 }
795 } 795 }
796 796
797 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, 797 void NotifyAnimationTakeover(base::TimeTicks monotonic_time,
798 TargetProperty::Type target_property, 798 TargetProperty::Type target_property,
799 double animation_start_time, 799 double animation_start_time,
800 std::unique_ptr<AnimationCurve> curve) override { 800 std::unique_ptr<AnimationCurve> curve) override {
801 EndTest(); 801 EndTest();
802 } 802 }
(...skipping 28 matching lines...) Expand all
831 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 831 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
832 832
833 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 833 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
834 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f), 834 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f),
835 EaseInOutTimingFunction::Create())); 835 EaseInOutTimingFunction::Create()));
836 std::unique_ptr<Animation> animation(Animation::Create( 836 std::unique_ptr<Animation> animation(Animation::Create(
837 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 837 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
838 animation->set_needs_synchronized_start_time(true); 838 animation->set_needs_synchronized_start_time(true);
839 839
840 AttachPlayersToTimeline(); 840 AttachPlayersToTimeline();
841 player_child_->AttachElement(scroll_layer_->id()); 841 player_child_->AttachElement(scroll_layer_->element_id());
842 player_child_->AddAnimation(std::move(animation)); 842 player_child_->AddAnimation(std::move(animation));
843 } 843 }
844 844
845 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 845 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
846 846
847 void BeginMainFrame(const BeginFrameArgs& args) override { 847 void BeginMainFrame(const BeginFrameArgs& args) override {
848 switch (layer_tree_host()->source_frame_number()) { 848 switch (layer_tree_host()->source_frame_number()) {
849 case 0: 849 case 0:
850 break; 850 break;
851 case 1: { 851 case 1: {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() 937 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers()
938 : frame_count_with_pending_tree_(0) {} 938 : frame_count_with_pending_tree_(0) {}
939 939
940 void BeginTest() override { 940 void BeginTest() override {
941 AttachPlayersToTimeline(); 941 AttachPlayersToTimeline();
942 PostSetNeedsCommitToMainThread(); 942 PostSetNeedsCommitToMainThread();
943 } 943 }
944 944
945 void DidCommit() override { 945 void DidCommit() override {
946 if (layer_tree_host()->source_frame_number() == 1) { 946 if (layer_tree_host()->source_frame_number() == 1) {
947 player_->AttachElement(layer_tree_host()->root_layer()->id()); 947 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
948 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); 948 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1);
949 } else if (layer_tree_host()->source_frame_number() == 2) { 949 } else if (layer_tree_host()->source_frame_number() == 2) {
950 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); 950 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true);
951 951
952 scoped_refptr<Layer> layer = Layer::Create(); 952 scoped_refptr<Layer> layer = CreateTestLayer();
953 layer_tree_host()->root_layer()->AddChild(layer); 953 layer_tree_host()->root_layer()->AddChild(layer);
954 layer->SetBounds(gfx::Size(4, 4)); 954 layer->SetBounds(gfx::Size(4, 4));
955 955
956 player_child_->AttachElement(layer->id()); 956 player_child_->AttachElement(layer->element_id());
957 player_child_->set_animation_delegate(this); 957 player_child_->set_animation_delegate(this);
958 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); 958 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true);
959 } 959 }
960 } 960 }
961 961
962 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { 962 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
963 host_impl->BlockNotifyReadyToActivateForTesting(true); 963 host_impl->BlockNotifyReadyToActivateForTesting(true);
964 } 964 }
965 965
966 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 966 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 1034
1035 layer_ = FakePictureLayer::Create(&client_); 1035 layer_ = FakePictureLayer::Create(&client_);
1036 layer_->SetBounds(gfx::Size(2, 2)); 1036 layer_->SetBounds(gfx::Size(2, 2));
1037 client_.set_bounds(layer_->bounds()); 1037 client_.set_bounds(layer_->bounds());
1038 // Transform the layer to 4,4 to start. 1038 // Transform the layer to 4,4 to start.
1039 gfx::Transform start_transform; 1039 gfx::Transform start_transform;
1040 start_transform.Translate(4.0, 4.0); 1040 start_transform.Translate(4.0, 4.0);
1041 layer_->SetTransform(start_transform); 1041 layer_->SetTransform(start_transform);
1042 1042
1043 layer_tree_host()->root_layer()->AddChild(layer_); 1043 layer_tree_host()->root_layer()->AddChild(layer_);
1044 player_->AttachElement(layer_->id()); 1044 player_->AttachElement(layer_->element_id());
1045 1045
1046 AttachPlayersToTimeline(); 1046 AttachPlayersToTimeline();
1047 } 1047 }
1048 1048
1049 void BeginTest() override { 1049 void BeginTest() override {
1050 // Add a translate from 6,7 to 8,9. 1050 // Add a translate from 6,7 to 8,9.
1051 TransformOperations start; 1051 TransformOperations start;
1052 start.AppendTranslate(6.f, 7.f, 0.f); 1052 start.AppendTranslate(6.f, 7.f, 0.f);
1053 TransformOperations end; 1053 TransformOperations end;
1054 end.AppendTranslate(8.f, 9.f, 0.f); 1054 end.AppendTranslate(8.f, 9.f, 0.f);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 SINGLE_AND_MULTI_THREAD_TEST_F( 1100 SINGLE_AND_MULTI_THREAD_TEST_F(
1101 LayerTreeHostAnimationTestPendingTreeAnimatesFirstCommit); 1101 LayerTreeHostAnimationTestPendingTreeAnimatesFirstCommit);
1102 1102
1103 // When a layer with an animation is removed from the tree and later re-added, 1103 // When a layer with an animation is removed from the tree and later re-added,
1104 // the animation should resume. 1104 // the animation should resume.
1105 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded 1105 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded
1106 : public LayerTreeHostAnimationTest { 1106 : public LayerTreeHostAnimationTest {
1107 public: 1107 public:
1108 void SetupTree() override { 1108 void SetupTree() override {
1109 LayerTreeHostAnimationTest::SetupTree(); 1109 LayerTreeHostAnimationTest::SetupTree();
1110 layer_ = Layer::Create(); 1110 layer_ = CreateTestLayer();
1111 layer_->SetBounds(gfx::Size(4, 4)); 1111 layer_->SetBounds(gfx::Size(4, 4));
1112 layer_tree_host()->root_layer()->AddChild(layer_); 1112 layer_tree_host()->root_layer()->AddChild(layer_);
1113 1113
1114 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); 1114 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get());
1115 timeline_->AttachPlayer(player_.get()); 1115 timeline_->AttachPlayer(player_.get());
1116 player_->AttachElement(layer_->id()); 1116 player_->AttachElement(layer_->element_id());
1117 DCHECK(player_->element_animations()); 1117 DCHECK(player_->element_animations());
1118 1118
1119 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); 1119 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true);
1120 } 1120 }
1121 1121
1122 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1122 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1123 1123
1124 void DidCommit() override { 1124 void DidCommit() override {
1125 switch (layer_tree_host()->source_frame_number()) { 1125 switch (layer_tree_host()->source_frame_number()) {
1126 case 0: 1126 case 0:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 }; 1182 };
1183 1183
1184 SINGLE_AND_MULTI_THREAD_TEST_F( 1184 SINGLE_AND_MULTI_THREAD_TEST_F(
1185 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded); 1185 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded);
1186 1186
1187 class LayerTreeHostAnimationTestAddAnimationAfterAnimating 1187 class LayerTreeHostAnimationTestAddAnimationAfterAnimating
1188 : public LayerTreeHostAnimationTest { 1188 : public LayerTreeHostAnimationTest {
1189 public: 1189 public:
1190 void SetupTree() override { 1190 void SetupTree() override {
1191 LayerTreeHostAnimationTest::SetupTree(); 1191 LayerTreeHostAnimationTest::SetupTree();
1192 layer_ = Layer::Create(); 1192 layer_ = CreateTestLayer();
1193 layer_->SetBounds(gfx::Size(4, 4)); 1193 layer_->SetBounds(gfx::Size(4, 4));
1194 layer_tree_host()->root_layer()->AddChild(layer_); 1194 layer_tree_host()->root_layer()->AddChild(layer_);
1195 1195
1196 AttachPlayersToTimeline(); 1196 AttachPlayersToTimeline();
1197 1197
1198 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1198 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1199 player_child_->AttachElement(layer_->id()); 1199 player_child_->AttachElement(layer_->element_id());
1200 } 1200 }
1201 1201
1202 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1202 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1203 1203
1204 void DidCommit() override { 1204 void DidCommit() override {
1205 switch (layer_tree_host()->source_frame_number()) { 1205 switch (layer_tree_host()->source_frame_number()) {
1206 case 1: 1206 case 1:
1207 // First frame: add an animation to the root layer. 1207 // First frame: add an animation to the root layer.
1208 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5); 1208 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5);
1209 break; 1209 break;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 public: 1250 public:
1251 void SetupTree() override { 1251 void SetupTree() override {
1252 LayerTreeHostAnimationTest::SetupTree(); 1252 LayerTreeHostAnimationTest::SetupTree();
1253 layer_ = FakePictureLayer::Create(&client_); 1253 layer_ = FakePictureLayer::Create(&client_);
1254 layer_->SetBounds(gfx::Size(4, 4)); 1254 layer_->SetBounds(gfx::Size(4, 4));
1255 client_.set_bounds(layer_->bounds()); 1255 client_.set_bounds(layer_->bounds());
1256 layer_tree_host()->root_layer()->AddChild(layer_); 1256 layer_tree_host()->root_layer()->AddChild(layer_);
1257 1257
1258 AttachPlayersToTimeline(); 1258 AttachPlayersToTimeline();
1259 1259
1260 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1260 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1261 player_child_->AttachElement(layer_->id()); 1261 player_child_->AttachElement(layer_->element_id());
1262 } 1262 }
1263 1263
1264 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1264 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1265 1265
1266 void DidCommit() override { 1266 void DidCommit() override {
1267 switch (layer_tree_host()->source_frame_number()) { 1267 switch (layer_tree_host()->source_frame_number()) {
1268 case 1: 1268 case 1:
1269 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); 1269 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5);
1270 break; 1270 break;
1271 case 2: 1271 case 2:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 : public LayerTreeHostAnimationTest { 1329 : public LayerTreeHostAnimationTest {
1330 public: 1330 public:
1331 void SetupTree() override { 1331 void SetupTree() override {
1332 LayerTreeHostAnimationTest::SetupTree(); 1332 LayerTreeHostAnimationTest::SetupTree();
1333 layer_ = FakePictureLayer::Create(&client_); 1333 layer_ = FakePictureLayer::Create(&client_);
1334 layer_->SetBounds(gfx::Size(4, 4)); 1334 layer_->SetBounds(gfx::Size(4, 4));
1335 client_.set_bounds(layer_->bounds()); 1335 client_.set_bounds(layer_->bounds());
1336 layer_tree_host()->root_layer()->AddChild(layer_); 1336 layer_tree_host()->root_layer()->AddChild(layer_);
1337 1337
1338 AttachPlayersToTimeline(); 1338 AttachPlayersToTimeline();
1339 player_->AttachElement(layer_->id()); 1339 player_->AttachElement(layer_->element_id());
1340 } 1340 }
1341 1341
1342 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1342 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1343 1343
1344 void DidCommit() override { 1344 void DidCommit() override {
1345 switch (layer_tree_host()->source_frame_number()) { 1345 switch (layer_tree_host()->source_frame_number()) {
1346 case 1: 1346 case 1:
1347 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); 1347 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5);
1348 break; 1348 break;
1349 case 2: 1349 case 2:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 1411
1412 void SetupTree() override { 1412 void SetupTree() override {
1413 LayerTreeHostAnimationTest::SetupTree(); 1413 LayerTreeHostAnimationTest::SetupTree();
1414 layer_ = FakePictureLayer::Create(&client_); 1414 layer_ = FakePictureLayer::Create(&client_);
1415 layer_->SetBounds(gfx::Size(4, 4)); 1415 layer_->SetBounds(gfx::Size(4, 4));
1416 client_.set_bounds(layer_->bounds()); 1416 client_.set_bounds(layer_->bounds());
1417 layer_tree_host()->root_layer()->AddChild(layer_); 1417 layer_tree_host()->root_layer()->AddChild(layer_);
1418 1418
1419 AttachPlayersToTimeline(); 1419 AttachPlayersToTimeline();
1420 1420
1421 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1421 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1422 player_child_->AttachElement(layer_->id()); 1422 player_child_->AttachElement(layer_->element_id());
1423 } 1423 }
1424 1424
1425 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1425 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1426 1426
1427 void DidCommit() override { 1427 void DidCommit() override {
1428 if (layer_tree_host()->source_frame_number() == 1) 1428 if (layer_tree_host()->source_frame_number() == 1)
1429 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5); 1429 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5);
1430 } 1430 }
1431 1431
1432 void WillCommit() override { 1432 void WillCommit() override {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 : called_animation_started_(false), called_animation_finished_(false) {} 1485 : called_animation_started_(false), called_animation_finished_(false) {}
1486 1486
1487 void SetupTree() override { 1487 void SetupTree() override {
1488 LayerTreeHostAnimationTest::SetupTree(); 1488 LayerTreeHostAnimationTest::SetupTree();
1489 picture_ = FakePictureLayer::Create(&client_); 1489 picture_ = FakePictureLayer::Create(&client_);
1490 picture_->SetBounds(gfx::Size(4, 4)); 1490 picture_->SetBounds(gfx::Size(4, 4));
1491 client_.set_bounds(picture_->bounds()); 1491 client_.set_bounds(picture_->bounds());
1492 layer_tree_host()->root_layer()->AddChild(picture_); 1492 layer_tree_host()->root_layer()->AddChild(picture_);
1493 1493
1494 AttachPlayersToTimeline(); 1494 AttachPlayersToTimeline();
1495 player_->AttachElement(picture_->id()); 1495 player_->AttachElement(picture_->element_id());
1496 player_->set_animation_delegate(this); 1496 player_->set_animation_delegate(this);
1497 } 1497 }
1498 1498
1499 void BeginTest() override { 1499 void BeginTest() override {
1500 PostAddLongAnimationToMainThreadPlayer(player_.get()); 1500 PostAddLongAnimationToMainThreadPlayer(player_.get());
1501 } 1501 }
1502 1502
1503 void NotifyAnimationStarted(base::TimeTicks monotonic_time, 1503 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
1504 TargetProperty::Type target_property, 1504 TargetProperty::Type target_property,
1505 int group) override { 1505 int group) override {
(...skipping 29 matching lines...) Expand all
1535 // if we destroy ElementAnimations. 1535 // if we destroy ElementAnimations.
1536 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction 1536 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction
1537 : public LayerTreeHostAnimationTest { 1537 : public LayerTreeHostAnimationTest {
1538 public: 1538 public:
1539 void SetupTree() override { 1539 void SetupTree() override {
1540 prev_screen_space_transform_is_animating_ = true; 1540 prev_screen_space_transform_is_animating_ = true;
1541 screen_space_transform_animation_stopped_ = false; 1541 screen_space_transform_animation_stopped_ = false;
1542 1542
1543 LayerTreeHostAnimationTest::SetupTree(); 1543 LayerTreeHostAnimationTest::SetupTree();
1544 AttachPlayersToTimeline(); 1544 AttachPlayersToTimeline();
1545 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1545 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1546 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); 1546 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5);
1547 } 1547 }
1548 1548
1549 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1549 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1550 1550
1551 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1551 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1552 if (host_impl->pending_tree()->source_frame_number() <= 1) { 1552 if (host_impl->pending_tree()->source_frame_number() <= 1) {
1553 EXPECT_TRUE(host_impl->pending_tree() 1553 EXPECT_TRUE(host_impl->pending_tree()
1554 ->root_layer() 1554 ->root_layer()
1555 ->screen_space_transform_is_animating()); 1555 ->screen_space_transform_is_animating());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 public: 1619 public:
1620 void SetupTree() override { 1620 void SetupTree() override {
1621 LayerTreeHostAnimationTest::SetupTree(); 1621 LayerTreeHostAnimationTest::SetupTree();
1622 layer_ = FakePictureLayer::Create(&client_); 1622 layer_ = FakePictureLayer::Create(&client_);
1623 layer_->SetBounds(gfx::Size(4, 4)); 1623 layer_->SetBounds(gfx::Size(4, 4));
1624 client_.set_bounds(layer_->bounds()); 1624 client_.set_bounds(layer_->bounds());
1625 layer_tree_host()->root_layer()->AddChild(layer_); 1625 layer_tree_host()->root_layer()->AddChild(layer_);
1626 1626
1627 AttachPlayersToTimeline(); 1627 AttachPlayersToTimeline();
1628 1628
1629 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1629 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1630 player_child_->AttachElement(layer_->id()); 1630 player_child_->AttachElement(layer_->element_id());
1631 } 1631 }
1632 1632
1633 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1633 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1634 1634
1635 void DidCommit() override { 1635 void DidCommit() override {
1636 if (layer_tree_host()->source_frame_number() == 1 || 1636 if (layer_tree_host()->source_frame_number() == 1 ||
1637 layer_tree_host()->source_frame_number() == 2) 1637 layer_tree_host()->source_frame_number() == 2)
1638 PostSetNeedsCommitToMainThread(); 1638 PostSetNeedsCommitToMainThread();
1639 } 1639 }
1640 1640
(...skipping 16 matching lines...) Expand all
1657 private: 1657 private:
1658 scoped_refptr<Layer> layer_; 1658 scoped_refptr<Layer> layer_;
1659 FakeContentLayerClient client_; 1659 FakeContentLayerClient client_;
1660 }; 1660 };
1661 1661
1662 MULTI_THREAD_TEST_F( 1662 MULTI_THREAD_TEST_F(
1663 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); 1663 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit);
1664 1664
1665 } // namespace 1665 } // namespace
1666 } // namespace cc 1666 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698