| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/test/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "cc/animation/animation.h" | 11 #include "cc/animation/animation.h" |
| 12 #include "cc/animation/animation_host.h" |
| 12 #include "cc/animation/animation_registrar.h" | 13 #include "cc/animation/animation_registrar.h" |
| 13 #include "cc/animation/layer_animation_controller.h" | 14 #include "cc/animation/layer_animation_controller.h" |
| 14 #include "cc/animation/timing_function.h" | 15 #include "cc/animation/timing_function.h" |
| 15 #include "cc/base/switches.h" | 16 #include "cc/base/switches.h" |
| 16 #include "cc/input/input_handler.h" | 17 #include "cc/input/input_handler.h" |
| 17 #include "cc/layers/content_layer.h" | 18 #include "cc/layers/content_layer.h" |
| 18 #include "cc/layers/layer.h" | 19 #include "cc/layers/layer.h" |
| 19 #include "cc/layers/layer_impl.h" | 20 #include "cc/layers/layer_impl.h" |
| 20 #include "cc/test/animation_test_common.h" | 21 #include "cc/test/animation_test_common.h" |
| 21 #include "cc/test/begin_frame_args_test.h" | 22 #include "cc/test/begin_frame_args_test.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 341 |
| 341 void AnimateLayers(base::TimeTicks monotonic_time) override { | 342 void AnimateLayers(base::TimeTicks monotonic_time) override { |
| 342 test_hooks_->WillAnimateLayers(this, monotonic_time); | 343 test_hooks_->WillAnimateLayers(this, monotonic_time); |
| 343 LayerTreeHostImpl::AnimateLayers(monotonic_time); | 344 LayerTreeHostImpl::AnimateLayers(monotonic_time); |
| 344 test_hooks_->AnimateLayers(this, monotonic_time); | 345 test_hooks_->AnimateLayers(this, monotonic_time); |
| 345 } | 346 } |
| 346 | 347 |
| 347 void UpdateAnimationState(bool start_ready_animations) override { | 348 void UpdateAnimationState(bool start_ready_animations) override { |
| 348 LayerTreeHostImpl::UpdateAnimationState(start_ready_animations); | 349 LayerTreeHostImpl::UpdateAnimationState(start_ready_animations); |
| 349 bool has_unfinished_animation = false; | 350 bool has_unfinished_animation = false; |
| 351 AnimationRegistrar* registrar = |
| 352 animation_registrar() ? animation_registrar() |
| 353 : animation_host()->animation_registrar(); |
| 350 for (const auto& it : | 354 for (const auto& it : |
| 351 animation_registrar()->active_animation_controllers_for_testing()) { | 355 registrar->active_animation_controllers_for_testing()) { |
| 352 if (it.second->HasActiveAnimation()) { | 356 if (it.second->HasActiveAnimation()) { |
| 353 has_unfinished_animation = true; | 357 has_unfinished_animation = true; |
| 354 break; | 358 break; |
| 355 } | 359 } |
| 356 } | 360 } |
| 357 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); | 361 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); |
| 358 } | 362 } |
| 359 | 363 |
| 360 void NotifyTileStateChanged(const Tile* tile) override { | 364 void NotifyTileStateChanged(const Tile* tile) override { |
| 361 LayerTreeHostImpl::NotifyTileStateChanged(tile); | 365 LayerTreeHostImpl::NotifyTileStateChanged(tile); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 void LayerTreeTest::PostAddLongAnimationToMainThread( | 593 void LayerTreeTest::PostAddLongAnimationToMainThread( |
| 590 Layer* layer_to_receive_animation) { | 594 Layer* layer_to_receive_animation) { |
| 591 main_task_runner_->PostTask( | 595 main_task_runner_->PostTask( |
| 592 FROM_HERE, | 596 FROM_HERE, |
| 593 base::Bind(&LayerTreeTest::DispatchAddAnimation, | 597 base::Bind(&LayerTreeTest::DispatchAddAnimation, |
| 594 main_thread_weak_ptr_, | 598 main_thread_weak_ptr_, |
| 595 base::Unretained(layer_to_receive_animation), | 599 base::Unretained(layer_to_receive_animation), |
| 596 1.0)); | 600 1.0)); |
| 597 } | 601 } |
| 598 | 602 |
| 603 void LayerTreeTest::PostAddAnimationToMainThreadPlayer( |
| 604 AnimationPlayer* player_to_receive_animation) { |
| 605 main_task_runner_->PostTask( |
| 606 FROM_HERE, |
| 607 base::Bind(&LayerTreeTest::DispatchAddAnimationToPlayer, |
| 608 main_thread_weak_ptr_, |
| 609 base::Unretained(player_to_receive_animation), 0.000004)); |
| 610 } |
| 611 |
| 612 void LayerTreeTest::PostAddInstantAnimationToMainThreadPlayer( |
| 613 AnimationPlayer* player_to_receive_animation) { |
| 614 main_task_runner_->PostTask( |
| 615 FROM_HERE, |
| 616 base::Bind(&LayerTreeTest::DispatchAddAnimationToPlayer, |
| 617 main_thread_weak_ptr_, |
| 618 base::Unretained(player_to_receive_animation), 0.0)); |
| 619 } |
| 620 |
| 621 void LayerTreeTest::PostAddLongAnimationToMainThreadPlayer( |
| 622 AnimationPlayer* player_to_receive_animation) { |
| 623 main_task_runner_->PostTask( |
| 624 FROM_HERE, |
| 625 base::Bind(&LayerTreeTest::DispatchAddAnimationToPlayer, |
| 626 main_thread_weak_ptr_, |
| 627 base::Unretained(player_to_receive_animation), 1.0)); |
| 628 } |
| 629 |
| 599 void LayerTreeTest::PostSetDeferCommitsToMainThread(bool defer_commits) { | 630 void LayerTreeTest::PostSetDeferCommitsToMainThread(bool defer_commits) { |
| 600 main_task_runner_->PostTask( | 631 main_task_runner_->PostTask( |
| 601 FROM_HERE, | 632 FROM_HERE, |
| 602 base::Bind(&LayerTreeTest::DispatchSetDeferCommits, | 633 base::Bind(&LayerTreeTest::DispatchSetDeferCommits, |
| 603 main_thread_weak_ptr_, defer_commits)); | 634 main_thread_weak_ptr_, defer_commits)); |
| 604 } | 635 } |
| 605 | 636 |
| 606 void LayerTreeTest::PostSetNeedsCommitToMainThread() { | 637 void LayerTreeTest::PostSetNeedsCommitToMainThread() { |
| 607 main_task_runner_->PostTask(FROM_HERE, | 638 main_task_runner_->PostTask(FROM_HERE, |
| 608 base::Bind(&LayerTreeTest::DispatchSetNeedsCommit, | 639 base::Bind(&LayerTreeTest::DispatchSetNeedsCommit, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, | 757 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, |
| 727 double animation_duration) { | 758 double animation_duration) { |
| 728 DCHECK(!proxy() || proxy()->IsMainThread()); | 759 DCHECK(!proxy() || proxy()->IsMainThread()); |
| 729 | 760 |
| 730 if (layer_to_receive_animation) { | 761 if (layer_to_receive_animation) { |
| 731 AddOpacityTransitionToLayer( | 762 AddOpacityTransitionToLayer( |
| 732 layer_to_receive_animation, animation_duration, 0, 0.5, true); | 763 layer_to_receive_animation, animation_duration, 0, 0.5, true); |
| 733 } | 764 } |
| 734 } | 765 } |
| 735 | 766 |
| 767 void LayerTreeTest::DispatchAddAnimationToPlayer( |
| 768 AnimationPlayer* player_to_receive_animation, |
| 769 double animation_duration) { |
| 770 DCHECK(!proxy() || proxy()->IsMainThread()); |
| 771 |
| 772 if (player_to_receive_animation) { |
| 773 AddOpacityTransitionToPlayer(player_to_receive_animation, |
| 774 animation_duration, 0, 0.5, true); |
| 775 } |
| 776 } |
| 777 |
| 736 void LayerTreeTest::DispatchSetDeferCommits(bool defer_commits) { | 778 void LayerTreeTest::DispatchSetDeferCommits(bool defer_commits) { |
| 737 DCHECK(!proxy() || proxy()->IsMainThread()); | 779 DCHECK(!proxy() || proxy()->IsMainThread()); |
| 738 | 780 |
| 739 if (layer_tree_host_) | 781 if (layer_tree_host_) |
| 740 layer_tree_host_->SetDeferCommits(defer_commits); | 782 layer_tree_host_->SetDeferCommits(defer_commits); |
| 741 } | 783 } |
| 742 | 784 |
| 743 void LayerTreeTest::DispatchSetNeedsCommit() { | 785 void LayerTreeTest::DispatchSetNeedsCommit() { |
| 744 DCHECK(!proxy() || proxy()->IsMainThread()); | 786 DCHECK(!proxy() || proxy()->IsMainThread()); |
| 745 | 787 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 LayerTreeHost* LayerTreeTest::layer_tree_host() { | 931 LayerTreeHost* LayerTreeTest::layer_tree_host() { |
| 890 // We check for a null proxy here as we sometimes ask for the layer tree host | 932 // We check for a null proxy here as we sometimes ask for the layer tree host |
| 891 // when the proxy does not exist, often for checking settings after a test has | 933 // when the proxy does not exist, often for checking settings after a test has |
| 892 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See | 934 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See |
| 893 // elsewhere in this file for other examples. | 935 // elsewhere in this file for other examples. |
| 894 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked()); | 936 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked()); |
| 895 return layer_tree_host_.get(); | 937 return layer_tree_host_.get(); |
| 896 } | 938 } |
| 897 | 939 |
| 898 } // namespace cc | 940 } // namespace cc |
| OLD | NEW |