| 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/ScrollAnimatorCompositorCoordinator.h" | 5 #include "platform/scroll/ScrollAnimatorCompositorCoordinator.h" |
| 6 | 6 |
| 7 #include "cc/animation/scroll_offset_animation_curve.h" | 7 #include "cc/animation/scroll_offset_animation_curve.h" |
| 8 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
| 9 #include "platform/animation/CompositorAnimation.h" | 9 #include "platform/animation/CompositorAnimation.h" |
| 10 #include "platform/animation/CompositorAnimationHost.h" | 10 #include "platform/animation/CompositorAnimationHost.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // animation. | 230 // animation. |
| 231 notifyCompositorAnimationFinished(group); | 231 notifyCompositorAnimationFinished(group); |
| 232 } | 232 } |
| 233 | 233 |
| 234 CompositorAnimationPlayer* | 234 CompositorAnimationPlayer* |
| 235 ScrollAnimatorCompositorCoordinator::compositorPlayer() const { | 235 ScrollAnimatorCompositorCoordinator::compositorPlayer() const { |
| 236 return m_compositorPlayer.get(); | 236 return m_compositorPlayer.get(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 FloatPoint ScrollAnimatorCompositorCoordinator::compositorOffsetFromBlinkOffset( | 239 FloatPoint ScrollAnimatorCompositorCoordinator::compositorOffsetFromBlinkOffset( |
| 240 FloatPoint offset) { | 240 ScrollOffset offset) { |
| 241 offset.moveBy(getScrollableArea()->scrollOrigin()); | 241 return getScrollableArea()->scrollOrigin() + offset; |
| 242 return offset; | |
| 243 } | 242 } |
| 244 | 243 |
| 245 FloatPoint ScrollAnimatorCompositorCoordinator::blinkOffsetFromCompositorOffset( | 244 ScrollOffset |
| 245 ScrollAnimatorCompositorCoordinator::blinkOffsetFromCompositorOffset( |
| 246 FloatPoint offset) { | 246 FloatPoint offset) { |
| 247 offset.moveBy(-getScrollableArea()->scrollOrigin()); | 247 return offset - getScrollableArea()->scrollOrigin(); |
| 248 return offset; | |
| 249 } | 248 } |
| 250 | 249 |
| 251 bool ScrollAnimatorCompositorCoordinator::hasImplOnlyAnimationUpdate() const { | 250 bool ScrollAnimatorCompositorCoordinator::hasImplOnlyAnimationUpdate() const { |
| 252 return !m_implOnlyAnimationAdjustment.isZero() || m_implOnlyAnimationTakeover; | 251 return !m_implOnlyAnimationAdjustment.isZero() || m_implOnlyAnimationTakeover; |
| 253 } | 252 } |
| 254 | 253 |
| 255 void ScrollAnimatorCompositorCoordinator::updateImplOnlyCompositorAnimations() { | 254 void ScrollAnimatorCompositorCoordinator::updateImplOnlyCompositorAnimations() { |
| 256 if (!hasImplOnlyAnimationUpdate()) | 255 if (!hasImplOnlyAnimationUpdate()) |
| 257 return; | 256 return; |
| 258 | 257 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 274 m_implOnlyAnimationTakeover = false; | 273 m_implOnlyAnimationTakeover = false; |
| 275 } | 274 } |
| 276 | 275 |
| 277 void ScrollAnimatorCompositorCoordinator::updateCompositorAnimations() { | 276 void ScrollAnimatorCompositorCoordinator::updateCompositorAnimations() { |
| 278 if (!getScrollableArea()->scrollAnimatorEnabled()) | 277 if (!getScrollableArea()->scrollAnimatorEnabled()) |
| 279 return; | 278 return; |
| 280 | 279 |
| 281 updateImplOnlyCompositorAnimations(); | 280 updateImplOnlyCompositorAnimations(); |
| 282 } | 281 } |
| 283 | 282 |
| 284 void ScrollAnimatorCompositorCoordinator::scrollPositionChanged( | 283 void ScrollAnimatorCompositorCoordinator::scrollOffsetChanged( |
| 285 const DoublePoint& offset, | 284 const ScrollOffset& offset, |
| 286 ScrollType scrollType) { | 285 ScrollType scrollType) { |
| 287 getScrollableArea()->scrollPositionChanged(offset, scrollType); | 286 getScrollableArea()->scrollOffsetChanged(offset, scrollType); |
| 288 } | 287 } |
| 289 | 288 |
| 290 void ScrollAnimatorCompositorCoordinator::adjustAnimationAndSetScrollPosition( | 289 void ScrollAnimatorCompositorCoordinator::adjustAnimationAndSetScrollOffset( |
| 291 const DoublePoint& position, | 290 const ScrollOffset& offset, |
| 292 ScrollType scrollType) { | 291 ScrollType scrollType) { |
| 293 // Subclasses should override this and adjust the animation as necessary. | 292 // Subclasses should override this and adjust the animation as necessary. |
| 294 scrollPositionChanged(position, scrollType); | 293 scrollOffsetChanged(offset, scrollType); |
| 295 } | 294 } |
| 296 | 295 |
| 297 void ScrollAnimatorCompositorCoordinator::adjustImplOnlyScrollOffsetAnimation( | 296 void ScrollAnimatorCompositorCoordinator::adjustImplOnlyScrollOffsetAnimation( |
| 298 const IntSize& adjustment) { | 297 const IntSize& adjustment) { |
| 299 if (!getScrollableArea()->scrollAnimatorEnabled()) | 298 if (!getScrollableArea()->scrollAnimatorEnabled()) |
| 300 return; | 299 return; |
| 301 | 300 |
| 302 m_implOnlyAnimationAdjustment.expand(adjustment.width(), adjustment.height()); | 301 m_implOnlyAnimationAdjustment.expand(adjustment.width(), adjustment.height()); |
| 303 | 302 |
| 304 getScrollableArea()->registerForAnimation(); | 303 getScrollableArea()->registerForAnimation(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 case RunState::WaitingToCancelOnCompositorButNewScroll: | 339 case RunState::WaitingToCancelOnCompositorButNewScroll: |
| 341 return String("WaitingToCancelOnCompositorButNewScroll"); | 340 return String("WaitingToCancelOnCompositorButNewScroll"); |
| 342 case RunState::RunningOnCompositorButNeedsAdjustment: | 341 case RunState::RunningOnCompositorButNeedsAdjustment: |
| 343 return String("RunningOnCompositorButNeedsAdjustment"); | 342 return String("RunningOnCompositorButNeedsAdjustment"); |
| 344 } | 343 } |
| 345 ASSERT_NOT_REACHED(); | 344 ASSERT_NOT_REACHED(); |
| 346 return String(); | 345 return String(); |
| 347 } | 346 } |
| 348 | 347 |
| 349 } // namespace blink | 348 } // namespace blink |
| OLD | NEW |