Commit 21533289 authored by ymalik's avatar ymalik Committed by Commit bot

Query compositing state only from UpdateAnimationState

https://codereview.chromium.org/2029323003 attempted to add an optimization
that would run an animation on the MT by querying m_scrollableArea->
shouldScrollOnMainThread. This was wrong because we were querying compositing
state outside of the CompositingClean state.

This reverts that CL.

The original bug was not fixed in the CL that this reverts and that CL was
just wrong.

This CL doesn't have a behavioral change.

BUG=639100

Review-Url: https://codereview.chromium.org/2338913002
Cr-Commit-Position: refs/heads/master@{#418596}
parent 0dc7ce1e
...@@ -188,14 +188,8 @@ bool ScrollAnimator::willAnimateToOffset(const FloatPoint& targetPos) ...@@ -188,14 +188,8 @@ bool ScrollAnimator::willAnimateToOffset(const FloatPoint& targetPos)
m_targetOffset = targetPos; m_targetOffset = targetPos;
m_startTime = m_timeFunction(); m_startTime = m_timeFunction();
if (registerAndScheduleAnimation()) { if (registerAndScheduleAnimation())
if (m_scrollableArea->shouldScrollOnMainThread()) { m_runState = RunState::WaitingToSendToCompositor;
createAnimationCurve();
m_runState = RunState::RunningOnMainThread;
} else {
m_runState = RunState::WaitingToSendToCompositor;
}
}
return true; return true;
} }
...@@ -305,13 +299,6 @@ void ScrollAnimator::createAnimationCurve() ...@@ -305,13 +299,6 @@ void ScrollAnimator::createAnimationCurve()
void ScrollAnimator::updateCompositorAnimations() void ScrollAnimator::updateCompositorAnimations()
{ {
ScrollAnimatorCompositorCoordinator::updateCompositorAnimations(); ScrollAnimatorCompositorCoordinator::updateCompositorAnimations();
if (m_runState == RunState::RunningOnMainThread) {
// We add a temporary main thread scrolling reason so that subsequent
// scrolls get handled on the main thread. This is removed when the
// animation is finished in ::tickAnimation.
addMainThreadScrollingReason();
return;
}
if (m_runState == RunState::PostAnimationCleanup) { if (m_runState == RunState::PostAnimationCleanup) {
postAnimationCleanupAndReset(); postAnimationCleanupAndReset();
......
...@@ -87,16 +87,6 @@ public: ...@@ -87,16 +87,6 @@ public:
animator = scrollAnimator; animator = scrollAnimator;
} }
bool shouldScrollOnMainThread() const override
{
return m_scrollOnMainThread;
}
void setScrollOnMainThread(bool scrollOnMainThread)
{
m_scrollOnMainThread = scrollOnMainThread;
}
DoublePoint scrollPositionDouble() const override DoublePoint scrollPositionDouble() const override
{ {
if (animator) if (animator)
...@@ -123,7 +113,6 @@ private: ...@@ -123,7 +113,6 @@ private:
: m_scrollAnimatorEnabled(scrollAnimatorEnabled) { } : m_scrollAnimatorEnabled(scrollAnimatorEnabled) { }
bool m_scrollAnimatorEnabled; bool m_scrollAnimatorEnabled;
bool m_scrollOnMainThread = false;
Member<ScrollAnimator> animator; Member<ScrollAnimator> animator;
}; };
...@@ -167,7 +156,6 @@ static void reset(ScrollAnimator& scrollAnimator) ...@@ -167,7 +156,6 @@ static void reset(ScrollAnimator& scrollAnimator)
TEST(ScrollAnimatorTest, MainThreadStates) TEST(ScrollAnimatorTest, MainThreadStates)
{ {
MockScrollableArea* scrollableArea = MockScrollableArea::create(true); MockScrollableArea* scrollableArea = MockScrollableArea::create(true);
scrollableArea->setScrollOnMainThread(true);
ScrollAnimator* scrollAnimator = new ScrollAnimator(scrollableArea, getMockedTime); ScrollAnimator* scrollAnimator = new ScrollAnimator(scrollableArea, getMockedTime);
EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)) EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1))
...@@ -175,8 +163,8 @@ TEST(ScrollAnimatorTest, MainThreadStates) ...@@ -175,8 +163,8 @@ TEST(ScrollAnimatorTest, MainThreadStates)
EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)) EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1))
.WillRepeatedly(Return(IntPoint(1000, 1000))); .WillRepeatedly(Return(IntPoint(1000, 1000)));
EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(2); EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(2);
// Once from userScroll. // Once from userScroll, once from updateCompositorAnimations.
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(1); EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(2);
EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1)) EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1))
.WillRepeatedly(Return(true)); .WillRepeatedly(Return(true));
...@@ -188,7 +176,7 @@ TEST(ScrollAnimatorTest, MainThreadStates) ...@@ -188,7 +176,7 @@ TEST(ScrollAnimatorTest, MainThreadStates)
// WaitingToSendToCompositor // WaitingToSendToCompositor
scrollAnimator->userScroll(ScrollByLine, FloatSize(10, 0)); scrollAnimator->userScroll(ScrollByLine, FloatSize(10, 0));
EXPECT_EQ(scrollAnimator->m_runState, EXPECT_EQ(scrollAnimator->m_runState,
ScrollAnimatorCompositorCoordinator::RunState::RunningOnMainThread); ScrollAnimatorCompositorCoordinator::RunState::WaitingToSendToCompositor);
// RunningOnMainThread // RunningOnMainThread
gMockedTime += 0.05; gMockedTime += 0.05;
......
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