| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef ScrollAnimatorCompositorCoordinator_h | 5 #ifndef ScrollAnimatorCompositorCoordinator_h |
| 6 #define ScrollAnimatorCompositorCoordinator_h | 6 #define ScrollAnimatorCompositorCoordinator_h |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "cc/animation/animation_curve.h" | 9 #include "cc/animation/animation_curve.h" |
| 10 #include "cc/animation/scroll_offset_animations.h" | 10 #include "cc/animation/scroll_offset_animations.h" |
| 11 #include "platform/PlatformExport.h" | 11 #include "platform/PlatformExport.h" |
| 12 #include "platform/animation/CompositorAnimationDelegate.h" | 12 #include "platform/animation/CompositorAnimationDelegate.h" |
| 13 #include "platform/animation/CompositorAnimationPlayerClient.h" | 13 #include "platform/animation/CompositorAnimationPlayerClient.h" |
| 14 #include "platform/geometry/FloatPoint.h" | |
| 15 #include "platform/graphics/CompositorElementId.h" | 14 #include "platform/graphics/CompositorElementId.h" |
| 16 #include "platform/heap/Handle.h" | 15 #include "platform/heap/Handle.h" |
| 17 #include "platform/scroll/ScrollTypes.h" | 16 #include "platform/scroll/ScrollTypes.h" |
| 18 #include "wtf/Allocator.h" | 17 #include "wtf/Allocator.h" |
| 19 #include "wtf/Noncopyable.h" | 18 #include "wtf/Noncopyable.h" |
| 20 #include <memory> | 19 #include <memory> |
| 21 | 20 |
| 22 namespace blink { | 21 namespace blink { |
| 23 | 22 |
| 24 class ScrollableArea; | 23 class ScrollableArea; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 PostAnimationCleanup, | 61 PostAnimationCleanup, |
| 63 | 62 |
| 64 // Running an animation on the compositor but need to continue it | 63 // Running an animation on the compositor but need to continue it |
| 65 // on the main thread. This could happen if a main thread scrolling | 64 // on the main thread. This could happen if a main thread scrolling |
| 66 // reason is added while animating the scroll offset. | 65 // reason is added while animating the scroll offset. |
| 67 RunningOnCompositorButNeedsTakeover, | 66 RunningOnCompositorButNeedsTakeover, |
| 68 | 67 |
| 69 // Waiting to cancel the animation currently running on the compositor | 68 // Waiting to cancel the animation currently running on the compositor |
| 70 // while another animation is requested. In this case, the currently | 69 // while another animation is requested. In this case, the currently |
| 71 // running animation is aborted and an animation to the new target | 70 // running animation is aborted and an animation to the new target |
| 72 // from the current position is started. | 71 // from the current offset is started. |
| 73 WaitingToCancelOnCompositorButNewScroll, | 72 WaitingToCancelOnCompositorButNewScroll, |
| 74 | 73 |
| 75 // Running an animation on the compositor but an adjustment to the | 74 // Running an animation on the compositor but an adjustment to the |
| 76 // scroll position was made on the main thread and the animation must | 75 // scroll offset was made on the main thread and the animation must |
| 77 // be updated. | 76 // be updated. |
| 78 RunningOnCompositorButNeedsAdjustment, | 77 RunningOnCompositorButNeedsAdjustment, |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 virtual ~ScrollAnimatorCompositorCoordinator(); | 80 virtual ~ScrollAnimatorCompositorCoordinator(); |
| 82 | 81 |
| 83 bool hasAnimationThatRequiresService() const; | 82 bool hasAnimationThatRequiresService() const; |
| 84 void dispose(); | 83 void dispose(); |
| 85 String runStateAsText() const; | 84 String runStateAsText() const; |
| 86 | 85 |
| 87 virtual bool hasRunningAnimation() const { return false; } | 86 virtual bool hasRunningAnimation() const { return false; } |
| 88 | 87 |
| 89 virtual void resetAnimationState(); | 88 virtual void resetAnimationState(); |
| 90 virtual void cancelAnimation(); | 89 virtual void cancelAnimation(); |
| 91 // Aborts the currently running scroll offset animation on the compositor | 90 // Aborts the currently running scroll offset animation on the compositor |
| 92 // and continues it on the main thread. This should only be called when in | 91 // and continues it on the main thread. This should only be called when in |
| 93 // DocumentLifecycle::LifecycleState::CompositingClean state. | 92 // DocumentLifecycle::LifecycleState::CompositingClean state. |
| 94 virtual void takeOverCompositorAnimation(); | 93 virtual void takeOverCompositorAnimation(); |
| 95 // Updates the scroll position of the animator's ScrollableArea by | 94 // Updates the scroll offset of the animator's ScrollableArea by |
| 96 // adjustment and update the target of an ongoing scroll offset animation. | 95 // adjustment and update the target of an ongoing scroll offset animation. |
| 97 virtual void adjustAnimationAndSetScrollPosition(const DoublePoint& position, | 96 virtual void adjustAnimationAndSetScrollOffset(const ScrollOffset&, |
| 98 ScrollType); | 97 ScrollType); |
| 99 virtual void updateCompositorAnimations(); | 98 virtual void updateCompositorAnimations(); |
| 100 | 99 |
| 101 virtual ScrollableArea* getScrollableArea() const = 0; | 100 virtual ScrollableArea* getScrollableArea() const = 0; |
| 102 virtual void tickAnimation(double monotonicTime) = 0; | 101 virtual void tickAnimation(double monotonicTime) = 0; |
| 103 virtual void notifyCompositorAnimationFinished(int groupId) = 0; | 102 virtual void notifyCompositorAnimationFinished(int groupId) = 0; |
| 104 virtual void notifyCompositorAnimationAborted(int groupId) = 0; | 103 virtual void notifyCompositorAnimationAborted(int groupId) = 0; |
| 105 virtual void layerForCompositedScrollingDidChange( | 104 virtual void layerForCompositedScrollingDidChange( |
| 106 CompositorAnimationTimeline*) = 0; | 105 CompositorAnimationTimeline*) = 0; |
| 107 | 106 |
| 108 RunState runStateForTesting() { return m_runState; } | 107 RunState runStateForTesting() { return m_runState; } |
| 109 | 108 |
| 110 DEFINE_INLINE_VIRTUAL_TRACE() {} | 109 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 111 | 110 |
| 112 protected: | 111 protected: |
| 113 explicit ScrollAnimatorCompositorCoordinator(); | 112 explicit ScrollAnimatorCompositorCoordinator(); |
| 114 | 113 |
| 115 void scrollPositionChanged(const DoublePoint& offset, ScrollType); | 114 void scrollOffsetChanged(const ScrollOffset&, ScrollType); |
| 116 | 115 |
| 117 void adjustImplOnlyScrollOffsetAnimation(const IntSize& adjustment); | 116 void adjustImplOnlyScrollOffsetAnimation(const IntSize& adjustment); |
| 118 IntSize implOnlyAnimationAdjustmentForTesting() { | 117 IntSize implOnlyAnimationAdjustmentForTesting() { |
| 119 return m_implOnlyAnimationAdjustment; | 118 return m_implOnlyAnimationAdjustment; |
| 120 } | 119 } |
| 121 | 120 |
| 122 void resetAnimationIds(); | 121 void resetAnimationIds(); |
| 123 bool addAnimation(std::unique_ptr<CompositorAnimation>); | 122 bool addAnimation(std::unique_ptr<CompositorAnimation>); |
| 124 void removeAnimation(); | 123 void removeAnimation(); |
| 125 virtual void abortAnimation(); | 124 virtual void abortAnimation(); |
| 126 | 125 |
| 127 FloatPoint compositorOffsetFromBlinkOffset(FloatPoint); | 126 // "offset" in the cc scrolling code is analagous to "position" in the blink |
| 128 FloatPoint blinkOffsetFromCompositorOffset(FloatPoint); | 127 // scrolling code: |
| 128 // they both represent the distance from the top-left of the overflow rect to |
| 129 // the top-left |
| 130 // of the viewport. In blink, "offset" refers to the distance of the viewport |
| 131 // from the |
| 132 // beginning of flow of the contents. In left-to-right flows, blink "offset" |
| 133 // and "position" are |
| 134 // equivalent, but in right-to-left flows (including direction:rtl, |
| 135 // writing-mode:vertical-rl, |
| 136 // and flex-direction:row-reverse), they aren't. See core/layout/README.md |
| 137 // for more info. |
| 138 FloatPoint compositorOffsetFromBlinkOffset(ScrollOffset); |
| 139 ScrollOffset blinkOffsetFromCompositorOffset(FloatPoint); |
| 129 | 140 |
| 130 void compositorAnimationFinished(int groupId); | 141 void compositorAnimationFinished(int groupId); |
| 131 // Returns true if the compositor player was attached to a new layer. | 142 // Returns true if the compositor player was attached to a new layer. |
| 132 bool reattachCompositorPlayerIfNeeded(CompositorAnimationTimeline*); | 143 bool reattachCompositorPlayerIfNeeded(CompositorAnimationTimeline*); |
| 133 | 144 |
| 134 // CompositorAnimationDelegate implementation. | 145 // CompositorAnimationDelegate implementation. |
| 135 void notifyAnimationStarted(double monotonicTime, int group) override; | 146 void notifyAnimationStarted(double monotonicTime, int group) override; |
| 136 void notifyAnimationFinished(double monotonicTime, int group) override; | 147 void notifyAnimationFinished(double monotonicTime, int group) override; |
| 137 void notifyAnimationAborted(double monotonicTime, int group) override; | 148 void notifyAnimationAborted(double monotonicTime, int group) override; |
| 138 void notifyAnimationTakeover(double monotonicTime, | 149 void notifyAnimationTakeover(double monotonicTime, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 bool hasImplOnlyAnimationUpdate() const; | 181 bool hasImplOnlyAnimationUpdate() const; |
| 171 void updateImplOnlyCompositorAnimations(); | 182 void updateImplOnlyCompositorAnimations(); |
| 172 // Accesses compositing state and should only be called when in or after | 183 // Accesses compositing state and should only be called when in or after |
| 173 // DocumentLifecycle::LifecycleState::CompositingClean. | 184 // DocumentLifecycle::LifecycleState::CompositingClean. |
| 174 void takeOverImplOnlyScrollOffsetAnimation(); | 185 void takeOverImplOnlyScrollOffsetAnimation(); |
| 175 }; | 186 }; |
| 176 | 187 |
| 177 } // namespace blink | 188 } // namespace blink |
| 178 | 189 |
| 179 #endif // ScrollAnimatorCompositorCoordinator_h | 190 #endif // ScrollAnimatorCompositorCoordinator_h |
| OLD | NEW |