| 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 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 int prevented_draw_; | 1066 int prevented_draw_; |
| 1067 int added_animations_; | 1067 int added_animations_; |
| 1068 int started_times_; | 1068 int started_times_; |
| 1069 FakeContentLayerClient client_; | 1069 FakeContentLayerClient client_; |
| 1070 scoped_refptr<FakeContentLayer> content_; | 1070 scoped_refptr<FakeContentLayer> content_; |
| 1071 }; | 1071 }; |
| 1072 | 1072 |
| 1073 MULTI_THREAD_TEST_F( | 1073 MULTI_THREAD_TEST_F( |
| 1074 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); | 1074 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); |
| 1075 | 1075 |
| 1076 // Verifies that when scroll offset is animated on the impl thread, updates | 1076 // Verifies that scroll offset animations are only accepted when impl-scrolling |
| 1077 // are sent back to the main thread. | 1077 // is supported, and that when scroll offset animations are accepted, |
| 1078 // scroll offset updates are sent back to the main thread. |
| 1078 class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated | 1079 class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated |
| 1079 : public LayerTreeHostAnimationTest { | 1080 : public LayerTreeHostAnimationTest { |
| 1080 public: | 1081 public: |
| 1081 LayerTreeHostAnimationTestScrollOffsetChangesArePropagated() {} | 1082 LayerTreeHostAnimationTestScrollOffsetChangesArePropagated() {} |
| 1082 | 1083 |
| 1083 virtual void SetupTree() OVERRIDE { | 1084 virtual void SetupTree() OVERRIDE { |
| 1084 LayerTreeHostAnimationTest::SetupTree(); | 1085 LayerTreeHostAnimationTest::SetupTree(); |
| 1085 | 1086 |
| 1086 scroll_layer_ = FakeContentLayer::Create(&client_); | 1087 scroll_layer_ = FakeContentLayer::Create(&client_); |
| 1087 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); | 1088 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); |
| 1088 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); | 1089 scroll_layer_->SetBounds(gfx::Size(1000, 1000)); |
| 1089 scroll_layer_->SetScrollOffset(gfx::Vector2d(10, 20)); | 1090 scroll_layer_->SetScrollOffset(gfx::Vector2d(10, 20)); |
| 1090 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 1091 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 1091 } | 1092 } |
| 1092 | 1093 |
| 1093 virtual void BeginTest() OVERRIDE { | 1094 virtual void BeginTest() OVERRIDE { |
| 1094 PostSetNeedsCommitToMainThread(); | 1095 PostSetNeedsCommitToMainThread(); |
| 1095 } | 1096 } |
| 1096 | 1097 |
| 1097 virtual void DidCommit() OVERRIDE { | 1098 virtual void DidCommit() OVERRIDE { |
| 1098 switch (layer_tree_host()->source_frame_number()) { | 1099 switch (layer_tree_host()->source_frame_number()) { |
| 1099 case 1: { | 1100 case 1: { |
| 1100 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 1101 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 1101 ScrollOffsetAnimationCurve::Create( | 1102 ScrollOffsetAnimationCurve::Create( |
| 1102 gfx::Vector2dF(500.f, 550.f), | 1103 gfx::Vector2dF(500.f, 550.f), |
| 1103 EaseInOutTimingFunction::Create())); | 1104 EaseInOutTimingFunction::Create())); |
| 1104 scoped_ptr<Animation> animation(Animation::Create( | 1105 scoped_ptr<Animation> animation(Animation::Create( |
| 1105 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); | 1106 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); |
| 1106 animation->set_needs_synchronized_start_time(true); | 1107 animation->set_needs_synchronized_start_time(true); |
| 1107 scroll_layer_->AddAnimation(animation.Pass()); | 1108 bool animation_added = scroll_layer_->AddAnimation(animation.Pass()); |
| 1109 bool impl_scrolling_supported = |
| 1110 layer_tree_host()->proxy()->SupportsImplScrolling(); |
| 1111 EXPECT_EQ(impl_scrolling_supported, animation_added); |
| 1112 if (!impl_scrolling_supported) |
| 1113 EndTest(); |
| 1108 break; | 1114 break; |
| 1109 } | 1115 } |
| 1110 default: | 1116 default: |
| 1111 if (scroll_layer_->scroll_offset().x() > 10 && | 1117 if (scroll_layer_->scroll_offset().x() > 10 && |
| 1112 scroll_layer_->scroll_offset().y() > 20) | 1118 scroll_layer_->scroll_offset().y() > 20) |
| 1113 EndTest(); | 1119 EndTest(); |
| 1114 } | 1120 } |
| 1115 } | 1121 } |
| 1116 | 1122 |
| 1117 virtual void AfterTest() OVERRIDE {} | 1123 virtual void AfterTest() OVERRIDE {} |
| 1118 | 1124 |
| 1119 private: | 1125 private: |
| 1120 FakeContentLayerClient client_; | 1126 FakeContentLayerClient client_; |
| 1121 scoped_refptr<FakeContentLayer> scroll_layer_; | 1127 scoped_refptr<FakeContentLayer> scroll_layer_; |
| 1122 }; | 1128 }; |
| 1123 | 1129 |
| 1124 // SingleThreadProxy doesn't send scroll updates from LayerTreeHostImpl to | 1130 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1125 // LayerTreeHost. | 1131 LayerTreeHostAnimationTestScrollOffsetChangesArePropagated); |
| 1126 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestScrollOffsetChangesArePropagated); | |
| 1127 | 1132 |
| 1128 // Ensure that animation time is correctly updated when animations are frozen | 1133 // Ensure that animation time is correctly updated when animations are frozen |
| 1129 // because of checkerboarding. | 1134 // because of checkerboarding. |
| 1130 class LayerTreeHostAnimationTestFrozenAnimationTickTime | 1135 class LayerTreeHostAnimationTestFrozenAnimationTickTime |
| 1131 : public LayerTreeHostAnimationTest { | 1136 : public LayerTreeHostAnimationTest { |
| 1132 public: | 1137 public: |
| 1133 LayerTreeHostAnimationTestFrozenAnimationTickTime() | 1138 LayerTreeHostAnimationTestFrozenAnimationTickTime() |
| 1134 : started_animating_(false), num_commits_(0), num_draw_attempts_(2) {} | 1139 : started_animating_(false), num_commits_(0), num_draw_attempts_(2) {} |
| 1135 | 1140 |
| 1136 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 1141 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 private: | 1339 private: |
| 1335 scoped_refptr<Layer> content_; | 1340 scoped_refptr<Layer> content_; |
| 1336 int num_swap_buffers_; | 1341 int num_swap_buffers_; |
| 1337 }; | 1342 }; |
| 1338 | 1343 |
| 1339 SINGLE_AND_MULTI_THREAD_TEST_F( | 1344 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1340 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1345 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
| 1341 | 1346 |
| 1342 } // namespace | 1347 } // namespace |
| 1343 } // namespace cc | 1348 } // namespace cc |
| OLD | NEW |