summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj <danakj@chromium.org>2015-08-19 15:25:44 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-19 22:27:02 +0000
commit12e2f6e4d40560f94d688e6969eb5d9358ead6e3 (patch)
treef7d0e001ac71760c78ecb2993fec3fcc96c8b403 /cc
parente6828f1324531cc46faadac0e9eff84da59f09cd (diff)
downloadchromium_src-12e2f6e4d40560f94d688e6969eb5d9358ead6e3.zip
chromium_src-12e2f6e4d40560f94d688e6969eb5d9358ead6e3.tar.gz
chromium_src-12e2f6e4d40560f94d688e6969eb5d9358ead6e3.tar.bz2
cc: Move animate steps from proxies to LayerTreeHostImpl.
Currently both proxies have early outs and call a few methods on LayerTreeHostImpl to do animations. This moves it all into a single Animate() call and consolidates the code in LayerTreeHostImpl. The old Animate() method took the current frame_time as an argument, but instead it can use it directly from the BeginFrameArgs. This required changes LayerTreeHostImpl tests that call Animate() to start/end impl frames to change the current frame time (which is more realistic). R=ajuma BUG=522658 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1297363004 Cr-Commit-Position: refs/heads/master@{#344351}
Diffstat (limited to 'cc')
-rw-r--r--cc/trees/layer_tree_host_impl.cc19
-rw-r--r--cc/trees/layer_tree_host_impl.h4
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc204
-rw-r--r--cc/trees/single_thread_proxy.cc23
-rw-r--r--cc/trees/single_thread_proxy.h1
-rw-r--r--cc/trees/thread_proxy.cc17
-rw-r--r--cc/trees/thread_proxy.h2
7 files changed, 184 insertions, 86 deletions
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 1b72a04..2612539 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -421,20 +421,33 @@ bool LayerTreeHostImpl::CanDraw() const {
return true;
}
-void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) {
+void LayerTreeHostImpl::Animate() {
+ // Don't animate if there is no active root layer.
+ // TODO(ajuma): Does this break things if first commit has an animation?
+ if (!active_tree()->root_layer())
+ return;
+
+ base::TimeTicks monotonic_time = CurrentBeginFrameArgs().frame_time;
+
// mithro(TODO): Enable these checks.
// DCHECK(!current_begin_frame_tracker_.HasFinished());
// DCHECK(monotonic_time == current_begin_frame_tracker_.Current().frame_time)
// << "Called animate with unknown frame time!?";
if (!root_layer_scroll_offset_delegate_ ||
(CurrentlyScrollingLayer() != InnerViewportScrollLayer() &&
- CurrentlyScrollingLayer() != OuterViewportScrollLayer())) {
+ CurrentlyScrollingLayer() != OuterViewportScrollLayer()))
AnimateInput(monotonic_time);
- }
AnimatePageScale(monotonic_time);
AnimateLayers(monotonic_time);
AnimateScrollbars(monotonic_time);
AnimateTopControls(monotonic_time);
+
+ // If animations are not visible, update the state now as Draw/Swap will never
+ // occur.
+ // TODO(ajuma): Left-overs from now-deleted background ticking?
+ bool animations_are_visible = visible() && CanDraw();
+ if (!animations_are_visible)
+ UpdateAnimationState(true);
}
bool LayerTreeHostImpl::PrepareTiles() {
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index 893b42a..851656b 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -227,7 +227,7 @@ class CC_EXPORT LayerTreeHostImpl
virtual void BeginMainFrameAborted(CommitEarlyOutReason reason);
virtual void BeginCommit();
virtual void CommitComplete();
- virtual void Animate(base::TimeTicks monotonic_time);
+ virtual void Animate();
virtual void UpdateAnimationState(bool start_ready_animations);
void ActivateAnimations();
void MainThreadHasStoppedFlinging();
@@ -434,8 +434,6 @@ class CC_EXPORT LayerTreeHostImpl
virtual void SetVisible(bool visible);
bool visible() const { return visible_; }
- bool AnimationsAreVisible() { return visible() && CanDraw(); }
-
void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
void SetNeedsAnimate();
void SetNeedsRedraw();
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 056e79b..06c5c83 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -171,8 +171,10 @@ class LayerTreeHostImplTest : public testing::Test,
host_impl_->SetViewportSize(gfx::Size(10, 10));
host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
// Set the BeginFrameArgs so that methods which use it are able to.
- host_impl_->WillBeginImplFrame(
- CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
+ host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting(
+ BEGINFRAME_FROM_HERE,
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(1)));
+ host_impl_->DidFinishImplFrame();
return init;
}
@@ -1646,6 +1648,9 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
base::TimeTicks halfway_through_animation = start_time + duration / 2;
base::TimeTicks end_time = start_time + duration;
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
// Non-anchor zoom-in
{
host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
@@ -1666,22 +1671,31 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
did_request_redraw_ = false;
did_request_animate_ = false;
- host_impl_->Animate(start_time);
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_animate_);
+ host_impl_->DidFinishImplFrame();
did_request_redraw_ = false;
did_request_animate_ = false;
- host_impl_->Animate(halfway_through_animation);
+ begin_frame_args.frame_time = halfway_through_animation;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_animate_);
+ host_impl_->DidFinishImplFrame();
did_request_redraw_ = false;
did_request_animate_ = false;
did_request_commit_ = false;
- host_impl_->Animate(end_time);
+ begin_frame_args.frame_time = end_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_commit_);
EXPECT_FALSE(did_request_animate_);
+ host_impl_->DidFinishImplFrame();
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
@@ -1690,6 +1704,10 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
gfx::Vector2d(-50, -50)));
}
+ start_time += base::TimeDelta::FromSeconds(10);
+ halfway_through_animation += base::TimeDelta::FromSeconds(10);
+ end_time += base::TimeDelta::FromSeconds(10);
+
// Anchor zoom-out
{
host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
@@ -1710,17 +1728,23 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
did_request_redraw_ = false;
did_request_animate_ = false;
- host_impl_->Animate(start_time);
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_animate_);
+ host_impl_->DidFinishImplFrame();
did_request_redraw_ = false;
did_request_commit_ = false;
did_request_animate_ = false;
- host_impl_->Animate(end_time);
+ begin_frame_args.frame_time = end_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_redraw_);
EXPECT_FALSE(did_request_animate_);
EXPECT_TRUE(did_request_commit_);
+ host_impl_->DidFinishImplFrame();
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
@@ -1747,6 +1771,9 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) {
base::TimeTicks halfway_through_animation = start_time + duration / 2;
base::TimeTicks end_time = start_time + duration;
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
// Anchor zoom with unchanged page scale should not change scroll or scale.
{
host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
@@ -1760,11 +1787,22 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) {
1.f,
duration)));
host_impl_->ActivateSyncTree();
- host_impl_->Animate(start_time);
- host_impl_->Animate(halfway_through_animation);
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time = halfway_through_animation;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_redraw_);
- host_impl_->Animate(end_time);
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time = end_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_commit_);
+ host_impl_->DidFinishImplFrame();
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
@@ -1799,6 +1837,9 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
base::TimeTicks end_time = start_time + duration;
float target_scale = 2.f;
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50));
// Make sure TakePageScaleAnimation works properly.
@@ -1825,9 +1866,12 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
false,
target_scale,
duration)));
- host_impl_->Animate(halfway_through_animation);
+ begin_frame_args.frame_time = halfway_through_animation;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_FALSE(did_request_animate_);
EXPECT_FALSE(did_request_redraw_);
+ host_impl_->DidFinishImplFrame();
// Activate the sync tree. This should cause the animation to become enabled.
// It should also clear the pointer on the sync tree.
@@ -1837,34 +1881,51 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
EXPECT_FALSE(did_request_redraw_);
EXPECT_TRUE(did_request_animate_);
+ start_time += base::TimeDelta::FromSeconds(10);
+ third_through_animation += base::TimeDelta::FromSeconds(10);
+ halfway_through_animation += base::TimeDelta::FromSeconds(10);
+ end_time += base::TimeDelta::FromSeconds(10);
+
// From here on, make sure the animation runs as normal.
did_request_redraw_ = false;
did_request_animate_ = false;
- host_impl_->Animate(start_time);
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_animate_);
+ host_impl_->DidFinishImplFrame();
did_request_redraw_ = false;
did_request_animate_ = false;
- host_impl_->Animate(third_through_animation);
+ begin_frame_args.frame_time = third_through_animation;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_animate_);
+ host_impl_->DidFinishImplFrame();
// Another activation shouldn't have any effect on the animation.
host_impl_->ActivateSyncTree();
did_request_redraw_ = false;
did_request_animate_ = false;
- host_impl_->Animate(halfway_through_animation);
+ begin_frame_args.frame_time = halfway_through_animation;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_animate_);
+ host_impl_->DidFinishImplFrame();
did_request_redraw_ = false;
did_request_animate_ = false;
did_request_commit_ = false;
- host_impl_->Animate(end_time);
+ begin_frame_args.frame_time = end_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_commit_);
EXPECT_FALSE(did_request_animate_);
+ host_impl_->DidFinishImplFrame();
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
@@ -1887,6 +1948,9 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) {
base::TimeTicks halfway_through_animation = start_time + duration / 2;
base::TimeTicks end_time = start_time + duration;
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50));
@@ -1895,14 +1959,23 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) {
scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
gfx::Vector2d(), false, 2.f, duration)));
host_impl_->ActivateSyncTree();
- host_impl_->Animate(start_time);
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_FALSE(did_complete_page_scale_animation_);
+ host_impl_->DidFinishImplFrame();
- host_impl_->Animate(halfway_through_animation);
+ begin_frame_args.frame_time = halfway_through_animation;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_FALSE(did_complete_page_scale_animation_);
+ host_impl_->DidFinishImplFrame();
- host_impl_->Animate(end_time);
+ begin_frame_args.frame_time = end_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_complete_page_scale_animation_);
+ host_impl_->DidFinishImplFrame();
}
class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl {
@@ -2016,13 +2089,17 @@ class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
EXPECT_FALSE(did_request_redraw_);
// After the scrollbar animation begins, we should start getting redraws.
- host_impl_->Animate(fake_now);
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_TRUE(did_request_animate_);
did_request_animate_ = false;
EXPECT_TRUE(did_request_redraw_);
did_request_redraw_ = false;
EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
EXPECT_TRUE(animation_task_.Equals(base::Closure()));
+ host_impl_->DidFinishImplFrame();
// Setting the scroll offset outside a scroll should also cause the
// scrollbar to appear and to schedule a scrollbar animation.
@@ -7011,8 +7088,12 @@ const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50;
TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) {
SetupScrollAndContentsLayers(gfx::Size(100, 100))
->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10));
- host_impl_->Animate(base::TimeTicks());
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_FALSE(did_request_redraw_);
+ host_impl_->DidFinishImplFrame();
}
TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) {
@@ -7181,7 +7262,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) {
// The top controls should properly animate until finished, despite the scroll
// offset being at the origin.
- base::TimeTicks animation_time = base::TimeTicks::Now();
+ BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting(
+ BEGINFRAME_FROM_HERE, base::TimeTicks::Now());
while (did_request_animate_) {
did_request_redraw_ = false;
did_request_animate_ = false;
@@ -7190,8 +7272,9 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) {
float old_offset =
host_impl_->top_controls_manager()->ControlsTopOffset();
- animation_time += base::TimeDelta::FromMilliseconds(5);
- host_impl_->Animate(animation_time);
+ begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
EXPECT_EQ(gfx::Vector2dF().ToString(),
scroll_layer->CurrentScrollOffset().ToString());
@@ -7209,6 +7292,7 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) {
EXPECT_TRUE(host_impl_->top_controls_manager()->animation());
EXPECT_TRUE(did_request_animate_);
}
+ host_impl_->DidFinishImplFrame();
}
EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
}
@@ -7251,7 +7335,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
EXPECT_FALSE(did_request_commit_);
// Animate the top controls to the limit.
- base::TimeTicks animation_time = base::TimeTicks::Now();
+ BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting(
+ BEGINFRAME_FROM_HERE, base::TimeTicks::Now());
while (did_request_animate_) {
did_request_redraw_ = false;
did_request_animate_ = false;
@@ -7260,8 +7345,9 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
float old_offset =
host_impl_->top_controls_manager()->ControlsTopOffset();
- animation_time += base::TimeDelta::FromMilliseconds(5);
- host_impl_->Animate(animation_time);
+ begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
float new_offset =
host_impl_->top_controls_manager()->ControlsTopOffset();
@@ -7270,6 +7356,7 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_commit_);
}
+ host_impl_->DidFinishImplFrame();
}
EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
EXPECT_EQ(-top_controls_height_,
@@ -7315,7 +7402,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest,
EXPECT_FALSE(did_request_commit_);
// Animate the top controls to the limit.
- base::TimeTicks animation_time = base::TimeTicks::Now();
+ BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting(
+ BEGINFRAME_FROM_HERE, base::TimeTicks::Now());
while (did_request_animate_) {
did_request_redraw_ = false;
did_request_animate_ = false;
@@ -7323,8 +7411,9 @@ TEST_F(LayerTreeHostImplWithTopControlsTest,
float old_offset = host_impl_->top_controls_manager()->ControlsTopOffset();
- animation_time += base::TimeDelta::FromMilliseconds(5);
- host_impl_->Animate(animation_time);
+ begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
float new_offset = host_impl_->top_controls_manager()->ControlsTopOffset();
@@ -7332,6 +7421,7 @@ TEST_F(LayerTreeHostImplWithTopControlsTest,
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_commit_);
}
+ host_impl_->DidFinishImplFrame();
}
EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
EXPECT_EQ(-top_controls_height_,
@@ -7777,17 +7867,26 @@ TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
base::TimeTicks start_time =
base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
- host_impl_->Animate(start_time);
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
host_impl_->UpdateAnimationState(true);
EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
+ host_impl_->DidFinishImplFrame();
- host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50));
+ 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();
@@ -7796,20 +7895,29 @@ TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
// Update target.
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
+ host_impl_->DidFinishImplFrame();
- host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200));
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(200);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
host_impl_->UpdateAnimationState(true);
y = scrolling_layer->CurrentScrollOffset().y();
EXPECT_TRUE(y > 50 && y < 100);
EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
+ host_impl_->DidFinishImplFrame();
- host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(250);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
host_impl_->UpdateAnimationState(true);
EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
scrolling_layer->CurrentScrollOffset());
EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
+ host_impl_->DidFinishImplFrame();
}
// Evolved from LayerTreeHostImplTest.ScrollAnimated.
@@ -7820,17 +7928,26 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
base::TimeTicks start_time =
base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
- host_impl_->Animate(start_time);
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
host_impl_->UpdateAnimationState(true);
EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
+ host_impl_->DidFinishImplFrame();
- host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50));
+ 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();
@@ -7839,20 +7956,29 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
// Update target.
EXPECT_EQ(InputHandler::SCROLL_STARTED,
host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
+ host_impl_->DidFinishImplFrame();
- host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200));
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(200);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
host_impl_->UpdateAnimationState(true);
y = scrolling_layer->CurrentScrollOffset().y();
EXPECT_TRUE(y > 50 && y < 100);
EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
+ host_impl_->DidFinishImplFrame();
- host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(250);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
host_impl_->UpdateAnimationState(true);
EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
scrolling_layer->CurrentScrollOffset());
EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
+ host_impl_->DidFinishImplFrame();
}
TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) {
@@ -8147,8 +8273,6 @@ class FakeVideoFrameController : public VideoFrameController {
};
TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) {
- host_impl_->DidFinishImplFrame();
-
BeginFrameArgs begin_frame_args =
CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
FakeVideoFrameController controller;
@@ -8172,8 +8296,6 @@ TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) {
}
TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) {
- host_impl_->DidFinishImplFrame();
-
BeginFrameArgs begin_frame_args =
CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
FakeVideoFrameController controller;
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index bf03378..7c30bfc 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -201,24 +201,6 @@ void SingleThreadProxy::SetNeedsUpdateLayers() {
SetNeedsCommit();
}
-void SingleThreadProxy::DoAnimate() {
- // Don't animate if there is no root layer.
- // TODO(mithro): Both Animate and UpdateAnimationState already have a
- // "!active_tree_->root_layer()" check?
- if (!layer_tree_host_impl_->active_tree()->root_layer()) {
- return;
- }
-
- layer_tree_host_impl_->Animate(
- layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time);
-
- // If animations are not visible, update the animation state now as it
- // won't happen in DoComposite.
- if (!layer_tree_host_impl_->AnimationsAreVisible()) {
- layer_tree_host_impl_->UpdateAnimationState(true);
- }
-}
-
void SingleThreadProxy::DoCommit() {
TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit");
DCHECK(Proxy::IsMainThread());
@@ -593,7 +575,8 @@ void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
layer_tree_host_impl_->PrepareTiles();
layer_tree_host_impl_->SynchronouslyInitializeAllTiles();
- DoAnimate();
+ // TODO(danakj): Don't do this last... we prepared the wrong things. D:
+ layer_tree_host_impl_->Animate();
LayerTreeHostImpl::FrameData frame;
DoComposite(&frame);
@@ -881,7 +864,7 @@ void SingleThreadProxy::ScheduledActionCommit() {
void SingleThreadProxy::ScheduledActionAnimate() {
TRACE_EVENT0("cc", "ScheduledActionAnimate");
DebugScopedSetImplThread impl(this);
- DoAnimate();
+ layer_tree_host_impl_->Animate();
}
void SingleThreadProxy::ScheduledActionActivateSyncTree() {
diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h
index 8bec2b1..c8defe5 100644
--- a/cc/trees/single_thread_proxy.h
+++ b/cc/trees/single_thread_proxy.h
@@ -128,7 +128,6 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
private:
void BeginMainFrame(const BeginFrameArgs& begin_frame_args);
void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason);
- void DoAnimate();
void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args);
void DoCommit();
DrawResult DoComposite(LayerTreeHostImpl::FrameData* frame);
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
index e530931..9fac98b 100644
--- a/cc/trees/thread_proxy.cc
+++ b/cc/trees/thread_proxy.cc
@@ -858,22 +858,7 @@ void ThreadProxy::ScheduledActionAnimate() {
TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
DCHECK(IsImplThread());
- // Don't animate if there is no root layer.
- // TODO(mithro): Both Animate and UpdateAnimationState already have a
- // "!active_tree_->root_layer()" check?
- if (!impl().layer_tree_host_impl->active_tree()->root_layer()) {
- return;
- }
-
- impl().animation_time =
- impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time;
- impl().layer_tree_host_impl->Animate(impl().animation_time);
-
- // If animations are not visible, update the state now as
- // ScheduledActionDrawAndSwapIfPossible will never be called.
- if (!impl().layer_tree_host_impl->AnimationsAreVisible()) {
- impl().layer_tree_host_impl->UpdateAnimationState(true);
- }
+ impl().layer_tree_host_impl->Animate();
}
void ThreadProxy::ScheduledActionCommit() {
diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h
index ae9c733..3aeef74 100644
--- a/cc/trees/thread_proxy.h
+++ b/cc/trees/thread_proxy.h
@@ -129,8 +129,6 @@ class CC_EXPORT ThreadProxy : public Proxy,
bool input_throttled_until_commit;
- base::TimeTicks animation_time;
-
// Whether a commit has been completed since the last time animations were
// ticked. If this happens, we need to animate again.
bool did_commit_after_animating;