| 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 "platform/PlatformExport.h" | 10 #include "platform/PlatformExport.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 public: | 29 public: |
| 30 virtual ~ScrollAnimatorCompositorCoordinator(); | 30 virtual ~ScrollAnimatorCompositorCoordinator(); |
| 31 | 31 |
| 32 bool hasAnimationThatRequiresService() const; | 32 bool hasAnimationThatRequiresService() const; |
| 33 void dispose(); | 33 void dispose(); |
| 34 | 34 |
| 35 virtual bool hasRunningAnimation() const { return false; } | 35 virtual bool hasRunningAnimation() const { return false; } |
| 36 | 36 |
| 37 virtual void resetAnimationState(); | 37 virtual void resetAnimationState(); |
| 38 virtual void cancelAnimation(); | 38 virtual void cancelAnimation(); |
| 39 // Aborts the currently running scroll offset animation on the compositor | |
| 40 // and continues it on the main thread. This should only be called when in | |
| 41 // DocumentLifecycle::LifecycleState::CompositingClean state. | |
| 42 virtual void takeoverCompositorAnimation(); | |
| 43 | 39 |
| 44 virtual ScrollableArea* scrollableArea() const = 0; | 40 virtual ScrollableArea* scrollableArea() const = 0; |
| 45 virtual void tickAnimation(double monotonicTime) = 0; | 41 virtual void tickAnimation(double monotonicTime) = 0; |
| 46 virtual void updateCompositorAnimations() = 0; | 42 virtual void updateCompositorAnimations() = 0; |
| 47 virtual void notifyCompositorAnimationFinished(int groupId) = 0; | 43 virtual void notifyCompositorAnimationFinished(int groupId) = 0; |
| 48 virtual void notifyCompositorAnimationAborted(int groupId) = 0; | 44 virtual void notifyCompositorAnimationAborted(int groupId) = 0; |
| 49 virtual void layerForCompositedScrollingDidChange(CompositorAnimationTimelin
e*) = 0; | 45 virtual void layerForCompositedScrollingDidChange(CompositorAnimationTimelin
e*) = 0; |
| 50 | 46 |
| 51 DEFINE_INLINE_VIRTUAL_TRACE() { } | 47 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 52 | 48 |
| 53 protected: | 49 protected: |
| 54 explicit ScrollAnimatorCompositorCoordinator(); | 50 explicit ScrollAnimatorCompositorCoordinator(); |
| 55 | 51 |
| 56 bool addAnimation(PassOwnPtr<CompositorAnimation>); | 52 bool addAnimation(PassOwnPtr<CompositorAnimation>); |
| 57 void removeAnimation(); | 53 void removeAnimation(); |
| 58 virtual void abortAnimation(); | 54 void abortAnimation(); |
| 59 | 55 |
| 60 void compositorAnimationFinished(int groupId); | 56 void compositorAnimationFinished(int groupId); |
| 61 // Returns true if the compositor player was attached to a new layer. | 57 // Returns true if the compositor player was attached to a new layer. |
| 62 bool reattachCompositorPlayerIfNeeded(CompositorAnimationTimeline*); | 58 bool reattachCompositorPlayerIfNeeded(CompositorAnimationTimeline*); |
| 63 | 59 |
| 64 // WebCompositorAnimationDelegate implementation. | 60 // WebCompositorAnimationDelegate implementation. |
| 65 void notifyAnimationStarted(double monotonicTime, int group) override; | 61 void notifyAnimationStarted(double monotonicTime, int group) override; |
| 66 void notifyAnimationFinished(double monotonicTime, int group) override; | 62 void notifyAnimationFinished(double monotonicTime, int group) override; |
| 67 void notifyAnimationAborted(double monotonicTime, int group) override; | 63 void notifyAnimationAborted(double monotonicTime, int group) override; |
| 68 void notifyAnimationTakeover( | 64 void notifyAnimationTakeover( |
| 69 double monotonicTime, | 65 double monotonicTime, |
| 70 double animationStartTime, | 66 double animationStartTime, |
| 71 scoped_ptr<cc::AnimationCurve>) override { }; | 67 scoped_ptr<cc::AnimationCurve>) override { }; |
| 72 | 68 |
| 73 // CompositorAnimationPlayerClient implementation. | 69 // CompositorAnimationPlayerClient implementation. |
| 74 CompositorAnimationPlayer* compositorPlayer() const override; | 70 CompositorAnimationPlayer* compositorPlayer() const override; |
| 75 | 71 |
| 76 friend class Internals; | 72 friend class Internals; |
| 77 FRIEND_TEST_ALL_PREFIXES(ScrollAnimatorTest, MainThreadStates); | 73 FRIEND_TEST_ALL_PREFIXES(ScrollAnimatorTest, MainThreadStates); |
| 78 FRIEND_TEST_ALL_PREFIXES(ScrollAnimatorTest, AnimatedScrollTakeover); | |
| 79 | 74 |
| 80 enum class RunState { | 75 enum class RunState { |
| 81 // No animation. | 76 // No animation. |
| 82 Idle, | 77 Idle, |
| 83 | 78 |
| 84 // Waiting to send an animation to the compositor. There might also | 79 // Waiting to send an animation to the compositor. There might also |
| 85 // already be another animation running on the compositor that will need | 80 // already be another animation running on the compositor that will need |
| 86 // to be canceled first. | 81 // to be canceled first. |
| 87 WaitingToSendToCompositor, | 82 WaitingToSendToCompositor, |
| 88 | 83 |
| 89 // Running an animation on the compositor. | 84 // Running an animation on the compositor. |
| 90 RunningOnCompositor, | 85 RunningOnCompositor, |
| 91 | 86 |
| 92 // Running an animation on the compositor but needs update. | 87 // Running an animation on the compositor but needs update. |
| 93 RunningOnCompositorButNeedsUpdate, | 88 RunningOnCompositorButNeedsUpdate, |
| 94 | 89 |
| 95 // Running an animation on the main thread. | 90 // Running an animation on the main thread. |
| 96 RunningOnMainThread, | 91 RunningOnMainThread, |
| 97 | 92 |
| 98 // Waiting to cancel the animation currently running on the compositor. | 93 // Waiting to cancel the animation currently running on the compositor. |
| 99 // There is no pending animation to replace the canceled animation. | 94 // There is no pending animation to replace the canceled animation. |
| 100 WaitingToCancelOnCompositor, | 95 WaitingToCancelOnCompositor, |
| 101 | 96 |
| 102 // Finished an animation that was running on the main thread or the | 97 // Finished an animation that was running on the main thread or the |
| 103 // compositor thread. When in this state, post animation cleanup can | 98 // compositor thread. When in this state, post animation cleanup can |
| 104 // be performed. | 99 // be performed. |
| 105 PostAnimationCleanup, | 100 PostAnimationCleanup |
| 106 | |
| 107 // Running an animation on the compositor but need to continue it | |
| 108 // on the main thread. This could happen if a main thread scrolling | |
| 109 // reason is added while animating the scroll offset. | |
| 110 RunningOnCompositorButNeedsTakeover, | |
| 111 }; | 101 }; |
| 112 | 102 |
| 113 OwnPtr<CompositorAnimationPlayer> m_compositorPlayer; | 103 OwnPtr<CompositorAnimationPlayer> m_compositorPlayer; |
| 114 int m_compositorAnimationAttachedToLayerId; | 104 int m_compositorAnimationAttachedToLayerId; |
| 115 RunState m_runState; | 105 RunState m_runState; |
| 116 int m_compositorAnimationId; | 106 int m_compositorAnimationId; |
| 117 int m_compositorAnimationGroupId; | 107 int m_compositorAnimationGroupId; |
| 118 }; | 108 }; |
| 119 | 109 |
| 120 } // namespace blink | 110 } // namespace blink |
| 121 | 111 |
| 122 #endif // ScrollAnimatorCompositorCoordinator_h | 112 #endif // ScrollAnimatorCompositorCoordinator_h |
| OLD | NEW |