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

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

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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_impl_unittest.cc ('k') | cc/trees/layer_tree_impl.h » ('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 26 matching lines...) Expand all
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
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
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
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
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
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
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
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
467 class LayerTreeHostAnimationTestLayerAddedWithAnimation 468 class LayerTreeHostAnimationTestLayerAddedWithAnimation
468 : public LayerTreeHostAnimationTest { 469 : public LayerTreeHostAnimationTest {
469 public: 470 public:
470 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 471 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
471 472
472 void DidCommit() override { 473 void DidCommit() override {
473 if (layer_tree_host()->source_frame_number() == 1) { 474 if (layer_tree_host()->source_frame_number() == 1) {
474 AttachPlayersToTimeline(); 475 AttachPlayersToTimeline();
475 476
476 scoped_refptr<Layer> layer = Layer::Create(); 477 scoped_refptr<Layer> layer = Layer::Create();
477 player_->AttachElement(layer->id()); 478 layer->SetElementId(ElementId(42, 0));
479 player_->AttachElement(layer->element_id());
478 player_->set_animation_delegate(this); 480 player_->set_animation_delegate(this);
479 481
480 // Any valid AnimationCurve will do here. 482 // Any valid AnimationCurve will do here.
481 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); 483 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve());
482 std::unique_ptr<Animation> animation( 484 std::unique_ptr<Animation> animation(
483 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY)); 485 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY));
484 player_->AddAnimation(std::move(animation)); 486 player_->AddAnimation(std::move(animation));
485 487
486 // We add the animation *before* attaching the layer to the tree. 488 // We add the animation *before* attaching the layer to the tree.
487 layer_tree_host()->root_layer()->AddChild(layer); 489 layer_tree_host()->root_layer()->AddChild(layer);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
707 LayerTreeHostAnimationTest::SetupTree(); 709 LayerTreeHostAnimationTest::SetupTree();
708 710
709 scroll_layer_ = FakePictureLayer::Create(&client_); 711 scroll_layer_ = FakePictureLayer::Create(&client_);
710 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); 712 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
711 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); 713 scroll_layer_->SetBounds(gfx::Size(1000, 1000));
712 client_.set_bounds(scroll_layer_->bounds()); 714 client_.set_bounds(scroll_layer_->bounds());
713 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 715 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
714 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 716 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
715 717
716 AttachPlayersToTimeline(); 718 AttachPlayersToTimeline();
717 player_child_->AttachElement(scroll_layer_->id()); 719 player_child_->AttachElement(scroll_layer_->element_id());
718 } 720 }
719 721
720 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 722 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
721 723
722 void DidCommit() override { 724 void DidCommit() override {
723 switch (layer_tree_host()->source_frame_number()) { 725 switch (layer_tree_host()->source_frame_number()) {
724 case 1: { 726 case 1: {
725 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 727 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
726 ScrollOffsetAnimationCurve::Create( 728 ScrollOffsetAnimationCurve::Create(
727 gfx::ScrollOffset(500.f, 550.f), 729 gfx::ScrollOffset(500.f, 550.f),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 void SetupTree() override { 767 void SetupTree() override {
766 LayerTreeHostAnimationTest::SetupTree(); 768 LayerTreeHostAnimationTest::SetupTree();
767 769
768 scroll_layer_ = FakePictureLayer::Create(&client_); 770 scroll_layer_ = FakePictureLayer::Create(&client_);
769 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); 771 scroll_layer_->SetBounds(gfx::Size(10000, 10000));
770 client_.set_bounds(scroll_layer_->bounds()); 772 client_.set_bounds(scroll_layer_->bounds());
771 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 773 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
772 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 774 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
773 775
774 AttachPlayersToTimeline(); 776 AttachPlayersToTimeline();
775 player_child_->AttachElement(scroll_layer_->id()); 777 player_child_->AttachElement(scroll_layer_->element_id());
776 // Allows NotifyAnimationTakeover to get called. 778 // Allows NotifyAnimationTakeover to get called.
777 player_child_->set_animation_delegate(this); 779 player_child_->set_animation_delegate(this);
778 } 780 }
779 781
780 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 782 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
781 783
782 void DidCommit() override { 784 void DidCommit() override {
783 if (layer_tree_host()->source_frame_number() == 1) { 785 if (layer_tree_host()->source_frame_number() == 1) {
784 // Add an update after the first commit to trigger the animation takeover 786 // Add an update after the first commit to trigger the animation takeover
785 // path. 787 // path.
786 layer_tree_host() 788 layer_tree_host()
787 ->animation_host() 789 ->animation_host()
788 ->scroll_offset_animations() 790 ->scroll_offset_animations()
789 .AddTakeoverUpdate(scroll_layer_->id()); 791 .AddTakeoverUpdate(scroll_layer_->element_id());
790 EXPECT_TRUE(layer_tree_host() 792 EXPECT_TRUE(layer_tree_host()
791 ->animation_host() 793 ->animation_host()
792 ->scroll_offset_animations() 794 ->scroll_offset_animations()
793 .HasUpdatesForTesting()); 795 .HasUpdatesForTesting());
794 } 796 }
795 } 797 }
796 798
797 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 799 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
798 if (host_impl->sync_tree()->source_frame_number() == 0) { 800 if (host_impl->sync_tree()->source_frame_number() == 0) {
799 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( 801 host_impl->animation_host()->ImplOnlyScrollAnimationCreate(
800 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), 802 scroll_layer_->element_id(), gfx::ScrollOffset(650.f, 750.f),
801 gfx::ScrollOffset(10, 20)); 803 gfx::ScrollOffset(10, 20));
802 } 804 }
803 } 805 }
804 806
805 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, 807 void NotifyAnimationTakeover(base::TimeTicks monotonic_time,
806 TargetProperty::Type target_property, 808 TargetProperty::Type target_property,
807 double animation_start_time, 809 double animation_start_time,
808 std::unique_ptr<AnimationCurve> curve) override { 810 std::unique_ptr<AnimationCurve> curve) override {
809 EndTest(); 811 EndTest();
810 } 812 }
(...skipping 17 matching lines...) Expand all
828 void SetupTree() override { 830 void SetupTree() override {
829 LayerTreeHostAnimationTest::SetupTree(); 831 LayerTreeHostAnimationTest::SetupTree();
830 832
831 scroll_layer_ = FakePictureLayer::Create(&client_); 833 scroll_layer_ = FakePictureLayer::Create(&client_);
832 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); 834 scroll_layer_->SetBounds(gfx::Size(10000, 10000));
833 client_.set_bounds(scroll_layer_->bounds()); 835 client_.set_bounds(scroll_layer_->bounds());
834 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 836 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
835 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 837 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
836 838
837 AttachPlayersToTimeline(); 839 AttachPlayersToTimeline();
838 player_child_->AttachElement(scroll_layer_->id()); 840 player_child_->AttachElement(scroll_layer_->element_id());
839 } 841 }
840 842
841 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 843 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
842 844
843 void DidCommit() override { 845 void DidCommit() override {
844 if (layer_tree_host()->source_frame_number() == 1) { 846 if (layer_tree_host()->source_frame_number() == 1) {
845 // Add an update after the first commit to trigger the animation update 847 // Add an update after the first commit to trigger the animation update
846 // path. 848 // path.
847 layer_tree_host() 849 layer_tree_host()
848 ->animation_host() 850 ->animation_host()
849 ->scroll_offset_animations() 851 ->scroll_offset_animations()
850 .AddAdjustmentUpdate(scroll_layer_->id(), 852 .AddAdjustmentUpdate(scroll_layer_->element_id(),
851 gfx::Vector2dF(100.f, 100.f)); 853 gfx::Vector2dF(100.f, 100.f));
852 EXPECT_TRUE(layer_tree_host() 854 EXPECT_TRUE(layer_tree_host()
853 ->animation_host() 855 ->animation_host()
854 ->scroll_offset_animations() 856 ->scroll_offset_animations()
855 .HasUpdatesForTesting()); 857 .HasUpdatesForTesting());
856 } else if (layer_tree_host()->source_frame_number() == 2) { 858 } else if (layer_tree_host()->source_frame_number() == 2) {
857 // Verify that the update queue is cleared after the update is applied. 859 // Verify that the update queue is cleared after the update is applied.
858 EXPECT_FALSE(layer_tree_host() 860 EXPECT_FALSE(layer_tree_host()
859 ->animation_host() 861 ->animation_host()
860 ->scroll_offset_animations() 862 ->scroll_offset_animations()
861 .HasUpdatesForTesting()); 863 .HasUpdatesForTesting());
862 } 864 }
863 } 865 }
864 866
865 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { 867 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
866 // Note that the frame number gets incremented after BeginCommitOnThread but 868 // Note that the frame number gets incremented after BeginCommitOnThread but
867 // before WillCommitCompleteOnThread and CommitCompleteOnThread. 869 // before WillCommitCompleteOnThread and CommitCompleteOnThread.
868 if (host_impl->sync_tree()->source_frame_number() == 0) { 870 if (host_impl->sync_tree()->source_frame_number() == 0) {
869 // This happens after the impl-only animation is added in 871 // This happens after the impl-only animation is added in
870 // WillCommitCompleteOnThread. 872 // WillCommitCompleteOnThread.
871 Animation* animation = 873 Animation* animation =
872 host_impl->animation_host() 874 host_impl->animation_host()
873 ->GetElementAnimationsForElementId(scroll_layer_->id()) 875 ->GetElementAnimationsForElementId(scroll_layer_->element_id())
874 ->GetAnimation(TargetProperty::SCROLL_OFFSET); 876 ->GetAnimation(TargetProperty::SCROLL_OFFSET);
875 ScrollOffsetAnimationCurve* curve = 877 ScrollOffsetAnimationCurve* curve =
876 animation->curve()->ToScrollOffsetAnimationCurve(); 878 animation->curve()->ToScrollOffsetAnimationCurve();
877 879
878 // Verifiy the initial and target position before the scroll offset 880 // Verifiy the initial and target position before the scroll offset
879 // update from MT. 881 // update from MT.
880 EXPECT_EQ(Animation::RunState::RUNNING, animation->run_state()); 882 EXPECT_EQ(Animation::RunState::RUNNING, animation->run_state());
881 EXPECT_EQ(gfx::ScrollOffset(10.f, 20.f), 883 EXPECT_EQ(gfx::ScrollOffset(10.f, 20.f),
882 curve->GetValue(base::TimeDelta())); 884 curve->GetValue(base::TimeDelta()));
883 EXPECT_EQ(gfx::ScrollOffset(650.f, 750.f), curve->target_value()); 885 EXPECT_EQ(gfx::ScrollOffset(650.f, 750.f), curve->target_value());
884 } 886 }
885 } 887 }
886 888
887 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 889 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
888 if (host_impl->sync_tree()->source_frame_number() == 0) { 890 if (host_impl->sync_tree()->source_frame_number() == 0) {
889 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( 891 host_impl->animation_host()->ImplOnlyScrollAnimationCreate(
890 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), 892 scroll_layer_->element_id(), gfx::ScrollOffset(650.f, 750.f),
891 gfx::ScrollOffset(10, 20)); 893 gfx::ScrollOffset(10, 20));
892 } 894 }
893 } 895 }
894 896
895 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 897 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
896 if (host_impl->sync_tree()->source_frame_number() == 1) { 898 if (host_impl->sync_tree()->source_frame_number() == 1) {
897 Animation* animation = 899 Animation* animation =
898 host_impl->animation_host() 900 host_impl->animation_host()
899 ->GetElementAnimationsForElementId(scroll_layer_->id()) 901 ->GetElementAnimationsForElementId(scroll_layer_->element_id())
900 ->GetAnimation(TargetProperty::SCROLL_OFFSET); 902 ->GetAnimation(TargetProperty::SCROLL_OFFSET);
901 ScrollOffsetAnimationCurve* curve = 903 ScrollOffsetAnimationCurve* curve =
902 animation->curve()->ToScrollOffsetAnimationCurve(); 904 animation->curve()->ToScrollOffsetAnimationCurve();
903 // Verifiy the initial and target position after the scroll offset 905 // Verifiy the initial and target position after the scroll offset
904 // update from MT 906 // update from MT
905 EXPECT_EQ(Animation::RunState::STARTING, animation->run_state()); 907 EXPECT_EQ(Animation::RunState::STARTING, animation->run_state());
906 EXPECT_EQ(gfx::ScrollOffset(110.f, 120.f), 908 EXPECT_EQ(gfx::ScrollOffset(110.f, 120.f),
907 curve->GetValue(base::TimeDelta())); 909 curve->GetValue(base::TimeDelta()));
908 EXPECT_EQ(gfx::ScrollOffset(750.f, 850.f), curve->target_value()); 910 EXPECT_EQ(gfx::ScrollOffset(750.f, 850.f), curve->target_value());
909 911
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 945 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
944 ScrollOffsetAnimationCurve::Create( 946 ScrollOffsetAnimationCurve::Create(
945 gfx::ScrollOffset(6500.f, 7500.f), 947 gfx::ScrollOffset(6500.f, 7500.f),
946 CubicBezierTimingFunction::CreatePreset( 948 CubicBezierTimingFunction::CreatePreset(
947 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); 949 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
948 std::unique_ptr<Animation> animation(Animation::Create( 950 std::unique_ptr<Animation> animation(Animation::Create(
949 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 951 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
950 animation->set_needs_synchronized_start_time(true); 952 animation->set_needs_synchronized_start_time(true);
951 953
952 AttachPlayersToTimeline(); 954 AttachPlayersToTimeline();
953 player_child_->AttachElement(scroll_layer_->id()); 955 player_child_->AttachElement(scroll_layer_->element_id());
954 player_child_->AddAnimation(std::move(animation)); 956 player_child_->AddAnimation(std::move(animation));
955 } 957 }
956 958
957 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 959 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
958 960
959 void BeginMainFrame(const BeginFrameArgs& args) override { 961 void BeginMainFrame(const BeginFrameArgs& args) override {
960 switch (layer_tree_host()->source_frame_number()) { 962 switch (layer_tree_host()->source_frame_number()) {
961 case 0: 963 case 0:
962 break; 964 break;
963 case 1: { 965 case 1: {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() 1053 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers()
1052 : frame_count_with_pending_tree_(0) {} 1054 : frame_count_with_pending_tree_(0) {}
1053 1055
1054 void BeginTest() override { 1056 void BeginTest() override {
1055 AttachPlayersToTimeline(); 1057 AttachPlayersToTimeline();
1056 PostSetNeedsCommitToMainThread(); 1058 PostSetNeedsCommitToMainThread();
1057 } 1059 }
1058 1060
1059 void DidCommit() override { 1061 void DidCommit() override {
1060 if (layer_tree_host()->source_frame_number() == 1) { 1062 if (layer_tree_host()->source_frame_number() == 1) {
1061 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1063 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1062 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); 1064 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1);
1063 } else if (layer_tree_host()->source_frame_number() == 2) { 1065 } else if (layer_tree_host()->source_frame_number() == 2) {
1064 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); 1066 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true);
1065 1067
1066 scoped_refptr<Layer> layer = Layer::Create(); 1068 scoped_refptr<Layer> layer = Layer::Create();
1067 layer_tree_host()->root_layer()->AddChild(layer); 1069 layer_tree_host()->root_layer()->AddChild(layer);
1070
1071 layer_tree_host()->SetElementIdsForTesting();
1068 layer->SetBounds(gfx::Size(4, 4)); 1072 layer->SetBounds(gfx::Size(4, 4));
1069 1073
1070 player_child_->AttachElement(layer->id()); 1074 player_child_->AttachElement(layer->element_id());
1071 player_child_->set_animation_delegate(this); 1075 player_child_->set_animation_delegate(this);
1072 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); 1076 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true);
1073 } 1077 }
1074 } 1078 }
1075 1079
1076 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { 1080 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
1077 host_impl->BlockNotifyReadyToActivateForTesting(true); 1081 host_impl->BlockNotifyReadyToActivateForTesting(true);
1078 } 1082 }
1079 1083
1080 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1084 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 1152
1149 layer_ = FakePictureLayer::Create(&client_); 1153 layer_ = FakePictureLayer::Create(&client_);
1150 layer_->SetBounds(gfx::Size(2, 2)); 1154 layer_->SetBounds(gfx::Size(2, 2));
1151 client_.set_bounds(layer_->bounds()); 1155 client_.set_bounds(layer_->bounds());
1152 // Transform the layer to 4,4 to start. 1156 // Transform the layer to 4,4 to start.
1153 gfx::Transform start_transform; 1157 gfx::Transform start_transform;
1154 start_transform.Translate(4.0, 4.0); 1158 start_transform.Translate(4.0, 4.0);
1155 layer_->SetTransform(start_transform); 1159 layer_->SetTransform(start_transform);
1156 1160
1157 layer_tree_host()->root_layer()->AddChild(layer_); 1161 layer_tree_host()->root_layer()->AddChild(layer_);
1158 player_->AttachElement(layer_->id()); 1162 layer_tree_host()->SetElementIdsForTesting();
1163
1164 player_->AttachElement(layer_->element_id());
1159 1165
1160 AttachPlayersToTimeline(); 1166 AttachPlayersToTimeline();
1161 } 1167 }
1162 1168
1163 void BeginTest() override { 1169 void BeginTest() override {
1164 // Add a translate from 6,7 to 8,9. 1170 // Add a translate from 6,7 to 8,9.
1165 TransformOperations start; 1171 TransformOperations start;
1166 start.AppendTranslate(6.f, 7.f, 0.f); 1172 start.AppendTranslate(6.f, 7.f, 0.f);
1167 TransformOperations end; 1173 TransformOperations end;
1168 end.AppendTranslate(8.f, 9.f, 0.f); 1174 end.AppendTranslate(8.f, 9.f, 0.f);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 // the animation should resume. 1224 // the animation should resume.
1219 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded 1225 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded
1220 : public LayerTreeHostAnimationTest { 1226 : public LayerTreeHostAnimationTest {
1221 public: 1227 public:
1222 void SetupTree() override { 1228 void SetupTree() override {
1223 LayerTreeHostAnimationTest::SetupTree(); 1229 LayerTreeHostAnimationTest::SetupTree();
1224 layer_ = Layer::Create(); 1230 layer_ = Layer::Create();
1225 layer_->SetBounds(gfx::Size(4, 4)); 1231 layer_->SetBounds(gfx::Size(4, 4));
1226 layer_tree_host()->root_layer()->AddChild(layer_); 1232 layer_tree_host()->root_layer()->AddChild(layer_);
1227 1233
1234 layer_tree_host()->SetElementIdsForTesting();
1235
1228 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); 1236 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get());
1229 timeline_->AttachPlayer(player_.get()); 1237 timeline_->AttachPlayer(player_.get());
1230 player_->AttachElement(layer_->id()); 1238 player_->AttachElement(layer_->element_id());
1231 DCHECK(player_->element_animations()); 1239 DCHECK(player_->element_animations());
1232 1240
1233 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); 1241 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true);
1234 } 1242 }
1235 1243
1236 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1244 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1237 1245
1238 void DidCommit() override { 1246 void DidCommit() override {
1239 switch (layer_tree_host()->source_frame_number()) { 1247 switch (layer_tree_host()->source_frame_number()) {
1240 case 0: 1248 case 0:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 : public LayerTreeHostAnimationTest { 1310 : public LayerTreeHostAnimationTest {
1303 public: 1311 public:
1304 void SetupTree() override { 1312 void SetupTree() override {
1305 LayerTreeHostAnimationTest::SetupTree(); 1313 LayerTreeHostAnimationTest::SetupTree();
1306 layer_ = Layer::Create(); 1314 layer_ = Layer::Create();
1307 layer_->SetBounds(gfx::Size(4, 4)); 1315 layer_->SetBounds(gfx::Size(4, 4));
1308 layer_tree_host()->root_layer()->AddChild(layer_); 1316 layer_tree_host()->root_layer()->AddChild(layer_);
1309 1317
1310 AttachPlayersToTimeline(); 1318 AttachPlayersToTimeline();
1311 1319
1312 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1320 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1313 player_child_->AttachElement(layer_->id()); 1321 player_child_->AttachElement(layer_->element_id());
1314 } 1322 }
1315 1323
1316 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1324 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1317 1325
1318 void DidCommit() override { 1326 void DidCommit() override {
1319 switch (layer_tree_host()->source_frame_number()) { 1327 switch (layer_tree_host()->source_frame_number()) {
1320 case 1: 1328 case 1:
1321 // First frame: add an animation to the root layer. 1329 // First frame: add an animation to the root layer.
1322 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5); 1330 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5);
1323 break; 1331 break;
1324 case 2: 1332 case 2:
1325 // Second frame: add an animation to the content layer. The root layer 1333 // Second frame: add an animation to the content layer. The root layer
1326 // animation has caused us to animate already during this frame. 1334 // animation has caused us to animate already during this frame.
1327 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false); 1335 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false);
1328 break; 1336 break;
1329 } 1337 }
1330 } 1338 }
1331 1339
1332 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { 1340 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
1333 // After both animations have started, verify that they have valid 1341 // After both animations have started, verify that they have valid
1334 // start times. 1342 // start times.
1335 if (host_impl->active_tree()->source_frame_number() < 2) 1343 if (host_impl->active_tree()->source_frame_number() < 2)
1336 return; 1344 return;
1337 AnimationHost::ElementToAnimationsMap element_animations_copy = 1345 AnimationHost::ElementToAnimationsMap element_animations_copy =
1338 host_impl->animation_host()->active_element_animations_for_testing(); 1346 host_impl->animation_host()->active_element_animations_for_testing();
1339 EXPECT_EQ(2u, element_animations_copy.size()); 1347 EXPECT_EQ(2u, element_animations_copy.size());
1340 for (auto& it : element_animations_copy) { 1348 for (auto& it : element_animations_copy) {
1341 int id = it.first; 1349 ElementId id = it.first;
1342 if (id == host_impl->active_tree()->root_layer_for_testing()->id()) { 1350 if (id ==
1351 host_impl->active_tree()->root_layer_for_testing()->element_id()) {
1343 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM); 1352 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM);
1344 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); 1353 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1345 } else if (id == layer_->id()) { 1354 } else if (id == layer_->element_id()) {
1346 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY); 1355 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY);
1347 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); 1356 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1348 } 1357 }
1349 EndTest(); 1358 EndTest();
1350 } 1359 }
1351 } 1360 }
1352 1361
1353 void AfterTest() override {} 1362 void AfterTest() override {}
1354 1363
1355 private: 1364 private:
1356 scoped_refptr<Layer> layer_; 1365 scoped_refptr<Layer> layer_;
1357 }; 1366 };
1358 1367
1359 SINGLE_AND_MULTI_THREAD_TEST_F( 1368 SINGLE_AND_MULTI_THREAD_TEST_F(
1360 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1369 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
1361 1370
1362 class LayerTreeHostAnimationTestRemoveAnimation 1371 class LayerTreeHostAnimationTestRemoveAnimation
1363 : public LayerTreeHostAnimationTest { 1372 : public LayerTreeHostAnimationTest {
1364 public: 1373 public:
1365 void SetupTree() override { 1374 void SetupTree() override {
1366 LayerTreeHostAnimationTest::SetupTree(); 1375 LayerTreeHostAnimationTest::SetupTree();
1367 layer_ = FakePictureLayer::Create(&client_); 1376 layer_ = FakePictureLayer::Create(&client_);
1368 layer_->SetBounds(gfx::Size(4, 4)); 1377 layer_->SetBounds(gfx::Size(4, 4));
1369 client_.set_bounds(layer_->bounds()); 1378 client_.set_bounds(layer_->bounds());
1370 layer_tree_host()->root_layer()->AddChild(layer_); 1379 layer_tree_host()->root_layer()->AddChild(layer_);
1371 1380
1372 AttachPlayersToTimeline(); 1381 AttachPlayersToTimeline();
1373 1382
1374 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1383 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1375 player_child_->AttachElement(layer_->id()); 1384 player_child_->AttachElement(layer_->element_id());
1376 } 1385 }
1377 1386
1378 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1387 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1379 1388
1380 void DidCommit() override { 1389 void DidCommit() override {
1381 switch (layer_tree_host()->source_frame_number()) { 1390 switch (layer_tree_host()->source_frame_number()) {
1382 case 1: 1391 case 1:
1383 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); 1392 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5);
1384 break; 1393 break;
1385 case 2: 1394 case 2:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 : public LayerTreeHostAnimationTest { 1452 : public LayerTreeHostAnimationTest {
1444 public: 1453 public:
1445 void SetupTree() override { 1454 void SetupTree() override {
1446 LayerTreeHostAnimationTest::SetupTree(); 1455 LayerTreeHostAnimationTest::SetupTree();
1447 layer_ = FakePictureLayer::Create(&client_); 1456 layer_ = FakePictureLayer::Create(&client_);
1448 layer_->SetBounds(gfx::Size(4, 4)); 1457 layer_->SetBounds(gfx::Size(4, 4));
1449 client_.set_bounds(layer_->bounds()); 1458 client_.set_bounds(layer_->bounds());
1450 layer_tree_host()->root_layer()->AddChild(layer_); 1459 layer_tree_host()->root_layer()->AddChild(layer_);
1451 1460
1452 AttachPlayersToTimeline(); 1461 AttachPlayersToTimeline();
1453 player_->AttachElement(layer_->id()); 1462 player_->AttachElement(layer_->element_id());
1454 } 1463 }
1455 1464
1456 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1465 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1457 1466
1458 void DidCommit() override { 1467 void DidCommit() override {
1459 switch (layer_tree_host()->source_frame_number()) { 1468 switch (layer_tree_host()->source_frame_number()) {
1460 case 1: 1469 case 1:
1461 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); 1470 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5);
1462 break; 1471 break;
1463 case 2: 1472 case 2:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1534
1526 void SetupTree() override { 1535 void SetupTree() override {
1527 LayerTreeHostAnimationTest::SetupTree(); 1536 LayerTreeHostAnimationTest::SetupTree();
1528 layer_ = FakePictureLayer::Create(&client_); 1537 layer_ = FakePictureLayer::Create(&client_);
1529 layer_->SetBounds(gfx::Size(4, 4)); 1538 layer_->SetBounds(gfx::Size(4, 4));
1530 client_.set_bounds(layer_->bounds()); 1539 client_.set_bounds(layer_->bounds());
1531 layer_tree_host()->root_layer()->AddChild(layer_); 1540 layer_tree_host()->root_layer()->AddChild(layer_);
1532 1541
1533 AttachPlayersToTimeline(); 1542 AttachPlayersToTimeline();
1534 1543
1535 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1544 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1536 player_child_->AttachElement(layer_->id()); 1545 player_child_->AttachElement(layer_->element_id());
1537 } 1546 }
1538 1547
1539 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1548 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1540 1549
1541 void DidCommit() override { 1550 void DidCommit() override {
1542 if (layer_tree_host()->source_frame_number() == 1) 1551 if (layer_tree_host()->source_frame_number() == 1)
1543 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5); 1552 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5);
1544 } 1553 }
1545 1554
1546 void WillCommit() override { 1555 void WillCommit() override {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 : called_animation_started_(false), called_animation_finished_(false) {} 1608 : called_animation_started_(false), called_animation_finished_(false) {}
1600 1609
1601 void SetupTree() override { 1610 void SetupTree() override {
1602 LayerTreeHostAnimationTest::SetupTree(); 1611 LayerTreeHostAnimationTest::SetupTree();
1603 picture_ = FakePictureLayer::Create(&client_); 1612 picture_ = FakePictureLayer::Create(&client_);
1604 picture_->SetBounds(gfx::Size(4, 4)); 1613 picture_->SetBounds(gfx::Size(4, 4));
1605 client_.set_bounds(picture_->bounds()); 1614 client_.set_bounds(picture_->bounds());
1606 layer_tree_host()->root_layer()->AddChild(picture_); 1615 layer_tree_host()->root_layer()->AddChild(picture_);
1607 1616
1608 AttachPlayersToTimeline(); 1617 AttachPlayersToTimeline();
1609 player_->AttachElement(picture_->id()); 1618 player_->AttachElement(picture_->element_id());
1610 player_->set_animation_delegate(this); 1619 player_->set_animation_delegate(this);
1611 } 1620 }
1612 1621
1613 void BeginTest() override { 1622 void BeginTest() override {
1614 PostAddLongAnimationToMainThreadPlayer(player_.get()); 1623 PostAddLongAnimationToMainThreadPlayer(player_.get());
1615 } 1624 }
1616 1625
1617 void NotifyAnimationStarted(base::TimeTicks monotonic_time, 1626 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
1618 TargetProperty::Type target_property, 1627 TargetProperty::Type target_property,
1619 int group) override { 1628 int group) override {
(...skipping 27 matching lines...) Expand all
1647 1656
1648 // Check that transform sync happens correctly at commit when we remove and add 1657 // Check that transform sync happens correctly at commit when we remove and add
1649 // a different animation player to an element. 1658 // a different animation player to an element.
1650 class LayerTreeHostAnimationTestChangeAnimationPlayer 1659 class LayerTreeHostAnimationTestChangeAnimationPlayer
1651 : public LayerTreeHostAnimationTest { 1660 : public LayerTreeHostAnimationTest {
1652 public: 1661 public:
1653 void SetupTree() override { 1662 void SetupTree() override {
1654 LayerTreeHostAnimationTest::SetupTree(); 1663 LayerTreeHostAnimationTest::SetupTree();
1655 AttachPlayersToTimeline(); 1664 AttachPlayersToTimeline();
1656 timeline_->DetachPlayer(player_child_.get()); 1665 timeline_->DetachPlayer(player_child_.get());
1657 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1666 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1658 1667
1659 TransformOperations start; 1668 TransformOperations start;
1660 start.AppendTranslate(5.f, 5.f, 0.f); 1669 start.AppendTranslate(5.f, 5.f, 0.f);
1661 TransformOperations end; 1670 TransformOperations end;
1662 end.AppendTranslate(5.f, 5.f, 0.f); 1671 end.AppendTranslate(5.f, 5.f, 0.f);
1663 AddAnimatedTransformToPlayer(player_.get(), 1.0, start, end); 1672 AddAnimatedTransformToPlayer(player_.get(), 1.0, start, end);
1664 } 1673 }
1665 1674
1666 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1675 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1667 1676
(...skipping 16 matching lines...) Expand all
1684 } 1693 }
1685 1694
1686 void DidCommit() override { PostSetNeedsCommitToMainThread(); } 1695 void DidCommit() override { PostSetNeedsCommitToMainThread(); }
1687 1696
1688 void WillBeginMainFrame() override { 1697 void WillBeginMainFrame() override {
1689 if (layer_tree_host()->source_frame_number() == 2) { 1698 if (layer_tree_host()->source_frame_number() == 2) {
1690 // Destroy player. 1699 // Destroy player.
1691 timeline_->DetachPlayer(player_.get()); 1700 timeline_->DetachPlayer(player_.get());
1692 player_ = nullptr; 1701 player_ = nullptr;
1693 timeline_->AttachPlayer(player_child_.get()); 1702 timeline_->AttachPlayer(player_child_.get());
1694 player_child_->AttachElement(layer_tree_host()->root_layer()->id()); 1703 player_child_->AttachElement(
1704 layer_tree_host()->root_layer()->element_id());
1695 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10); 1705 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10);
1696 Animation* animation = player_child_->element_animations()->GetAnimation( 1706 Animation* animation = player_child_->element_animations()->GetAnimation(
1697 TargetProperty::TRANSFORM); 1707 TargetProperty::TRANSFORM);
1698 animation->set_start_time(base::TimeTicks::Now() + 1708 animation->set_start_time(base::TimeTicks::Now() +
1699 base::TimeDelta::FromSecondsD(1000)); 1709 base::TimeDelta::FromSecondsD(1000));
1700 animation->set_fill_mode(Animation::FillMode::NONE); 1710 animation->set_fill_mode(Animation::FillMode::NONE);
1701 } 1711 }
1702 } 1712 }
1703 1713
1704 void AfterTest() override {} 1714 void AfterTest() override {}
1705 }; 1715 };
1706 1716
1707 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestChangeAnimationPlayer); 1717 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestChangeAnimationPlayer);
1708 1718
1709 // Check that SetTransformIsPotentiallyAnimatingChanged is called 1719 // Check that SetTransformIsPotentiallyAnimatingChanged is called
1710 // if we destroy ElementAnimations. 1720 // if we destroy ElementAnimations.
1711 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction 1721 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction
1712 : public LayerTreeHostAnimationTest { 1722 : public LayerTreeHostAnimationTest {
1713 public: 1723 public:
1714 void SetupTree() override { 1724 void SetupTree() override {
1715 prev_screen_space_transform_is_animating_ = true; 1725 prev_screen_space_transform_is_animating_ = true;
1716 screen_space_transform_animation_stopped_ = false; 1726 screen_space_transform_animation_stopped_ = false;
1717 1727
1718 LayerTreeHostAnimationTest::SetupTree(); 1728 LayerTreeHostAnimationTest::SetupTree();
1719 AttachPlayersToTimeline(); 1729 AttachPlayersToTimeline();
1720 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1730 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1721 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); 1731 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5);
1722 } 1732 }
1723 1733
1724 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1734 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1725 1735
1726 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1736 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1727 if (host_impl->pending_tree()->source_frame_number() <= 1) { 1737 if (host_impl->pending_tree()->source_frame_number() <= 1) {
1728 EXPECT_TRUE(host_impl->pending_tree() 1738 EXPECT_TRUE(host_impl->pending_tree()
1729 ->root_layer_for_testing() 1739 ->root_layer_for_testing()
1730 ->screen_space_transform_is_animating()); 1740 ->screen_space_transform_is_animating());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 public: 1804 public:
1795 void SetupTree() override { 1805 void SetupTree() override {
1796 LayerTreeHostAnimationTest::SetupTree(); 1806 LayerTreeHostAnimationTest::SetupTree();
1797 layer_ = FakePictureLayer::Create(&client_); 1807 layer_ = FakePictureLayer::Create(&client_);
1798 layer_->SetBounds(gfx::Size(4, 4)); 1808 layer_->SetBounds(gfx::Size(4, 4));
1799 client_.set_bounds(layer_->bounds()); 1809 client_.set_bounds(layer_->bounds());
1800 layer_tree_host()->root_layer()->AddChild(layer_); 1810 layer_tree_host()->root_layer()->AddChild(layer_);
1801 1811
1802 AttachPlayersToTimeline(); 1812 AttachPlayersToTimeline();
1803 1813
1804 player_->AttachElement(layer_tree_host()->root_layer()->id()); 1814 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1805 player_child_->AttachElement(layer_->id()); 1815 player_child_->AttachElement(layer_->element_id());
1806 } 1816 }
1807 1817
1808 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1818 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1809 1819
1810 void DidCommit() override { 1820 void DidCommit() override {
1811 if (layer_tree_host()->source_frame_number() == 1 || 1821 if (layer_tree_host()->source_frame_number() == 1 ||
1812 layer_tree_host()->source_frame_number() == 2) 1822 layer_tree_host()->source_frame_number() == 2)
1813 PostSetNeedsCommitToMainThread(); 1823 PostSetNeedsCommitToMainThread();
1814 } 1824 }
1815 1825
(...skipping 16 matching lines...) Expand all
1832 private: 1842 private:
1833 scoped_refptr<Layer> layer_; 1843 scoped_refptr<Layer> layer_;
1834 FakeContentLayerClient client_; 1844 FakeContentLayerClient client_;
1835 }; 1845 };
1836 1846
1837 MULTI_THREAD_TEST_F( 1847 MULTI_THREAD_TEST_F(
1838 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); 1848 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit);
1839 1849
1840 } // namespace 1850 } // namespace
1841 } // namespace cc 1851 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698