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

Side by Side Diff: Source/core/animation/css/CSSAnimationUpdate.h

Issue 1281493004: Make CSSAnimationUpdate stack-allocated (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/animation/css/CSSAnimations.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CSSAnimationUpdate_h 5 #ifndef CSSAnimationUpdate_h
6 #define CSSAnimationUpdate_h 6 #define CSSAnimationUpdate_h
7 7
8 #include "core/animation/AnimationStack.h" 8 #include "core/animation/AnimationStack.h"
9 #include "core/animation/InertEffect.h"
9 #include "core/animation/Interpolation.h" 10 #include "core/animation/Interpolation.h"
10 #include "core/animation/KeyframeEffectModel.h" 11 #include "core/animation/KeyframeEffectModel.h"
11 #include "core/animation/css/CSSAnimatableValueFactory.h" 12 #include "core/animation/css/CSSAnimatableValueFactory.h"
12 #include "core/animation/css/CSSPropertyEquality.h" 13 #include "core/animation/css/CSSPropertyEquality.h"
13 #include "core/css/CSSKeyframesRule.h" 14 #include "core/css/CSSKeyframesRule.h"
14 #include "core/layout/LayoutObject.h" 15 #include "core/layout/LayoutObject.h"
15 #include "wtf/HashMap.h" 16 #include "wtf/HashMap.h"
16 #include "wtf/Vector.h" 17 #include "wtf/Vector.h"
17 #include "wtf/text/AtomicString.h" 18 #include "wtf/text/AtomicString.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 class Animation; 22 class Animation;
22 class InertEffect;
23 23
24 // This class stores the CSS Animations/Transitions information we use during a style recalc. 24 // This class stores the CSS Animations/Transitions information we use during a style recalc.
25 // This includes updates to animations/transitions as well as the Interpolations to be applied. 25 // This includes updates to animations/transitions as well as the Interpolations to be applied.
26 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS SAnimationUpdate> { 26 class CSSAnimationUpdate final {
27 DISALLOW_ALLOCATION();
27 public: 28 public:
28 class NewAnimation { 29 class NewAnimation {
29 ALLOW_ONLY_INLINE_ALLOCATION(); 30 ALLOW_ONLY_INLINE_ALLOCATION();
30 public: 31 public:
31 NewAnimation() 32 NewAnimation()
32 : styleRuleVersion(0) 33 : styleRuleVersion(0)
33 { 34 {
34 } 35 }
35 36
36 NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertEffect> effe ct, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) 37 NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertEffect> effe ct, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 visitor->trace(animation); 124 visitor->trace(animation);
124 visitor->trace(model); 125 visitor->trace(model);
125 visitor->trace(snapshot); 126 visitor->trace(snapshot);
126 } 127 }
127 128
128 RawPtrWillBeMember<Animation> animation; 129 RawPtrWillBeMember<Animation> animation;
129 RawPtrWillBeMember<KeyframeEffectModelBase> model; 130 RawPtrWillBeMember<KeyframeEffectModelBase> model;
130 CompositableStyleSnapshot snapshot; 131 CompositableStyleSnapshot snapshot;
131 }; 132 };
132 133
134 CSSAnimationUpdate()
135 : m_isEmpty(true)
136 {
137 }
138
139 ~CSSAnimationUpdate()
140 {
141 #if ENABLE(OILPAN)
142 // For performance reasons, explicitly clear HeapVectors and
143 // HeapHashMaps to avoid giving a pressure on Oilpan's GC.
144 clear();
145 #endif
146 }
147
148 void setPendingUpdate(const CSSAnimationUpdate& update)
alancutter (OOO until 2018) 2015/08/19 07:26:43 s/setPendingUpdate/copy/ ?
haraken 2015/08/19 12:08:11 Done.
149 {
150 ASSERT(m_isEmpty);
151 m_isEmpty = false;
152 m_newAnimations = update.newAnimations();
153 m_animationsWithUpdates = update.animationsWithUpdates();
154 m_animationsWithStyleUpdates = update.animationsWithStyleUpdates();
155 m_newTransitions = update.newTransitions();
156 m_activeInterpolationsForAnimations = update.activeInterpolationsForAnim ations();
157 m_activeInterpolationsForTransitions = update.activeInterpolationsForTra nsitions();
158 m_cancelledAnimationNames = update.cancelledAnimationNames();
159 m_animationsWithPauseToggled = update.animationsWithPauseToggled();
160 m_cancelledTransitions = update.cancelledTransitions();
161 m_finishedTransitions = update.finishedTransitions();
162 }
163
164 void clear()
165 {
166 m_newAnimations.clear();
167 m_animationsWithUpdates.clear();
168 m_animationsWithStyleUpdates.clear();
169 m_newTransitions.clear();
170 m_activeInterpolationsForAnimations.clear();
171 m_activeInterpolationsForTransitions.clear();
172 m_cancelledAnimationNames.clear();
173 m_animationsWithPauseToggled.clear();
174 m_cancelledTransitions.clear();
175 m_finishedTransitions.clear();
176 m_isEmpty = true;
177 }
178
179 bool isEmpty() const { return m_isEmpty; }
alancutter (OOO until 2018) 2015/08/19 07:26:43 This function should remain as it was otherwise th
haraken 2015/08/19 12:08:11 Done.
180
133 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertEffect> effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKey frames> styleRule) 181 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertEffect> effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKey frames> styleRule)
134 { 182 {
135 effect->setName(animationName); 183 effect->setName(animationName);
136 m_newAnimations.append(NewAnimation(animationName, effect, timing, style Rule)); 184 m_newAnimations.append(NewAnimation(animationName, effect, timing, style Rule));
137 } 185 }
138 // Returns whether animation has been suppressed and should be filtered duri ng style application. 186 // Returns whether animation has been suppressed and should be filtered duri ng style application.
139 bool isSuppressedAnimation(const Animation* animation) const { return m_supp ressedAnimations.contains(animation); } 187 bool isSuppressedAnimation(const Animation* animation) const { return m_supp ressedAnimations.contains(animation); }
140 void cancelAnimation(const AtomicString& name, Animation& animation) 188 void cancelAnimation(const AtomicString& name, Animation& animation)
141 { 189 {
142 m_cancelledAnimationNames.append(name); 190 m_cancelledAnimationNames.append(name);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 const NewTransitionMap& newTransitions() const { return m_newTransitions; } 256 const NewTransitionMap& newTransitions() const { return m_newTransitions; }
209 const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancel ledTransitions; } 257 const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancel ledTransitions; }
210 const HashSet<CSSPropertyID>& finishedTransitions() const { return m_finishe dTransitions; } 258 const HashSet<CSSPropertyID>& finishedTransitions() const { return m_finishe dTransitions; }
211 259
212 void adoptActiveInterpolationsForAnimations(ActiveInterpolationMap& newMap) { newMap.swap(m_activeInterpolationsForAnimations); } 260 void adoptActiveInterpolationsForAnimations(ActiveInterpolationMap& newMap) { newMap.swap(m_activeInterpolationsForAnimations); }
213 void adoptActiveInterpolationsForTransitions(ActiveInterpolationMap& newMap) { newMap.swap(m_activeInterpolationsForTransitions); } 261 void adoptActiveInterpolationsForTransitions(ActiveInterpolationMap& newMap) { newMap.swap(m_activeInterpolationsForTransitions); }
214 const ActiveInterpolationMap& activeInterpolationsForAnimations() const { re turn m_activeInterpolationsForAnimations; } 262 const ActiveInterpolationMap& activeInterpolationsForAnimations() const { re turn m_activeInterpolationsForAnimations; }
215 const ActiveInterpolationMap& activeInterpolationsForTransitions() const { r eturn m_activeInterpolationsForTransitions; } 263 const ActiveInterpolationMap& activeInterpolationsForTransitions() const { r eturn m_activeInterpolationsForTransitions; }
216 ActiveInterpolationMap& activeInterpolationsForAnimations() { return m_activ eInterpolationsForAnimations; } 264 ActiveInterpolationMap& activeInterpolationsForAnimations() { return m_activ eInterpolationsForAnimations; }
217 265
218 bool isEmpty() const
219 {
220 return m_newAnimations.isEmpty()
221 && m_cancelledAnimationNames.isEmpty()
222 && m_suppressedAnimations.isEmpty()
223 && m_animationsWithPauseToggled.isEmpty()
224 && m_animationsWithUpdates.isEmpty()
225 && m_animationsWithStyleUpdates.isEmpty()
226 && m_newTransitions.isEmpty()
227 && m_cancelledTransitions.isEmpty()
228 && m_finishedTransitions.isEmpty()
229 && m_activeInterpolationsForAnimations.isEmpty()
230 && m_activeInterpolationsForTransitions.isEmpty();
231 }
232
233 DECLARE_TRACE();
234
235 private: 266 private:
236 // Order is significant since it defines the order in which new animations 267 // Order is significant since it defines the order in which new animations
237 // will be started. Note that there may be multiple animations present 268 // will be started. Note that there may be multiple animations present
238 // with the same name, due to the way in which we split up animations with 269 // with the same name, due to the way in which we split up animations with
239 // incomplete keyframes. 270 // incomplete keyframes.
240 WillBeHeapVector<NewAnimation> m_newAnimations; 271 WillBeHeapVector<NewAnimation> m_newAnimations;
241 Vector<AtomicString> m_cancelledAnimationNames; 272 Vector<AtomicString> m_cancelledAnimationNames;
242 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> m_suppressedAnimation s; 273 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> m_suppressedAnimation s;
243 Vector<AtomicString> m_animationsWithPauseToggled; 274 Vector<AtomicString> m_animationsWithPauseToggled;
244 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; 275 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates;
245 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates; 276 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates;
246 277
247 NewTransitionMap m_newTransitions; 278 NewTransitionMap m_newTransitions;
248 HashSet<CSSPropertyID> m_cancelledTransitions; 279 HashSet<CSSPropertyID> m_cancelledTransitions;
249 HashSet<CSSPropertyID> m_finishedTransitions; 280 HashSet<CSSPropertyID> m_finishedTransitions;
250 281
251 ActiveInterpolationMap m_activeInterpolationsForAnimations; 282 ActiveInterpolationMap m_activeInterpolationsForAnimations;
252 ActiveInterpolationMap m_activeInterpolationsForTransitions; 283 ActiveInterpolationMap m_activeInterpolationsForTransitions;
284
285 bool m_isEmpty;
286
287 friend class PendingAnimationUpdate;
alancutter (OOO until 2018) 2015/08/19 07:26:43 No need for friend class.
haraken 2015/08/19 12:08:11 Done.
253 }; 288 };
254 289
255 } // namespace blink 290 } // namespace blink
256 291
257 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); 292 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation);
258 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); 293 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation);
259 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationSty le); 294 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationSty le);
260 295
261 #endif 296 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/animation/css/CSSAnimations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698