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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #include "core/animation/TimedItem.h" | 34 #include "core/animation/TimedItem.h" |
35 #include "core/events/EventTarget.h" | 35 #include "core/events/EventTarget.h" |
36 #include "wtf/RefPtr.h" | 36 #include "wtf/RefPtr.h" |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
40 class DocumentTimeline; | 40 class DocumentTimeline; |
41 class ExceptionState; | 41 class ExceptionState; |
42 | 42 |
43 class AnimationPlayer FINAL : public RefCounted<AnimationPlayer>, public EventTa
rgetWithInlineData { | 43 class AnimationPlayer FINAL : public RefCountedWillBeRefCountedGarbageCollected<
AnimationPlayer>, public EventTargetWithInlineData { |
44 REFCOUNTED_EVENT_TARGET(AnimationPlayer); | 44 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<A
nimationPlayer>); |
45 public: | 45 public: |
46 | 46 |
47 ~AnimationPlayer(); | 47 ~AnimationPlayer(); |
48 static PassRefPtr<AnimationPlayer> create(DocumentTimeline&, TimedItem*); | 48 static PassRefPtrWillBeRawPtr<AnimationPlayer> create(DocumentTimeline&, Tim
edItem*); |
49 | 49 |
50 // Returns whether the player is finished. | 50 // Returns whether the player is finished. |
51 bool update(TimingUpdateReason); | 51 bool update(TimingUpdateReason); |
52 | 52 |
53 // timeToEffectChange returns: | 53 // timeToEffectChange returns: |
54 // infinity - if this player is no longer in effect | 54 // infinity - if this player is no longer in effect |
55 // 0 - if this player requires an update on the next frame | 55 // 0 - if this player requires an update on the next frame |
56 // n - if this player requires an update after 'n' units of time | 56 // n - if this player requires an update after 'n' units of time |
57 double timeToEffectChange(); | 57 double timeToEffectChange(); |
58 | 58 |
(...skipping 18 matching lines...) Expand all Loading... |
77 DEFINE_ATTRIBUTE_EVENT_LISTENER(finish); | 77 DEFINE_ATTRIBUTE_EVENT_LISTENER(finish); |
78 | 78 |
79 virtual const AtomicString& interfaceName() const OVERRIDE; | 79 virtual const AtomicString& interfaceName() const OVERRIDE; |
80 virtual ExecutionContext* executionContext() const OVERRIDE; | 80 virtual ExecutionContext* executionContext() const OVERRIDE; |
81 | 81 |
82 double playbackRate() const { return m_playbackRate; } | 82 double playbackRate() const { return m_playbackRate; } |
83 void setPlaybackRate(double); | 83 void setPlaybackRate(double); |
84 const DocumentTimeline* timeline() const { return m_timeline; } | 84 const DocumentTimeline* timeline() const { return m_timeline; } |
85 DocumentTimeline* timeline() { return m_timeline; } | 85 DocumentTimeline* timeline() { return m_timeline; } |
86 | 86 |
87 void timelineDestroyed() { m_timeline = 0; } | 87 #if !ENABLE(OILPAN) |
| 88 void timelineDestroyed() { m_timeline = nullptr; } |
| 89 #endif |
88 | 90 |
89 bool hasStartTime() const { return !isNull(m_startTime); } | 91 bool hasStartTime() const { return !isNull(m_startTime); } |
90 double startTime() const { return m_startTime * 1000; } | 92 double startTime() const { return m_startTime * 1000; } |
91 double startTimeInternal() const { return m_startTime; } | 93 double startTimeInternal() const { return m_startTime; } |
92 void setStartTime(double startTime) { setStartTimeInternal(startTime / 1000)
; } | 94 void setStartTime(double startTime) { setStartTimeInternal(startTime / 1000)
; } |
93 void setStartTimeInternal(double, bool isUpdateFromCompositor = false); | 95 void setStartTimeInternal(double, bool isUpdateFromCompositor = false); |
94 | 96 |
95 const TimedItem* source() const { return m_content.get(); } | 97 const TimedItem* source() const { return m_content.get(); } |
96 TimedItem* source() { return m_content.get(); } | 98 TimedItem* source() { return m_content.get(); } |
97 TimedItem* source(bool& isNull) { isNull = !m_content; return m_content.get(
); } | 99 TimedItem* source(bool& isNull) { isNull = !m_content; return m_content.get(
); } |
(...skipping 19 matching lines...) Expand all Loading... |
117 | 119 |
118 class SortInfo { | 120 class SortInfo { |
119 public: | 121 public: |
120 friend class AnimationPlayer; | 122 friend class AnimationPlayer; |
121 bool operator<(const SortInfo& other) const; | 123 bool operator<(const SortInfo& other) const; |
122 double startTime() const { return m_startTime; } | 124 double startTime() const { return m_startTime; } |
123 private: | 125 private: |
124 SortInfo(unsigned sequenceNumber, double startTime) | 126 SortInfo(unsigned sequenceNumber, double startTime) |
125 : m_sequenceNumber(sequenceNumber) | 127 : m_sequenceNumber(sequenceNumber) |
126 , m_startTime(startTime) | 128 , m_startTime(startTime) |
127 { } | 129 { |
| 130 } |
128 unsigned m_sequenceNumber; | 131 unsigned m_sequenceNumber; |
129 double m_startTime; | 132 double m_startTime; |
130 }; | 133 }; |
131 | 134 |
132 const SortInfo& sortInfo() const { return m_sortInfo; } | 135 const SortInfo& sortInfo() const { return m_sortInfo; } |
133 | 136 |
134 static bool hasLowerPriority(AnimationPlayer* player1, AnimationPlayer* play
er2) | 137 static bool hasLowerPriority(AnimationPlayer* player1, AnimationPlayer* play
er2) |
135 { | 138 { |
136 return player1->sortInfo() < player2->sortInfo(); | 139 return player1->sortInfo() < player2->sortInfo(); |
137 } | 140 } |
138 | 141 |
| 142 #if !ENABLE(OILPAN) |
139 // Checks if the AnimationStack is the last reference holder to the Player. | 143 // Checks if the AnimationStack is the last reference holder to the Player. |
140 // This won't be needed when AnimationPlayer is moved to Oilpan. | 144 // This won't be needed when AnimationPlayer is moved to Oilpan. |
141 bool canFree() const; | 145 bool canFree() const; |
| 146 #endif |
142 | 147 |
143 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even
tListener>, bool useCapture = false) OVERRIDE; | 148 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even
tListener>, bool useCapture = false) OVERRIDE; |
144 | 149 |
| 150 void trace(Visitor*); |
| 151 |
145 private: | 152 private: |
146 AnimationPlayer(DocumentTimeline&, TimedItem*); | 153 AnimationPlayer(DocumentTimeline&, TimedItem*); |
147 double sourceEnd() const; | 154 double sourceEnd() const; |
148 bool limited(double currentTime) const; | 155 bool limited(double currentTime) const; |
149 double currentTimeWithoutLag() const; | 156 double currentTimeWithoutLag() const; |
150 double currentTimeWithLag() const; | 157 double currentTimeWithLag() const; |
151 void updateTimingState(double newCurrentTime); | 158 void updateTimingState(double newCurrentTime); |
152 void updateCurrentTimingState(); | 159 void updateCurrentTimingState(); |
153 | 160 |
154 double m_playbackRate; | 161 double m_playbackRate; |
155 double m_startTime; | 162 double m_startTime; |
156 double m_holdTime; | 163 double m_holdTime; |
157 double m_storedTimeLag; | 164 double m_storedTimeLag; |
158 | 165 |
159 SortInfo m_sortInfo; | 166 SortInfo m_sortInfo; |
160 | 167 |
161 RefPtr<TimedItem> m_content; | 168 RefPtrWillBeMember<TimedItem> m_content; |
162 // FIXME: We should keep the timeline alive and have this as non-null | 169 RawPtrWillBeMember<DocumentTimeline> m_timeline; |
163 // but this is tricky to do without Oilpan | |
164 DocumentTimeline* m_timeline; | |
165 // Reflects all pausing, including via pauseForTesting(). | 170 // Reflects all pausing, including via pauseForTesting(). |
166 bool m_paused; | 171 bool m_paused; |
167 bool m_held; | 172 bool m_held; |
168 bool m_isPausedForTesting; | 173 bool m_isPausedForTesting; |
169 | 174 |
170 // This indicates timing information relevant to the player has changed by | 175 // This indicates timing information relevant to the player has changed by |
171 // means other than the ordinary progression of time | 176 // means other than the ordinary progression of time |
172 bool m_outdated; | 177 bool m_outdated; |
173 | 178 |
174 bool m_finished; | 179 bool m_finished; |
175 }; | 180 }; |
176 | 181 |
177 } // namespace | 182 } // namespace |
178 | 183 |
179 #endif | 184 #endif |
OLD | NEW |