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

Unified Diff: Source/platform/scroll/ScrollAnimatorNone.cpp

Issue 244253002: Avoid useless initialization in ScrollAnimatorNone::PerAxisData::animateScroll() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move code to a new inline function Created 6 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/scroll/ScrollAnimatorNone.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scroll/ScrollAnimatorNone.cpp
diff --git a/Source/platform/scroll/ScrollAnimatorNone.cpp b/Source/platform/scroll/ScrollAnimatorNone.cpp
index 4a24201241b5a35b37f3c3de5060472d319feafb..3a4e7ed612ec125298409c4e4f983f0f837d8ffb 100644
--- a/Source/platform/scroll/ScrollAnimatorNone.cpp
+++ b/Source/platform/scroll/ScrollAnimatorNone.cpp
@@ -324,6 +324,17 @@ bool ScrollAnimatorNone::PerAxisData::updateDataFromParameters(float step, float
return true;
}
+inline double ScrollAnimatorNone::PerAxisData::newScrollAnimationPosition(double deltaTime)
+{
+ if (deltaTime < m_attackTime)
+ return attackCurve(m_attackCurve, deltaTime, m_attackTime, m_startPosition, m_attackPosition);
+ if (deltaTime < (m_animationTime - m_releaseTime))
+ return m_attackPosition + (deltaTime - m_attackTime) * m_desiredVelocity;
+ // release is based on targeting the exact final position.
+ double releaseDeltaT = deltaTime - (m_animationTime - m_releaseTime);
+ return releaseCurve(m_releaseCurve, releaseDeltaT, m_releaseTime, m_releasePosition, m_desiredPosition);
+}
+
// FIXME: Add in jank detection trace events into this function.
bool ScrollAnimatorNone::PerAxisData::animateScroll(double currentTime)
{
@@ -334,23 +345,13 @@ bool ScrollAnimatorNone::PerAxisData::animateScroll(double currentTime)
m_lastAnimationTime = currentTime;
double deltaTime = currentTime - m_startTime;
- double newPosition = *m_currentPosition;
if (deltaTime > m_animationTime) {
*m_currentPosition = m_desiredPosition;
reset();
return false;
}
- if (deltaTime < m_attackTime)
- newPosition = attackCurve(m_attackCurve, deltaTime, m_attackTime, m_startPosition, m_attackPosition);
- else if (deltaTime < (m_animationTime - m_releaseTime))
- newPosition = m_attackPosition + (deltaTime - m_attackTime) * m_desiredVelocity;
- else {
- // release is based on targeting the exact final position.
- double releaseDeltaT = deltaTime - (m_animationTime - m_releaseTime);
- newPosition = releaseCurve(m_releaseCurve, releaseDeltaT, m_releaseTime, m_releasePosition, m_desiredPosition);
- }
-
+ double newPosition = newScrollAnimationPosition(deltaTime);
// Normalize velocity to a per second amount. Could be used to check for jank.
if (lastScrollInterval > 0)
m_currentVelocity = (newPosition - *m_currentPosition) / lastScrollInterval;
« no previous file with comments | « Source/platform/scroll/ScrollAnimatorNone.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698