Commit 68d3fc19 authored by skyostil@chromium.org's avatar skyostil@chromium.org

cc: Don't schedule top controls animation when there isn't one

If the top controls manager calculates an animation scroll delta of
zero, we schedule another animation attempt for the following frame.
This causes the compositor to run constantly -- for instance -- on pages
where scrolling JavaScript-driven instead of impl-driven.

The fix is to bail out if there is no active top controls animation.

TEST=LayerTreeHostImplWithTopControlsTest.NoIdleAnimation
BUG=309648

Review URL: https://codereview.chromium.org/167013003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251770 0039d316-1c4b-4281-b951-d872f2087c98
parent 378b5cca
...@@ -2633,7 +2633,7 @@ void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks time) { ...@@ -2633,7 +2633,7 @@ void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks time) {
} }
void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) {
if (!top_controls_manager_) if (!top_controls_manager_ || !top_controls_manager_->animation())
return; return;
gfx::Vector2dF scroll = top_controls_manager_->Animate(time); gfx::Vector2dF scroll = top_controls_manager_->Animate(time);
if (active_tree_->TotalScrollOffset().y() == 0.f) if (active_tree_->TotalScrollOffset().y() == 0.f)
......
...@@ -5811,5 +5811,21 @@ TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) { ...@@ -5811,5 +5811,21 @@ TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) {
} }
} }
class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest {
public:
virtual void SetUp() OVERRIDE {
LayerTreeSettings settings = DefaultSettings();
settings.calculate_top_controls_position = true;
CreateHostImpl(settings, CreateOutputSurface());
}
};
TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) {
SetupScrollAndContentsLayers(gfx::Size(100, 100))
->SetScrollOffset(gfx::Vector2d(0, 10));
host_impl_->Animate(base::TimeTicks(), base::Time());
EXPECT_FALSE(did_request_redraw_);
}
} // namespace } // namespace
} // namespace cc } // namespace cc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment