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 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
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/CompositorFactory.h" |
33 #include "platform/TraceEvent.h" | 34 #include "platform/TraceEvent.h" |
| 35 #include "platform/animation/WebCompositorAnimation.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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 218 |
218 m_compositorAnimationId = 0; | 219 m_compositorAnimationId = 0; |
219 m_compositorAnimationGroupId = 0; | 220 m_compositorAnimationGroupId = 0; |
220 | 221 |
221 m_animationCurve->updateTarget(m_timeFunction() - m_startTime, | 222 m_animationCurve->updateTarget(m_timeFunction() - m_startTime, |
222 m_targetOffset); | 223 m_targetOffset); |
223 m_runState = RunState::WaitingToSendToCompositor; | 224 m_runState = RunState::WaitingToSendToCompositor; |
224 } | 225 } |
225 | 226 |
226 if (!m_animationCurve) { | 227 if (!m_animationCurve) { |
227 m_animationCurve = adoptPtr(Platform::current()->compositorSupport() | 228 m_animationCurve = adoptPtr(CompositorFactory::current().createScrol
lOffsetAnimationCurve( |
228 ->createScrollOffsetAnimationCurve( | 229 m_targetOffset, |
229 m_targetOffset, | 230 WebCompositorAnimationCurve::TimingFunctionTypeEaseInOut, |
230 WebCompositorAnimationCurve::TimingFunctionTypeEaseInOut, | 231 m_lastGranularity == ScrollByPixel ? |
231 m_lastGranularity == ScrollByPixel ? | 232 WebScrollOffsetAnimationCurve::ScrollDurationInverseDelta : |
232 WebScrollOffsetAnimationCurve::ScrollDurationInverseDelt
a : | 233 WebScrollOffsetAnimationCurve::ScrollDurationConstant)); |
233 WebScrollOffsetAnimationCurve::ScrollDurationConstant)); | |
234 m_animationCurve->setInitialValue(currentPosition()); | 234 m_animationCurve->setInitialValue(currentPosition()); |
235 } | 235 } |
236 | 236 |
237 bool sentToCompositor = false; | 237 bool sentToCompositor = false; |
238 if (!m_scrollableArea->shouldScrollOnMainThread()) { | 238 if (!m_scrollableArea->shouldScrollOnMainThread()) { |
239 OwnPtr<WebCompositorAnimation> animation = adoptPtr( | 239 OwnPtr<WebCompositorAnimation> animation = adoptPtr( |
240 Platform::current()->compositorSupport()->createAnimation( | 240 CompositorFactory::current().createAnimation( |
241 *m_animationCurve, | 241 *m_animationCurve, |
242 WebCompositorAnimation::TargetPropertyScrollOffset)); | 242 WebCompositorAnimation::TargetPropertyScrollOffset)); |
243 // Being here means that either there is an animation that needs | 243 // Being here means that either there is an animation that needs |
244 // to be sent to the compositor, or an animation that needs to | 244 // to be sent to the compositor, or an animation that needs to |
245 // be updated (a new scroll event before the previous animation | 245 // be updated (a new scroll event before the previous animation |
246 // is finished). In either case, the start time is when the | 246 // is finished). In either case, the start time is when the |
247 // first animation was initiated. This re-targets the animation | 247 // first animation was initiated. This re-targets the animation |
248 // using the current time on main thread. | 248 // using the current time on main thread. |
249 animation->setStartTime(m_startTime); | 249 animation->setStartTime(m_startTime); |
250 | 250 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 return true; | 300 return true; |
301 } | 301 } |
302 | 302 |
303 DEFINE_TRACE(ScrollAnimator) | 303 DEFINE_TRACE(ScrollAnimator) |
304 { | 304 { |
305 ScrollAnimatorBase::trace(visitor); | 305 ScrollAnimatorBase::trace(visitor); |
306 } | 306 } |
307 | 307 |
308 } // namespace blink | 308 } // namespace blink |
OLD | NEW |