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

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

Issue 2251143002: cc: Reland Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better fix? Created 4 years, 4 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 26 matching lines...) Expand all
37 player_id_(AnimationIdProvider::NextPlayerId()), 37 player_id_(AnimationIdProvider::NextPlayerId()),
38 player_child_id_(AnimationIdProvider::NextPlayerId()) { 38 player_child_id_(AnimationIdProvider::NextPlayerId()) {
39 timeline_ = AnimationTimeline::Create(timeline_id_); 39 timeline_ = AnimationTimeline::Create(timeline_id_);
40 player_ = AnimationPlayer::Create(player_id_); 40 player_ = AnimationPlayer::Create(player_id_);
41 player_child_ = AnimationPlayer::Create(player_child_id_); 41 player_child_ = AnimationPlayer::Create(player_child_id_);
42 42
43 player_->set_animation_delegate(this); 43 player_->set_animation_delegate(this);
44 } 44 }
45 45
46 void AttachPlayersToTimeline() { 46 void AttachPlayersToTimeline() {
47 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); 47 layer_tree()->animation_host()->AddAnimationTimeline(timeline_.get());
48 layer_tree_host()->SetElementIdsForTesting(); 48 layer_tree_host()->SetElementIdsForTesting();
49 timeline_->AttachPlayer(player_.get()); 49 timeline_->AttachPlayer(player_.get());
50 timeline_->AttachPlayer(player_child_.get()); 50 timeline_->AttachPlayer(player_child_.get());
51 } 51 }
52 52
53 protected: 53 protected:
54 scoped_refptr<AnimationTimeline> timeline_; 54 scoped_refptr<AnimationTimeline> timeline_;
55 scoped_refptr<AnimationPlayer> player_; 55 scoped_refptr<AnimationPlayer> player_;
56 scoped_refptr<AnimationPlayer> player_child_; 56 scoped_refptr<AnimationPlayer> player_child_;
57 57
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // Add a layer animation and confirm that 140 // Add a layer animation and confirm that
141 // LayerTreeHostImpl::UpdateAnimationState does get called. 141 // LayerTreeHostImpl::UpdateAnimationState does get called.
142 class LayerTreeHostAnimationTestAddAnimation 142 class LayerTreeHostAnimationTestAddAnimation
143 : public LayerTreeHostAnimationTest { 143 : public LayerTreeHostAnimationTest {
144 public: 144 public:
145 LayerTreeHostAnimationTestAddAnimation() 145 LayerTreeHostAnimationTestAddAnimation()
146 : update_animation_state_was_called_(false) {} 146 : update_animation_state_was_called_(false) {}
147 147
148 void BeginTest() override { 148 void BeginTest() override {
149 AttachPlayersToTimeline(); 149 AttachPlayersToTimeline();
150 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 150 player_->AttachElement(layer_tree()->root_layer()->element_id());
151 PostAddInstantAnimationToMainThreadPlayer(player_.get()); 151 PostAddInstantAnimationToMainThreadPlayer(player_.get());
152 } 152 }
153 153
154 void UpdateAnimationState(LayerTreeHostImpl* host_impl, 154 void UpdateAnimationState(LayerTreeHostImpl* host_impl,
155 bool has_unfinished_animation) override { 155 bool has_unfinished_animation) override {
156 EXPECT_FALSE(has_unfinished_animation); 156 EXPECT_FALSE(has_unfinished_animation);
157 update_animation_state_was_called_ = true; 157 update_animation_state_was_called_ = true;
158 } 158 }
159 159
160 void NotifyAnimationStarted(base::TimeTicks monotonic_time, 160 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
(...skipping 20 matching lines...) Expand all
181 // Add a layer animation to a layer, but continually fail to draw. Confirm that 181 // Add a layer animation to a layer, but continually fail to draw. Confirm that
182 // after a while, we do eventually force a draw. 182 // after a while, we do eventually force a draw.
183 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws 183 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws
184 : public LayerTreeHostAnimationTest { 184 : public LayerTreeHostAnimationTest {
185 public: 185 public:
186 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws() 186 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws()
187 : started_animating_(false) {} 187 : started_animating_(false) {}
188 188
189 void BeginTest() override { 189 void BeginTest() override {
190 AttachPlayersToTimeline(); 190 AttachPlayersToTimeline();
191 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 191 player_->AttachElement(layer_tree()->root_layer()->element_id());
192 PostAddAnimationToMainThreadPlayer(player_.get()); 192 PostAddAnimationToMainThreadPlayer(player_.get());
193 } 193 }
194 194
195 void AnimateLayers(LayerTreeHostImpl* host_impl, 195 void AnimateLayers(LayerTreeHostImpl* host_impl,
196 base::TimeTicks monotonic_time) override { 196 base::TimeTicks monotonic_time) override {
197 started_animating_ = true; 197 started_animating_ = true;
198 } 198 }
199 199
200 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 200 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
201 if (started_animating_) 201 if (started_animating_)
(...skipping 17 matching lines...) Expand all
219 219
220 // Ensures that animations eventually get deleted. 220 // Ensures that animations eventually get deleted.
221 class LayerTreeHostAnimationTestAnimationsGetDeleted 221 class LayerTreeHostAnimationTestAnimationsGetDeleted
222 : public LayerTreeHostAnimationTest { 222 : public LayerTreeHostAnimationTest {
223 public: 223 public:
224 LayerTreeHostAnimationTestAnimationsGetDeleted() 224 LayerTreeHostAnimationTestAnimationsGetDeleted()
225 : started_animating_(false) {} 225 : started_animating_(false) {}
226 226
227 void BeginTest() override { 227 void BeginTest() override {
228 AttachPlayersToTimeline(); 228 AttachPlayersToTimeline();
229 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 229 player_->AttachElement(layer_tree()->root_layer()->element_id());
230 PostAddAnimationToMainThreadPlayer(player_.get()); 230 PostAddAnimationToMainThreadPlayer(player_.get());
231 } 231 }
232 232
233 void AnimateLayers(LayerTreeHostImpl* host_impl, 233 void AnimateLayers(LayerTreeHostImpl* host_impl,
234 base::TimeTicks monotonic_time) override { 234 base::TimeTicks monotonic_time) override {
235 bool have_animations = !host_impl->animation_host() 235 bool have_animations = !host_impl->animation_host()
236 ->active_element_animations_for_testing() 236 ->active_element_animations_for_testing()
237 .empty(); 237 .empty();
238 if (!started_animating_ && have_animations) { 238 if (!started_animating_ && have_animations) {
239 started_animating_ = true; 239 started_animating_ = true;
(...skipping 22 matching lines...) Expand all
262 262
263 // Ensure that an animation's timing function is respected. 263 // Ensure that an animation's timing function is respected.
264 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction 264 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction
265 : public LayerTreeHostAnimationTest { 265 : public LayerTreeHostAnimationTest {
266 public: 266 public:
267 void SetupTree() override { 267 void SetupTree() override {
268 LayerTreeHostAnimationTest::SetupTree(); 268 LayerTreeHostAnimationTest::SetupTree();
269 picture_ = FakePictureLayer::Create(&client_); 269 picture_ = FakePictureLayer::Create(&client_);
270 picture_->SetBounds(gfx::Size(4, 4)); 270 picture_->SetBounds(gfx::Size(4, 4));
271 client_.set_bounds(picture_->bounds()); 271 client_.set_bounds(picture_->bounds());
272 layer_tree_host()->root_layer()->AddChild(picture_); 272 layer_tree()->root_layer()->AddChild(picture_);
273 273
274 AttachPlayersToTimeline(); 274 AttachPlayersToTimeline();
275 player_child_->AttachElement(picture_->element_id()); 275 player_child_->AttachElement(picture_->element_id());
276 } 276 }
277 277
278 void BeginTest() override { 278 void BeginTest() override {
279 PostAddAnimationToMainThreadPlayer(player_child_.get()); 279 PostAddAnimationToMainThreadPlayer(player_child_.get());
280 } 280 }
281 281
282 void AnimateLayers(LayerTreeHostImpl* host_impl, 282 void AnimateLayers(LayerTreeHostImpl* host_impl,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // impl thread animations. 327 // impl thread animations.
328 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes 328 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes
329 : public LayerTreeHostAnimationTest { 329 : public LayerTreeHostAnimationTest {
330 public: 330 public:
331 void SetupTree() override { 331 void SetupTree() override {
332 LayerTreeHostAnimationTest::SetupTree(); 332 LayerTreeHostAnimationTest::SetupTree();
333 picture_ = FakePictureLayer::Create(&client_); 333 picture_ = FakePictureLayer::Create(&client_);
334 picture_->SetBounds(gfx::Size(4, 4)); 334 picture_->SetBounds(gfx::Size(4, 4));
335 client_.set_bounds(picture_->bounds()); 335 client_.set_bounds(picture_->bounds());
336 336
337 layer_tree_host()->root_layer()->AddChild(picture_); 337 layer_tree()->root_layer()->AddChild(picture_);
338 338
339 AttachPlayersToTimeline(); 339 AttachPlayersToTimeline();
340 player_child_->set_animation_delegate(this); 340 player_child_->set_animation_delegate(this);
341 player_child_->AttachElement(picture_->element_id()); 341 player_child_->AttachElement(picture_->element_id());
342 } 342 }
343 343
344 void BeginTest() override { 344 void BeginTest() override {
345 PostAddAnimationToMainThreadPlayer(player_child_.get()); 345 PostAddAnimationToMainThreadPlayer(player_child_.get());
346 } 346 }
347 347
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 SINGLE_AND_MULTI_THREAD_TEST_F( 386 SINGLE_AND_MULTI_THREAD_TEST_F(
387 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes); 387 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes);
388 388
389 // Ensures that notify animation finished is called. 389 // Ensures that notify animation finished is called.
390 class LayerTreeHostAnimationTestAnimationFinishedEvents 390 class LayerTreeHostAnimationTestAnimationFinishedEvents
391 : public LayerTreeHostAnimationTest { 391 : public LayerTreeHostAnimationTest {
392 public: 392 public:
393 void BeginTest() override { 393 void BeginTest() override {
394 AttachPlayersToTimeline(); 394 AttachPlayersToTimeline();
395 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 395 player_->AttachElement(layer_tree()->root_layer()->element_id());
396 PostAddInstantAnimationToMainThreadPlayer(player_.get()); 396 PostAddInstantAnimationToMainThreadPlayer(player_.get());
397 } 397 }
398 398
399 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 399 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
400 TargetProperty::Type target_property, 400 TargetProperty::Type target_property,
401 int group) override { 401 int group) override {
402 Animation* animation = 402 Animation* animation =
403 player_->element_animations()->GetAnimation(TargetProperty::OPACITY); 403 player_->element_animations()->GetAnimation(TargetProperty::OPACITY);
404 if (animation) 404 if (animation)
405 player_->element_animations()->RemoveAnimation(animation->id()); 405 player_->element_animations()->RemoveAnimation(animation->id());
(...skipping 10 matching lines...) Expand all
416 // subtree to be skipped. 416 // subtree to be skipped.
417 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity 417 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity
418 : public LayerTreeHostAnimationTest { 418 : public LayerTreeHostAnimationTest {
419 public: 419 public:
420 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity() 420 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity()
421 : update_check_layer_() {} 421 : update_check_layer_() {}
422 422
423 void SetupTree() override { 423 void SetupTree() override {
424 update_check_layer_ = FakePictureLayer::Create(&client_); 424 update_check_layer_ = FakePictureLayer::Create(&client_);
425 update_check_layer_->SetOpacity(0.f); 425 update_check_layer_->SetOpacity(0.f);
426 layer_tree_host()->SetRootLayer(update_check_layer_); 426 layer_tree()->SetRootLayer(update_check_layer_);
427 client_.set_bounds(update_check_layer_->bounds()); 427 client_.set_bounds(update_check_layer_->bounds());
428 LayerTreeHostAnimationTest::SetupTree(); 428 LayerTreeHostAnimationTest::SetupTree();
429 429
430 AttachPlayersToTimeline(); 430 AttachPlayersToTimeline();
431 player_->AttachElement(update_check_layer_->element_id()); 431 player_->AttachElement(update_check_layer_->element_id());
432 } 432 }
433 433
434 void BeginTest() override { 434 void BeginTest() override {
435 PostAddAnimationToMainThreadPlayer(player_.get()); 435 PostAddAnimationToMainThreadPlayer(player_.get());
436 } 436 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 player_->AttachElement(layer->element_id()); 480 player_->AttachElement(layer->element_id());
481 player_->set_animation_delegate(this); 481 player_->set_animation_delegate(this);
482 482
483 // Any valid AnimationCurve will do here. 483 // Any valid AnimationCurve will do here.
484 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); 484 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve());
485 std::unique_ptr<Animation> animation( 485 std::unique_ptr<Animation> animation(
486 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY)); 486 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY));
487 player_->AddAnimation(std::move(animation)); 487 player_->AddAnimation(std::move(animation));
488 488
489 // We add the animation *before* attaching the layer to the tree. 489 // We add the animation *before* attaching the layer to the tree.
490 layer_tree_host()->root_layer()->AddChild(layer); 490 layer_tree()->root_layer()->AddChild(layer);
491 } 491 }
492 } 492 }
493 493
494 void AnimateLayers(LayerTreeHostImpl* impl_host, 494 void AnimateLayers(LayerTreeHostImpl* impl_host,
495 base::TimeTicks monotonic_time) override { 495 base::TimeTicks monotonic_time) override {
496 EndTest(); 496 EndTest();
497 } 497 }
498 498
499 void AfterTest() override {} 499 void AfterTest() override {}
500 }; 500 };
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 618
619 // Animations should not be started when frames are being skipped due to 619 // Animations should not be started when frames are being skipped due to
620 // checkerboard. 620 // checkerboard.
621 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations 621 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
622 : public LayerTreeHostAnimationTest { 622 : public LayerTreeHostAnimationTest {
623 void SetupTree() override { 623 void SetupTree() override {
624 LayerTreeHostAnimationTest::SetupTree(); 624 LayerTreeHostAnimationTest::SetupTree();
625 picture_ = FakePictureLayer::Create(&client_); 625 picture_ = FakePictureLayer::Create(&client_);
626 picture_->SetBounds(gfx::Size(4, 4)); 626 picture_->SetBounds(gfx::Size(4, 4));
627 client_.set_bounds(picture_->bounds()); 627 client_.set_bounds(picture_->bounds());
628 layer_tree_host()->root_layer()->AddChild(picture_); 628 layer_tree()->root_layer()->AddChild(picture_);
629 629
630 AttachPlayersToTimeline(); 630 AttachPlayersToTimeline();
631 player_child_->AttachElement(picture_->element_id()); 631 player_child_->AttachElement(picture_->element_id());
632 player_child_->set_animation_delegate(this); 632 player_child_->set_animation_delegate(this);
633 } 633 }
634 634
635 void InitializeSettings(LayerTreeSettings* settings) override { 635 void InitializeSettings(LayerTreeSettings* settings) override {
636 // Make sure that drawing many times doesn't cause a checkerboarded 636 // Make sure that drawing many times doesn't cause a checkerboarded
637 // animation to start so we avoid flake in this test. 637 // animation to start so we avoid flake in this test.
638 settings->timeout_and_draw_when_animation_checkerboards = false; 638 settings->timeout_and_draw_when_animation_checkerboards = false;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 // Verifies that scroll offset animations are only accepted when impl-scrolling 703 // Verifies that scroll offset animations are only accepted when impl-scrolling
704 // is supported, and that when scroll offset animations are accepted, 704 // is supported, and that when scroll offset animations are accepted,
705 // scroll offset updates are sent back to the main thread. 705 // scroll offset updates are sent back to the main thread.
706 class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated 706 class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated
707 : public LayerTreeHostAnimationTest { 707 : public LayerTreeHostAnimationTest {
708 public: 708 public:
709 void SetupTree() override { 709 void SetupTree() override {
710 LayerTreeHostAnimationTest::SetupTree(); 710 LayerTreeHostAnimationTest::SetupTree();
711 711
712 scroll_layer_ = FakePictureLayer::Create(&client_); 712 scroll_layer_ = FakePictureLayer::Create(&client_);
713 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); 713 scroll_layer_->SetScrollClipLayerId(layer_tree()->root_layer()->id());
714 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); 714 scroll_layer_->SetBounds(gfx::Size(1000, 1000));
715 client_.set_bounds(scroll_layer_->bounds()); 715 client_.set_bounds(scroll_layer_->bounds());
716 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 716 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
717 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 717 layer_tree()->root_layer()->AddChild(scroll_layer_);
718 718
719 AttachPlayersToTimeline(); 719 AttachPlayersToTimeline();
720 player_child_->AttachElement(scroll_layer_->element_id()); 720 player_child_->AttachElement(scroll_layer_->element_id());
721 } 721 }
722 722
723 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 723 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
724 724
725 void DidCommit() override { 725 void DidCommit() override {
726 switch (layer_tree_host()->source_frame_number()) { 726 switch (layer_tree_host()->source_frame_number()) {
727 case 1: { 727 case 1: {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 public: 765 public:
766 LayerTreeHostAnimationTestScrollOffsetAnimationTakeover() {} 766 LayerTreeHostAnimationTestScrollOffsetAnimationTakeover() {}
767 767
768 void SetupTree() override { 768 void SetupTree() override {
769 LayerTreeHostAnimationTest::SetupTree(); 769 LayerTreeHostAnimationTest::SetupTree();
770 770
771 scroll_layer_ = FakePictureLayer::Create(&client_); 771 scroll_layer_ = FakePictureLayer::Create(&client_);
772 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); 772 scroll_layer_->SetBounds(gfx::Size(10000, 10000));
773 client_.set_bounds(scroll_layer_->bounds()); 773 client_.set_bounds(scroll_layer_->bounds());
774 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 774 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
775 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 775 layer_tree()->root_layer()->AddChild(scroll_layer_);
776 776
777 AttachPlayersToTimeline(); 777 AttachPlayersToTimeline();
778 player_child_->AttachElement(scroll_layer_->element_id()); 778 player_child_->AttachElement(scroll_layer_->element_id());
779 // Allows NotifyAnimationTakeover to get called. 779 // Allows NotifyAnimationTakeover to get called.
780 player_child_->set_animation_delegate(this); 780 player_child_->set_animation_delegate(this);
781 } 781 }
782 782
783 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 783 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
784 784
785 void DidCommit() override { 785 void DidCommit() override {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 public: 828 public:
829 LayerTreeHostAnimationTestScrollOffsetAnimationAdjusted() {} 829 LayerTreeHostAnimationTestScrollOffsetAnimationAdjusted() {}
830 830
831 void SetupTree() override { 831 void SetupTree() override {
832 LayerTreeHostAnimationTest::SetupTree(); 832 LayerTreeHostAnimationTest::SetupTree();
833 833
834 scroll_layer_ = FakePictureLayer::Create(&client_); 834 scroll_layer_ = FakePictureLayer::Create(&client_);
835 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); 835 scroll_layer_->SetBounds(gfx::Size(10000, 10000));
836 client_.set_bounds(scroll_layer_->bounds()); 836 client_.set_bounds(scroll_layer_->bounds());
837 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 837 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
838 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 838 layer_tree()->root_layer()->AddChild(scroll_layer_);
839 839
840 AttachPlayersToTimeline(); 840 AttachPlayersToTimeline();
841 player_child_->AttachElement(scroll_layer_->element_id()); 841 player_child_->AttachElement(scroll_layer_->element_id());
842 } 842 }
843 843
844 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 844 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
845 845
846 void DidCommit() override { 846 void DidCommit() override {
847 if (layer_tree_host()->source_frame_number() == 1) { 847 if (layer_tree_host()->source_frame_number() == 1) {
848 // Add an update after the first commit to trigger the animation update 848 // Add an update after the first commit to trigger the animation update
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval 930 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval
931 : public LayerTreeHostAnimationTest { 931 : public LayerTreeHostAnimationTest {
932 public: 932 public:
933 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval() 933 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval()
934 : final_postion_(50.0, 100.0) {} 934 : final_postion_(50.0, 100.0) {}
935 935
936 void SetupTree() override { 936 void SetupTree() override {
937 LayerTreeHostAnimationTest::SetupTree(); 937 LayerTreeHostAnimationTest::SetupTree();
938 938
939 scroll_layer_ = FakePictureLayer::Create(&client_); 939 scroll_layer_ = FakePictureLayer::Create(&client_);
940 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); 940 scroll_layer_->SetScrollClipLayerId(layer_tree()->root_layer()->id());
941 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); 941 scroll_layer_->SetBounds(gfx::Size(10000, 10000));
942 client_.set_bounds(scroll_layer_->bounds()); 942 client_.set_bounds(scroll_layer_->bounds());
943 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0)); 943 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0));
944 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 944 layer_tree()->root_layer()->AddChild(scroll_layer_);
945 945
946 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 946 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
947 ScrollOffsetAnimationCurve::Create( 947 ScrollOffsetAnimationCurve::Create(
948 gfx::ScrollOffset(6500.f, 7500.f), 948 gfx::ScrollOffset(6500.f, 7500.f),
949 CubicBezierTimingFunction::CreatePreset( 949 CubicBezierTimingFunction::CreatePreset(
950 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); 950 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
951 std::unique_ptr<Animation> animation(Animation::Create( 951 std::unique_ptr<Animation> animation(Animation::Create(
952 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 952 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
953 animation->set_needs_synchronized_start_time(true); 953 animation->set_needs_synchronized_start_time(true);
954 954
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() 1054 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers()
1055 : frame_count_with_pending_tree_(0) {} 1055 : frame_count_with_pending_tree_(0) {}
1056 1056
1057 void BeginTest() override { 1057 void BeginTest() override {
1058 AttachPlayersToTimeline(); 1058 AttachPlayersToTimeline();
1059 PostSetNeedsCommitToMainThread(); 1059 PostSetNeedsCommitToMainThread();
1060 } 1060 }
1061 1061
1062 void DidCommit() override { 1062 void DidCommit() override {
1063 if (layer_tree_host()->source_frame_number() == 1) { 1063 if (layer_tree_host()->source_frame_number() == 1) {
1064 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 1064 player_->AttachElement(layer_tree()->root_layer()->element_id());
1065 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); 1065 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1);
1066 } else if (layer_tree_host()->source_frame_number() == 2) { 1066 } else if (layer_tree_host()->source_frame_number() == 2) {
1067 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); 1067 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true);
1068 1068
1069 scoped_refptr<Layer> layer = Layer::Create(); 1069 scoped_refptr<Layer> layer = Layer::Create();
1070 layer_tree_host()->root_layer()->AddChild(layer); 1070 layer_tree()->root_layer()->AddChild(layer);
1071 1071
1072 layer_tree_host()->SetElementIdsForTesting(); 1072 layer_tree_host()->SetElementIdsForTesting();
1073 layer->SetBounds(gfx::Size(4, 4)); 1073 layer->SetBounds(gfx::Size(4, 4));
1074 1074
1075 player_child_->AttachElement(layer->element_id()); 1075 player_child_->AttachElement(layer->element_id());
1076 player_child_->set_animation_delegate(this); 1076 player_child_->set_animation_delegate(this);
1077 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); 1077 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true);
1078 } 1078 }
1079 } 1079 }
1080 1080
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 LayerTreeHostAnimationTest::SetupTree(); 1152 LayerTreeHostAnimationTest::SetupTree();
1153 1153
1154 layer_ = FakePictureLayer::Create(&client_); 1154 layer_ = FakePictureLayer::Create(&client_);
1155 layer_->SetBounds(gfx::Size(2, 2)); 1155 layer_->SetBounds(gfx::Size(2, 2));
1156 client_.set_bounds(layer_->bounds()); 1156 client_.set_bounds(layer_->bounds());
1157 // Transform the layer to 4,4 to start. 1157 // Transform the layer to 4,4 to start.
1158 gfx::Transform start_transform; 1158 gfx::Transform start_transform;
1159 start_transform.Translate(4.0, 4.0); 1159 start_transform.Translate(4.0, 4.0);
1160 layer_->SetTransform(start_transform); 1160 layer_->SetTransform(start_transform);
1161 1161
1162 layer_tree_host()->root_layer()->AddChild(layer_); 1162 layer_tree()->root_layer()->AddChild(layer_);
1163 layer_tree_host()->SetElementIdsForTesting(); 1163 layer_tree_host()->SetElementIdsForTesting();
1164 1164
1165 player_->AttachElement(layer_->element_id()); 1165 player_->AttachElement(layer_->element_id());
1166 1166
1167 AttachPlayersToTimeline(); 1167 AttachPlayersToTimeline();
1168 } 1168 }
1169 1169
1170 void BeginTest() override { 1170 void BeginTest() override {
1171 // Add a translate from 6,7 to 8,9. 1171 // Add a translate from 6,7 to 8,9.
1172 TransformOperations start; 1172 TransformOperations start;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1223
1224 // When a layer with an animation is removed from the tree and later re-added, 1224 // When a layer with an animation is removed from the tree and later re-added,
1225 // the animation should resume. 1225 // the animation should resume.
1226 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded 1226 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded
1227 : public LayerTreeHostAnimationTest { 1227 : public LayerTreeHostAnimationTest {
1228 public: 1228 public:
1229 void SetupTree() override { 1229 void SetupTree() override {
1230 LayerTreeHostAnimationTest::SetupTree(); 1230 LayerTreeHostAnimationTest::SetupTree();
1231 layer_ = Layer::Create(); 1231 layer_ = Layer::Create();
1232 layer_->SetBounds(gfx::Size(4, 4)); 1232 layer_->SetBounds(gfx::Size(4, 4));
1233 layer_tree_host()->root_layer()->AddChild(layer_); 1233 layer_tree()->root_layer()->AddChild(layer_);
1234 1234
1235 layer_tree_host()->SetElementIdsForTesting(); 1235 layer_tree_host()->SetElementIdsForTesting();
1236 1236
1237 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); 1237 layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get());
1238 timeline_->AttachPlayer(player_.get()); 1238 timeline_->AttachPlayer(player_.get());
1239 player_->AttachElement(layer_->element_id()); 1239 player_->AttachElement(layer_->element_id());
1240 DCHECK(player_->element_animations()); 1240 DCHECK(player_->element_animations());
1241 1241
1242 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); 1242 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true);
1243 } 1243 }
(...skipping 11 matching lines...) Expand all
1255 break; 1255 break;
1256 case 1: 1256 case 1:
1257 layer_->RemoveFromParent(); 1257 layer_->RemoveFromParent();
1258 EXPECT_FALSE( 1258 EXPECT_FALSE(
1259 player_->element_animations()->has_element_in_active_list()); 1259 player_->element_animations()->has_element_in_active_list());
1260 EXPECT_FALSE( 1260 EXPECT_FALSE(
1261 player_->element_animations()->has_element_in_pending_list()); 1261 player_->element_animations()->has_element_in_pending_list());
1262 EXPECT_FALSE(layer_tree_host()->animation_host()->NeedsAnimateLayers()); 1262 EXPECT_FALSE(layer_tree_host()->animation_host()->NeedsAnimateLayers());
1263 break; 1263 break;
1264 case 2: 1264 case 2:
1265 layer_tree_host()->root_layer()->AddChild(layer_); 1265 layer_tree()->root_layer()->AddChild(layer_);
1266 EXPECT_TRUE( 1266 EXPECT_TRUE(
1267 player_->element_animations()->has_element_in_active_list()); 1267 player_->element_animations()->has_element_in_active_list());
1268 EXPECT_FALSE( 1268 EXPECT_FALSE(
1269 player_->element_animations()->has_element_in_pending_list()); 1269 player_->element_animations()->has_element_in_pending_list());
1270 EXPECT_TRUE(layer_tree_host()->animation_host()->NeedsAnimateLayers()); 1270 EXPECT_TRUE(layer_tree_host()->animation_host()->NeedsAnimateLayers());
1271 break; 1271 break;
1272 } 1272 }
1273 } 1273 }
1274 1274
1275 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1275 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 SINGLE_AND_MULTI_THREAD_TEST_F( 1307 SINGLE_AND_MULTI_THREAD_TEST_F(
1308 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded); 1308 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded);
1309 1309
1310 class LayerTreeHostAnimationTestAddAnimationAfterAnimating 1310 class LayerTreeHostAnimationTestAddAnimationAfterAnimating
1311 : public LayerTreeHostAnimationTest { 1311 : public LayerTreeHostAnimationTest {
1312 public: 1312 public:
1313 void SetupTree() override { 1313 void SetupTree() override {
1314 LayerTreeHostAnimationTest::SetupTree(); 1314 LayerTreeHostAnimationTest::SetupTree();
1315 layer_ = Layer::Create(); 1315 layer_ = Layer::Create();
1316 layer_->SetBounds(gfx::Size(4, 4)); 1316 layer_->SetBounds(gfx::Size(4, 4));
1317 layer_tree_host()->root_layer()->AddChild(layer_); 1317 layer_tree()->root_layer()->AddChild(layer_);
1318 1318
1319 AttachPlayersToTimeline(); 1319 AttachPlayersToTimeline();
1320 1320
1321 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 1321 player_->AttachElement(layer_tree()->root_layer()->element_id());
1322 player_child_->AttachElement(layer_->element_id()); 1322 player_child_->AttachElement(layer_->element_id());
1323 } 1323 }
1324 1324
1325 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1325 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1326 1326
1327 void DidCommit() override { 1327 void DidCommit() override {
1328 switch (layer_tree_host()->source_frame_number()) { 1328 switch (layer_tree_host()->source_frame_number()) {
1329 case 1: 1329 case 1:
1330 // First frame: add an animation to the root layer. 1330 // First frame: add an animation to the root layer.
1331 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5); 1331 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1382 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
1383 1383
1384 class LayerTreeHostAnimationTestRemoveAnimation 1384 class LayerTreeHostAnimationTestRemoveAnimation
1385 : public LayerTreeHostAnimationTest { 1385 : public LayerTreeHostAnimationTest {
1386 public: 1386 public:
1387 void SetupTree() override { 1387 void SetupTree() override {
1388 LayerTreeHostAnimationTest::SetupTree(); 1388 LayerTreeHostAnimationTest::SetupTree();
1389 layer_ = FakePictureLayer::Create(&client_); 1389 layer_ = FakePictureLayer::Create(&client_);
1390 layer_->SetBounds(gfx::Size(4, 4)); 1390 layer_->SetBounds(gfx::Size(4, 4));
1391 client_.set_bounds(layer_->bounds()); 1391 client_.set_bounds(layer_->bounds());
1392 layer_tree_host()->root_layer()->AddChild(layer_); 1392 layer_tree()->root_layer()->AddChild(layer_);
1393 1393
1394 AttachPlayersToTimeline(); 1394 AttachPlayersToTimeline();
1395 1395
1396 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 1396 player_->AttachElement(layer_tree()->root_layer()->element_id());
1397 player_child_->AttachElement(layer_->element_id()); 1397 player_child_->AttachElement(layer_->element_id());
1398 } 1398 }
1399 1399
1400 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1400 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1401 1401
1402 void DidCommit() override { 1402 void DidCommit() override {
1403 switch (layer_tree_host()->source_frame_number()) { 1403 switch (layer_tree_host()->source_frame_number()) {
1404 case 1: 1404 case 1:
1405 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); 1405 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5);
1406 break; 1406 break;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestRemoveAnimation); 1463 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestRemoveAnimation);
1464 1464
1465 class LayerTreeHostAnimationTestIsAnimating 1465 class LayerTreeHostAnimationTestIsAnimating
1466 : public LayerTreeHostAnimationTest { 1466 : public LayerTreeHostAnimationTest {
1467 public: 1467 public:
1468 void SetupTree() override { 1468 void SetupTree() override {
1469 LayerTreeHostAnimationTest::SetupTree(); 1469 LayerTreeHostAnimationTest::SetupTree();
1470 layer_ = FakePictureLayer::Create(&client_); 1470 layer_ = FakePictureLayer::Create(&client_);
1471 layer_->SetBounds(gfx::Size(4, 4)); 1471 layer_->SetBounds(gfx::Size(4, 4));
1472 client_.set_bounds(layer_->bounds()); 1472 client_.set_bounds(layer_->bounds());
1473 layer_tree_host()->root_layer()->AddChild(layer_); 1473 layer_tree()->root_layer()->AddChild(layer_);
1474 1474
1475 AttachPlayersToTimeline(); 1475 AttachPlayersToTimeline();
1476 player_->AttachElement(layer_->element_id()); 1476 player_->AttachElement(layer_->element_id());
1477 } 1477 }
1478 1478
1479 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1479 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1480 1480
1481 void DidCommit() override { 1481 void DidCommit() override {
1482 switch (layer_tree_host()->source_frame_number()) { 1482 switch (layer_tree_host()->source_frame_number()) {
1483 case 1: 1483 case 1:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 : public LayerTreeHostAnimationTest { 1544 : public LayerTreeHostAnimationTest {
1545 public: 1545 public:
1546 LayerTreeHostAnimationTestAnimationFinishesDuringCommit() 1546 LayerTreeHostAnimationTestAnimationFinishesDuringCommit()
1547 : signalled_(false) {} 1547 : signalled_(false) {}
1548 1548
1549 void SetupTree() override { 1549 void SetupTree() override {
1550 LayerTreeHostAnimationTest::SetupTree(); 1550 LayerTreeHostAnimationTest::SetupTree();
1551 layer_ = FakePictureLayer::Create(&client_); 1551 layer_ = FakePictureLayer::Create(&client_);
1552 layer_->SetBounds(gfx::Size(4, 4)); 1552 layer_->SetBounds(gfx::Size(4, 4));
1553 client_.set_bounds(layer_->bounds()); 1553 client_.set_bounds(layer_->bounds());
1554 layer_tree_host()->root_layer()->AddChild(layer_); 1554 layer_tree()->root_layer()->AddChild(layer_);
1555 1555
1556 AttachPlayersToTimeline(); 1556 AttachPlayersToTimeline();
1557 1557
1558 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 1558 player_->AttachElement(layer_tree()->root_layer()->element_id());
1559 player_child_->AttachElement(layer_->element_id()); 1559 player_child_->AttachElement(layer_->element_id());
1560 } 1560 }
1561 1561
1562 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1562 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1563 1563
1564 void DidCommit() override { 1564 void DidCommit() override {
1565 if (layer_tree_host()->source_frame_number() == 1) 1565 if (layer_tree_host()->source_frame_number() == 1)
1566 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5); 1566 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5);
1567 } 1567 }
1568 1568
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 : public LayerTreeHostAnimationTest { 1620 : public LayerTreeHostAnimationTest {
1621 public: 1621 public:
1622 LayerTreeHostAnimationTestNotifyAnimationFinished() 1622 LayerTreeHostAnimationTestNotifyAnimationFinished()
1623 : called_animation_started_(false), called_animation_finished_(false) {} 1623 : called_animation_started_(false), called_animation_finished_(false) {}
1624 1624
1625 void SetupTree() override { 1625 void SetupTree() override {
1626 LayerTreeHostAnimationTest::SetupTree(); 1626 LayerTreeHostAnimationTest::SetupTree();
1627 picture_ = FakePictureLayer::Create(&client_); 1627 picture_ = FakePictureLayer::Create(&client_);
1628 picture_->SetBounds(gfx::Size(4, 4)); 1628 picture_->SetBounds(gfx::Size(4, 4));
1629 client_.set_bounds(picture_->bounds()); 1629 client_.set_bounds(picture_->bounds());
1630 layer_tree_host()->root_layer()->AddChild(picture_); 1630 layer_tree()->root_layer()->AddChild(picture_);
1631 1631
1632 AttachPlayersToTimeline(); 1632 AttachPlayersToTimeline();
1633 player_->AttachElement(picture_->element_id()); 1633 player_->AttachElement(picture_->element_id());
1634 player_->set_animation_delegate(this); 1634 player_->set_animation_delegate(this);
1635 } 1635 }
1636 1636
1637 void BeginTest() override { 1637 void BeginTest() override {
1638 PostAddLongAnimationToMainThreadPlayer(player_.get()); 1638 PostAddLongAnimationToMainThreadPlayer(player_.get());
1639 } 1639 }
1640 1640
(...skipping 30 matching lines...) Expand all
1671 1671
1672 // Check that transform sync happens correctly at commit when we remove and add 1672 // Check that transform sync happens correctly at commit when we remove and add
1673 // a different animation player to an element. 1673 // a different animation player to an element.
1674 class LayerTreeHostAnimationTestChangeAnimationPlayer 1674 class LayerTreeHostAnimationTestChangeAnimationPlayer
1675 : public LayerTreeHostAnimationTest { 1675 : public LayerTreeHostAnimationTest {
1676 public: 1676 public:
1677 void SetupTree() override { 1677 void SetupTree() override {
1678 LayerTreeHostAnimationTest::SetupTree(); 1678 LayerTreeHostAnimationTest::SetupTree();
1679 AttachPlayersToTimeline(); 1679 AttachPlayersToTimeline();
1680 timeline_->DetachPlayer(player_child_.get()); 1680 timeline_->DetachPlayer(player_child_.get());
1681 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 1681 player_->AttachElement(layer_tree()->root_layer()->element_id());
1682 1682
1683 TransformOperations start; 1683 TransformOperations start;
1684 start.AppendTranslate(5.f, 5.f, 0.f); 1684 start.AppendTranslate(5.f, 5.f, 0.f);
1685 TransformOperations end; 1685 TransformOperations end;
1686 end.AppendTranslate(5.f, 5.f, 0.f); 1686 end.AppendTranslate(5.f, 5.f, 0.f);
1687 AddAnimatedTransformToPlayer(player_.get(), 1.0, start, end); 1687 AddAnimatedTransformToPlayer(player_.get(), 1.0, start, end);
1688 } 1688 }
1689 1689
1690 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1690 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1691 1691
(...skipping 16 matching lines...) Expand all
1708 } 1708 }
1709 1709
1710 void DidCommit() override { PostSetNeedsCommitToMainThread(); } 1710 void DidCommit() override { PostSetNeedsCommitToMainThread(); }
1711 1711
1712 void WillBeginMainFrame() override { 1712 void WillBeginMainFrame() override {
1713 if (layer_tree_host()->source_frame_number() == 2) { 1713 if (layer_tree_host()->source_frame_number() == 2) {
1714 // Destroy player. 1714 // Destroy player.
1715 timeline_->DetachPlayer(player_.get()); 1715 timeline_->DetachPlayer(player_.get());
1716 player_ = nullptr; 1716 player_ = nullptr;
1717 timeline_->AttachPlayer(player_child_.get()); 1717 timeline_->AttachPlayer(player_child_.get());
1718 player_child_->AttachElement( 1718 player_child_->AttachElement(layer_tree()->root_layer()->element_id());
1719 layer_tree_host()->root_layer()->element_id());
1720 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10); 1719 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10);
1721 Animation* animation = player_child_->element_animations()->GetAnimation( 1720 Animation* animation = player_child_->element_animations()->GetAnimation(
1722 TargetProperty::TRANSFORM); 1721 TargetProperty::TRANSFORM);
1723 animation->set_start_time(base::TimeTicks::Now() + 1722 animation->set_start_time(base::TimeTicks::Now() +
1724 base::TimeDelta::FromSecondsD(1000)); 1723 base::TimeDelta::FromSecondsD(1000));
1725 animation->set_fill_mode(Animation::FillMode::NONE); 1724 animation->set_fill_mode(Animation::FillMode::NONE);
1726 } 1725 }
1727 } 1726 }
1728 1727
1729 void AfterTest() override {} 1728 void AfterTest() override {}
1730 }; 1729 };
1731 1730
1732 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestChangeAnimationPlayer); 1731 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestChangeAnimationPlayer);
1733 1732
1734 // Check that SetTransformIsPotentiallyAnimatingChanged is called 1733 // Check that SetTransformIsPotentiallyAnimatingChanged is called
1735 // if we destroy ElementAnimations. 1734 // if we destroy ElementAnimations.
1736 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction 1735 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction
1737 : public LayerTreeHostAnimationTest { 1736 : public LayerTreeHostAnimationTest {
1738 public: 1737 public:
1739 void SetupTree() override { 1738 void SetupTree() override {
1740 prev_screen_space_transform_is_animating_ = true; 1739 prev_screen_space_transform_is_animating_ = true;
1741 screen_space_transform_animation_stopped_ = false; 1740 screen_space_transform_animation_stopped_ = false;
1742 1741
1743 LayerTreeHostAnimationTest::SetupTree(); 1742 LayerTreeHostAnimationTest::SetupTree();
1744 AttachPlayersToTimeline(); 1743 AttachPlayersToTimeline();
1745 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 1744 player_->AttachElement(layer_tree()->root_layer()->element_id());
1746 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); 1745 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5);
1747 } 1746 }
1748 1747
1749 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1748 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1750 1749
1751 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1750 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1752 if (host_impl->pending_tree()->source_frame_number() <= 1) { 1751 if (host_impl->pending_tree()->source_frame_number() <= 1) {
1753 EXPECT_TRUE(host_impl->pending_tree() 1752 EXPECT_TRUE(host_impl->pending_tree()
1754 ->root_layer_for_testing() 1753 ->root_layer_for_testing()
1755 ->screen_space_transform_is_animating()); 1754 ->screen_space_transform_is_animating());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 1814
1816 // Check that we invalidate property trees on AnimationPlayer::SetNeedsCommit. 1815 // Check that we invalidate property trees on AnimationPlayer::SetNeedsCommit.
1817 class LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit 1816 class LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit
1818 : public LayerTreeHostAnimationTest { 1817 : public LayerTreeHostAnimationTest {
1819 public: 1818 public:
1820 void SetupTree() override { 1819 void SetupTree() override {
1821 LayerTreeHostAnimationTest::SetupTree(); 1820 LayerTreeHostAnimationTest::SetupTree();
1822 layer_ = FakePictureLayer::Create(&client_); 1821 layer_ = FakePictureLayer::Create(&client_);
1823 layer_->SetBounds(gfx::Size(4, 4)); 1822 layer_->SetBounds(gfx::Size(4, 4));
1824 client_.set_bounds(layer_->bounds()); 1823 client_.set_bounds(layer_->bounds());
1825 layer_tree_host()->root_layer()->AddChild(layer_); 1824 layer_tree()->root_layer()->AddChild(layer_);
1826 1825
1827 AttachPlayersToTimeline(); 1826 AttachPlayersToTimeline();
1828 1827
1829 player_->AttachElement(layer_tree_host()->root_layer()->element_id()); 1828 player_->AttachElement(layer_tree()->root_layer()->element_id());
1830 player_child_->AttachElement(layer_->element_id()); 1829 player_child_->AttachElement(layer_->element_id());
1831 } 1830 }
1832 1831
1833 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1832 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1834 1833
1835 void DidCommit() override { 1834 void DidCommit() override {
1836 if (layer_tree_host()->source_frame_number() == 1 || 1835 if (layer_tree_host()->source_frame_number() == 1 ||
1837 layer_tree_host()->source_frame_number() == 2) 1836 layer_tree_host()->source_frame_number() == 2)
1838 PostSetNeedsCommitToMainThread(); 1837 PostSetNeedsCommitToMainThread();
1839 } 1838 }
1840 1839
1841 void UpdateLayerTreeHost() override { 1840 void UpdateLayerTreeHost() override {
1842 if (layer_tree_host()->source_frame_number() == 1) { 1841 if (layer_tree_host()->source_frame_number() == 1) {
1843 EXPECT_FALSE(layer_tree_host()->property_trees()->needs_rebuild); 1842 EXPECT_FALSE(layer_tree()->property_trees()->needs_rebuild);
1844 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); 1843 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5);
1845 } 1844 }
1846 1845
1847 EXPECT_TRUE(layer_tree_host()->property_trees()->needs_rebuild); 1846 EXPECT_TRUE(layer_tree()->property_trees()->needs_rebuild);
1848 } 1847 }
1849 1848
1850 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 1849 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
1851 if (host_impl->active_tree()->source_frame_number() >= 2) 1850 if (host_impl->active_tree()->source_frame_number() >= 2)
1852 EndTest(); 1851 EndTest();
1853 } 1852 }
1854 1853
1855 void AfterTest() override {} 1854 void AfterTest() override {}
1856 1855
1857 private: 1856 private:
1858 scoped_refptr<Layer> layer_; 1857 scoped_refptr<Layer> layer_;
1859 FakeContentLayerClient client_; 1858 FakeContentLayerClient client_;
1860 }; 1859 };
1861 1860
1862 MULTI_THREAD_TEST_F( 1861 MULTI_THREAD_TEST_F(
1863 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); 1862 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit);
1864 1863
1865 } // namespace 1864 } // namespace
1866 } // namespace cc 1865 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698