OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef AnimationTimeline_h | 31 #ifndef AnimationTimeline_h |
32 #define AnimationTimeline_h | 32 #define AnimationTimeline_h |
33 | 33 |
34 #include "bindings/core/v8/ScriptWrappable.h" | 34 #include "bindings/core/v8/ScriptWrappable.h" |
35 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
36 #include "core/animation/AnimationEffect.h" | 36 #include "core/animation/Animation.h" |
37 #include "core/animation/AnimationPlayer.h" | 37 #include "core/animation/EffectModel.h" |
38 #include "core/dom/Element.h" | 38 #include "core/dom/Element.h" |
39 #include "platform/Timer.h" | 39 #include "platform/Timer.h" |
40 #include "platform/heap/Handle.h" | 40 #include "platform/heap/Handle.h" |
41 #include "public/platform/WebCompositorAnimationTimeline.h" | 41 #include "public/platform/WebCompositorAnimationTimeline.h" |
42 #include "wtf/RefCounted.h" | 42 #include "wtf/RefCounted.h" |
43 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
44 #include "wtf/Vector.h" | 44 #include "wtf/Vector.h" |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 class Document; | 48 class Document; |
49 class AnimationNode; | 49 class AnimationEffect; |
50 | 50 |
51 // AnimationTimeline is constructed and owned by Document, and tied to its lifec
ycle. | 51 // AnimationTimeline is constructed and owned by Document, and tied to its lifec
ycle. |
52 class CORE_EXPORT AnimationTimeline : public RefCountedWillBeGarbageCollectedFin
alized<AnimationTimeline>, public ScriptWrappable { | 52 class CORE_EXPORT AnimationTimeline : public RefCountedWillBeGarbageCollectedFin
alized<AnimationTimeline>, public ScriptWrappable { |
53 DEFINE_WRAPPERTYPEINFO(); | 53 DEFINE_WRAPPERTYPEINFO(); |
54 public: | 54 public: |
55 class PlatformTiming : public NoBaseWillBeGarbageCollectedFinalized<Platform
Timing> { | 55 class PlatformTiming : public NoBaseWillBeGarbageCollectedFinalized<Platform
Timing> { |
56 | 56 |
57 public: | 57 public: |
58 // Calls AnimationTimeline's wake() method after duration seconds. | 58 // Calls AnimationTimeline's wake() method after duration seconds. |
59 virtual void wakeAfter(double duration) = 0; | 59 virtual void wakeAfter(double duration) = 0; |
60 virtual void cancelWake() = 0; | 60 virtual void cancelWake() = 0; |
61 virtual void serviceOnNextFrame() = 0; | 61 virtual void serviceOnNextFrame() = 0; |
62 virtual ~PlatformTiming() { } | 62 virtual ~PlatformTiming() { } |
63 DEFINE_INLINE_VIRTUAL_TRACE() { } | 63 DEFINE_INLINE_VIRTUAL_TRACE() { } |
64 }; | 64 }; |
65 | 65 |
66 static PassRefPtrWillBeRawPtr<AnimationTimeline> create(Document*, PassOwnPt
rWillBeRawPtr<PlatformTiming> = nullptr); | 66 static PassRefPtrWillBeRawPtr<AnimationTimeline> create(Document*, PassOwnPt
rWillBeRawPtr<PlatformTiming> = nullptr); |
67 ~AnimationTimeline(); | 67 ~AnimationTimeline(); |
68 | 68 |
69 void serviceAnimations(TimingUpdateReason); | 69 void serviceAnimations(TimingUpdateReason); |
70 void scheduleNextService(); | 70 void scheduleNextService(); |
71 | 71 |
72 AnimationPlayer* play(AnimationNode*); | 72 Animation* play(AnimationEffect*); |
73 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> getAnimationPlayers(); | 73 WillBeHeapVector<RefPtrWillBeMember<Animation>> getAnimations(); |
74 | 74 |
75 void playerAttached(AnimationPlayer&); | 75 void animationAttached(Animation&); |
76 #if !ENABLE(OILPAN) | 76 #if !ENABLE(OILPAN) |
77 void playerDestroyed(AnimationPlayer* player) | 77 void animationDestroyed(Animation* animation) |
78 { | 78 { |
79 ASSERT(m_players.contains(player)); | 79 ASSERT(m_animations.contains(animation)); |
80 m_players.remove(player); | 80 m_animations.remove(animation); |
81 } | 81 } |
82 #endif | 82 #endif |
83 | 83 |
84 bool hasPendingUpdates() const { return !m_playersNeedingUpdate.isEmpty(); } | 84 bool hasPendingUpdates() const { return !m_animationsNeedingUpdate.isEmpty()
; } |
85 double zeroTime(); | 85 double zeroTime(); |
86 double currentTime(bool& isNull); | 86 double currentTime(bool& isNull); |
87 double currentTime(); | 87 double currentTime(); |
88 double currentTimeInternal(bool& isNull); | 88 double currentTimeInternal(bool& isNull); |
89 double currentTimeInternal(); | 89 double currentTimeInternal(); |
90 void setCurrentTime(double); | 90 void setCurrentTime(double); |
91 void setCurrentTimeInternal(double); | 91 void setCurrentTimeInternal(double); |
92 double effectiveTime(); | 92 double effectiveTime(); |
93 void pauseAnimationsForTesting(double); | 93 void pauseAnimationsForTesting(double); |
94 | 94 |
95 void setOutdatedAnimationPlayer(AnimationPlayer*); | 95 void setOutdatedAnimation(Animation*); |
96 bool hasOutdatedAnimationPlayer() const; | 96 bool hasOutdatedAnimation() const; |
97 bool needsAnimationTimingUpdate(); | 97 bool needsAnimationTimingUpdate(); |
98 | 98 |
99 void setPlaybackRate(double); | 99 void setPlaybackRate(double); |
100 double playbackRate() const; | 100 double playbackRate() const; |
101 | 101 |
102 WebCompositorAnimationTimeline* compositorTimeline() const { return m_compos
itorTimeline.get(); } | 102 WebCompositorAnimationTimeline* compositorTimeline() const { return m_compos
itorTimeline.get(); } |
103 | 103 |
104 Document* document() { return m_document.get(); } | 104 Document* document() { return m_document.get(); } |
105 #if !ENABLE(OILPAN) | 105 #if !ENABLE(OILPAN) |
106 void detachFromDocument(); | 106 void detachFromDocument(); |
107 #endif | 107 #endif |
108 void wake(); | 108 void wake(); |
109 | 109 |
110 DECLARE_TRACE(); | 110 DECLARE_TRACE(); |
111 | 111 |
112 protected: | 112 protected: |
113 AnimationTimeline(Document*, PassOwnPtrWillBeRawPtr<PlatformTiming>); | 113 AnimationTimeline(Document*, PassOwnPtrWillBeRawPtr<PlatformTiming>); |
114 | 114 |
115 private: | 115 private: |
116 RawPtrWillBeMember<Document> m_document; | 116 RawPtrWillBeMember<Document> m_document; |
117 double m_zeroTime; | 117 double m_zeroTime; |
118 bool m_zeroTimeInitialized; | 118 bool m_zeroTimeInitialized; |
119 // AnimationPlayers which will be updated on the next frame | 119 // Animations which will be updated on the next frame |
120 // i.e. current, in effect, or had timing changed | 120 // i.e. current, in effect, or had timing changed |
121 WillBeHeapHashSet<RefPtrWillBeMember<AnimationPlayer>> m_playersNeedingUpdat
e; | 121 WillBeHeapHashSet<RefPtrWillBeMember<Animation>> m_animationsNeedingUpdate; |
122 WillBeHeapHashSet<RawPtrWillBeWeakMember<AnimationPlayer>> m_players; | 122 WillBeHeapHashSet<RawPtrWillBeWeakMember<Animation>> m_animations; |
123 | 123 |
124 double m_playbackRate; | 124 double m_playbackRate; |
125 | 125 |
126 friend class SMILTimeContainer; | 126 friend class SMILTimeContainer; |
127 static const double s_minimumDelay; | 127 static const double s_minimumDelay; |
128 | 128 |
129 OwnPtrWillBeMember<PlatformTiming> m_timing; | 129 OwnPtrWillBeMember<PlatformTiming> m_timing; |
130 double m_lastCurrentTimeInternal; | 130 double m_lastCurrentTimeInternal; |
131 | 131 |
132 OwnPtr<WebCompositorAnimationTimeline> m_compositorTimeline; | 132 OwnPtr<WebCompositorAnimationTimeline> m_compositorTimeline; |
(...skipping 19 matching lines...) Expand all Loading... |
152 RawPtrWillBeMember<AnimationTimeline> m_timeline; | 152 RawPtrWillBeMember<AnimationTimeline> m_timeline; |
153 Timer<AnimationTimelineTiming> m_timer; | 153 Timer<AnimationTimelineTiming> m_timer; |
154 }; | 154 }; |
155 | 155 |
156 friend class AnimationAnimationTimelineTest; | 156 friend class AnimationAnimationTimelineTest; |
157 }; | 157 }; |
158 | 158 |
159 } // namespace blink | 159 } // namespace blink |
160 | 160 |
161 #endif | 161 #endif |
OLD | NEW |