OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |