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 #ifndef ProgrammaticScrollAnimator_h | 5 #ifndef ProgrammaticScrollAnimator_h |
6 #define ProgrammaticScrollAnimator_h | 6 #define ProgrammaticScrollAnimator_h |
7 | 7 |
8 #include "platform/geometry/FloatPoint.h" | 8 #include "platform/geometry/FloatPoint.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/Allocator.h" | |
13 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.h" |
14 #include "wtf/OwnPtr.h" | 13 #include "wtf/OwnPtr.h" |
15 #include "wtf/PassOwnPtr.h" | |
16 | 14 |
17 namespace blink { | 15 namespace blink { |
18 | 16 |
19 class ScrollableArea; | 17 class ScrollableArea; |
20 class WebCompositorAnimationPlayer; | 18 class WebCompositorAnimationPlayer; |
21 class WebCompositorAnimationTimeline; | 19 class WebCompositorAnimationTimeline; |
22 class WebScrollOffsetAnimationCurve; | 20 class WebScrollOffsetAnimationCurve; |
23 | 21 |
24 // Animator for fixed-destination scrolls, such as those triggered by | 22 // Animator for fixed-destination scrolls, such as those triggered by |
25 // CSSOM View scroll APIs. | 23 // CSSOM View scroll APIs. |
26 class ProgrammaticScrollAnimator : private WebCompositorAnimationPlayerClient, W
ebCompositorAnimationDelegate { | 24 class ProgrammaticScrollAnimator : public GarbageCollectedFinalized<Programmatic
ScrollAnimator>, private WebCompositorAnimationPlayerClient, WebCompositorAnimat
ionDelegate { |
27 WTF_MAKE_NONCOPYABLE(ProgrammaticScrollAnimator); | 25 WTF_MAKE_NONCOPYABLE(ProgrammaticScrollAnimator); |
28 USING_FAST_MALLOC(ProgrammaticScrollAnimator); | |
29 public: | 26 public: |
30 static PassOwnPtr<ProgrammaticScrollAnimator> create(ScrollableArea*); | 27 static ProgrammaticScrollAnimator* create(ScrollableArea*); |
31 | 28 |
32 ~ProgrammaticScrollAnimator(); | 29 ~ProgrammaticScrollAnimator(); |
33 | 30 |
34 void scrollToOffsetWithoutAnimation(const FloatPoint&); | 31 void scrollToOffsetWithoutAnimation(const FloatPoint&); |
35 void animateToOffset(FloatPoint); | 32 void animateToOffset(FloatPoint); |
36 void cancelAnimation(); | 33 void cancelAnimation(); |
37 void tickAnimation(double monotonicTime); | 34 void tickAnimation(double monotonicTime); |
38 bool hasAnimationThatRequiresService() const; | 35 bool hasAnimationThatRequiresService() const; |
39 void updateCompositorAnimations(); | 36 void updateCompositorAnimations(); |
40 void layerForCompositedScrollingDidChange(WebCompositorAnimationTimeline*); | 37 void layerForCompositedScrollingDidChange(WebCompositorAnimationTimeline*); |
41 void notifyCompositorAnimationFinished(int groupId); | 38 void notifyCompositorAnimationFinished(int groupId); |
42 // WebCompositorAnimationDelegate implementation. | 39 // WebCompositorAnimationDelegate implementation. |
43 void notifyAnimationStarted(double monotonicTime, int group) override; | 40 void notifyAnimationStarted(double monotonicTime, int group) override; |
44 void notifyAnimationFinished(double monotonicTime, int group) override; | 41 void notifyAnimationFinished(double monotonicTime, int group) override; |
45 | 42 |
46 // WebCompositorAnimationPlayerClient implementation. | 43 // WebCompositorAnimationPlayerClient implementation. |
47 WebCompositorAnimationPlayer* compositorPlayer() const override; | 44 WebCompositorAnimationPlayer* compositorPlayer() const override; |
48 | 45 |
| 46 DECLARE_TRACE(); |
| 47 |
49 private: | 48 private: |
50 explicit ProgrammaticScrollAnimator(ScrollableArea*); | 49 explicit ProgrammaticScrollAnimator(ScrollableArea*); |
51 | 50 |
52 enum class RunState { | 51 enum class RunState { |
53 // No animation. | 52 // No animation. |
54 Idle, | 53 Idle, |
55 | 54 |
56 // Waiting to send an animation to the compositor. There might also | 55 // Waiting to send an animation to the compositor. There might also |
57 // already be another animation running on the compositor that will need | 56 // already be another animation running on the compositor that will need |
58 // to be canceled first. | 57 // to be canceled first. |
(...skipping 10 matching lines...) Expand all Loading... |
69 WaitingToCancelOnCompositor | 68 WaitingToCancelOnCompositor |
70 }; | 69 }; |
71 | 70 |
72 void resetAnimationState(); | 71 void resetAnimationState(); |
73 void notifyPositionChanged(const DoublePoint&); | 72 void notifyPositionChanged(const DoublePoint&); |
74 void reattachCompositorPlayerIfNeeded(WebCompositorAnimationTimeline*); | 73 void reattachCompositorPlayerIfNeeded(WebCompositorAnimationTimeline*); |
75 | 74 |
76 OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer; | 75 OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer; |
77 int m_compositorAnimationAttachedToLayerId; | 76 int m_compositorAnimationAttachedToLayerId; |
78 | 77 |
79 GC_PLUGIN_IGNORE("509911") | 78 RawPtrWillBeMember<ScrollableArea> m_scrollableArea; |
80 ScrollableArea* m_scrollableArea; | |
81 OwnPtr<WebScrollOffsetAnimationCurve> m_animationCurve; | 79 OwnPtr<WebScrollOffsetAnimationCurve> m_animationCurve; |
82 FloatPoint m_targetOffset; | 80 FloatPoint m_targetOffset; |
83 double m_startTime; | 81 double m_startTime; |
84 RunState m_runState; | 82 RunState m_runState; |
85 int m_compositorAnimationId; | 83 int m_compositorAnimationId; |
86 int m_compositorAnimationGroupId; | 84 int m_compositorAnimationGroupId; |
87 }; | 85 }; |
88 | 86 |
89 } // namespace blink | 87 } // namespace blink |
90 | 88 |
91 #endif // ProgrammaticScrollAnimator_h | 89 #endif // ProgrammaticScrollAnimator_h |
OLD | NEW |