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

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
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/Allocator.h" 16 #include "wtf/Allocator.h"
16 #include "wtf/HashMap.h" 17 #include "wtf/HashMap.h"
17 #include "wtf/Vector.h" 18 #include "wtf/Vector.h"
18 #include "wtf/text/AtomicString.h" 19 #include "wtf/text/AtomicString.h"
19 20
20 namespace blink { 21 namespace blink {
21 22
22 class Animation; 23 class Animation;
23 class InertEffect;
24 24
25 // This class stores the CSS Animations/Transitions information we use during a style recalc. 25 // This class stores the CSS Animations/Transitions information we use during a style recalc.
26 // This includes updates to animations/transitions as well as the Interpolations to be applied. 26 // This includes updates to animations/transitions as well as the Interpolations to be applied.
27 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS SAnimationUpdate> { 27 class CSSAnimationUpdate final {
28 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(CSSAnimationUpdate); 28 DISALLOW_ALLOCATION();
29 WTF_MAKE_NONCOPYABLE(CSSAnimationUpdate); 29 WTF_MAKE_NONCOPYABLE(CSSAnimationUpdate);
30 public: 30 public:
31 CSSAnimationUpdate() { }
32
33 class NewAnimation { 31 class NewAnimation {
34 ALLOW_ONLY_INLINE_ALLOCATION(); 32 ALLOW_ONLY_INLINE_ALLOCATION();
35 public: 33 public:
36 NewAnimation() 34 NewAnimation()
37 : styleRuleVersion(0) 35 : styleRuleVersion(0)
38 { 36 {
39 } 37 }
40 38
41 NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertEffect> effe ct, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) 39 NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertEffect> effe ct, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule)
42 : name(name) 40 : name(name)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 visitor->trace(animation); 126 visitor->trace(animation);
129 visitor->trace(model); 127 visitor->trace(model);
130 visitor->trace(snapshot); 128 visitor->trace(snapshot);
131 } 129 }
132 130
133 RawPtrWillBeMember<Animation> animation; 131 RawPtrWillBeMember<Animation> animation;
134 RawPtrWillBeMember<KeyframeEffectModelBase> model; 132 RawPtrWillBeMember<KeyframeEffectModelBase> model;
135 CompositableStyleSnapshot snapshot; 133 CompositableStyleSnapshot snapshot;
136 }; 134 };
137 135
136 CSSAnimationUpdate()
137 #if ENABLE(ASSERT)
138 : m_isCleared(true)
139 #endif
140 {
141 }
142
143 ~CSSAnimationUpdate()
144 {
145 #if ENABLE(OILPAN)
146 // For performance reasons, explicitly clear HeapVectors and
147 // HeapHashMaps to avoid giving a pressure on Oilpan's GC.
148 clear();
149 #endif
150 }
151
152 void copy(const CSSAnimationUpdate& update)
153 {
154 #if ENABLE(ASSERT)
155 ASSERT(m_isCleared);
156 m_isCleared = false;
157 #endif
alancutter (OOO until 2018) 2015/08/20 02:06:58 I'm not sure it's worthwhile adding 4 ifdefs for a
haraken 2015/08/20 03:01:25 Done.
158 m_newAnimations = update.newAnimations();
159 m_animationsWithUpdates = update.animationsWithUpdates();
160 m_animationsWithStyleUpdates = update.animationsWithStyleUpdates();
161 m_newTransitions = update.newTransitions();
162 m_activeInterpolationsForAnimations = update.activeInterpolationsForAnim ations();
163 m_activeInterpolationsForTransitions = update.activeInterpolationsForTra nsitions();
164 m_cancelledAnimationNames = update.cancelledAnimationNames();
165 m_animationsWithPauseToggled = update.animationsWithPauseToggled();
166 m_cancelledTransitions = update.cancelledTransitions();
167 m_finishedTransitions = update.finishedTransitions();
168 }
169
170 void clear()
171 {
172 m_newAnimations.clear();
173 m_animationsWithUpdates.clear();
174 m_animationsWithStyleUpdates.clear();
175 m_newTransitions.clear();
176 m_activeInterpolationsForAnimations.clear();
177 m_activeInterpolationsForTransitions.clear();
178 m_cancelledAnimationNames.clear();
179 m_animationsWithPauseToggled.clear();
180 m_cancelledTransitions.clear();
181 m_finishedTransitions.clear();
182 #if ENABLE(ASSERT)
183 m_isCleared = true;
184 #endif
185 }
186
138 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertEffect> effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKey frames> styleRule) 187 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertEffect> effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKey frames> styleRule)
139 { 188 {
140 effect->setName(animationName); 189 effect->setName(animationName);
141 m_newAnimations.append(NewAnimation(animationName, effect, timing, style Rule)); 190 m_newAnimations.append(NewAnimation(animationName, effect, timing, style Rule));
142 } 191 }
143 // Returns whether animation has been suppressed and should be filtered duri ng style application. 192 // Returns whether animation has been suppressed and should be filtered duri ng style application.
144 bool isSuppressedAnimation(const Animation* animation) const { return m_supp ressedAnimations.contains(animation); } 193 bool isSuppressedAnimation(const Animation* animation) const { return m_supp ressedAnimations.contains(animation); }
145 void cancelAnimation(const AtomicString& name, Animation& animation) 194 void cancelAnimation(const AtomicString& name, Animation& animation)
146 { 195 {
147 m_cancelledAnimationNames.append(name); 196 m_cancelledAnimationNames.append(name);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 && m_animationsWithPauseToggled.isEmpty() 277 && m_animationsWithPauseToggled.isEmpty()
229 && m_animationsWithUpdates.isEmpty() 278 && m_animationsWithUpdates.isEmpty()
230 && m_animationsWithStyleUpdates.isEmpty() 279 && m_animationsWithStyleUpdates.isEmpty()
231 && m_newTransitions.isEmpty() 280 && m_newTransitions.isEmpty()
232 && m_cancelledTransitions.isEmpty() 281 && m_cancelledTransitions.isEmpty()
233 && m_finishedTransitions.isEmpty() 282 && m_finishedTransitions.isEmpty()
234 && m_activeInterpolationsForAnimations.isEmpty() 283 && m_activeInterpolationsForAnimations.isEmpty()
235 && m_activeInterpolationsForTransitions.isEmpty(); 284 && m_activeInterpolationsForTransitions.isEmpty();
236 } 285 }
237 286
238 DECLARE_TRACE(); 287 DEFINE_INLINE_TRACE()
288 {
289 #if ENABLE(OILPAN)
290 visitor->trace(m_newTransitions);
291 visitor->trace(m_activeInterpolationsForAnimations);
292 visitor->trace(m_activeInterpolationsForTransitions);
293 visitor->trace(m_newAnimations);
294 visitor->trace(m_suppressedAnimations);
295 visitor->trace(m_animationsWithUpdates);
296 visitor->trace(m_animationsWithStyleUpdates);
297 #endif
298 }
239 299
240 private: 300 private:
241 // Order is significant since it defines the order in which new animations 301 // Order is significant since it defines the order in which new animations
242 // will be started. Note that there may be multiple animations present 302 // will be started. Note that there may be multiple animations present
243 // with the same name, due to the way in which we split up animations with 303 // with the same name, due to the way in which we split up animations with
244 // incomplete keyframes. 304 // incomplete keyframes.
245 WillBeHeapVector<NewAnimation> m_newAnimations; 305 WillBeHeapVector<NewAnimation> m_newAnimations;
246 Vector<AtomicString> m_cancelledAnimationNames; 306 Vector<AtomicString> m_cancelledAnimationNames;
247 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> m_suppressedAnimation s; 307 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> m_suppressedAnimation s;
248 Vector<AtomicString> m_animationsWithPauseToggled; 308 Vector<AtomicString> m_animationsWithPauseToggled;
249 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; 309 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates;
250 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates; 310 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates;
251 311
252 NewTransitionMap m_newTransitions; 312 NewTransitionMap m_newTransitions;
253 HashSet<CSSPropertyID> m_cancelledTransitions; 313 HashSet<CSSPropertyID> m_cancelledTransitions;
254 HashSet<CSSPropertyID> m_finishedTransitions; 314 HashSet<CSSPropertyID> m_finishedTransitions;
255 315
256 ActiveInterpolationMap m_activeInterpolationsForAnimations; 316 ActiveInterpolationMap m_activeInterpolationsForAnimations;
257 ActiveInterpolationMap m_activeInterpolationsForTransitions; 317 ActiveInterpolationMap m_activeInterpolationsForTransitions;
318
319 #if ENABLE(ASSERT)
320 bool m_isCleared;
321 #endif
258 }; 322 };
259 323
260 } // namespace blink 324 } // namespace blink
261 325
262 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); 326 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation);
263 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); 327 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation);
264 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationSty le); 328 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationSty le);
265 329
266 #endif 330 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/animation/css/CSSAnimations.h » ('j') | Source/core/animation/css/CSSAnimations.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698