| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 m_targetOffset = targetPos; | 143 m_targetOffset = targetPos; |
| 144 ASSERT(m_runState == RunState::RunningOnMainThread | 144 ASSERT(m_runState == RunState::RunningOnMainThread |
| 145 || m_runState == RunState::RunningOnCompositor | 145 || m_runState == RunState::RunningOnCompositor |
| 146 || m_runState == RunState::RunningOnCompositorButNeedsUpdate | 146 || m_runState == RunState::RunningOnCompositorButNeedsUpdate |
| 147 || m_runState == RunState::RunningOnCompositorButNeedsTakeover); | 147 || m_runState == RunState::RunningOnCompositorButNeedsTakeover); |
| 148 | 148 |
| 149 // Running on the main thread, simply update the target offset instead | 149 // Running on the main thread, simply update the target offset instead |
| 150 // of sending to the compositor. | 150 // of sending to the compositor. |
| 151 if (m_runState == RunState::RunningOnMainThread) { | 151 if (m_runState == RunState::RunningOnMainThread) { |
| 152 m_animationCurve->updateTarget(m_timeFunction() - m_startTime, targe
tPos); | 152 m_animationCurve->updateTarget(m_timeFunction() - m_startTime, |
| 153 compositorOffsetFromBlinkOffset(targetPos)); |
| 153 return true; | 154 return true; |
| 154 } | 155 } |
| 155 | 156 |
| 156 if (registerAndScheduleAnimation()) | 157 if (registerAndScheduleAnimation()) |
| 157 m_runState = RunState::RunningOnCompositorButNeedsUpdate; | 158 m_runState = RunState::RunningOnCompositorButNeedsUpdate; |
| 158 return true; | 159 return true; |
| 159 } | 160 } |
| 160 | 161 |
| 161 if ((targetPos - currentPosition()).isZero()) | 162 if ((targetPos - currentPosition()).isZero()) |
| 162 return false; | 163 return false; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 180 | 181 |
| 181 void ScrollAnimator::tickAnimation(double monotonicTime) | 182 void ScrollAnimator::tickAnimation(double monotonicTime) |
| 182 { | 183 { |
| 183 if (m_runState != RunState::RunningOnMainThread) | 184 if (m_runState != RunState::RunningOnMainThread) |
| 184 return; | 185 return; |
| 185 | 186 |
| 186 TRACE_EVENT0("blink", "ScrollAnimator::tickAnimation"); | 187 TRACE_EVENT0("blink", "ScrollAnimator::tickAnimation"); |
| 187 double elapsedTime = monotonicTime - m_startTime; | 188 double elapsedTime = monotonicTime - m_startTime; |
| 188 | 189 |
| 189 bool isFinished = (elapsedTime > m_animationCurve->duration()); | 190 bool isFinished = (elapsedTime > m_animationCurve->duration()); |
| 190 FloatPoint offset = isFinished ? m_animationCurve->targetValue() | 191 FloatPoint offset = blinkOffsetFromCompositorOffset(isFinished |
| 191 : m_animationCurve->getValue(elapsedTime); | 192 ? m_animationCurve->targetValue() |
| 193 : m_animationCurve->getValue(elapsedTime)); |
| 192 | 194 |
| 193 offset = FloatPoint(m_scrollableArea->clampScrollPosition(offset)); | 195 offset = FloatPoint(m_scrollableArea->clampScrollPosition(offset)); |
| 194 | 196 |
| 195 m_currentPos = offset; | 197 m_currentPos = offset; |
| 196 | 198 |
| 197 if (isFinished) | 199 if (isFinished) |
| 198 m_runState = RunState::PostAnimationCleanup; | 200 m_runState = RunState::PostAnimationCleanup; |
| 199 else | 201 else |
| 200 scrollableArea()->scheduleAnimation(); | 202 scrollableArea()->scheduleAnimation(); |
| 201 | 203 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 || m_runState == RunState::RunningOnCompositorButNeedsUpdate) { | 281 || m_runState == RunState::RunningOnCompositorButNeedsUpdate) { |
| 280 if (m_runState == RunState::RunningOnCompositorButNeedsUpdate) { | 282 if (m_runState == RunState::RunningOnCompositorButNeedsUpdate) { |
| 281 // Abort the running animation before a new one with an updated | 283 // Abort the running animation before a new one with an updated |
| 282 // target is added. | 284 // target is added. |
| 283 abortAnimation(); | 285 abortAnimation(); |
| 284 | 286 |
| 285 m_compositorAnimationId = 0; | 287 m_compositorAnimationId = 0; |
| 286 m_compositorAnimationGroupId = 0; | 288 m_compositorAnimationGroupId = 0; |
| 287 | 289 |
| 288 m_animationCurve->updateTarget(m_timeFunction() - m_startTime, | 290 m_animationCurve->updateTarget(m_timeFunction() - m_startTime, |
| 289 m_targetOffset); | 291 compositorOffsetFromBlinkOffset(m_targetOffset)); |
| 290 m_runState = RunState::WaitingToSendToCompositor; | 292 m_runState = RunState::WaitingToSendToCompositor; |
| 291 } | 293 } |
| 292 | 294 |
| 293 if (!m_animationCurve) { | 295 if (!m_animationCurve) { |
| 294 m_animationCurve = adoptPtr(CompositorFactory::current().createScrol
lOffsetAnimationCurve( | 296 m_animationCurve = adoptPtr(CompositorFactory::current().createScrol
lOffsetAnimationCurve( |
| 295 m_targetOffset, | 297 compositorOffsetFromBlinkOffset(m_targetOffset), |
| 296 CompositorAnimationCurve::TimingFunctionTypeEaseInOut, | 298 CompositorAnimationCurve::TimingFunctionTypeEaseInOut, |
| 297 m_lastGranularity == ScrollByPixel ? | 299 m_lastGranularity == ScrollByPixel ? |
| 298 CompositorScrollOffsetAnimationCurve::ScrollDurationInverseD
elta : | 300 CompositorScrollOffsetAnimationCurve::ScrollDurationInverseD
elta : |
| 299 CompositorScrollOffsetAnimationCurve::ScrollDurationConstant
)); | 301 CompositorScrollOffsetAnimationCurve::ScrollDurationConstant
)); |
| 300 m_animationCurve->setInitialValue(currentPosition()); | 302 m_animationCurve->setInitialValue(compositorOffsetFromBlinkOffset(cu
rrentPosition())); |
| 301 } | 303 } |
| 302 | 304 |
| 303 bool runningOnMainThread = false; | 305 bool runningOnMainThread = false; |
| 304 bool sentToCompositor = sendAnimationToCompositor(); | 306 bool sentToCompositor = sendAnimationToCompositor(); |
| 305 if (!sentToCompositor) { | 307 if (!sentToCompositor) { |
| 306 runningOnMainThread = registerAndScheduleAnimation(); | 308 runningOnMainThread = registerAndScheduleAnimation(); |
| 307 if (runningOnMainThread) | 309 if (runningOnMainThread) |
| 308 m_runState = RunState::RunningOnMainThread; | 310 m_runState = RunState::RunningOnMainThread; |
| 309 } | 311 } |
| 310 | 312 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 } | 399 } |
| 398 return true; | 400 return true; |
| 399 } | 401 } |
| 400 | 402 |
| 401 DEFINE_TRACE(ScrollAnimator) | 403 DEFINE_TRACE(ScrollAnimator) |
| 402 { | 404 { |
| 403 ScrollAnimatorBase::trace(visitor); | 405 ScrollAnimatorBase::trace(visitor); |
| 404 } | 406 } |
| 405 | 407 |
| 406 } // namespace blink | 408 } // namespace blink |
| OLD | NEW |