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

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

Issue 1148333002: cc: Make re-added animations get pushed to the compositor thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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/animation/layer_animation_controller_unittest.cc ('k') | no next file » | 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 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 921
922 void AfterTest() override {} 922 void AfterTest() override {}
923 923
924 private: 924 private:
925 int frame_count_with_pending_tree_; 925 int frame_count_with_pending_tree_;
926 }; 926 };
927 927
928 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( 928 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F(
929 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers); 929 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers);
930 930
931 // When a layer with an animation is removed from the tree and later re-added,
932 // the animation should resume.
933 class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded
934 : public LayerTreeHostAnimationTest {
935 public:
936 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded() {}
937
938 void SetupTree() override {
939 LayerTreeHostAnimationTest::SetupTree();
940 content_ = Layer::Create();
941 content_->SetBounds(gfx::Size(4, 4));
942 layer_tree_host()->root_layer()->AddChild(content_);
943 AddOpacityTransitionToLayer(content_.get(), 10000.0, 0.1f, 0.9f, true);
944 }
945
946 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
947
948 void DidCommit() override {
949 switch (layer_tree_host()->source_frame_number()) {
950 case 1:
951 content_->RemoveFromParent();
952 break;
953 case 2:
954 layer_tree_host()->root_layer()->AddChild(content_);
955 break;
956 }
957 }
958
959 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
960 switch (host_impl->active_tree()->source_frame_number()) {
961 case 0:
962 EXPECT_TRUE(host_impl->animation_registrar()->needs_animate_layers());
963 break;
964 case 1:
965 EXPECT_FALSE(host_impl->animation_registrar()->needs_animate_layers());
966 break;
967 case 2:
968 EXPECT_TRUE(host_impl->animation_registrar()->needs_animate_layers());
969 EndTest();
970 break;
971 }
972 }
973
974 void AfterTest() override {}
975
976 private:
977 scoped_refptr<Layer> content_;
978 };
979
980 SINGLE_AND_MULTI_THREAD_TEST_F(
981 LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded);
982
931 class LayerTreeHostAnimationTestAddAnimationAfterAnimating 983 class LayerTreeHostAnimationTestAddAnimationAfterAnimating
932 : public LayerTreeHostAnimationTest { 984 : public LayerTreeHostAnimationTest {
933 public: 985 public:
934 LayerTreeHostAnimationTestAddAnimationAfterAnimating() 986 LayerTreeHostAnimationTestAddAnimationAfterAnimating()
935 : num_swap_buffers_(0) {} 987 : num_swap_buffers_(0) {}
936 988
937 void SetupTree() override { 989 void SetupTree() override {
938 LayerTreeHostAnimationTest::SetupTree(); 990 LayerTreeHostAnimationTest::SetupTree();
939 content_ = Layer::Create(); 991 content_ = Layer::Create();
940 content_->SetBounds(gfx::Size(4, 4)); 992 content_->SetBounds(gfx::Size(4, 4));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 private: 1037 private:
986 scoped_refptr<Layer> content_; 1038 scoped_refptr<Layer> content_;
987 int num_swap_buffers_; 1039 int num_swap_buffers_;
988 }; 1040 };
989 1041
990 SINGLE_AND_MULTI_THREAD_TEST_F( 1042 SINGLE_AND_MULTI_THREAD_TEST_F(
991 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1043 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
992 1044
993 } // namespace 1045 } // namespace
994 } // namespace cc 1046 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/layer_animation_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698