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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 AnimationNode; |
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 GarbageCollectedFinalized<Animation Timeline>, public ScriptWrappable { |
53 DEFINE_WRAPPERTYPEINFO(); | 53 DEFINE_WRAPPERTYPEINFO(); |
54 public: | 54 public: |
55 class PlatformTiming : public NoBaseWillBeGarbageCollectedFinalized<Platform Timing> { | 55 class PlatformTiming : public GarbageCollectedFinalized<PlatformTiming> { |
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 AnimationTimeline* create(Document*, 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 AnimationPlayer* play(AnimationNode*); |
73 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> getAnimationPlayers(); | 73 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> getAnimationPlayers(); |
74 | 74 |
75 void playerAttached(AnimationPlayer&); | 75 void playerAttached(AnimationPlayer&); |
76 #if !ENABLE(OILPAN) | |
77 void playerDestroyed(AnimationPlayer* player) | |
78 { | |
79 ASSERT(m_players.contains(player)); | |
80 m_players.remove(player); | |
81 } | |
82 #endif | |
83 | 76 |
84 bool hasPendingUpdates() const { return !m_playersNeedingUpdate.isEmpty(); } | 77 bool hasPendingUpdates() const { return !m_playersNeedingUpdate.isEmpty(); } |
85 double zeroTime(); | 78 double zeroTime(); |
86 double currentTime(bool& isNull); | 79 double currentTime(bool& isNull); |
87 double currentTime(); | 80 double currentTime(); |
88 double currentTimeInternal(bool& isNull); | 81 double currentTimeInternal(bool& isNull); |
89 double currentTimeInternal(); | 82 double currentTimeInternal(); |
90 void setCurrentTime(double); | 83 void setCurrentTime(double); |
91 void setCurrentTimeInternal(double); | 84 void setCurrentTimeInternal(double); |
92 double effectiveTime(); | 85 double effectiveTime(); |
93 void pauseAnimationsForTesting(double); | 86 void pauseAnimationsForTesting(double); |
94 | 87 |
95 void setOutdatedAnimationPlayer(AnimationPlayer*); | 88 void setOutdatedAnimationPlayer(AnimationPlayer*); |
96 bool hasOutdatedAnimationPlayer() const; | 89 bool hasOutdatedAnimationPlayer() const; |
97 bool needsAnimationTimingUpdate(); | 90 bool needsAnimationTimingUpdate(); |
98 | 91 |
99 void setPlaybackRate(double); | 92 void setPlaybackRate(double); |
100 double playbackRate() const; | 93 double playbackRate() const; |
101 | 94 |
102 WebCompositorAnimationTimeline* compositorTimeline() const { return m_compos itorTimeline.get(); } | 95 WebCompositorAnimationTimeline* compositorTimeline() const { return m_compos itorTimeline.get(); } |
103 | 96 |
104 Document* document() { return m_document.get(); } | 97 Document* document() { return m_document.get(); } |
105 #if !ENABLE(OILPAN) | |
106 void detachFromDocument(); | |
haraken
2015/05/08 00:13:06
Ditto.
peria
2015/05/08 02:21:20
Acknowledged.
| |
107 #endif | |
108 void wake(); | 98 void wake(); |
109 | 99 |
110 DECLARE_TRACE(); | 100 DECLARE_TRACE(); |
111 | 101 |
112 protected: | 102 protected: |
113 AnimationTimeline(Document*, PassOwnPtrWillBeRawPtr<PlatformTiming>); | 103 AnimationTimeline(Document*, PlatformTiming*); |
114 | 104 |
115 private: | 105 private: |
116 RawPtrWillBeMember<Document> m_document; | 106 RawPtrWillBeMember<Document> m_document; |
117 double m_zeroTime; | 107 double m_zeroTime; |
118 bool m_zeroTimeInitialized; | 108 bool m_zeroTimeInitialized; |
119 // AnimationPlayers which will be updated on the next frame | 109 // AnimationPlayers which will be updated on the next frame |
120 // i.e. current, in effect, or had timing changed | 110 // i.e. current, in effect, or had timing changed |
121 WillBeHeapHashSet<RefPtrWillBeMember<AnimationPlayer>> m_playersNeedingUpdat e; | 111 WillBeHeapHashSet<RefPtrWillBeMember<AnimationPlayer>> m_playersNeedingUpdat e; |
122 WillBeHeapHashSet<RawPtrWillBeWeakMember<AnimationPlayer>> m_players; | 112 WillBeHeapHashSet<RawPtrWillBeWeakMember<AnimationPlayer>> m_players; |
123 | 113 |
124 double m_playbackRate; | 114 double m_playbackRate; |
125 | 115 |
126 friend class SMILTimeContainer; | 116 friend class SMILTimeContainer; |
127 static const double s_minimumDelay; | 117 static const double s_minimumDelay; |
128 | 118 |
129 OwnPtrWillBeMember<PlatformTiming> m_timing; | 119 Member<PlatformTiming> m_timing; |
130 double m_lastCurrentTimeInternal; | 120 double m_lastCurrentTimeInternal; |
131 | 121 |
132 OwnPtr<WebCompositorAnimationTimeline> m_compositorTimeline; | 122 OwnPtr<WebCompositorAnimationTimeline> m_compositorTimeline; |
133 | 123 |
134 class AnimationTimelineTiming final : public PlatformTiming { | 124 class AnimationTimelineTiming final : public PlatformTiming { |
135 public: | 125 public: |
136 AnimationTimelineTiming(AnimationTimeline* timeline) | 126 AnimationTimelineTiming(AnimationTimeline* timeline) |
137 : m_timeline(timeline) | 127 : m_timeline(timeline) |
138 , m_timer(this, &AnimationTimelineTiming::timerFired) | 128 , m_timer(this, &AnimationTimelineTiming::timerFired) |
139 { | 129 { |
140 ASSERT(m_timeline); | 130 ASSERT(m_timeline); |
141 } | 131 } |
142 | 132 |
143 virtual void wakeAfter(double duration) override; | 133 virtual void wakeAfter(double duration) override; |
144 virtual void cancelWake() override; | 134 virtual void cancelWake() override; |
145 virtual void serviceOnNextFrame() override; | 135 virtual void serviceOnNextFrame() override; |
146 | 136 |
147 void timerFired(Timer<AnimationTimelineTiming>*) { m_timeline->wake(); } | 137 void timerFired(Timer<AnimationTimelineTiming>*) { m_timeline->wake(); } |
148 | 138 |
149 DECLARE_VIRTUAL_TRACE(); | 139 DECLARE_VIRTUAL_TRACE(); |
150 | 140 |
151 private: | 141 private: |
152 RawPtrWillBeMember<AnimationTimeline> m_timeline; | 142 Member<AnimationTimeline> m_timeline; |
153 Timer<AnimationTimelineTiming> m_timer; | 143 Timer<AnimationTimelineTiming> m_timer; |
154 }; | 144 }; |
155 | 145 |
156 friend class AnimationAnimationTimelineTest; | 146 friend class AnimationAnimationTimelineTest; |
157 }; | 147 }; |
158 | 148 |
159 } // namespace blink | 149 } // namespace blink |
160 | 150 |
161 #endif | 151 #endif |
OLD | NEW |