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