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

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

Issue 2661523003: cc: Merge LayerTree into the LayerTreeHost. (Closed)
Patch Set: auto Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "cc/animation/animation_curve.h" 9 #include "cc/animation/animation_curve.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
(...skipping 27 matching lines...) Expand all
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 animation_host()->AddAnimationTimeline(timeline_.get()); 47 animation_host()->AddAnimationTimeline(timeline_.get());
48 layer_tree()->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 void GetImplTimelineAndPlayerByID(const LayerTreeHostImpl& host_impl) { 53 void GetImplTimelineAndPlayerByID(const LayerTreeHostImpl& host_impl) {
54 AnimationHost* animation_host_impl = GetImplAnimationHost(&host_impl); 54 AnimationHost* animation_host_impl = GetImplAnimationHost(&host_impl);
55 timeline_impl_ = animation_host_impl->GetTimelineById(timeline_id_); 55 timeline_impl_ = animation_host_impl->GetTimelineById(timeline_id_);
56 EXPECT_TRUE(timeline_impl_); 56 EXPECT_TRUE(timeline_impl_);
57 player_impl_ = timeline_impl_->GetPlayerById(player_id_); 57 player_impl_ = timeline_impl_->GetPlayerById(player_id_);
58 EXPECT_TRUE(player_impl_); 58 EXPECT_TRUE(player_impl_);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // Add a layer animation and confirm that 159 // Add a layer animation and confirm that
160 // LayerTreeHostImpl::UpdateAnimationState does get called. 160 // LayerTreeHostImpl::UpdateAnimationState does get called.
161 class LayerTreeHostAnimationTestAddAnimation 161 class LayerTreeHostAnimationTestAddAnimation
162 : public LayerTreeHostAnimationTest { 162 : public LayerTreeHostAnimationTest {
163 public: 163 public:
164 LayerTreeHostAnimationTestAddAnimation() 164 LayerTreeHostAnimationTestAddAnimation()
165 : update_animation_state_was_called_(false) {} 165 : update_animation_state_was_called_(false) {}
166 166
167 void BeginTest() override { 167 void BeginTest() override {
168 AttachPlayersToTimeline(); 168 AttachPlayersToTimeline();
169 player_->AttachElement(layer_tree()->root_layer()->element_id()); 169 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
170 PostAddInstantAnimationToMainThreadPlayer(player_.get()); 170 PostAddInstantAnimationToMainThreadPlayer(player_.get());
171 } 171 }
172 172
173 void UpdateAnimationState(LayerTreeHostImpl* host_impl, 173 void UpdateAnimationState(LayerTreeHostImpl* host_impl,
174 bool has_unfinished_animation) override { 174 bool has_unfinished_animation) override {
175 EXPECT_FALSE(has_unfinished_animation); 175 EXPECT_FALSE(has_unfinished_animation);
176 update_animation_state_was_called_ = true; 176 update_animation_state_was_called_ = true;
177 } 177 }
178 178
179 void NotifyAnimationStarted(base::TimeTicks monotonic_time, 179 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
(...skipping 19 matching lines...) Expand all
199 // Add a layer animation to a layer, but continually fail to draw. Confirm that 199 // Add a layer animation to a layer, but continually fail to draw. Confirm that
200 // after a while, we do eventually force a draw. 200 // after a while, we do eventually force a draw.
201 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws 201 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws
202 : public LayerTreeHostAnimationTest { 202 : public LayerTreeHostAnimationTest {
203 public: 203 public:
204 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws() 204 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws()
205 : started_animating_(false) {} 205 : started_animating_(false) {}
206 206
207 void BeginTest() override { 207 void BeginTest() override {
208 AttachPlayersToTimeline(); 208 AttachPlayersToTimeline();
209 player_->AttachElement(layer_tree()->root_layer()->element_id()); 209 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
210 PostAddAnimationToMainThreadPlayer(player_.get()); 210 PostAddAnimationToMainThreadPlayer(player_.get());
211 } 211 }
212 212
213 void AnimateLayers(LayerTreeHostImpl* host_impl, 213 void AnimateLayers(LayerTreeHostImpl* host_impl,
214 base::TimeTicks monotonic_time) override { 214 base::TimeTicks monotonic_time) override {
215 started_animating_ = true; 215 started_animating_ = true;
216 } 216 }
217 217
218 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 218 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
219 if (started_animating_) 219 if (started_animating_)
(...skipping 17 matching lines...) Expand all
237 237
238 // Ensures that animations eventually get deleted. 238 // Ensures that animations eventually get deleted.
239 class LayerTreeHostAnimationTestAnimationsGetDeleted 239 class LayerTreeHostAnimationTestAnimationsGetDeleted
240 : public LayerTreeHostAnimationTest { 240 : public LayerTreeHostAnimationTest {
241 public: 241 public:
242 LayerTreeHostAnimationTestAnimationsGetDeleted() 242 LayerTreeHostAnimationTestAnimationsGetDeleted()
243 : started_animating_(false) {} 243 : started_animating_(false) {}
244 244
245 void BeginTest() override { 245 void BeginTest() override {
246 AttachPlayersToTimeline(); 246 AttachPlayersToTimeline();
247 player_->AttachElement(layer_tree()->root_layer()->element_id()); 247 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
248 PostAddAnimationToMainThreadPlayer(player_.get()); 248 PostAddAnimationToMainThreadPlayer(player_.get());
249 } 249 }
250 250
251 void AnimateLayers(LayerTreeHostImpl* host_impl, 251 void AnimateLayers(LayerTreeHostImpl* host_impl,
252 base::TimeTicks monotonic_time) override { 252 base::TimeTicks monotonic_time) override {
253 bool have_animations = 253 bool have_animations =
254 !GetImplAnimationHost(host_impl)->ticking_players_for_testing().empty(); 254 !GetImplAnimationHost(host_impl)->ticking_players_for_testing().empty();
255 if (!started_animating_ && have_animations) { 255 if (!started_animating_ && have_animations) {
256 started_animating_ = true; 256 started_animating_ = true;
257 return; 257 return;
(...skipping 21 matching lines...) Expand all
279 279
280 // Ensure that an animation's timing function is respected. 280 // Ensure that an animation's timing function is respected.
281 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction 281 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction
282 : public LayerTreeHostAnimationTest { 282 : public LayerTreeHostAnimationTest {
283 public: 283 public:
284 void SetupTree() override { 284 void SetupTree() override {
285 LayerTreeHostAnimationTest::SetupTree(); 285 LayerTreeHostAnimationTest::SetupTree();
286 picture_ = FakePictureLayer::Create(&client_); 286 picture_ = FakePictureLayer::Create(&client_);
287 picture_->SetBounds(gfx::Size(4, 4)); 287 picture_->SetBounds(gfx::Size(4, 4));
288 client_.set_bounds(picture_->bounds()); 288 client_.set_bounds(picture_->bounds());
289 layer_tree()->root_layer()->AddChild(picture_); 289 layer_tree_host()->root_layer()->AddChild(picture_);
290 290
291 AttachPlayersToTimeline(); 291 AttachPlayersToTimeline();
292 player_child_->AttachElement(picture_->element_id()); 292 player_child_->AttachElement(picture_->element_id());
293 } 293 }
294 294
295 void BeginTest() override { 295 void BeginTest() override {
296 PostAddAnimationToMainThreadPlayer(player_child_.get()); 296 PostAddAnimationToMainThreadPlayer(player_child_.get());
297 } 297 }
298 298
299 void AnimateLayers(LayerTreeHostImpl* host_impl, 299 void AnimateLayers(LayerTreeHostImpl* host_impl,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // impl thread animations. 343 // impl thread animations.
344 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes 344 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes
345 : public LayerTreeHostAnimationTest { 345 : public LayerTreeHostAnimationTest {
346 public: 346 public:
347 void SetupTree() override { 347 void SetupTree() override {
348 LayerTreeHostAnimationTest::SetupTree(); 348 LayerTreeHostAnimationTest::SetupTree();
349 picture_ = FakePictureLayer::Create(&client_); 349 picture_ = FakePictureLayer::Create(&client_);
350 picture_->SetBounds(gfx::Size(4, 4)); 350 picture_->SetBounds(gfx::Size(4, 4));
351 client_.set_bounds(picture_->bounds()); 351 client_.set_bounds(picture_->bounds());
352 352
353 layer_tree()->root_layer()->AddChild(picture_); 353 layer_tree_host()->root_layer()->AddChild(picture_);
354 354
355 AttachPlayersToTimeline(); 355 AttachPlayersToTimeline();
356 player_child_->set_animation_delegate(this); 356 player_child_->set_animation_delegate(this);
357 player_child_->AttachElement(picture_->element_id()); 357 player_child_->AttachElement(picture_->element_id());
358 } 358 }
359 359
360 void BeginTest() override { 360 void BeginTest() override {
361 PostAddAnimationToMainThreadPlayer(player_child_.get()); 361 PostAddAnimationToMainThreadPlayer(player_child_.get());
362 } 362 }
363 363
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 399
400 SINGLE_AND_MULTI_THREAD_TEST_F( 400 SINGLE_AND_MULTI_THREAD_TEST_F(
401 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes); 401 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes);
402 402
403 // Ensures that notify animation finished is called. 403 // Ensures that notify animation finished is called.
404 class LayerTreeHostAnimationTestAnimationFinishedEvents 404 class LayerTreeHostAnimationTestAnimationFinishedEvents
405 : public LayerTreeHostAnimationTest { 405 : public LayerTreeHostAnimationTest {
406 public: 406 public:
407 void BeginTest() override { 407 void BeginTest() override {
408 AttachPlayersToTimeline(); 408 AttachPlayersToTimeline();
409 player_->AttachElement(layer_tree()->root_layer()->element_id()); 409 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
410 PostAddInstantAnimationToMainThreadPlayer(player_.get()); 410 PostAddInstantAnimationToMainThreadPlayer(player_.get());
411 } 411 }
412 412
413 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 413 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
414 TargetProperty::Type target_property, 414 TargetProperty::Type target_property,
415 int group) override { 415 int group) override {
416 Animation* animation = player_->GetAnimation(TargetProperty::OPACITY); 416 Animation* animation = player_->GetAnimation(TargetProperty::OPACITY);
417 if (animation) 417 if (animation)
418 player_->RemoveAnimation(animation->id()); 418 player_->RemoveAnimation(animation->id());
419 EndTest(); 419 EndTest();
420 } 420 }
421 421
422 void AfterTest() override {} 422 void AfterTest() override {}
423 }; 423 };
424 424
425 SINGLE_AND_MULTI_THREAD_TEST_F( 425 SINGLE_AND_MULTI_THREAD_TEST_F(
426 LayerTreeHostAnimationTestAnimationFinishedEvents); 426 LayerTreeHostAnimationTestAnimationFinishedEvents);
427 427
428 // Ensures that when opacity is being animated, this value does not cause the 428 // Ensures that when opacity is being animated, this value does not cause the
429 // subtree to be skipped. 429 // subtree to be skipped.
430 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity 430 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity
431 : public LayerTreeHostAnimationTest { 431 : public LayerTreeHostAnimationTest {
432 public: 432 public:
433 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity() 433 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity()
434 : update_check_layer_() {} 434 : update_check_layer_() {}
435 435
436 void SetupTree() override { 436 void SetupTree() override {
437 update_check_layer_ = FakePictureLayer::Create(&client_); 437 update_check_layer_ = FakePictureLayer::Create(&client_);
438 update_check_layer_->SetOpacity(0.f); 438 update_check_layer_->SetOpacity(0.f);
439 layer_tree()->SetRootLayer(update_check_layer_); 439 layer_tree_host()->SetRootLayer(update_check_layer_);
440 client_.set_bounds(update_check_layer_->bounds()); 440 client_.set_bounds(update_check_layer_->bounds());
441 LayerTreeHostAnimationTest::SetupTree(); 441 LayerTreeHostAnimationTest::SetupTree();
442 442
443 AttachPlayersToTimeline(); 443 AttachPlayersToTimeline();
444 player_->AttachElement(update_check_layer_->element_id()); 444 player_->AttachElement(update_check_layer_->element_id());
445 } 445 }
446 446
447 void BeginTest() override { 447 void BeginTest() override {
448 PostAddAnimationToMainThreadPlayer(player_.get()); 448 PostAddAnimationToMainThreadPlayer(player_.get());
449 } 449 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 player_->AttachElement(layer->element_id()); 493 player_->AttachElement(layer->element_id());
494 player_->set_animation_delegate(this); 494 player_->set_animation_delegate(this);
495 495
496 // Any valid AnimationCurve will do here. 496 // Any valid AnimationCurve will do here.
497 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); 497 std::unique_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve());
498 std::unique_ptr<Animation> animation( 498 std::unique_ptr<Animation> animation(
499 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY)); 499 Animation::Create(std::move(curve), 1, 1, TargetProperty::OPACITY));
500 player_->AddAnimation(std::move(animation)); 500 player_->AddAnimation(std::move(animation));
501 501
502 // We add the animation *before* attaching the layer to the tree. 502 // We add the animation *before* attaching the layer to the tree.
503 layer_tree()->root_layer()->AddChild(layer); 503 layer_tree_host()->root_layer()->AddChild(layer);
504 } 504 }
505 } 505 }
506 506
507 void AnimateLayers(LayerTreeHostImpl* impl_host, 507 void AnimateLayers(LayerTreeHostImpl* impl_host,
508 base::TimeTicks monotonic_time) override { 508 base::TimeTicks monotonic_time) override {
509 EndTest(); 509 EndTest();
510 } 510 }
511 511
512 void AfterTest() override {} 512 void AfterTest() override {}
513 }; 513 };
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 631
632 // Animations should not be started when frames are being skipped due to 632 // Animations should not be started when frames are being skipped due to
633 // checkerboard. 633 // checkerboard.
634 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations 634 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
635 : public LayerTreeHostAnimationTest { 635 : public LayerTreeHostAnimationTest {
636 void SetupTree() override { 636 void SetupTree() override {
637 LayerTreeHostAnimationTest::SetupTree(); 637 LayerTreeHostAnimationTest::SetupTree();
638 picture_ = FakePictureLayer::Create(&client_); 638 picture_ = FakePictureLayer::Create(&client_);
639 picture_->SetBounds(gfx::Size(4, 4)); 639 picture_->SetBounds(gfx::Size(4, 4));
640 client_.set_bounds(picture_->bounds()); 640 client_.set_bounds(picture_->bounds());
641 layer_tree()->root_layer()->AddChild(picture_); 641 layer_tree_host()->root_layer()->AddChild(picture_);
642 642
643 AttachPlayersToTimeline(); 643 AttachPlayersToTimeline();
644 player_child_->AttachElement(picture_->element_id()); 644 player_child_->AttachElement(picture_->element_id());
645 player_child_->set_animation_delegate(this); 645 player_child_->set_animation_delegate(this);
646 } 646 }
647 647
648 void InitializeSettings(LayerTreeSettings* settings) override { 648 void InitializeSettings(LayerTreeSettings* settings) override {
649 // Make sure that drawing many times doesn't cause a checkerboarded 649 // Make sure that drawing many times doesn't cause a checkerboarded
650 // animation to start so we avoid flake in this test. 650 // animation to start so we avoid flake in this test.
651 settings->timeout_and_draw_when_animation_checkerboards = false; 651 settings->timeout_and_draw_when_animation_checkerboards = false;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 // Verifies that scroll offset animations are only accepted when impl-scrolling 716 // Verifies that scroll offset animations are only accepted when impl-scrolling
717 // is supported, and that when scroll offset animations are accepted, 717 // is supported, and that when scroll offset animations are accepted,
718 // scroll offset updates are sent back to the main thread. 718 // scroll offset updates are sent back to the main thread.
719 class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated 719 class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated
720 : public LayerTreeHostAnimationTest { 720 : public LayerTreeHostAnimationTest {
721 public: 721 public:
722 void SetupTree() override { 722 void SetupTree() override {
723 LayerTreeHostAnimationTest::SetupTree(); 723 LayerTreeHostAnimationTest::SetupTree();
724 724
725 scroll_layer_ = FakePictureLayer::Create(&client_); 725 scroll_layer_ = FakePictureLayer::Create(&client_);
726 scroll_layer_->SetScrollClipLayerId(layer_tree()->root_layer()->id()); 726 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
727 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); 727 scroll_layer_->SetBounds(gfx::Size(1000, 1000));
728 client_.set_bounds(scroll_layer_->bounds()); 728 client_.set_bounds(scroll_layer_->bounds());
729 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 729 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
730 layer_tree()->root_layer()->AddChild(scroll_layer_); 730 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
731 731
732 AttachPlayersToTimeline(); 732 AttachPlayersToTimeline();
733 player_child_->AttachElement(scroll_layer_->element_id()); 733 player_child_->AttachElement(scroll_layer_->element_id());
734 } 734 }
735 735
736 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 736 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
737 737
738 void DidCommit() override { 738 void DidCommit() override {
739 switch (layer_tree_host()->SourceFrameNumber()) { 739 switch (layer_tree_host()->SourceFrameNumber()) {
740 case 1: { 740 case 1: {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 public: 777 public:
778 LayerTreeHostAnimationTestScrollOffsetAnimationTakeover() {} 778 LayerTreeHostAnimationTestScrollOffsetAnimationTakeover() {}
779 779
780 void SetupTree() override { 780 void SetupTree() override {
781 LayerTreeHostAnimationTest::SetupTree(); 781 LayerTreeHostAnimationTest::SetupTree();
782 782
783 scroll_layer_ = FakePictureLayer::Create(&client_); 783 scroll_layer_ = FakePictureLayer::Create(&client_);
784 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); 784 scroll_layer_->SetBounds(gfx::Size(10000, 10000));
785 client_.set_bounds(scroll_layer_->bounds()); 785 client_.set_bounds(scroll_layer_->bounds());
786 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 786 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
787 scroll_layer_->SetScrollClipLayerId(layer_tree()->root_layer()->id()); 787 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
788 layer_tree()->root_layer()->AddChild(scroll_layer_); 788 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
789 789
790 AttachPlayersToTimeline(); 790 AttachPlayersToTimeline();
791 player_child_->AttachElement(scroll_layer_->element_id()); 791 player_child_->AttachElement(scroll_layer_->element_id());
792 // Allows NotifyAnimationTakeover to get called. 792 // Allows NotifyAnimationTakeover to get called.
793 player_child_->set_animation_delegate(this); 793 player_child_->set_animation_delegate(this);
794 } 794 }
795 795
796 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 796 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
797 797
798 void DidCommit() override { 798 void DidCommit() override {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 public: 837 public:
838 LayerTreeHostAnimationTestScrollOffsetAnimationAdjusted() {} 838 LayerTreeHostAnimationTestScrollOffsetAnimationAdjusted() {}
839 839
840 void SetupTree() override { 840 void SetupTree() override {
841 LayerTreeHostAnimationTest::SetupTree(); 841 LayerTreeHostAnimationTest::SetupTree();
842 842
843 scroll_layer_ = FakePictureLayer::Create(&client_); 843 scroll_layer_ = FakePictureLayer::Create(&client_);
844 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); 844 scroll_layer_->SetBounds(gfx::Size(10000, 10000));
845 client_.set_bounds(scroll_layer_->bounds()); 845 client_.set_bounds(scroll_layer_->bounds());
846 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); 846 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20));
847 scroll_layer_->SetScrollClipLayerId(layer_tree()->root_layer()->id()); 847 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
848 layer_tree()->root_layer()->AddChild(scroll_layer_); 848 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
849 849
850 AttachPlayersToTimeline(); 850 AttachPlayersToTimeline();
851 } 851 }
852 852
853 AnimationPlayer& ScrollOffsetPlayer( 853 AnimationPlayer& ScrollOffsetPlayer(
854 const LayerTreeHostImpl& host_impl, 854 const LayerTreeHostImpl& host_impl,
855 scoped_refptr<FakePictureLayer> layer) const { 855 scoped_refptr<FakePictureLayer> layer) const {
856 scoped_refptr<ElementAnimations> element_animations = 856 scoped_refptr<ElementAnimations> element_animations =
857 GetImplAnimationHost(&host_impl) 857 GetImplAnimationHost(&host_impl)
858 ->GetElementAnimationsForElementId(layer->element_id()); 858 ->GetElementAnimationsForElementId(layer->element_id());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval 944 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval
945 : public LayerTreeHostAnimationTest { 945 : public LayerTreeHostAnimationTest {
946 public: 946 public:
947 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval() 947 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval()
948 : final_postion_(50.0, 100.0) {} 948 : final_postion_(50.0, 100.0) {}
949 949
950 void SetupTree() override { 950 void SetupTree() override {
951 LayerTreeHostAnimationTest::SetupTree(); 951 LayerTreeHostAnimationTest::SetupTree();
952 952
953 scroll_layer_ = FakePictureLayer::Create(&client_); 953 scroll_layer_ = FakePictureLayer::Create(&client_);
954 scroll_layer_->SetScrollClipLayerId(layer_tree()->root_layer()->id()); 954 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id());
955 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); 955 scroll_layer_->SetBounds(gfx::Size(10000, 10000));
956 client_.set_bounds(scroll_layer_->bounds()); 956 client_.set_bounds(scroll_layer_->bounds());
957 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0)); 957 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0));
958 layer_tree()->root_layer()->AddChild(scroll_layer_); 958 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
959 959
960 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 960 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
961 ScrollOffsetAnimationCurve::Create( 961 ScrollOffsetAnimationCurve::Create(
962 gfx::ScrollOffset(6500.f, 7500.f), 962 gfx::ScrollOffset(6500.f, 7500.f),
963 CubicBezierTimingFunction::CreatePreset( 963 CubicBezierTimingFunction::CreatePreset(
964 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); 964 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
965 std::unique_ptr<Animation> animation(Animation::Create( 965 std::unique_ptr<Animation> animation(Animation::Create(
966 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 966 std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
967 animation->set_needs_synchronized_start_time(true); 967 animation->set_needs_synchronized_start_time(true);
968 968
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() 1067 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers()
1068 : frame_count_with_pending_tree_(0) {} 1068 : frame_count_with_pending_tree_(0) {}
1069 1069
1070 void BeginTest() override { 1070 void BeginTest() override {
1071 AttachPlayersToTimeline(); 1071 AttachPlayersToTimeline();
1072 PostSetNeedsCommitToMainThread(); 1072 PostSetNeedsCommitToMainThread();
1073 } 1073 }
1074 1074
1075 void DidCommit() override { 1075 void DidCommit() override {
1076 if (layer_tree_host()->SourceFrameNumber() == 1) { 1076 if (layer_tree_host()->SourceFrameNumber() == 1) {
1077 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1077 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1078 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); 1078 AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1);
1079 } else if (layer_tree_host()->SourceFrameNumber() == 2) { 1079 } else if (layer_tree_host()->SourceFrameNumber() == 2) {
1080 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); 1080 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true);
1081 1081
1082 scoped_refptr<Layer> layer = Layer::Create(); 1082 scoped_refptr<Layer> layer = Layer::Create();
1083 layer_tree()->root_layer()->AddChild(layer); 1083 layer_tree_host()->root_layer()->AddChild(layer);
1084 1084
1085 layer_tree()->SetElementIdsForTesting(); 1085 layer_tree_host()->SetElementIdsForTesting();
1086 layer->SetBounds(gfx::Size(4, 4)); 1086 layer->SetBounds(gfx::Size(4, 4));
1087 1087
1088 player_child_->AttachElement(layer->element_id()); 1088 player_child_->AttachElement(layer->element_id());
1089 player_child_->set_animation_delegate(this); 1089 player_child_->set_animation_delegate(this);
1090 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); 1090 AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true);
1091 } 1091 }
1092 } 1092 }
1093 1093
1094 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { 1094 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
1095 host_impl->BlockNotifyReadyToActivateForTesting(true); 1095 host_impl->BlockNotifyReadyToActivateForTesting(true);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 LayerTreeHostAnimationTest::SetupTree(); 1162 LayerTreeHostAnimationTest::SetupTree();
1163 1163
1164 layer_ = FakePictureLayer::Create(&client_); 1164 layer_ = FakePictureLayer::Create(&client_);
1165 layer_->SetBounds(gfx::Size(2, 2)); 1165 layer_->SetBounds(gfx::Size(2, 2));
1166 client_.set_bounds(layer_->bounds()); 1166 client_.set_bounds(layer_->bounds());
1167 // Transform the layer to 4,4 to start. 1167 // Transform the layer to 4,4 to start.
1168 gfx::Transform start_transform; 1168 gfx::Transform start_transform;
1169 start_transform.Translate(4.0, 4.0); 1169 start_transform.Translate(4.0, 4.0);
1170 layer_->SetTransform(start_transform); 1170 layer_->SetTransform(start_transform);
1171 1171
1172 layer_tree()->root_layer()->AddChild(layer_); 1172 layer_tree_host()->root_layer()->AddChild(layer_);
1173 layer_tree()->SetElementIdsForTesting(); 1173 layer_tree_host()->SetElementIdsForTesting();
1174 1174
1175 player_->AttachElement(layer_->element_id()); 1175 player_->AttachElement(layer_->element_id());
1176 1176
1177 AttachPlayersToTimeline(); 1177 AttachPlayersToTimeline();
1178 } 1178 }
1179 1179
1180 void BeginTest() override { 1180 void BeginTest() override {
1181 // Add a translate from 6,7 to 8,9. 1181 // Add a translate from 6,7 to 8,9.
1182 TransformOperations start; 1182 TransformOperations start;
1183 start.AppendTranslate(6.f, 7.f, 0.f); 1183 start.AppendTranslate(6.f, 7.f, 0.f);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 1231
1232 // When a layer with an animation is removed from the tree and later re-added, 1232 // When a layer with an animation is removed from the tree and later re-added,
1233 // the animation should resume. 1233 // the animation should resume.
1234 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded 1234 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded
1235 : public LayerTreeHostAnimationTest { 1235 : public LayerTreeHostAnimationTest {
1236 public: 1236 public:
1237 void SetupTree() override { 1237 void SetupTree() override {
1238 LayerTreeHostAnimationTest::SetupTree(); 1238 LayerTreeHostAnimationTest::SetupTree();
1239 layer_ = Layer::Create(); 1239 layer_ = Layer::Create();
1240 layer_->SetBounds(gfx::Size(4, 4)); 1240 layer_->SetBounds(gfx::Size(4, 4));
1241 layer_tree()->root_layer()->AddChild(layer_); 1241 layer_tree_host()->root_layer()->AddChild(layer_);
1242 1242
1243 layer_tree()->SetElementIdsForTesting(); 1243 layer_tree_host()->SetElementIdsForTesting();
1244 1244
1245 animation_host()->AddAnimationTimeline(timeline_.get()); 1245 animation_host()->AddAnimationTimeline(timeline_.get());
1246 timeline_->AttachPlayer(player_.get()); 1246 timeline_->AttachPlayer(player_.get());
1247 player_->AttachElement(layer_->element_id()); 1247 player_->AttachElement(layer_->element_id());
1248 DCHECK(player_->element_animations()); 1248 DCHECK(player_->element_animations());
1249 1249
1250 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); 1250 AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true);
1251 } 1251 }
1252 1252
1253 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1253 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1254 1254
1255 void DidCommit() override { 1255 void DidCommit() override {
1256 switch (layer_tree_host()->SourceFrameNumber()) { 1256 switch (layer_tree_host()->SourceFrameNumber()) {
1257 case 0: 1257 case 0:
1258 EXPECT_TRUE( 1258 EXPECT_TRUE(
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_TRUE(animation_host()->NeedsTickAnimations()); 1262 EXPECT_TRUE(animation_host()->NeedsTickAnimations());
1263 break; 1263 break;
1264 case 1: 1264 case 1:
1265 layer_->RemoveFromParent(); 1265 layer_->RemoveFromParent();
1266 EXPECT_FALSE( 1266 EXPECT_FALSE(
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_FALSE(animation_host()->NeedsTickAnimations()); 1270 EXPECT_FALSE(animation_host()->NeedsTickAnimations());
1271 break; 1271 break;
1272 case 2: 1272 case 2:
1273 layer_tree()->root_layer()->AddChild(layer_); 1273 layer_tree_host()->root_layer()->AddChild(layer_);
1274 EXPECT_TRUE( 1274 EXPECT_TRUE(
1275 player_->element_animations()->has_element_in_active_list()); 1275 player_->element_animations()->has_element_in_active_list());
1276 EXPECT_FALSE( 1276 EXPECT_FALSE(
1277 player_->element_animations()->has_element_in_pending_list()); 1277 player_->element_animations()->has_element_in_pending_list());
1278 EXPECT_TRUE(animation_host()->NeedsTickAnimations()); 1278 EXPECT_TRUE(animation_host()->NeedsTickAnimations());
1279 break; 1279 break;
1280 } 1280 }
1281 } 1281 }
1282 1282
1283 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1283 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 SINGLE_AND_MULTI_THREAD_TEST_F( 1315 SINGLE_AND_MULTI_THREAD_TEST_F(
1316 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded); 1316 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded);
1317 1317
1318 class LayerTreeHostAnimationTestAddAnimationAfterAnimating 1318 class LayerTreeHostAnimationTestAddAnimationAfterAnimating
1319 : public LayerTreeHostAnimationTest { 1319 : public LayerTreeHostAnimationTest {
1320 public: 1320 public:
1321 void SetupTree() override { 1321 void SetupTree() override {
1322 LayerTreeHostAnimationTest::SetupTree(); 1322 LayerTreeHostAnimationTest::SetupTree();
1323 layer_ = Layer::Create(); 1323 layer_ = Layer::Create();
1324 layer_->SetBounds(gfx::Size(4, 4)); 1324 layer_->SetBounds(gfx::Size(4, 4));
1325 layer_tree()->root_layer()->AddChild(layer_); 1325 layer_tree_host()->root_layer()->AddChild(layer_);
1326 1326
1327 AttachPlayersToTimeline(); 1327 AttachPlayersToTimeline();
1328 1328
1329 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1329 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1330 player_child_->AttachElement(layer_->element_id()); 1330 player_child_->AttachElement(layer_->element_id());
1331 } 1331 }
1332 1332
1333 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1333 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1334 1334
1335 void DidCommit() override { 1335 void DidCommit() override {
1336 switch (layer_tree_host()->SourceFrameNumber()) { 1336 switch (layer_tree_host()->SourceFrameNumber()) {
1337 case 1: 1337 case 1:
1338 // First frame: add an animation to the root layer. 1338 // First frame: add an animation to the root layer.
1339 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5); 1339 AddAnimatedTransformToPlayer(player_.get(), 0.1, 5, 5);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1389 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
1390 1390
1391 class LayerTreeHostAnimationTestRemoveAnimation 1391 class LayerTreeHostAnimationTestRemoveAnimation
1392 : public LayerTreeHostAnimationTest { 1392 : public LayerTreeHostAnimationTest {
1393 public: 1393 public:
1394 void SetupTree() override { 1394 void SetupTree() override {
1395 LayerTreeHostAnimationTest::SetupTree(); 1395 LayerTreeHostAnimationTest::SetupTree();
1396 layer_ = FakePictureLayer::Create(&client_); 1396 layer_ = FakePictureLayer::Create(&client_);
1397 layer_->SetBounds(gfx::Size(4, 4)); 1397 layer_->SetBounds(gfx::Size(4, 4));
1398 client_.set_bounds(layer_->bounds()); 1398 client_.set_bounds(layer_->bounds());
1399 layer_tree()->root_layer()->AddChild(layer_); 1399 layer_tree_host()->root_layer()->AddChild(layer_);
1400 1400
1401 AttachPlayersToTimeline(); 1401 AttachPlayersToTimeline();
1402 1402
1403 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1403 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1404 player_child_->AttachElement(layer_->element_id()); 1404 player_child_->AttachElement(layer_->element_id());
1405 } 1405 }
1406 1406
1407 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1407 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1408 1408
1409 void DidCommit() override { 1409 void DidCommit() override {
1410 switch (layer_tree_host()->SourceFrameNumber()) { 1410 switch (layer_tree_host()->SourceFrameNumber()) {
1411 case 1: 1411 case 1:
1412 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); 1412 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5);
1413 break; 1413 break;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestRemoveAnimation); 1469 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestRemoveAnimation);
1470 1470
1471 class LayerTreeHostAnimationTestIsAnimating 1471 class LayerTreeHostAnimationTestIsAnimating
1472 : public LayerTreeHostAnimationTest { 1472 : public LayerTreeHostAnimationTest {
1473 public: 1473 public:
1474 void SetupTree() override { 1474 void SetupTree() override {
1475 LayerTreeHostAnimationTest::SetupTree(); 1475 LayerTreeHostAnimationTest::SetupTree();
1476 layer_ = FakePictureLayer::Create(&client_); 1476 layer_ = FakePictureLayer::Create(&client_);
1477 layer_->SetBounds(gfx::Size(4, 4)); 1477 layer_->SetBounds(gfx::Size(4, 4));
1478 client_.set_bounds(layer_->bounds()); 1478 client_.set_bounds(layer_->bounds());
1479 layer_tree()->root_layer()->AddChild(layer_); 1479 layer_tree_host()->root_layer()->AddChild(layer_);
1480 1480
1481 AttachPlayersToTimeline(); 1481 AttachPlayersToTimeline();
1482 player_->AttachElement(layer_->element_id()); 1482 player_->AttachElement(layer_->element_id());
1483 } 1483 }
1484 1484
1485 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1485 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1486 1486
1487 void DidCommit() override { 1487 void DidCommit() override {
1488 switch (layer_tree_host()->SourceFrameNumber()) { 1488 switch (layer_tree_host()->SourceFrameNumber()) {
1489 case 1: 1489 case 1:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 : public LayerTreeHostAnimationTest { 1549 : public LayerTreeHostAnimationTest {
1550 public: 1550 public:
1551 LayerTreeHostAnimationTestAnimationFinishesDuringCommit() 1551 LayerTreeHostAnimationTestAnimationFinishesDuringCommit()
1552 : signalled_(false) {} 1552 : signalled_(false) {}
1553 1553
1554 void SetupTree() override { 1554 void SetupTree() override {
1555 LayerTreeHostAnimationTest::SetupTree(); 1555 LayerTreeHostAnimationTest::SetupTree();
1556 layer_ = FakePictureLayer::Create(&client_); 1556 layer_ = FakePictureLayer::Create(&client_);
1557 layer_->SetBounds(gfx::Size(4, 4)); 1557 layer_->SetBounds(gfx::Size(4, 4));
1558 client_.set_bounds(layer_->bounds()); 1558 client_.set_bounds(layer_->bounds());
1559 layer_tree()->root_layer()->AddChild(layer_); 1559 layer_tree_host()->root_layer()->AddChild(layer_);
1560 1560
1561 AttachPlayersToTimeline(); 1561 AttachPlayersToTimeline();
1562 1562
1563 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1563 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1564 player_child_->AttachElement(layer_->element_id()); 1564 player_child_->AttachElement(layer_->element_id());
1565 } 1565 }
1566 1566
1567 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1567 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1568 1568
1569 void DidCommit() override { 1569 void DidCommit() override {
1570 if (layer_tree_host()->SourceFrameNumber() == 1) 1570 if (layer_tree_host()->SourceFrameNumber() == 1)
1571 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5); 1571 AddAnimatedTransformToPlayer(player_child_.get(), 0.04, 5, 5);
1572 } 1572 }
1573 1573
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 : public LayerTreeHostAnimationTest { 1625 : public LayerTreeHostAnimationTest {
1626 public: 1626 public:
1627 LayerTreeHostAnimationTestNotifyAnimationFinished() 1627 LayerTreeHostAnimationTestNotifyAnimationFinished()
1628 : called_animation_started_(false), called_animation_finished_(false) {} 1628 : called_animation_started_(false), called_animation_finished_(false) {}
1629 1629
1630 void SetupTree() override { 1630 void SetupTree() override {
1631 LayerTreeHostAnimationTest::SetupTree(); 1631 LayerTreeHostAnimationTest::SetupTree();
1632 picture_ = FakePictureLayer::Create(&client_); 1632 picture_ = FakePictureLayer::Create(&client_);
1633 picture_->SetBounds(gfx::Size(4, 4)); 1633 picture_->SetBounds(gfx::Size(4, 4));
1634 client_.set_bounds(picture_->bounds()); 1634 client_.set_bounds(picture_->bounds());
1635 layer_tree()->root_layer()->AddChild(picture_); 1635 layer_tree_host()->root_layer()->AddChild(picture_);
1636 1636
1637 AttachPlayersToTimeline(); 1637 AttachPlayersToTimeline();
1638 player_->AttachElement(picture_->element_id()); 1638 player_->AttachElement(picture_->element_id());
1639 player_->set_animation_delegate(this); 1639 player_->set_animation_delegate(this);
1640 } 1640 }
1641 1641
1642 void BeginTest() override { 1642 void BeginTest() override {
1643 PostAddLongAnimationToMainThreadPlayer(player_.get()); 1643 PostAddLongAnimationToMainThreadPlayer(player_.get());
1644 } 1644 }
1645 1645
(...skipping 30 matching lines...) Expand all
1676 1676
1677 // Check that transform sync happens correctly at commit when we remove and add 1677 // Check that transform sync happens correctly at commit when we remove and add
1678 // a different animation player to an element. 1678 // a different animation player to an element.
1679 class LayerTreeHostAnimationTestChangeAnimationPlayer 1679 class LayerTreeHostAnimationTestChangeAnimationPlayer
1680 : public LayerTreeHostAnimationTest { 1680 : public LayerTreeHostAnimationTest {
1681 public: 1681 public:
1682 void SetupTree() override { 1682 void SetupTree() override {
1683 LayerTreeHostAnimationTest::SetupTree(); 1683 LayerTreeHostAnimationTest::SetupTree();
1684 AttachPlayersToTimeline(); 1684 AttachPlayersToTimeline();
1685 timeline_->DetachPlayer(player_child_.get()); 1685 timeline_->DetachPlayer(player_child_.get());
1686 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1686 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1687 1687
1688 TransformOperations start; 1688 TransformOperations start;
1689 start.AppendTranslate(5.f, 5.f, 0.f); 1689 start.AppendTranslate(5.f, 5.f, 0.f);
1690 TransformOperations end; 1690 TransformOperations end;
1691 end.AppendTranslate(5.f, 5.f, 0.f); 1691 end.AppendTranslate(5.f, 5.f, 0.f);
1692 AddAnimatedTransformToPlayer(player_.get(), 1.0, start, end); 1692 AddAnimatedTransformToPlayer(player_.get(), 1.0, start, end);
1693 } 1693 }
1694 1694
1695 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1695 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1696 1696
(...skipping 16 matching lines...) Expand all
1713 } 1713 }
1714 1714
1715 void DidCommit() override { PostSetNeedsCommitToMainThread(); } 1715 void DidCommit() override { PostSetNeedsCommitToMainThread(); }
1716 1716
1717 void WillBeginMainFrame() override { 1717 void WillBeginMainFrame() override {
1718 if (layer_tree_host()->SourceFrameNumber() == 2) { 1718 if (layer_tree_host()->SourceFrameNumber() == 2) {
1719 // Destroy player. 1719 // Destroy player.
1720 timeline_->DetachPlayer(player_.get()); 1720 timeline_->DetachPlayer(player_.get());
1721 player_ = nullptr; 1721 player_ = nullptr;
1722 timeline_->AttachPlayer(player_child_.get()); 1722 timeline_->AttachPlayer(player_child_.get());
1723 player_child_->AttachElement(layer_tree()->root_layer()->element_id()); 1723 player_child_->AttachElement(
1724 layer_tree_host()->root_layer()->element_id());
1724 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10); 1725 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10);
1725 Animation* animation = 1726 Animation* animation =
1726 player_child_->GetAnimation(TargetProperty::TRANSFORM); 1727 player_child_->GetAnimation(TargetProperty::TRANSFORM);
1727 animation->set_start_time(base::TimeTicks::Now() + 1728 animation->set_start_time(base::TimeTicks::Now() +
1728 base::TimeDelta::FromSecondsD(1000)); 1729 base::TimeDelta::FromSecondsD(1000));
1729 animation->set_fill_mode(Animation::FillMode::NONE); 1730 animation->set_fill_mode(Animation::FillMode::NONE);
1730 } 1731 }
1731 } 1732 }
1732 1733
1733 void AfterTest() override {} 1734 void AfterTest() override {}
1734 }; 1735 };
1735 1736
1736 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestChangeAnimationPlayer); 1737 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestChangeAnimationPlayer);
1737 1738
1738 // Check that SetTransformIsPotentiallyAnimatingChanged is called 1739 // Check that SetTransformIsPotentiallyAnimatingChanged is called
1739 // if we destroy ElementAnimations. 1740 // if we destroy ElementAnimations.
1740 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction 1741 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction
1741 : public LayerTreeHostAnimationTest { 1742 : public LayerTreeHostAnimationTest {
1742 public: 1743 public:
1743 void SetupTree() override { 1744 void SetupTree() override {
1744 prev_screen_space_transform_is_animating_ = true; 1745 prev_screen_space_transform_is_animating_ = true;
1745 screen_space_transform_animation_stopped_ = false; 1746 screen_space_transform_animation_stopped_ = false;
1746 1747
1747 LayerTreeHostAnimationTest::SetupTree(); 1748 LayerTreeHostAnimationTest::SetupTree();
1748 AttachPlayersToTimeline(); 1749 AttachPlayersToTimeline();
1749 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1750 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1750 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); 1751 AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5);
1751 } 1752 }
1752 1753
1753 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1754 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1754 1755
1755 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1756 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1756 if (host_impl->pending_tree()->source_frame_number() <= 1) { 1757 if (host_impl->pending_tree()->source_frame_number() <= 1) {
1757 EXPECT_TRUE(host_impl->pending_tree() 1758 EXPECT_TRUE(host_impl->pending_tree()
1758 ->root_layer_for_testing() 1759 ->root_layer_for_testing()
1759 ->screen_space_transform_is_animating()); 1760 ->screen_space_transform_is_animating());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 1820
1820 // Check that we invalidate property trees on AnimationPlayer::SetNeedsCommit. 1821 // Check that we invalidate property trees on AnimationPlayer::SetNeedsCommit.
1821 class LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit 1822 class LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit
1822 : public LayerTreeHostAnimationTest { 1823 : public LayerTreeHostAnimationTest {
1823 public: 1824 public:
1824 void SetupTree() override { 1825 void SetupTree() override {
1825 LayerTreeHostAnimationTest::SetupTree(); 1826 LayerTreeHostAnimationTest::SetupTree();
1826 layer_ = FakePictureLayer::Create(&client_); 1827 layer_ = FakePictureLayer::Create(&client_);
1827 layer_->SetBounds(gfx::Size(4, 4)); 1828 layer_->SetBounds(gfx::Size(4, 4));
1828 client_.set_bounds(layer_->bounds()); 1829 client_.set_bounds(layer_->bounds());
1829 layer_tree()->root_layer()->AddChild(layer_); 1830 layer_tree_host()->root_layer()->AddChild(layer_);
1830 1831
1831 AttachPlayersToTimeline(); 1832 AttachPlayersToTimeline();
1832 1833
1833 player_->AttachElement(layer_tree()->root_layer()->element_id()); 1834 player_->AttachElement(layer_tree_host()->root_layer()->element_id());
1834 player_child_->AttachElement(layer_->element_id()); 1835 player_child_->AttachElement(layer_->element_id());
1835 } 1836 }
1836 1837
1837 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1838 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1838 1839
1839 void DidCommit() override { 1840 void DidCommit() override {
1840 if (layer_tree_host()->SourceFrameNumber() == 1 || 1841 if (layer_tree_host()->SourceFrameNumber() == 1 ||
1841 layer_tree_host()->SourceFrameNumber() == 2) 1842 layer_tree_host()->SourceFrameNumber() == 2)
1842 PostSetNeedsCommitToMainThread(); 1843 PostSetNeedsCommitToMainThread();
1843 } 1844 }
1844 1845
1845 void UpdateLayerTreeHost() override { 1846 void UpdateLayerTreeHost() override {
1846 if (layer_tree_host()->SourceFrameNumber() == 1) { 1847 if (layer_tree_host()->SourceFrameNumber() == 1) {
1847 EXPECT_FALSE(layer_tree()->property_trees()->needs_rebuild); 1848 EXPECT_FALSE(layer_tree_host()->property_trees()->needs_rebuild);
1848 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); 1849 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5);
1849 } 1850 }
1850 1851
1851 EXPECT_TRUE(layer_tree()->property_trees()->needs_rebuild); 1852 EXPECT_TRUE(layer_tree_host()->property_trees()->needs_rebuild);
1852 } 1853 }
1853 1854
1854 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 1855 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
1855 if (host_impl->active_tree()->source_frame_number() >= 2) 1856 if (host_impl->active_tree()->source_frame_number() >= 2)
1856 EndTest(); 1857 EndTest();
1857 } 1858 }
1858 1859
1859 void AfterTest() override {} 1860 void AfterTest() override {}
1860 1861
1861 private: 1862 private:
1862 scoped_refptr<Layer> layer_; 1863 scoped_refptr<Layer> layer_;
1863 FakeContentLayerClient client_; 1864 FakeContentLayerClient client_;
1864 }; 1865 };
1865 1866
1866 MULTI_THREAD_TEST_F( 1867 MULTI_THREAD_TEST_F(
1867 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); 1868 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit);
1868 1869
1869 } // namespace 1870 } // namespace
1870 } // namespace cc 1871 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698