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> |
14 | 16 |
15 namespace blink { | 17 namespace blink { |
16 | 18 |
17 ProgrammaticScrollAnimator::ProgrammaticScrollAnimator(ScrollableArea* scrollabl
eArea) | 19 ProgrammaticScrollAnimator::ProgrammaticScrollAnimator(ScrollableArea* scrollabl
eArea) |
18 : m_scrollableArea(scrollableArea) | 20 : m_scrollableArea(scrollableArea) |
19 , m_startTime(0.0) | 21 , m_startTime(0.0) |
20 { | 22 { |
21 } | 23 } |
22 | 24 |
23 ProgrammaticScrollAnimator::~ProgrammaticScrollAnimator() | 25 ProgrammaticScrollAnimator::~ProgrammaticScrollAnimator() |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 115 } |
114 } | 116 } |
115 | 117 |
116 if (m_runState == RunState::WaitingToSendToCompositor) { | 118 if (m_runState == RunState::WaitingToSendToCompositor) { |
117 if (!m_compositorAnimationAttachedToLayerId) | 119 if (!m_compositorAnimationAttachedToLayerId) |
118 reattachCompositorPlayerIfNeeded(getScrollableArea()->compositorAnim
ationTimeline()); | 120 reattachCompositorPlayerIfNeeded(getScrollableArea()->compositorAnim
ationTimeline()); |
119 | 121 |
120 bool sentToCompositor = false; | 122 bool sentToCompositor = false; |
121 | 123 |
122 if (!m_scrollableArea->shouldScrollOnMainThread()) { | 124 if (!m_scrollableArea->shouldScrollOnMainThread()) { |
123 OwnPtr<CompositorAnimation> animation = CompositorAnimation::create(
*m_animationCurve, CompositorTargetProperty::SCROLL_OFFSET, 0, 0); | 125 std::unique_ptr<CompositorAnimation> animation = CompositorAnimation
::create(*m_animationCurve, CompositorTargetProperty::SCROLL_OFFSET, 0, 0); |
124 | 126 |
125 int animationId = animation->id(); | 127 int animationId = animation->id(); |
126 int animationGroupId = animation->group(); | 128 int animationGroupId = animation->group(); |
127 | 129 |
128 if (addAnimation(std::move(animation))) { | 130 if (addAnimation(std::move(animation))) { |
129 sentToCompositor = true; | 131 sentToCompositor = true; |
130 m_runState = RunState::RunningOnCompositor; | 132 m_runState = RunState::RunningOnCompositor; |
131 m_compositorAnimationId = animationId; | 133 m_compositorAnimationId = animationId; |
132 m_compositorAnimationGroupId = animationGroupId; | 134 m_compositorAnimationGroupId = animationGroupId; |
133 } | 135 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); | 173 ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); |
172 } | 174 } |
173 | 175 |
174 DEFINE_TRACE(ProgrammaticScrollAnimator) | 176 DEFINE_TRACE(ProgrammaticScrollAnimator) |
175 { | 177 { |
176 visitor->trace(m_scrollableArea); | 178 visitor->trace(m_scrollableArea); |
177 ScrollAnimatorCompositorCoordinator::trace(visitor); | 179 ScrollAnimatorCompositorCoordinator::trace(visitor); |
178 } | 180 } |
179 | 181 |
180 } // namespace blink | 182 } // namespace blink |
OLD | NEW |