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

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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 189 }
185 } 190 }
186 return result; 191 return result;
187 } 192 }
188 193
189 void KeyframeEffectModel::ensureKeyframeGroups() const 194 void KeyframeEffectModel::ensureKeyframeGroups() const
190 { 195 {
191 if (m_keyframeGroups) 196 if (m_keyframeGroups)
192 return; 197 return;
193 198
194 m_keyframeGroups = adoptPtr(new KeyframeGroupMap); 199 m_keyframeGroups = adoptPtrWillBeNoop(new KeyframeGroupMap);
195 const KeyframeVector keyframes = normalizedKeyframes(getFrames()); 200 const KeyframeVector keyframes = normalizedKeyframes(getFrames());
196 for (KeyframeVector::const_iterator keyframeIter = keyframes.begin(); keyfra meIter != keyframes.end(); ++keyframeIter) { 201 for (KeyframeVector::const_iterator keyframeIter = keyframes.begin(); keyfra meIter != keyframes.end(); ++keyframeIter) {
197 const Keyframe* keyframe = keyframeIter->get(); 202 const Keyframe* keyframe = keyframeIter->get();
198 PropertySet keyframeProperties = keyframe->properties(); 203 PropertySet keyframeProperties = keyframe->properties();
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, adoptPtrWillBeNoop(new P ropertySpecificKeyframeGroup)).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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_ keyframeGroups->end(); ++iter) { 257 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_ keyframeGroups->end(); ++iter) {
253 const PropertySpecificKeyframeVector& keyframeVector = iter->value->keyf rames(); 258 const PropertySpecificKeyframeVector& keyframeVector = iter->value->keyf rames();
254 for (size_t i = 0; i < keyframeVector.size(); ++i) { 259 for (size_t i = 0; i < keyframeVector.size(); ++i) {
255 if (keyframeVector[i]->composite() != AnimationEffect::CompositeRepl ace) 260 if (keyframeVector[i]->composite() != AnimationEffect::CompositeRepl ace)
256 return false; 261 return false;
257 } 262 }
258 } 263 }
259 return true; 264 return true;
260 } 265 }
261 266
267 void KeyframeEffectModel::trace(Visitor* visitor)
268 {
269 visitor->trace(m_keyframes);
270 #if ENABLE_OILPAN
271 visitor->trace(m_keyframeGroups);
272 #endif
273 }
274
262 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, Composit eOperation composite) 275 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, Composit eOperation composite)
263 : m_offset(offset) 276 : m_offset(offset)
264 , m_easing(easing) 277 , m_easing(easing)
265 , m_composite(composite) 278 , m_composite(composite)
266 { 279 {
267 m_value = AnimatableValue::takeConstRef(value); 280 m_value = AnimatableValue::takeConstRef(value);
268 } 281 }
269 282
270 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, PassRefPtr<AnimatableValue> value, Com positeOperation composite) 283 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, PassRefPtrWillBeRawPtr<AnimatableValue > value, CompositeOperation composite)
271 : m_offset(offset) 284 : m_offset(offset)
272 , m_easing(easing) 285 , m_easing(easing)
273 , m_value(value) 286 , m_value(value)
274 , m_composite(composite) 287 , m_composite(composite)
275 { 288 {
276 ASSERT(!isNull(m_offset)); 289 ASSERT(!isNull(m_offset));
277 } 290 }
278 291
279 PassOwnPtr<KeyframeEffectModel::PropertySpecificKeyframe> KeyframeEffectModel::P ropertySpecificKeyframe::cloneWithOffset(double offset) const 292 PassOwnPtrWillBeRawPtr<KeyframeEffectModel::PropertySpecificKeyframe> KeyframeEf fectModel::PropertySpecificKeyframe::cloneWithOffset(double offset) const
280 { 293 {
281 return adoptPtr(new PropertySpecificKeyframe(offset, m_easing, m_value, m_co mposite)); 294 return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset, m_easing, m_v alue.get(), m_composite));
282 } 295 }
283 296
297 void KeyframeEffectModel::PropertySpecificKeyframe::trace(Visitor* visitor)
298 {
299 visitor->trace(m_value);
300 }
284 301
285 void KeyframeEffectModel::PropertySpecificKeyframeGroup::appendKeyframe(PassOwnP tr<PropertySpecificKeyframe> keyframe) 302 void KeyframeEffectModel::PropertySpecificKeyframeGroup::appendKeyframe(PassOwnP trWillBeRawPtr<PropertySpecificKeyframe> keyframe)
286 { 303 {
287 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of fset()); 304 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of fset());
288 m_keyframes.append(keyframe); 305 m_keyframes.append(keyframe);
289 } 306 }
290 307
291 void KeyframeEffectModel::PropertySpecificKeyframeGroup::removeRedundantKeyframe s() 308 void KeyframeEffectModel::PropertySpecificKeyframeGroup::removeRedundantKeyframe s()
292 { 309 {
293 // As an optimization, removes keyframes in the following categories, as 310 // As an optimization, removes keyframes in the following categories, as
294 // they will never be used by sample(). 311 // they will never be used by sample().
295 // - End keyframes with the same offset as their neighbor 312 // - End keyframes with the same offset as their neighbor
296 // - Interior keyframes with the same offset as both their neighbors 313 // - Interior keyframes with the same offset as both their neighbors
297 // Note that synthetic keyframes must be added before this method is 314 // Note that synthetic keyframes must be added before this method is
298 // called. 315 // called.
299 ASSERT(m_keyframes.size() >= 2); 316 ASSERT(m_keyframes.size() >= 2);
300 for (int i = m_keyframes.size() - 1; i >= 0; --i) { 317 for (int i = m_keyframes.size() - 1; i >= 0; --i) {
301 double offset = m_keyframes[i]->offset(); 318 double offset = m_keyframes[i]->offset();
302 bool hasSameOffsetAsPreviousNeighbor = !i || m_keyframes[i - 1]->offset( ) == offset; 319 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; 320 bool hasSameOffsetAsNextNeighbor = i == static_cast<int>(m_keyframes.siz e() - 1) || m_keyframes[i + 1]->offset() == offset;
304 if (hasSameOffsetAsPreviousNeighbor && hasSameOffsetAsNextNeighbor) 321 if (hasSameOffsetAsPreviousNeighbor && hasSameOffsetAsNextNeighbor)
305 m_keyframes.remove(i); 322 m_keyframes.remove(i);
306 } 323 }
307 ASSERT(m_keyframes.size() >= 2); 324 ASSERT(m_keyframes.size() >= 2);
308 } 325 }
309 326
310 void KeyframeEffectModel::PropertySpecificKeyframeGroup::addSyntheticKeyframeIfR equired() 327 void KeyframeEffectModel::PropertySpecificKeyframeGroup::addSyntheticKeyframeIfR equired()
311 { 328 {
312 ASSERT(!m_keyframes.isEmpty()); 329 ASSERT(!m_keyframes.isEmpty());
313 if (m_keyframes.first()->offset() != 0.0) 330 if (m_keyframes.first()->offset() != 0.0)
314 m_keyframes.insert(0, adoptPtr(new PropertySpecificKeyframe(0, nullptr, AnimatableValue::neutralValue(), CompositeAdd))); 331 m_keyframes.insert(0, adoptPtrWillBeNoop(new PropertySpecificKeyframe(0, nullptr, AnimatableValue::neutralValue(), CompositeAdd)));
315 if (m_keyframes.last()->offset() != 1.0) 332 if (m_keyframes.last()->offset() != 1.0)
316 appendKeyframe(adoptPtr(new PropertySpecificKeyframe(1, nullptr, Animata bleValue::neutralValue(), CompositeAdd))); 333 appendKeyframe(adoptPtrWillBeNoop(new PropertySpecificKeyframe(1, nullpt r, AnimatableValue::neutralValue(), CompositeAdd)));
317 } 334 }
318 335
319 void KeyframeEffectModel::trace(Visitor* visitor) 336 void KeyframeEffectModel::PropertySpecificKeyframeGroup::trace(Visitor* visitor)
320 { 337 {
338 #if ENABLE_OILPAN
321 visitor->trace(m_keyframes); 339 visitor->trace(m_keyframes);
340 #endif
322 } 341 }
323 342
324 } // namespace 343 } // namespace
OLDNEW
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.h ('k') | Source/core/animation/KeyframeEffectModelTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698