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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h

Issue 1782563002: Takeover MT initiated animations from the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 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 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
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();
39 43
40 virtual ScrollableArea* scrollableArea() const = 0; 44 virtual ScrollableArea* scrollableArea() const = 0;
41 virtual void tickAnimation(double monotonicTime) = 0; 45 virtual void tickAnimation(double monotonicTime) = 0;
42 virtual void updateCompositorAnimations() = 0; 46 virtual void updateCompositorAnimations() = 0;
43 virtual void notifyCompositorAnimationFinished(int groupId) = 0; 47 virtual void notifyCompositorAnimationFinished(int groupId) = 0;
44 virtual void notifyCompositorAnimationAborted(int groupId) = 0; 48 virtual void notifyCompositorAnimationAborted(int groupId) = 0;
45 virtual void layerForCompositedScrollingDidChange(CompositorAnimationTimelin e*) = 0; 49 virtual void layerForCompositedScrollingDidChange(CompositorAnimationTimelin e*) = 0;
46 50
47 DEFINE_INLINE_VIRTUAL_TRACE() { } 51 DEFINE_INLINE_VIRTUAL_TRACE() { }
48 52
49 protected: 53 protected:
50 explicit ScrollAnimatorCompositorCoordinator(); 54 explicit ScrollAnimatorCompositorCoordinator();
51 55
52 bool addAnimation(PassOwnPtr<CompositorAnimation>); 56 bool addAnimation(PassOwnPtr<CompositorAnimation>);
53 void removeAnimation(); 57 void removeAnimation();
54 void abortAnimation(); 58 virtual void abortAnimation();
55 59
56 void compositorAnimationFinished(int groupId); 60 void compositorAnimationFinished(int groupId);
57 // Returns true if the compositor player was attached to a new layer. 61 // Returns true if the compositor player was attached to a new layer.
58 bool reattachCompositorPlayerIfNeeded(CompositorAnimationTimeline*); 62 bool reattachCompositorPlayerIfNeeded(CompositorAnimationTimeline*);
59 63
60 // WebCompositorAnimationDelegate implementation. 64 // WebCompositorAnimationDelegate implementation.
61 void notifyAnimationStarted(double monotonicTime, int group) override; 65 void notifyAnimationStarted(double monotonicTime, int group) override;
62 void notifyAnimationFinished(double monotonicTime, int group) override; 66 void notifyAnimationFinished(double monotonicTime, int group) override;
63 void notifyAnimationAborted(double monotonicTime, int group) override; 67 void notifyAnimationAborted(double monotonicTime, int group) override;
64 void notifyAnimationTakeover( 68 void notifyAnimationTakeover(
65 double monotonicTime, 69 double monotonicTime,
66 double animationStartTime, 70 double animationStartTime,
67 scoped_ptr<cc::AnimationCurve>) override { }; 71 scoped_ptr<cc::AnimationCurve>) override { };
68 72
69 // CompositorAnimationPlayerClient implementation. 73 // CompositorAnimationPlayerClient implementation.
70 CompositorAnimationPlayer* compositorPlayer() const override; 74 CompositorAnimationPlayer* compositorPlayer() const override;
71 75
72 friend class Internals; 76 friend class Internals;
73 FRIEND_TEST_ALL_PREFIXES(ScrollAnimatorTest, MainThreadStates); 77 FRIEND_TEST_ALL_PREFIXES(ScrollAnimatorTest, MainThreadStates);
78 FRIEND_TEST_ALL_PREFIXES(ScrollAnimatorTest, AnimatedScrollTakeover);
74 79
75 enum class RunState { 80 enum class RunState {
76 // No animation. 81 // No animation.
77 Idle, 82 Idle,
78 83
79 // Waiting to send an animation to the compositor. There might also 84 // Waiting to send an animation to the compositor. There might also
80 // already be another animation running on the compositor that will need 85 // already be another animation running on the compositor that will need
81 // to be canceled first. 86 // to be canceled first.
82 WaitingToSendToCompositor, 87 WaitingToSendToCompositor,
83 88
84 // Running an animation on the compositor. 89 // Running an animation on the compositor.
85 RunningOnCompositor, 90 RunningOnCompositor,
86 91
87 // Running an animation on the compositor but needs update. 92 // Running an animation on the compositor but needs update.
88 RunningOnCompositorButNeedsUpdate, 93 RunningOnCompositorButNeedsUpdate,
89 94
90 // Running an animation on the main thread. 95 // Running an animation on the main thread.
91 RunningOnMainThread, 96 RunningOnMainThread,
92 97
93 // Waiting to cancel the animation currently running on the compositor. 98 // Waiting to cancel the animation currently running on the compositor.
94 // There is no pending animation to replace the canceled animation. 99 // There is no pending animation to replace the canceled animation.
95 WaitingToCancelOnCompositor, 100 WaitingToCancelOnCompositor,
96 101
97 // Finished an animation that was running on the main thread or the 102 // Finished an animation that was running on the main thread or the
98 // compositor thread. When in this state, post animation cleanup can 103 // compositor thread. When in this state, post animation cleanup can
99 // be performed. 104 // be performed.
100 PostAnimationCleanup 105 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,
101 }; 111 };
102 112
103 OwnPtr<CompositorAnimationPlayer> m_compositorPlayer; 113 OwnPtr<CompositorAnimationPlayer> m_compositorPlayer;
104 int m_compositorAnimationAttachedToLayerId; 114 int m_compositorAnimationAttachedToLayerId;
105 RunState m_runState; 115 RunState m_runState;
106 int m_compositorAnimationId; 116 int m_compositorAnimationId;
107 int m_compositorAnimationGroupId; 117 int m_compositorAnimationGroupId;
108 }; 118 };
109 119
110 } // namespace blink 120 } // namespace blink
111 121
112 #endif // ScrollAnimatorCompositorCoordinator_h 122 #endif // ScrollAnimatorCompositorCoordinator_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698