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

Side by Side Diff: cc/test/layer_tree_test.cc

Issue 1010663002: CC Animations: Redirect all compositor animation requests to AnimationHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@introduce
Patch Set: Rebase. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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/layer.h" 18 #include "cc/layers/layer.h"
18 #include "cc/layers/layer_impl.h" 19 #include "cc/layers/layer_impl.h"
19 #include "cc/test/animation_test_common.h" 20 #include "cc/test/animation_test_common.h"
20 #include "cc/test/begin_frame_args_test.h" 21 #include "cc/test/begin_frame_args_test.h"
21 #include "cc/test/fake_external_begin_frame_source.h" 22 #include "cc/test/fake_external_begin_frame_source.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 352
352 void AnimateLayers(base::TimeTicks monotonic_time) override { 353 void AnimateLayers(base::TimeTicks monotonic_time) override {
353 test_hooks_->WillAnimateLayers(this, monotonic_time); 354 test_hooks_->WillAnimateLayers(this, monotonic_time);
354 LayerTreeHostImpl::AnimateLayers(monotonic_time); 355 LayerTreeHostImpl::AnimateLayers(monotonic_time);
355 test_hooks_->AnimateLayers(this, monotonic_time); 356 test_hooks_->AnimateLayers(this, monotonic_time);
356 } 357 }
357 358
358 void UpdateAnimationState(bool start_ready_animations) override { 359 void UpdateAnimationState(bool start_ready_animations) override {
359 LayerTreeHostImpl::UpdateAnimationState(start_ready_animations); 360 LayerTreeHostImpl::UpdateAnimationState(start_ready_animations);
360 bool has_unfinished_animation = false; 361 bool has_unfinished_animation = false;
362 AnimationRegistrar* registrar =
363 animation_registrar() ? animation_registrar()
364 : animation_host()->animation_registrar();
361 for (const auto& it : 365 for (const auto& it :
362 animation_registrar()->active_animation_controllers_for_testing()) { 366 registrar->active_animation_controllers_for_testing()) {
363 if (it.second->HasActiveAnimation()) { 367 if (it.second->HasActiveAnimation()) {
364 has_unfinished_animation = true; 368 has_unfinished_animation = true;
365 break; 369 break;
366 } 370 }
367 } 371 }
368 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); 372 test_hooks_->UpdateAnimationState(this, has_unfinished_animation);
369 } 373 }
370 374
371 void NotifyTileStateChanged(const Tile* tile) override { 375 void NotifyTileStateChanged(const Tile* tile) override {
372 LayerTreeHostImpl::NotifyTileStateChanged(tile); 376 LayerTreeHostImpl::NotifyTileStateChanged(tile);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, 758 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation,
728 double animation_duration) { 759 double animation_duration) {
729 DCHECK(!proxy() || proxy()->IsMainThread()); 760 DCHECK(!proxy() || proxy()->IsMainThread());
730 761
731 if (layer_to_receive_animation) { 762 if (layer_to_receive_animation) {
732 AddOpacityTransitionToLayer( 763 AddOpacityTransitionToLayer(
733 layer_to_receive_animation, animation_duration, 0, 0.5, true); 764 layer_to_receive_animation, animation_duration, 0, 0.5, true);
734 } 765 }
735 } 766 }
736 767
768 void LayerTreeTest::DispatchAddAnimationToPlayer(
769 AnimationPlayer* player_to_receive_animation,
770 double animation_duration) {
771 DCHECK(!proxy() || proxy()->IsMainThread());
772
773 if (player_to_receive_animation) {
774 AddOpacityTransitionToPlayer(player_to_receive_animation,
775 animation_duration, 0, 0.5, true);
776 }
777 }
778
737 void LayerTreeTest::DispatchSetDeferCommits(bool defer_commits) { 779 void LayerTreeTest::DispatchSetDeferCommits(bool defer_commits) {
738 DCHECK(!proxy() || proxy()->IsMainThread()); 780 DCHECK(!proxy() || proxy()->IsMainThread());
739 781
740 if (layer_tree_host_) 782 if (layer_tree_host_)
741 layer_tree_host_->SetDeferCommits(defer_commits); 783 layer_tree_host_->SetDeferCommits(defer_commits);
742 } 784 }
743 785
744 void LayerTreeTest::DispatchSetNeedsCommit() { 786 void LayerTreeTest::DispatchSetNeedsCommit() {
745 DCHECK(!proxy() || proxy()->IsMainThread()); 787 DCHECK(!proxy() || proxy()->IsMainThread());
746 788
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 LayerTreeHost* LayerTreeTest::layer_tree_host() { 926 LayerTreeHost* LayerTreeTest::layer_tree_host() {
885 // We check for a null proxy here as we sometimes ask for the layer tree host 927 // We check for a null proxy here as we sometimes ask for the layer tree host
886 // when the proxy does not exist, often for checking settings after a test has 928 // when the proxy does not exist, often for checking settings after a test has
887 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See 929 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See
888 // elsewhere in this file for other examples. 930 // elsewhere in this file for other examples.
889 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked()); 931 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked());
890 return layer_tree_host_.get(); 932 return layer_tree_host_.get();
891 } 933 }
892 934
893 } // namespace cc 935 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698