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

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

Issue 181383005: Revert 253439 "Make it possible to cancel commits following an a..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/cc/trees/layer_tree_host.cc ('k') | trunk/src/cc/trees/thread_proxy.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 "cc/animation/animation_curve.h" 7 #include "cc/animation/animation_curve.h"
8 #include "cc/animation/layer_animation_controller.h" 8 #include "cc/animation/layer_animation_controller.h"
9 #include "cc/animation/scroll_offset_animation_curve.h" 9 #include "cc/animation/scroll_offset_animation_curve.h"
10 #include "cc/animation/timing_function.h" 10 #include "cc/animation/timing_function.h"
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount); 776 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount);
777 777
778 class LayerTreeHostAnimationTestContinuousAnimate 778 class LayerTreeHostAnimationTestContinuousAnimate
779 : public LayerTreeHostAnimationTest { 779 : public LayerTreeHostAnimationTest {
780 public: 780 public:
781 LayerTreeHostAnimationTestContinuousAnimate() 781 LayerTreeHostAnimationTestContinuousAnimate()
782 : num_commit_complete_(0), 782 : num_commit_complete_(0),
783 num_draw_layers_(0) { 783 num_draw_layers_(0) {
784 } 784 }
785 785
786 virtual void SetupTree() OVERRIDE {
787 LayerTreeHostAnimationTest::SetupTree();
788 // Create a fake content layer so we actually produce new content for every
789 // animation frame.
790 content_ = FakeContentLayer::Create(&client_);
791 content_->set_always_update_resources(true);
792 layer_tree_host()->root_layer()->AddChild(content_);
793 }
794
795 virtual void BeginTest() OVERRIDE { 786 virtual void BeginTest() OVERRIDE {
796 PostSetNeedsCommitToMainThread(); 787 PostSetNeedsCommitToMainThread();
797 } 788 }
798 789
799 virtual void Animate(base::TimeTicks) OVERRIDE { 790 virtual void Animate(base::TimeTicks) OVERRIDE {
800 if (num_draw_layers_ == 2) 791 if (num_draw_layers_ == 2)
801 return; 792 return;
802 layer_tree_host()->SetNeedsAnimate(); 793 layer_tree_host()->SetNeedsAnimate();
803 } 794 }
804 795
(...skipping 13 matching lines...) Expand all
818 } 809 }
819 810
820 virtual void AfterTest() OVERRIDE { 811 virtual void AfterTest() OVERRIDE {
821 // Check that we didn't commit twice between first and second draw. 812 // Check that we didn't commit twice between first and second draw.
822 EXPECT_EQ(1, num_commit_complete_); 813 EXPECT_EQ(1, num_commit_complete_);
823 } 814 }
824 815
825 private: 816 private:
826 int num_commit_complete_; 817 int num_commit_complete_;
827 int num_draw_layers_; 818 int num_draw_layers_;
828 FakeContentLayerClient client_;
829 scoped_refptr<FakeContentLayer> content_;
830 }; 819 };
831 820
832 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate); 821 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate);
833 822
834 class LayerTreeHostAnimationTestCancelAnimateCommit
835 : public LayerTreeHostAnimationTest {
836 public:
837 LayerTreeHostAnimationTestCancelAnimateCommit() : num_animate_calls_(0) {}
838
839 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
840
841 virtual void Animate(base::TimeTicks) OVERRIDE {
842 // No-op animate will cancel the commit.
843 if (++num_animate_calls_ == 2) {
844 EndTest();
845 return;
846 }
847 layer_tree_host()->SetNeedsAnimate();
848 }
849
850 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE {
851 FAIL() << "Commit should have been canceled.";
852 }
853
854 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
855 FAIL() << "Draw should have been canceled.";
856 }
857
858 virtual void AfterTest() OVERRIDE { EXPECT_EQ(2, num_animate_calls_); }
859
860 private:
861 int num_animate_calls_;
862 FakeContentLayerClient client_;
863 scoped_refptr<FakeContentLayer> content_;
864 };
865
866 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCancelAnimateCommit);
867
868 class LayerTreeHostAnimationTestForceRedraw
869 : public LayerTreeHostAnimationTest {
870 public:
871 LayerTreeHostAnimationTestForceRedraw()
872 : num_animate_(0), num_draw_layers_(0) {}
873
874 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
875
876 virtual void Animate(base::TimeTicks) OVERRIDE {
877 num_animate_++;
878 layer_tree_host()->SetNeedsAnimate();
879 }
880
881 virtual void Layout() OVERRIDE {
882 layer_tree_host()->SetNextCommitForcesRedraw();
883 }
884
885 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
886 num_draw_layers_++;
887 EndTest();
888 }
889
890 virtual void AfterTest() OVERRIDE {
891 EXPECT_EQ(2, num_animate_);
892 EXPECT_EQ(1, num_draw_layers_);
893 }
894
895 private:
896 int num_animate_;
897 int num_draw_layers_;
898 };
899
900 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestForceRedraw);
901
902 // Make sure the main thread can still execute animations when CanDraw() is not 823 // Make sure the main thread can still execute animations when CanDraw() is not
903 // true. 824 // true.
904 class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw 825 class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw
905 : public LayerTreeHostAnimationTest { 826 : public LayerTreeHostAnimationTest {
906 public: 827 public:
907 LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw() : started_times_(0) {} 828 LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw() : started_times_(0) {}
908 829
909 virtual void SetupTree() OVERRIDE { 830 virtual void SetupTree() OVERRIDE {
910 LayerTreeHostAnimationTest::SetupTree(); 831 LayerTreeHostAnimationTest::SetupTree();
911 content_ = FakeContentLayer::Create(&client_); 832 content_ = FakeContentLayer::Create(&client_);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 int num_draw_attempts_; 1122 int num_draw_attempts_;
1202 base::TimeTicks last_main_thread_tick_time_; 1123 base::TimeTicks last_main_thread_tick_time_;
1203 base::TimeTicks expected_impl_tick_time_; 1124 base::TimeTicks expected_impl_tick_time_;
1204 }; 1125 };
1205 1126
1206 // Only the non-impl-paint multi-threaded compositor freezes animations. 1127 // Only the non-impl-paint multi-threaded compositor freezes animations.
1207 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime); 1128 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime);
1208 1129
1209 } // namespace 1130 } // namespace
1210 } // namespace cc 1131 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/trees/layer_tree_host.cc ('k') | trunk/src/cc/trees/thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698