| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/scroll/ProgrammaticScrollAnimator.h" | 5 #include "platform/scroll/ProgrammaticScrollAnimator.h" |
| 6 | 6 |
| 7 #include "platform/animation/CompositorAnimation.h" | 7 #include "platform/animation/CompositorAnimation.h" |
| 8 #include "platform/animation/CompositorScrollOffsetAnimationCurve.h" | 8 #include "platform/animation/CompositorScrollOffsetAnimationCurve.h" |
| 9 #include "platform/geometry/IntPoint.h" | 9 #include "platform/geometry/IntPoint.h" |
| 10 #include "platform/graphics/GraphicsLayer.h" | 10 #include "platform/graphics/GraphicsLayer.h" |
| 11 #include "platform/scroll/ScrollableArea.h" | 11 #include "platform/scroll/ScrollableArea.h" |
| 12 #include "public/platform/Platform.h" | 12 #include "public/platform/Platform.h" |
| 13 #include "public/platform/WebCompositorSupport.h" | 13 #include "public/platform/WebCompositorSupport.h" |
| 14 #include "wtf/PtrUtil.h" | |
| 15 #include <memory> | |
| 16 | 14 |
| 17 namespace blink { | 15 namespace blink { |
| 18 | 16 |
| 19 ProgrammaticScrollAnimator::ProgrammaticScrollAnimator(ScrollableArea* scrollabl
eArea) | 17 ProgrammaticScrollAnimator::ProgrammaticScrollAnimator(ScrollableArea* scrollabl
eArea) |
| 20 : m_scrollableArea(scrollableArea) | 18 : m_scrollableArea(scrollableArea) |
| 21 , m_startTime(0.0) | 19 , m_startTime(0.0) |
| 22 { | 20 { |
| 23 } | 21 } |
| 24 | 22 |
| 25 ProgrammaticScrollAnimator::~ProgrammaticScrollAnimator() | 23 ProgrammaticScrollAnimator::~ProgrammaticScrollAnimator() |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 113 } |
| 116 } | 114 } |
| 117 | 115 |
| 118 if (m_runState == RunState::WaitingToSendToCompositor) { | 116 if (m_runState == RunState::WaitingToSendToCompositor) { |
| 119 if (!m_compositorAnimationAttachedToLayerId) | 117 if (!m_compositorAnimationAttachedToLayerId) |
| 120 reattachCompositorPlayerIfNeeded(getScrollableArea()->compositorAnim
ationTimeline()); | 118 reattachCompositorPlayerIfNeeded(getScrollableArea()->compositorAnim
ationTimeline()); |
| 121 | 119 |
| 122 bool sentToCompositor = false; | 120 bool sentToCompositor = false; |
| 123 | 121 |
| 124 if (!m_scrollableArea->shouldScrollOnMainThread()) { | 122 if (!m_scrollableArea->shouldScrollOnMainThread()) { |
| 125 std::unique_ptr<CompositorAnimation> animation = CompositorAnimation
::create(*m_animationCurve, CompositorTargetProperty::SCROLL_OFFSET, 0, 0); | 123 OwnPtr<CompositorAnimation> animation = CompositorAnimation::create(
*m_animationCurve, CompositorTargetProperty::SCROLL_OFFSET, 0, 0); |
| 126 | 124 |
| 127 int animationId = animation->id(); | 125 int animationId = animation->id(); |
| 128 int animationGroupId = animation->group(); | 126 int animationGroupId = animation->group(); |
| 129 | 127 |
| 130 if (addAnimation(std::move(animation))) { | 128 if (addAnimation(std::move(animation))) { |
| 131 sentToCompositor = true; | 129 sentToCompositor = true; |
| 132 m_runState = RunState::RunningOnCompositor; | 130 m_runState = RunState::RunningOnCompositor; |
| 133 m_compositorAnimationId = animationId; | 131 m_compositorAnimationId = animationId; |
| 134 m_compositorAnimationGroupId = animationGroupId; | 132 m_compositorAnimationGroupId = animationGroupId; |
| 135 } | 133 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); | 171 ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); |
| 174 } | 172 } |
| 175 | 173 |
| 176 DEFINE_TRACE(ProgrammaticScrollAnimator) | 174 DEFINE_TRACE(ProgrammaticScrollAnimator) |
| 177 { | 175 { |
| 178 visitor->trace(m_scrollableArea); | 176 visitor->trace(m_scrollableArea); |
| 179 ScrollAnimatorCompositorCoordinator::trace(visitor); | 177 ScrollAnimatorCompositorCoordinator::trace(visitor); |
| 180 } | 178 } |
| 181 | 179 |
| 182 } // namespace blink | 180 } // namespace blink |
| OLD | NEW |