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

Side by Side Diff: Source/core/animation/Animation.cpp

Issue 225073004: Oilpan: Completely move core/animations/ to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 /* 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 28 matching lines...) Expand all
39 #include "core/animation/CompositorAnimations.h" 39 #include "core/animation/CompositorAnimations.h"
40 #include "core/animation/DocumentTimeline.h" 40 #include "core/animation/DocumentTimeline.h"
41 #include "core/animation/Interpolation.h" 41 #include "core/animation/Interpolation.h"
42 #include "core/animation/KeyframeEffectModel.h" 42 #include "core/animation/KeyframeEffectModel.h"
43 #include "core/dom/Element.h" 43 #include "core/dom/Element.h"
44 #include "core/frame/UseCounter.h" 44 #include "core/frame/UseCounter.h"
45 #include "core/rendering/RenderLayer.h" 45 #include "core/rendering/RenderLayer.h"
46 46
47 namespace WebCore { 47 namespace WebCore {
48 48
49 PassRefPtr<Animation> Animation::create(Element* target, PassRefPtrWillBeRawPtr< AnimationEffect> effect, const Timing& timing, Priority priority, PassOwnPtr<Eve ntDelegate> eventDelegate) 49 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* target, PassRefPtrW illBeRawPtr<AnimationEffect> effect, const Timing& timing, Priority priority, Pa ssOwnPtr<EventDelegate> eventDelegate)
50 { 50 {
51 return adoptRef(new Animation(target, effect, timing, priority, eventDelegat e)); 51 return adoptRefWillBeNoop(new Animation(target, effect, timing, priority, ev entDelegate));
52 } 52 }
53 53
54 PassRefPtr<Animation> Animation::create(Element* element, PassRefPtrWillBeRawPtr <AnimationEffect> effect, const Dictionary& timingInputDictionary) 54 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, PassRefPtr WillBeRawPtr<AnimationEffect> effect, const Dictionary& timingInputDictionary)
55 { 55 {
56 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); 56 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
57 return create(element, effect, TimingInput::convert(timingInputDictionary)); 57 return create(element, effect, TimingInput::convert(timingInputDictionary));
58 } 58 }
59 PassRefPtr<Animation> Animation::create(Element* element, PassRefPtrWillBeRawPtr <AnimationEffect> effect, double duration) 59 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, PassRefPtr WillBeRawPtr<AnimationEffect> effect, double duration)
60 { 60 {
61 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); 61 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
62 return create(element, effect, TimingInput::convert(duration)); 62 return create(element, effect, TimingInput::convert(duration));
63 } 63 }
64 PassRefPtr<Animation> Animation::create(Element* element, PassRefPtrWillBeRawPtr <AnimationEffect> effect) 64 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, PassRefPtr WillBeRawPtr<AnimationEffect> effect)
65 { 65 {
66 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); 66 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
67 return create(element, effect, Timing()); 67 return create(element, effect, Timing());
68 } 68 }
69 PassRefPtr<Animation> Animation::create(Element* element, const Vector<Dictionar y>& keyframeDictionaryVector, const Dictionary& timingInputDictionary, Exception State& exceptionState) 69 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect or<Dictionary>& keyframeDictionaryVector, const Dictionary& timingInputDictionar y, ExceptionState& exceptionState)
70 { 70 {
71 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); 71 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
72 if (element) 72 if (element)
73 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectObjectTiming); 73 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectObjectTiming);
74 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), TimingInput::convert(timingInputDictionary)); 74 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), TimingInput::convert(timingInputDictionary));
75 } 75 }
76 PassRefPtr<Animation> Animation::create(Element* element, const Vector<Dictionar y>& keyframeDictionaryVector, double duration, ExceptionState& exceptionState) 76 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect or<Dictionary>& keyframeDictionaryVector, double duration, ExceptionState& excep tionState)
77 { 77 {
78 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); 78 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
79 if (element) 79 if (element)
80 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectDoubleTiming); 80 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectDoubleTiming);
81 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), TimingInput::convert(duration)); 81 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), TimingInput::convert(duration));
82 } 82 }
83 PassRefPtr<Animation> Animation::create(Element* element, const Vector<Dictionar y>& keyframeDictionaryVector, ExceptionState& exceptionState) 83 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect or<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState)
84 { 84 {
85 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); 85 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
86 if (element) 86 if (element)
87 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectNoTiming); 87 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectNoTiming);
88 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), Timing()); 88 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), Timing());
89 } 89 }
90 90
91 Animation::Animation(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> ef fect, const Timing& timing, Priority priority, PassOwnPtr<EventDelegate> eventDe legate) 91 Animation::Animation(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> ef fect, const Timing& timing, Priority priority, PassOwnPtr<EventDelegate> eventDe legate)
92 : TimedItem(timing, eventDelegate) 92 : TimedItem(timing, eventDelegate)
93 , m_target(target) 93 , m_target(target)
94 , m_effect(effect) 94 , m_effect(effect)
95 , m_sampledEffect(0) 95 , m_sampledEffect(nullptr)
96 , m_priority(priority) 96 , m_priority(priority)
97 { 97 {
98 if (m_target) 98 if (m_target)
99 m_target->ensureActiveAnimations().addAnimation(this); 99 m_target->ensureActiveAnimations().addAnimation(this);
100 } 100 }
101 101
102 Animation::~Animation() 102 Animation::~Animation()
103 { 103 {
104 if (m_target) 104 if (m_target)
105 m_target->activeAnimations()->notifyAnimationDestroyed(this); 105 m_target->activeAnimations()->notifyAnimationDestroyed(this);
106 } 106 }
107 107
108 void Animation::didAttach() 108 void Animation::attach(AnimationPlayer* player)
109 { 109 {
110 if (m_target) { 110 if (m_target) {
111 m_target->ensureActiveAnimations().addPlayer(player()); 111 m_target->ensureActiveAnimations().addPlayer(player);
112 m_target->setNeedsAnimationStyleRecalc(); 112 m_target->setNeedsAnimationStyleRecalc();
113 } 113 }
114 TimedItem::attach(player);
114 } 115 }
115 116
116 void Animation::willDetach() 117 void Animation::detach()
117 { 118 {
118 if (m_target) 119 if (m_target)
119 m_target->activeAnimations()->removePlayer(player()); 120 m_target->activeAnimations()->removePlayer(player());
120 if (m_sampledEffect) 121 if (m_sampledEffect)
121 clearEffects(); 122 clearEffects();
123 TimedItem::detach();
122 } 124 }
123 125
124 void Animation::specifiedTimingChanged() 126 void Animation::specifiedTimingChanged()
125 { 127 {
126 cancelAnimationOnCompositor(); 128 cancelAnimationOnCompositor();
127 if (player()) { 129 if (player()) {
128 // FIXME: Needs to consider groups when added. 130 // FIXME: Needs to consider groups when added.
129 ASSERT(player()->source() == this); 131 ASSERT(player()->source() == this);
130 player()->schedulePendingAnimationOnCompositor(); 132 player()->schedulePendingAnimationOnCompositor();
131 } 133 }
(...skipping 11 matching lines...) Expand all
143 if (!m_target || !m_effect) 145 if (!m_target || !m_effect)
144 return; 146 return;
145 147
146 double iteration = currentIteration(); 148 double iteration = currentIteration();
147 ASSERT(iteration >= 0); 149 ASSERT(iteration >= 0);
148 // FIXME: Handle iteration values which overflow int. 150 // FIXME: Handle iteration values which overflow int.
149 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > in terpolations = m_effect->sample(static_cast<int>(iteration), timeFraction(), ite rationDuration()); 151 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > in terpolations = m_effect->sample(static_cast<int>(iteration), timeFraction(), ite rationDuration());
150 if (m_sampledEffect) { 152 if (m_sampledEffect) {
151 m_sampledEffect->setInterpolations(interpolations.release()); 153 m_sampledEffect->setInterpolations(interpolations.release());
152 } else if (!interpolations->isEmpty()) { 154 } else if (!interpolations->isEmpty()) {
153 OwnPtr<SampledEffect> sampledEffect = SampledEffect::create(this, interp olations.release()); 155 OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create( this, interpolations.release());
154 m_sampledEffect = sampledEffect.get(); 156 m_sampledEffect = sampledEffect.get();
155 ensureAnimationStack(m_target).add(sampledEffect.release()); 157 ensureAnimationStack(m_target).add(sampledEffect.release());
156 } else { 158 } else {
157 return; 159 return;
158 } 160 }
159 161
160 m_target->setNeedsAnimationStyleRecalc(); 162 m_target->setNeedsAnimationStyleRecalc();
161 } 163 }
162 164
163 void Animation::clearEffects() 165 void Animation::clearEffects()
164 { 166 {
165 ASSERT(player()); 167 ASSERT(player());
166 ASSERT(m_sampledEffect); 168 ASSERT(m_sampledEffect);
167 169
168 m_sampledEffect->clear(); 170 m_sampledEffect->detach();
169 m_sampledEffect = 0; 171 m_sampledEffect = nullptr;
170 cancelAnimationOnCompositor(); 172 cancelAnimationOnCompositor();
171 m_target->setNeedsAnimationStyleRecalc(); 173 m_target->setNeedsAnimationStyleRecalc();
172 invalidate(); 174 invalidate();
173 } 175 }
174 176
175 void Animation::updateChildrenAndEffects() const 177 void Animation::updateChildrenAndEffects() const
176 { 178 {
177 if (!m_effect) 179 if (!m_effect)
178 return; 180 return;
179 if (isInEffect()) 181 if (isInEffect())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return std::numeric_limits<double>::infinity(); 220 return std::numeric_limits<double>::infinity();
219 default: 221 default:
220 ASSERT_NOT_REACHED(); 222 ASSERT_NOT_REACHED();
221 return std::numeric_limits<double>::infinity(); 223 return std::numeric_limits<double>::infinity();
222 } 224 }
223 } 225 }
224 226
225 void Animation::notifySampledEffectRemovedFromAnimationStack() 227 void Animation::notifySampledEffectRemovedFromAnimationStack()
226 { 228 {
227 ASSERT(m_sampledEffect); 229 ASSERT(m_sampledEffect);
228 m_sampledEffect = 0; 230 m_sampledEffect = nullptr;
229 } 231 }
230 232
231 void Animation::notifyElementDestroyed() 233 void Animation::notifyElementDestroyed()
232 { 234 {
233 // If our player is kept alive just by the sampledEffect, we might get our 235 // If our player is kept alive just by the sampledEffect, we might get our
234 // destructor called when we call SampledEffect::clear(), so we need to 236 // destructor called when we call SampledEffect::clear(), so we need to
235 // clear m_sampledEffect first. 237 // clear m_sampledEffect first.
236 m_target = 0; 238 m_target = 0;
237 clearEventDelegate(); 239 clearEventDelegate();
238 SampledEffect* sampledEffect = m_sampledEffect; 240 SampledEffect* sampledEffect = m_sampledEffect;
239 m_sampledEffect = 0; 241 m_sampledEffect = nullptr;
240 if (sampledEffect) 242 if (sampledEffect)
241 sampledEffect->clear(); 243 sampledEffect->detach();
242 } 244 }
243 245
244 bool Animation::isCandidateForAnimationOnCompositor() const 246 bool Animation::isCandidateForAnimationOnCompositor() const
245 { 247 {
246 if (!effect() || !m_target) 248 if (!effect() || !m_target)
247 return false; 249 return false;
248 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor (specifiedTiming(), *effect()); 250 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor (specifiedTiming(), *effect());
249 } 251 }
250 252
251 bool Animation::maybeStartAnimationOnCompositor(double startTime) 253 bool Animation::maybeStartAnimationOnCompositor(double startTime)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 295
294 void Animation::pauseAnimationForTestingOnCompositor(double pauseTime) 296 void Animation::pauseAnimationForTestingOnCompositor(double pauseTime)
295 { 297 {
296 ASSERT(hasActiveAnimationsOnCompositor()); 298 ASSERT(hasActiveAnimationsOnCompositor());
297 if (!m_target || !m_target->renderer()) 299 if (!m_target || !m_target->renderer())
298 return; 300 return;
299 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i) 301 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i)
300 CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(* m_target, m_compositorAnimationIds[i], pauseTime); 302 CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(* m_target, m_compositorAnimationIds[i], pauseTime);
301 } 303 }
302 304
305 void Animation::trace(Visitor* visitor)
306 {
307 visitor->trace(m_effect);
308 visitor->trace(m_sampledEffect);
309 TimedItem::trace(visitor);
310 }
311
303 } // namespace WebCore 312 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698