OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 m_attackPosition = m_releasePosition - (m_animationTime - m_releaseTime
- m_attackTime) * m_desiredVelocity; | 317 m_attackPosition = m_releasePosition - (m_animationTime - m_releaseTime
- m_attackTime) * m_desiredVelocity; |
318 | 318 |
319 if (sustainTimeLeft) { | 319 if (sustainTimeLeft) { |
320 double roundOff = m_releasePosition - ((attackAreaLeft ? m_attackPositio
n : *m_currentPosition) + m_desiredVelocity * sustainTimeLeft); | 320 double roundOff = m_releasePosition - ((attackAreaLeft ? m_attackPositio
n : *m_currentPosition) + m_desiredVelocity * sustainTimeLeft); |
321 m_desiredVelocity += roundOff / sustainTimeLeft; | 321 m_desiredVelocity += roundOff / sustainTimeLeft; |
322 } | 322 } |
323 | 323 |
324 return true; | 324 return true; |
325 } | 325 } |
326 | 326 |
| 327 inline double ScrollAnimatorNone::PerAxisData::newScrollAnimationPosition(double
deltaTime) |
| 328 { |
| 329 if (deltaTime < m_attackTime) |
| 330 return attackCurve(m_attackCurve, deltaTime, m_attackTime, m_startPositi
on, m_attackPosition); |
| 331 if (deltaTime < (m_animationTime - m_releaseTime)) |
| 332 return m_attackPosition + (deltaTime - m_attackTime) * m_desiredVelocity
; |
| 333 // release is based on targeting the exact final position. |
| 334 double releaseDeltaT = deltaTime - (m_animationTime - m_releaseTime); |
| 335 return releaseCurve(m_releaseCurve, releaseDeltaT, m_releaseTime, m_releaseP
osition, m_desiredPosition); |
| 336 } |
| 337 |
327 // FIXME: Add in jank detection trace events into this function. | 338 // FIXME: Add in jank detection trace events into this function. |
328 bool ScrollAnimatorNone::PerAxisData::animateScroll(double currentTime) | 339 bool ScrollAnimatorNone::PerAxisData::animateScroll(double currentTime) |
329 { | 340 { |
330 double lastScrollInterval = currentTime - m_lastAnimationTime; | 341 double lastScrollInterval = currentTime - m_lastAnimationTime; |
331 if (lastScrollInterval < kMinimumTimerInterval) | 342 if (lastScrollInterval < kMinimumTimerInterval) |
332 return true; | 343 return true; |
333 | 344 |
334 m_lastAnimationTime = currentTime; | 345 m_lastAnimationTime = currentTime; |
335 | 346 |
336 double deltaTime = currentTime - m_startTime; | 347 double deltaTime = currentTime - m_startTime; |
337 double newPosition = *m_currentPosition; | |
338 | 348 |
339 if (deltaTime > m_animationTime) { | 349 if (deltaTime > m_animationTime) { |
340 *m_currentPosition = m_desiredPosition; | 350 *m_currentPosition = m_desiredPosition; |
341 reset(); | 351 reset(); |
342 return false; | 352 return false; |
343 } | 353 } |
344 if (deltaTime < m_attackTime) | 354 double newPosition = newScrollAnimationPosition(deltaTime); |
345 newPosition = attackCurve(m_attackCurve, deltaTime, m_attackTime, m_star
tPosition, m_attackPosition); | |
346 else if (deltaTime < (m_animationTime - m_releaseTime)) | |
347 newPosition = m_attackPosition + (deltaTime - m_attackTime) * m_desiredV
elocity; | |
348 else { | |
349 // release is based on targeting the exact final position. | |
350 double releaseDeltaT = deltaTime - (m_animationTime - m_releaseTime); | |
351 newPosition = releaseCurve(m_releaseCurve, releaseDeltaT, m_releaseTime,
m_releasePosition, m_desiredPosition); | |
352 } | |
353 | |
354 // Normalize velocity to a per second amount. Could be used to check for jan
k. | 355 // Normalize velocity to a per second amount. Could be used to check for jan
k. |
355 if (lastScrollInterval > 0) | 356 if (lastScrollInterval > 0) |
356 m_currentVelocity = (newPosition - *m_currentPosition) / lastScrollInter
val; | 357 m_currentVelocity = (newPosition - *m_currentPosition) / lastScrollInter
val; |
357 *m_currentPosition = newPosition; | 358 *m_currentPosition = newPosition; |
358 | 359 |
359 return true; | 360 return true; |
360 } | 361 } |
361 | 362 |
362 void ScrollAnimatorNone::PerAxisData::updateVisibleLength(int visibleLength) | 363 void ScrollAnimatorNone::PerAxisData::updateVisibleLength(int visibleLength) |
363 { | 364 { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 return m_animationActive; | 518 return m_animationActive; |
518 } | 519 } |
519 | 520 |
520 void ScrollAnimatorNone::stopAnimationTimerIfNeeded() | 521 void ScrollAnimatorNone::stopAnimationTimerIfNeeded() |
521 { | 522 { |
522 if (animationTimerActive()) | 523 if (animationTimerActive()) |
523 m_animationActive = false; | 524 m_animationActive = false; |
524 } | 525 } |
525 | 526 |
526 } // namespace WebCore | 527 } // namespace WebCore |
OLD | NEW |