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

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

Issue 95763002: cc: Support animating scroll offset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.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 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/timing_function.h" 10 #include "cc/animation/timing_function.h"
10 #include "cc/layers/layer.h" 11 #include "cc/layers/layer.h"
11 #include "cc/layers/layer_impl.h" 12 #include "cc/layers/layer_impl.h"
12 #include "cc/test/animation_test_common.h" 13 #include "cc/test/animation_test_common.h"
13 #include "cc/test/fake_content_layer.h" 14 #include "cc/test/fake_content_layer.h"
14 #include "cc/test/fake_content_layer_client.h" 15 #include "cc/test/fake_content_layer_client.h"
15 #include "cc/test/layer_tree_test.h" 16 #include "cc/test/layer_tree_test.h"
16 #include "cc/trees/layer_tree_impl.h" 17 #include "cc/trees/layer_tree_impl.h"
17 18
18 namespace cc { 19 namespace cc {
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 int added_animations_; 922 int added_animations_;
922 int started_times_; 923 int started_times_;
923 int finished_times_; 924 int finished_times_;
924 FakeContentLayerClient client_; 925 FakeContentLayerClient client_;
925 scoped_refptr<FakeContentLayer> content_; 926 scoped_refptr<FakeContentLayer> content_;
926 }; 927 };
927 928
928 MULTI_THREAD_TEST_F( 929 MULTI_THREAD_TEST_F(
929 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); 930 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations);
930 931
932 // Verifies that when scroll offset is animated on the impl thread, updates
933 // are sent back to the main thread.
934 class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated
935 : public LayerTreeHostAnimationTest {
936 public:
937 LayerTreeHostAnimationTestScrollOffsetChangesArePropagated() {}
938
939 virtual void SetupTree() OVERRIDE {
940 LayerTreeHostAnimationTest::SetupTree();
941
942 scroll_layer_ = FakeContentLayer::Create(&client_);
943 scroll_layer_->SetScrollable(true);
944 scroll_layer_->SetBounds(gfx::Size(1000, 1000));
945 scroll_layer_->SetScrollOffset(gfx::Vector2d(10, 20));
946 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
947 }
948
949 virtual void BeginTest() OVERRIDE {
950 PostSetNeedsCommitToMainThread();
951 }
952
953 virtual void DidCommit() OVERRIDE {
954 switch (layer_tree_host()->source_frame_number()) {
955 case 1: {
956 scoped_ptr<ScrollOffsetAnimationCurve> curve(
957 ScrollOffsetAnimationCurve::Create(
958 gfx::Vector2dF(500.f, 550.f),
959 EaseInOutTimingFunction::Create()));
960 scoped_ptr<Animation> animation(Animation::Create(
961 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
962 animation->set_needs_synchronized_start_time(true);
963 scroll_layer_->AddAnimation(animation.Pass());
964 break;
965 }
966 default:
967 if (scroll_layer_->scroll_offset().x() > 10 &&
968 scroll_layer_->scroll_offset().y() > 20)
969 EndTest();
970 }
971 }
972
973 virtual void AfterTest() OVERRIDE {}
974
975 private:
976 FakeContentLayerClient client_;
977 scoped_refptr<FakeContentLayer> scroll_layer_;
978 };
979
980 // SingleThreadProxy doesn't send scroll updates from LayerTreeHostImpl to
981 // LayerTreeHost.
982 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestScrollOffsetChangesArePropagated);
983
931 } // namespace 984 } // namespace
932 } // namespace cc 985 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698