| 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 13 matching lines...) Expand all  Loading... | 
| 24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
| 25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
| 26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 29  */ | 29  */ | 
| 30 | 30 | 
| 31 #include "platform/scroll/ScrollAnimator.h" | 31 #include "platform/scroll/ScrollAnimator.h" | 
| 32 | 32 | 
| 33 #include "platform/TraceEvent.h" | 33 #include "platform/TraceEvent.h" | 
|  | 34 #include "platform/animation/CompositorAnimation.h" | 
|  | 35 #include "platform/graphics/CompositorFactory.h" | 
| 34 #include "platform/graphics/GraphicsLayer.h" | 36 #include "platform/graphics/GraphicsLayer.h" | 
| 35 #include "platform/scroll/ScrollableArea.h" | 37 #include "platform/scroll/ScrollableArea.h" | 
| 36 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" | 
| 37 #include "public/platform/WebCompositorAnimation.h" |  | 
| 38 #include "public/platform/WebCompositorSupport.h" | 39 #include "public/platform/WebCompositorSupport.h" | 
| 39 #include "wtf/CurrentTime.h" | 40 #include "wtf/CurrentTime.h" | 
| 40 #include "wtf/PassRefPtr.h" | 41 #include "wtf/PassRefPtr.h" | 
| 41 | 42 | 
| 42 namespace blink { | 43 namespace blink { | 
| 43 | 44 | 
| 44 PassOwnPtrWillBeRawPtr<ScrollAnimatorBase> ScrollAnimatorBase::create(Scrollable
     Area* scrollableArea) | 45 PassOwnPtrWillBeRawPtr<ScrollAnimatorBase> ScrollAnimatorBase::create(Scrollable
     Area* scrollableArea) | 
| 45 { | 46 { | 
| 46     if (scrollableArea && scrollableArea->scrollAnimatorEnabled()) | 47     if (scrollableArea && scrollableArea->scrollAnimatorEnabled()) | 
| 47         return adoptPtrWillBeNoop(new ScrollAnimator(scrollableArea)); | 48         return adoptPtrWillBeNoop(new ScrollAnimator(scrollableArea)); | 
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 221 | 222 | 
| 222             m_compositorAnimationId = 0; | 223             m_compositorAnimationId = 0; | 
| 223             m_compositorAnimationGroupId = 0; | 224             m_compositorAnimationGroupId = 0; | 
| 224 | 225 | 
| 225             m_animationCurve->updateTarget(m_timeFunction() - m_startTime, | 226             m_animationCurve->updateTarget(m_timeFunction() - m_startTime, | 
| 226                 m_targetOffset); | 227                 m_targetOffset); | 
| 227             m_runState = RunState::WaitingToSendToCompositor; | 228             m_runState = RunState::WaitingToSendToCompositor; | 
| 228         } | 229         } | 
| 229 | 230 | 
| 230         if (!m_animationCurve) { | 231         if (!m_animationCurve) { | 
| 231             m_animationCurve = adoptPtr(Platform::current()->compositorSupport() | 232             m_animationCurve = adoptPtr(CompositorFactory::current().createScrol
     lOffsetAnimationCurve( | 
| 232                 ->createScrollOffsetAnimationCurve( | 233                 m_targetOffset, | 
| 233                     m_targetOffset, | 234                 CompositorAnimationCurve::TimingFunctionTypeEaseInOut, | 
| 234                     WebCompositorAnimationCurve::TimingFunctionTypeEaseInOut, | 235                 m_lastGranularity == ScrollByPixel ? | 
| 235                     m_lastGranularity == ScrollByPixel ? | 236                     CompositorScrollOffsetAnimationCurve::ScrollDurationInverseD
     elta : | 
| 236                         WebScrollOffsetAnimationCurve::ScrollDurationInverseDelt
     a : | 237                     CompositorScrollOffsetAnimationCurve::ScrollDurationConstant
     )); | 
| 237                         WebScrollOffsetAnimationCurve::ScrollDurationConstant)); |  | 
| 238             m_animationCurve->setInitialValue(currentPosition()); | 238             m_animationCurve->setInitialValue(currentPosition()); | 
| 239         } | 239         } | 
| 240 | 240 | 
| 241         bool sentToCompositor = false; | 241         bool sentToCompositor = false; | 
| 242         if (!m_scrollableArea->shouldScrollOnMainThread()) { | 242         if (!m_scrollableArea->shouldScrollOnMainThread()) { | 
| 243             OwnPtr<WebCompositorAnimation> animation = adoptPtr( | 243             OwnPtr<CompositorAnimation> animation = adoptPtr( | 
| 244                 Platform::current()->compositorSupport()->createAnimation( | 244                 CompositorFactory::current().createAnimation( | 
| 245                     *m_animationCurve, | 245                     *m_animationCurve, | 
| 246                     WebCompositorAnimation::TargetPropertyScrollOffset)); | 246                     CompositorAnimation::TargetPropertyScrollOffset)); | 
| 247             // Being here means that either there is an animation that needs | 247             // Being here means that either there is an animation that needs | 
| 248             // to be sent to the compositor, or an animation that needs to | 248             // to be sent to the compositor, or an animation that needs to | 
| 249             // be updated (a new scroll event before the previous animation | 249             // be updated (a new scroll event before the previous animation | 
| 250             // is finished). In either case, the start time is when the | 250             // is finished). In either case, the start time is when the | 
| 251             // first animation was initiated. This re-targets the animation | 251             // first animation was initiated. This re-targets the animation | 
| 252             // using the current time on main thread. | 252             // using the current time on main thread. | 
| 253             animation->setStartTime(m_startTime); | 253             animation->setStartTime(m_startTime); | 
| 254 | 254 | 
| 255             int animationId = animation->id(); | 255             int animationId = animation->id(); | 
| 256             int animationGroupId = animation->group(); | 256             int animationGroupId = animation->group(); | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 281 { | 281 { | 
| 282     ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); | 282     ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); | 
| 283 } | 283 } | 
| 284 | 284 | 
| 285 void ScrollAnimator::cancelAnimation() | 285 void ScrollAnimator::cancelAnimation() | 
| 286 { | 286 { | 
| 287     ScrollAnimatorCompositorCoordinator::cancelAnimation(); | 287     ScrollAnimatorCompositorCoordinator::cancelAnimation(); | 
| 288 } | 288 } | 
| 289 | 289 | 
| 290 void ScrollAnimator::layerForCompositedScrollingDidChange( | 290 void ScrollAnimator::layerForCompositedScrollingDidChange( | 
| 291     WebCompositorAnimationTimeline* timeline) | 291     CompositorAnimationTimeline* timeline) | 
| 292 { | 292 { | 
| 293     reattachCompositorPlayerIfNeeded(timeline); | 293     reattachCompositorPlayerIfNeeded(timeline); | 
| 294 } | 294 } | 
| 295 | 295 | 
| 296 bool ScrollAnimator::registerAndScheduleAnimation() | 296 bool ScrollAnimator::registerAndScheduleAnimation() | 
| 297 { | 297 { | 
| 298     scrollableArea()->registerForAnimation(); | 298     scrollableArea()->registerForAnimation(); | 
| 299     if (!m_scrollableArea->scheduleAnimation()) { | 299     if (!m_scrollableArea->scheduleAnimation()) { | 
| 300         scrollToOffsetWithoutAnimation(m_targetOffset); | 300         scrollToOffsetWithoutAnimation(m_targetOffset); | 
| 301         resetAnimationState(); | 301         resetAnimationState(); | 
| 302         return false; | 302         return false; | 
| 303     } | 303     } | 
| 304     return true; | 304     return true; | 
| 305 } | 305 } | 
| 306 | 306 | 
| 307 DEFINE_TRACE(ScrollAnimator) | 307 DEFINE_TRACE(ScrollAnimator) | 
| 308 { | 308 { | 
| 309     ScrollAnimatorBase::trace(visitor); | 309     ScrollAnimatorBase::trace(visitor); | 
| 310 } | 310 } | 
| 311 | 311 | 
| 312 } // namespace blink | 312 } // namespace blink | 
| OLD | NEW | 
|---|