| 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 "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 10 #include "public/platform/WebCompositorAnimationDelegate.h" | 10 #include "public/platform/WebCompositorAnimationDelegate.h" |
| 11 #include "public/platform/WebCompositorAnimationPlayerClient.h" | 11 #include "public/platform/WebCompositorAnimationPlayerClient.h" |
| 12 #include "wtf/OwnPtr.h" | 12 #include "wtf/OwnPtr.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class ScrollableArea; | 16 class ScrollableArea; |
| 17 class WebCompositorAnimationPlayer; | 17 class WebCompositorAnimationPlayer; |
| 18 class WebCompositorAnimationTimeline; | 18 class WebCompositorAnimationTimeline; |
| 19 | 19 |
| 20 class PLATFORM_EXPORT ScrollAnimatorCompositorCoordinator : public NoBaseWillBeG
arbageCollectedFinalized<ScrollAnimatorCompositorCoordinator>, private WebCompos
itorAnimationPlayerClient, WebCompositorAnimationDelegate { | 20 class PLATFORM_EXPORT ScrollAnimatorCompositorCoordinator : public NoBaseWillBeG
arbageCollectedFinalized<ScrollAnimatorCompositorCoordinator>, private WebCompos
itorAnimationPlayerClient, WebCompositorAnimationDelegate { |
| 21 public: | 21 public: |
| 22 virtual ~ScrollAnimatorCompositorCoordinator(); | 22 virtual ~ScrollAnimatorCompositorCoordinator(); |
| 23 | 23 |
| 24 bool hasAnimationThatRequiresService() const; | 24 bool hasAnimationThatRequiresService() const; |
| 25 void cancelAnimation(); | |
| 26 | 25 |
| 27 virtual void resetAnimationState(); | 26 virtual void resetAnimationState(); |
| 27 virtual void cancelAnimation(); |
| 28 | 28 |
| 29 virtual ScrollableArea* scrollableArea() const = 0; | 29 virtual ScrollableArea* scrollableArea() const = 0; |
| 30 virtual void tickAnimation(double monotonicTime) = 0; | 30 virtual void tickAnimation(double monotonicTime) = 0; |
| 31 virtual void updateCompositorAnimations() = 0; | 31 virtual void updateCompositorAnimations() = 0; |
| 32 virtual void notifyCompositorAnimationFinished(int groupId) = 0; | 32 virtual void notifyCompositorAnimationFinished(int groupId) = 0; |
| 33 virtual void layerForCompositedScrollingDidChange(WebCompositorAnimationTime
line*) = 0; | 33 virtual void layerForCompositedScrollingDidChange(WebCompositorAnimationTime
line*) = 0; |
| 34 | 34 |
| 35 DEFINE_INLINE_VIRTUAL_TRACE() { } | 35 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 explicit ScrollAnimatorCompositorCoordinator(); | 38 explicit ScrollAnimatorCompositorCoordinator(); |
| 39 | 39 |
| 40 bool addAnimation(PassOwnPtr<WebCompositorAnimation>); | 40 bool addAnimation(PassOwnPtr<WebCompositorAnimation>); |
| 41 void removeAnimation(); | 41 void removeAnimation(); |
| 42 void abortAnimation(); |
| 42 | 43 |
| 43 void compositorAnimationFinished(int groupId); | 44 void compositorAnimationFinished(int groupId); |
| 44 void reattachCompositorPlayerIfNeeded(WebCompositorAnimationTimeline*); | 45 void reattachCompositorPlayerIfNeeded(WebCompositorAnimationTimeline*); |
| 45 | 46 |
| 46 // WebCompositorAnimationDelegate implementation. | 47 // WebCompositorAnimationDelegate implementation. |
| 47 void notifyAnimationStarted(double monotonicTime, int group) override; | 48 void notifyAnimationStarted(double monotonicTime, int group) override; |
| 48 void notifyAnimationFinished(double monotonicTime, int group) override; | 49 void notifyAnimationFinished(double monotonicTime, int group) override; |
| 49 | 50 |
| 50 // WebCompositorAnimationPlayerClient implementation. | 51 // WebCompositorAnimationPlayerClient implementation. |
| 51 WebCompositorAnimationPlayer* compositorPlayer() const override; | 52 WebCompositorAnimationPlayer* compositorPlayer() const override; |
| 52 | 53 |
| 53 enum class RunState { | 54 enum class RunState { |
| 54 // No animation. | 55 // No animation. |
| 55 Idle, | 56 Idle, |
| 56 | 57 |
| 57 // Waiting to send an animation to the compositor. There might also | 58 // Waiting to send an animation to the compositor. There might also |
| 58 // already be another animation running on the compositor that will need | 59 // already be another animation running on the compositor that will need |
| 59 // to be canceled first. | 60 // to be canceled first. |
| 60 WaitingToSendToCompositor, | 61 WaitingToSendToCompositor, |
| 61 | 62 |
| 62 // Running an animation on the compositor. | 63 // Running an animation on the compositor. |
| 63 RunningOnCompositor, | 64 RunningOnCompositor, |
| 64 | 65 |
| 66 // Running an animation on the compositor but needs update. |
| 67 RunningOnCompositorButNeedsUpdate, |
| 68 |
| 65 // Running an animation on the main thread. | 69 // Running an animation on the main thread. |
| 66 RunningOnMainThread, | 70 RunningOnMainThread, |
| 67 | 71 |
| 68 // Waiting to cancel the animation currently running on the compositor. | 72 // Waiting to cancel the animation currently running on the compositor. |
| 69 // There is no pending animation to replace the canceled animation. | 73 // There is no pending animation to replace the canceled animation. |
| 70 WaitingToCancelOnCompositor | 74 WaitingToCancelOnCompositor |
| 71 }; | 75 }; |
| 72 | 76 |
| 73 OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer; | 77 OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer; |
| 74 int m_compositorAnimationAttachedToLayerId; | 78 int m_compositorAnimationAttachedToLayerId; |
| 75 RunState m_runState; | 79 RunState m_runState; |
| 76 int m_compositorAnimationId; | 80 int m_compositorAnimationId; |
| 77 int m_compositorAnimationGroupId; | 81 int m_compositorAnimationGroupId; |
| 78 }; | 82 }; |
| 79 | 83 |
| 80 } // namespace blink | 84 } // namespace blink |
| 81 | 85 |
| 82 #endif // ScrollAnimatorCompositorCoordinator_h | 86 #endif // ScrollAnimatorCompositorCoordinator_h |
| OLD | NEW |