summaryrefslogtreecommitdiffstats
path: root/cc/trees/layer_tree_host_impl_unittest.cc
diff options
context:
space:
mode:
authorymalik <ymalik@chromium.org>2016-02-29 23:32:07 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-01 07:33:37 +0000
commit6581bb3e791018e48d078a910ddfdce19a1c10bb (patch)
tree4ecb54dae2af25a8af24515c9914ef6098c8cf2b /cc/trees/layer_tree_host_impl_unittest.cc
parent1b2d1c9f119d12e861e202f39353cc5fb33f982a (diff)
downloadchromium_src-6581bb3e791018e48d078a910ddfdce19a1c10bb.zip
chromium_src-6581bb3e791018e48d078a910ddfdce19a1c10bb.tar.gz
chromium_src-6581bb3e791018e48d078a910ddfdce19a1c10bb.tar.bz2
Share animations from compositor to main thread.
This CL introduces a new state that a compositor animation can be in, namely, ABORT_BUT_NEEDS_COMPLETION. When a main thread scrolling reason is added, the current scroll offset animation is put into this state. The layer animation controller looks for impl-only animations in this state and passes a TAKEOVER animation event to the main thread with the animation_curve. The main thread then completes the animation. Notes: - This CL is for impl only animations, i.e, the jidder bug won't be fixed for an animation running on cc that was initiated by the main thread (keyboard scroll). Future CL will add the takeover logic for MT-initiated animations. - This CL doesn't support the takeover notification from the old animation path. The old path is where we don't use CompositorAnimationPlayer and its better to not add the plumbing for something that will be removed soon anyway. Design-doc https://docs.google.com/a/google.com/document/d/1JUYvp5gilux7bca8vfmE4Rr5BUjSthizmz7g4BnOnBA/edit?usp=sharing Test page: http://philipwalton.github.io/polyfill/demos/position-sticky/ BUG=581875 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1734063003 Cr-Commit-Position: refs/heads/master@{#378411}
Diffstat (limited to 'cc/trees/layer_tree_host_impl_unittest.cc')
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 2f543e9..25b066c 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -9457,6 +9457,64 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
host_impl_->DidFinishImplFrame();
}
+// Test that a smooth scroll offset animation is marked finished when a main
+// thread scrolling reason is added. The animation is then finished on the
+// main thread.
+TEST_F(LayerTreeHostImplTimelinesTest,
+ ScrollAnimatedFinishedByMainThreadScrollingReason) {
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
+ DrawFrame();
+
+ base::TimeTicks start_time =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
+
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
+ // Perform animated scroll.
+ EXPECT_EQ(
+ InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread);
+
+ LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
+
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty(
+ scrolling_layer->id(), TargetProperty::SCROLL_OFFSET));
+
+ EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(50);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ float y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 1 && y < 49);
+
+ // Add main thread scrolling reason.
+ scrolling_layer->set_main_thread_scrolling_reasons(
+ MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects);
+ host_impl_->UpdateAnimationState(true);
+
+ // The main thread scrolling reason should have marked the smooth scroll
+ // animation as finished.
+ EXPECT_FALSE(
+ host_impl_->animation_host()->HasActiveAnimation(scrolling_layer->id()));
+ EXPECT_TRUE(y > 1 && y < 49);
+ EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
+ host_impl_->DidFinishImplFrame();
+}
+
// Evolved from LayerTreeHostImplTest.ScrollAnimated.
TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
const gfx::Size content_size(1000, 1000);