Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: Source/platform/scroll/ProgrammaticScrollAnimator.h

Issue 1254963011: Revert of Animations: Port ProgrammaticScrollAnimator to use compositor timelines (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@linkhigh
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "public/platform/WebCompositorAnimationDelegate.h"
10 #include "public/platform/WebCompositorAnimationPlayerClient.h"
11 #include "wtf/FastAllocBase.h" 9 #include "wtf/FastAllocBase.h"
12 #include "wtf/Noncopyable.h" 10 #include "wtf/Noncopyable.h"
13 #include "wtf/OwnPtr.h" 11 #include "wtf/OwnPtr.h"
14 #include "wtf/PassOwnPtr.h" 12 #include "wtf/PassOwnPtr.h"
15 13
16 namespace blink { 14 namespace blink {
17 15
18 class ScrollableArea; 16 class ScrollableArea;
19 class WebCompositorAnimationPlayer;
20 class WebCompositorAnimationTimeline;
21 class WebScrollOffsetAnimationCurve; 17 class WebScrollOffsetAnimationCurve;
22 18
23 // Animator for fixed-destination scrolls, such as those triggered by 19 // Animator for fixed-destination scrolls, such as those triggered by
24 // CSSOM View scroll APIs. 20 // CSSOM View scroll APIs.
25 class ProgrammaticScrollAnimator : private WebCompositorAnimationPlayerClient, W ebCompositorAnimationDelegate { 21 class ProgrammaticScrollAnimator {
26 WTF_MAKE_NONCOPYABLE(ProgrammaticScrollAnimator); 22 WTF_MAKE_NONCOPYABLE(ProgrammaticScrollAnimator);
27 WTF_MAKE_FAST_ALLOCATED(ProgrammaticScrollAnimator); 23 WTF_MAKE_FAST_ALLOCATED(ProgrammaticScrollAnimator);
28 public: 24 public:
29 static PassOwnPtr<ProgrammaticScrollAnimator> create(ScrollableArea*); 25 static PassOwnPtr<ProgrammaticScrollAnimator> create(ScrollableArea*);
30 26
31 ~ProgrammaticScrollAnimator(); 27 ~ProgrammaticScrollAnimator();
32 28
33 void scrollToOffsetWithoutAnimation(const FloatPoint&); 29 void scrollToOffsetWithoutAnimation(const FloatPoint&);
34 void animateToOffset(FloatPoint); 30 void animateToOffset(FloatPoint);
35 void cancelAnimation(); 31 void cancelAnimation();
36 void tickAnimation(double monotonicTime); 32 void tickAnimation(double monotonicTime);
37 bool hasAnimationThatRequiresService() const; 33 bool hasAnimationThatRequiresService() const;
38 void updateCompositorAnimations(); 34 void updateCompositorAnimations();
39 void layerForCompositedScrollingDidChange(WebCompositorAnimationTimeline*); 35 void layerForCompositedScrollingDidChange();
40 void notifyCompositorAnimationFinished(int groupId); 36 void notifyCompositorAnimationFinished(int groupId);
41 // WebCompositorAnimationDelegate implementation.
42 void notifyAnimationStarted(double monotonicTime, int group) override;
43 void notifyAnimationFinished(double monotonicTime, int group) override;
44
45 // WebCompositorAnimationPlayerClient implementation.
46 WebCompositorAnimationPlayer* compositorPlayer() const override;
47 37
48 private: 38 private:
49 explicit ProgrammaticScrollAnimator(ScrollableArea*); 39 explicit ProgrammaticScrollAnimator(ScrollableArea*);
50 40
51 enum class RunState { 41 enum class RunState {
52 // No animation. 42 // No animation.
53 Idle, 43 Idle,
54 44
55 // Waiting to send an animation to the compositor. There might also 45 // Waiting to send an animation to the compositor. There might also
56 // already be another animation running on the compositor that will need 46 // already be another animation running on the compositor that will need
57 // to be canceled first. 47 // to be canceled first.
58 WaitingToSendToCompositor, 48 WaitingToSendToCompositor,
59 49
60 // Running an animation on the compositor. 50 // Running an animation on the compositor.
61 RunningOnCompositor, 51 RunningOnCompositor,
62 52
63 // Running an animation on the main thread. 53 // Running an animation on the main thread.
64 RunningOnMainThread, 54 RunningOnMainThread,
65 55
66 // Waiting to cancel the animation currently running on the compositor. 56 // Waiting to cancel the animation currently running on the compositor.
67 // There is no pending animation to replace the canceled animation. 57 // There is no pending animation to replace the canceled animation.
68 WaitingToCancelOnCompositor 58 WaitingToCancelOnCompositor
69 }; 59 };
70 60
71 void resetAnimationState(); 61 void resetAnimationState();
72 void notifyPositionChanged(const DoublePoint&); 62 void notifyPositionChanged(const DoublePoint&);
73 void reattachCompositorPlayerIfNeeded(WebCompositorAnimationTimeline*);
74
75 OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer;
76 int m_compositorAnimationAttachedToLayerId;
77 63
78 ScrollableArea* m_scrollableArea; 64 ScrollableArea* m_scrollableArea;
79 OwnPtr<WebScrollOffsetAnimationCurve> m_animationCurve; 65 OwnPtr<WebScrollOffsetAnimationCurve> m_animationCurve;
80 FloatPoint m_targetOffset; 66 FloatPoint m_targetOffset;
81 double m_startTime; 67 double m_startTime;
82 RunState m_runState; 68 RunState m_runState;
83 int m_compositorAnimationId; 69 int m_compositorAnimationId;
84 int m_compositorAnimationGroupId; 70 int m_compositorAnimationGroupId;
85 }; 71 };
86 72
87 } // namespace blink 73 } // namespace blink
88 74
89 #endif // ProgrammaticScrollAnimator_h 75 #endif // ProgrammaticScrollAnimator_h
OLDNEW
« no previous file with comments | « Source/core/page/scrolling/ScrollingCoordinator.cpp ('k') | Source/platform/scroll/ProgrammaticScrollAnimator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698