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

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

Issue 204743002: Oilpan: Move AnimatableValue's hierarchy to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return properties; 84 return properties;
85 } 85 }
86 86
87 PassRefPtrWillBeRawPtr<Keyframe> Keyframe::cloneWithOffset(double offset) const 87 PassRefPtrWillBeRawPtr<Keyframe> Keyframe::cloneWithOffset(double offset) const
88 { 88 {
89 RefPtrWillBeRawPtr<Keyframe> theClone = clone(); 89 RefPtrWillBeRawPtr<Keyframe> theClone = clone();
90 theClone->setOffset(offset); 90 theClone->setOffset(offset);
91 return theClone.release(); 91 return theClone.release();
92 } 92 }
93 93
94 void Keyframe::trace(Visitor* visitor)
95 {
96 visitor->trace(m_propertyValues);
97 }
98
94 KeyframeEffectModel::KeyframeEffectModel(const KeyframeVector& keyframes) 99 KeyframeEffectModel::KeyframeEffectModel(const KeyframeVector& keyframes)
95 : m_keyframes(keyframes) 100 : m_keyframes(keyframes)
96 { 101 {
97 } 102 }
98 103
99 PropertySet KeyframeEffectModel::properties() const 104 PropertySet KeyframeEffectModel::properties() const
100 { 105 {
101 PropertySet result; 106 PropertySet result;
102 if (!m_keyframes.size()) { 107 if (!m_keyframes.size()) {
103 return result; 108 return result;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 for (PropertySet::const_iterator propertyIter = keyframeProperties.begin (); propertyIter != keyframeProperties.end(); ++propertyIter) { 204 for (PropertySet::const_iterator propertyIter = keyframeProperties.begin (); propertyIter != keyframeProperties.end(); ++propertyIter) {
200 CSSPropertyID property = *propertyIter; 205 CSSPropertyID property = *propertyIter;
201 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper ty); 206 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper ty);
202 PropertySpecificKeyframeGroup* group; 207 PropertySpecificKeyframeGroup* group;
203 if (groupIter == m_keyframeGroups->end()) 208 if (groupIter == m_keyframeGroups->end())
204 group = m_keyframeGroups->add(property, adoptPtr(new PropertySpe cificKeyframeGroup)).storedValue->value.get(); 209 group = m_keyframeGroups->add(property, adoptPtr(new PropertySpe cificKeyframeGroup)).storedValue->value.get();
205 else 210 else
206 group = groupIter->value.get(); 211 group = groupIter->value.get();
207 212
208 ASSERT(keyframe->composite() == AnimationEffect::CompositeReplace); 213 ASSERT(keyframe->composite() == AnimationEffect::CompositeReplace);
209 group->appendKeyframe(adoptPtr( 214 group->appendKeyframe(adoptPtrWillBeNoop(
210 new PropertySpecificKeyframe(keyframe->offset(), keyframe->easin g(), keyframe->propertyValue(property), keyframe->composite()))); 215 new PropertySpecificKeyframe(keyframe->offset(), keyframe->easin g(), keyframe->propertyValue(property), keyframe->composite())));
211 } 216 }
212 } 217 }
213 218
214 // Add synthetic keyframes. 219 // Add synthetic keyframes.
215 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_ keyframeGroups->end(); ++iter) { 220 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_ keyframeGroups->end(); ++iter) {
216 iter->value->addSyntheticKeyframeIfRequired(); 221 iter->value->addSyntheticKeyframeIfRequired();
217 iter->value->removeRedundantKeyframes(); 222 iter->value->removeRedundantKeyframes();
218 } 223 }
219 } 224 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 265 }
261 266
262 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, Composit eOperation composite) 267 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, Composit eOperation composite)
263 : m_offset(offset) 268 : m_offset(offset)
264 , m_easing(easing) 269 , m_easing(easing)
265 , m_composite(composite) 270 , m_composite(composite)
266 { 271 {
267 m_value = AnimatableValue::takeConstRef(value); 272 m_value = AnimatableValue::takeConstRef(value);
268 } 273 }
269 274
270 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, PassRefPtr<AnimatableValue> value, Com positeOperation composite) 275 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, PassRefPtrWillBeRawPtr<AnimatableValue > value, CompositeOperation composite)
271 : m_offset(offset) 276 : m_offset(offset)
272 , m_easing(easing) 277 , m_easing(easing)
273 , m_value(value) 278 , m_value(value)
274 , m_composite(composite) 279 , m_composite(composite)
275 { 280 {
276 ASSERT(!isNull(m_offset)); 281 ASSERT(!isNull(m_offset));
277 } 282 }
278 283
279 PassOwnPtr<KeyframeEffectModel::PropertySpecificKeyframe> KeyframeEffectModel::P ropertySpecificKeyframe::cloneWithOffset(double offset) const 284 PassOwnPtrWillBeRawPtr<KeyframeEffectModel::PropertySpecificKeyframe> KeyframeEf fectModel::PropertySpecificKeyframe::cloneWithOffset(double offset) const
280 { 285 {
281 return adoptPtr(new PropertySpecificKeyframe(offset, m_easing, m_value, m_co mposite)); 286 return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset, m_easing, m_v alue.get(), m_composite));
282 } 287 }
283 288
284 289
285 void KeyframeEffectModel::PropertySpecificKeyframeGroup::appendKeyframe(PassOwnP tr<PropertySpecificKeyframe> keyframe) 290 void KeyframeEffectModel::PropertySpecificKeyframeGroup::appendKeyframe(PassOwnP trWillBeRawPtr<PropertySpecificKeyframe> keyframe)
286 { 291 {
287 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of fset()); 292 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of fset());
288 m_keyframes.append(keyframe); 293 m_keyframes.append(keyframe);
289 } 294 }
290 295
291 void KeyframeEffectModel::PropertySpecificKeyframeGroup::removeRedundantKeyframe s() 296 void KeyframeEffectModel::PropertySpecificKeyframeGroup::removeRedundantKeyframe s()
292 { 297 {
293 // As an optimization, removes keyframes in the following categories, as 298 // As an optimization, removes keyframes in the following categories, as
294 // they will never be used by sample(). 299 // they will never be used by sample().
295 // - End keyframes with the same offset as their neighbor 300 // - End keyframes with the same offset as their neighbor
296 // - Interior keyframes with the same offset as both their neighbors 301 // - Interior keyframes with the same offset as both their neighbors
297 // Note that synthetic keyframes must be added before this method is 302 // Note that synthetic keyframes must be added before this method is
298 // called. 303 // called.
299 ASSERT(m_keyframes.size() >= 2); 304 ASSERT(m_keyframes.size() >= 2);
300 for (int i = m_keyframes.size() - 1; i >= 0; --i) { 305 for (int i = m_keyframes.size() - 1; i >= 0; --i) {
301 double offset = m_keyframes[i]->offset(); 306 double offset = m_keyframes[i]->offset();
302 bool hasSameOffsetAsPreviousNeighbor = !i || m_keyframes[i - 1]->offset( ) == offset; 307 bool hasSameOffsetAsPreviousNeighbor = !i || m_keyframes[i - 1]->offset( ) == offset;
303 bool hasSameOffsetAsNextNeighbor = i == static_cast<int>(m_keyframes.siz e() - 1) || m_keyframes[i + 1]->offset() == offset; 308 bool hasSameOffsetAsNextNeighbor = i == static_cast<int>(m_keyframes.siz e() - 1) || m_keyframes[i + 1]->offset() == offset;
304 if (hasSameOffsetAsPreviousNeighbor && hasSameOffsetAsNextNeighbor) 309 if (hasSameOffsetAsPreviousNeighbor && hasSameOffsetAsNextNeighbor)
305 m_keyframes.remove(i); 310 m_keyframes.remove(i);
306 } 311 }
307 ASSERT(m_keyframes.size() >= 2); 312 ASSERT(m_keyframes.size() >= 2);
308 } 313 }
309 314
310 void KeyframeEffectModel::PropertySpecificKeyframeGroup::addSyntheticKeyframeIfR equired() 315 void KeyframeEffectModel::PropertySpecificKeyframeGroup::addSyntheticKeyframeIfR equired()
311 { 316 {
312 ASSERT(!m_keyframes.isEmpty()); 317 ASSERT(!m_keyframes.isEmpty());
313 if (m_keyframes.first()->offset() != 0.0) 318 if (m_keyframes.first()->offset() != 0.0)
314 m_keyframes.insert(0, adoptPtr(new PropertySpecificKeyframe(0, nullptr, AnimatableValue::neutralValue(), CompositeAdd))); 319 m_keyframes.insert(0, adoptPtrWillBeNoop(new PropertySpecificKeyframe(0, nullptr, AnimatableValue::neutralValue(), CompositeAdd)));
315 if (m_keyframes.last()->offset() != 1.0) 320 if (m_keyframes.last()->offset() != 1.0)
316 appendKeyframe(adoptPtr(new PropertySpecificKeyframe(1, nullptr, Animata bleValue::neutralValue(), CompositeAdd))); 321 appendKeyframe(adoptPtrWillBeNoop(new PropertySpecificKeyframe(1, nullpt r, AnimatableValue::neutralValue(), CompositeAdd)));
317 } 322 }
318 323
319 void KeyframeEffectModel::trace(Visitor* visitor) 324 void KeyframeEffectModel::trace(Visitor* visitor)
320 { 325 {
321 visitor->trace(m_keyframes); 326 visitor->trace(m_keyframes);
322 } 327 }
323 328
324 } // namespace 329 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698