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 "platform/PlatformExport.h" | 9 #include "platform/PlatformExport.h" |
| 10 #include "platform/animation/CompositorAnimationPlayerClient.h" |
10 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
11 #include "public/platform/WebCompositorAnimationDelegate.h" | 12 #include "public/platform/WebCompositorAnimationDelegate.h" |
12 #include "public/platform/WebCompositorAnimationPlayerClient.h" | |
13 #include "wtf/Allocator.h" | 13 #include "wtf/Allocator.h" |
14 #include "wtf/Noncopyable.h" | 14 #include "wtf/Noncopyable.h" |
15 #include "wtf/OwnPtr.h" | 15 #include "wtf/OwnPtr.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 class ScrollableArea; | 19 class ScrollableArea; |
20 class WebCompositorAnimationPlayer; | 20 class CompositorAnimation; |
21 class WebCompositorAnimationTimeline; | 21 class CompositorAnimationPlayer; |
| 22 class CompositorAnimationTimeline; |
22 | 23 |
23 class PLATFORM_EXPORT ScrollAnimatorCompositorCoordinator : public NoBaseWillBeG
arbageCollectedFinalized<ScrollAnimatorCompositorCoordinator>, private WebCompos
itorAnimationPlayerClient, WebCompositorAnimationDelegate { | 24 class PLATFORM_EXPORT ScrollAnimatorCompositorCoordinator : public NoBaseWillBeG
arbageCollectedFinalized<ScrollAnimatorCompositorCoordinator>, private Composito
rAnimationPlayerClient, WebCompositorAnimationDelegate { |
24 USING_FAST_MALLOC_WILL_BE_REMOVED(ScrollAnimatorCompositorCoordinator); | 25 USING_FAST_MALLOC_WILL_BE_REMOVED(ScrollAnimatorCompositorCoordinator); |
25 WTF_MAKE_NONCOPYABLE(ScrollAnimatorCompositorCoordinator); | 26 WTF_MAKE_NONCOPYABLE(ScrollAnimatorCompositorCoordinator); |
26 public: | 27 public: |
27 virtual ~ScrollAnimatorCompositorCoordinator(); | 28 virtual ~ScrollAnimatorCompositorCoordinator(); |
28 | 29 |
29 bool hasAnimationThatRequiresService() const; | 30 bool hasAnimationThatRequiresService() const; |
30 | 31 |
31 virtual void resetAnimationState(); | 32 virtual void resetAnimationState(); |
32 virtual void cancelAnimation(); | 33 virtual void cancelAnimation(); |
33 | 34 |
34 virtual ScrollableArea* scrollableArea() const = 0; | 35 virtual ScrollableArea* scrollableArea() const = 0; |
35 virtual void tickAnimation(double monotonicTime) = 0; | 36 virtual void tickAnimation(double monotonicTime) = 0; |
36 virtual void updateCompositorAnimations() = 0; | 37 virtual void updateCompositorAnimations() = 0; |
37 virtual void notifyCompositorAnimationFinished(int groupId) = 0; | 38 virtual void notifyCompositorAnimationFinished(int groupId) = 0; |
38 virtual void notifyCompositorAnimationAborted(int groupId) = 0; | 39 virtual void notifyCompositorAnimationAborted(int groupId) = 0; |
39 virtual void layerForCompositedScrollingDidChange(WebCompositorAnimationTime
line*) = 0; | 40 virtual void layerForCompositedScrollingDidChange(CompositorAnimationTimelin
e*) = 0; |
40 | 41 |
41 DEFINE_INLINE_VIRTUAL_TRACE() { } | 42 DEFINE_INLINE_VIRTUAL_TRACE() { } |
42 | 43 |
43 protected: | 44 protected: |
44 explicit ScrollAnimatorCompositorCoordinator(); | 45 explicit ScrollAnimatorCompositorCoordinator(); |
45 | 46 |
46 bool addAnimation(PassOwnPtr<WebCompositorAnimation>); | 47 bool addAnimation(PassOwnPtr<CompositorAnimation>); |
47 void removeAnimation(); | 48 void removeAnimation(); |
48 void abortAnimation(); | 49 void abortAnimation(); |
49 | 50 |
50 void compositorAnimationFinished(int groupId); | 51 void compositorAnimationFinished(int groupId); |
51 void reattachCompositorPlayerIfNeeded(WebCompositorAnimationTimeline*); | 52 void reattachCompositorPlayerIfNeeded(CompositorAnimationTimeline*); |
52 | 53 |
53 // WebCompositorAnimationDelegate implementation. | 54 // WebCompositorAnimationDelegate implementation. |
54 void notifyAnimationStarted(double monotonicTime, int group) override; | 55 void notifyAnimationStarted(double monotonicTime, int group) override; |
55 void notifyAnimationFinished(double monotonicTime, int group) override; | 56 void notifyAnimationFinished(double monotonicTime, int group) override; |
56 void notifyAnimationAborted(double monotonicTime, int group) override; | 57 void notifyAnimationAborted(double monotonicTime, int group) override; |
57 | 58 |
58 // WebCompositorAnimationPlayerClient implementation. | 59 // CompositorAnimationPlayerClient implementation. |
59 WebCompositorAnimationPlayer* compositorPlayer() const override; | 60 CompositorAnimationPlayer* compositorPlayer() const override; |
60 | 61 |
61 friend class Internals; | 62 friend class Internals; |
62 FRIEND_TEST_ALL_PREFIXES(ScrollAnimatorTest, MainThreadStates); | 63 FRIEND_TEST_ALL_PREFIXES(ScrollAnimatorTest, MainThreadStates); |
63 | 64 |
64 enum class RunState { | 65 enum class RunState { |
65 // No animation. | 66 // No animation. |
66 Idle, | 67 Idle, |
67 | 68 |
68 // Waiting to send an animation to the compositor. There might also | 69 // Waiting to send an animation to the compositor. There might also |
69 // already be another animation running on the compositor that will need | 70 // already be another animation running on the compositor that will need |
(...skipping 12 matching lines...) Expand all Loading... |
82 // Waiting to cancel the animation currently running on the compositor. | 83 // Waiting to cancel the animation currently running on the compositor. |
83 // There is no pending animation to replace the canceled animation. | 84 // There is no pending animation to replace the canceled animation. |
84 WaitingToCancelOnCompositor, | 85 WaitingToCancelOnCompositor, |
85 | 86 |
86 // Finished an animation that was running on the main thread or the | 87 // Finished an animation that was running on the main thread or the |
87 // compositor thread. When in this state, post animation cleanup can | 88 // compositor thread. When in this state, post animation cleanup can |
88 // be performed. | 89 // be performed. |
89 PostAnimationCleanup | 90 PostAnimationCleanup |
90 }; | 91 }; |
91 | 92 |
92 OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer; | 93 OwnPtr<CompositorAnimationPlayer> m_compositorPlayer; |
93 int m_compositorAnimationAttachedToLayerId; | 94 int m_compositorAnimationAttachedToLayerId; |
94 RunState m_runState; | 95 RunState m_runState; |
95 int m_compositorAnimationId; | 96 int m_compositorAnimationId; |
96 int m_compositorAnimationGroupId; | 97 int m_compositorAnimationGroupId; |
97 }; | 98 }; |
98 | 99 |
99 } // namespace blink | 100 } // namespace blink |
100 | 101 |
101 #endif // ScrollAnimatorCompositorCoordinator_h | 102 #endif // ScrollAnimatorCompositorCoordinator_h |
OLD | NEW |