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

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

Issue 1276183004: Oilpan: Unship oilpan from temporary animation objects (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 void KeyframeEffectModelBase::setFrames(KeyframeVector& keyframes) 58 void KeyframeEffectModelBase::setFrames(KeyframeVector& keyframes)
59 { 59 {
60 // TODO(samli): Should also notify/invalidate the animation 60 // TODO(samli): Should also notify/invalidate the animation
61 m_keyframes = keyframes; 61 m_keyframes = keyframes;
62 m_keyframeGroups = nullptr; 62 m_keyframeGroups = nullptr;
63 m_interpolationEffect = nullptr; 63 m_interpolationEffect = nullptr;
64 } 64 }
65 65
66 void KeyframeEffectModelBase::sample(int iteration, double fraction, double iter ationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolat ion>>>& result) const 66 void KeyframeEffectModelBase::sample(int iteration, double fraction, double iter ationDuration, OwnPtr<Vector<RefPtr<Interpolation>>>& result) const
67 { 67 {
68 ASSERT(iteration >= 0); 68 ASSERT(iteration >= 0);
69 ASSERT(!isNull(fraction)); 69 ASSERT(!isNull(fraction));
70 ensureKeyframeGroups(); 70 ensureKeyframeGroups();
71 ensureInterpolationEffect(); 71 ensureInterpolationEffect();
72 72
73 return m_interpolationEffect->getActiveInterpolations(fraction, iterationDur ation, result); 73 return m_interpolationEffect->getActiveInterpolations(fraction, iterationDur ation, result);
74 } 74 }
75 75
76 void KeyframeEffectModelBase::forceConversionsToAnimatableValues(Element& elemen t, const ComputedStyle* baseStyle) 76 void KeyframeEffectModelBase::forceConversionsToAnimatableValues(Element& elemen t, const ComputedStyle* baseStyle)
77 { 77 {
78 ensureKeyframeGroups(); 78 ensureKeyframeGroups();
79 snapshotCompositableProperties(element, baseStyle); 79 snapshotCompositableProperties(element, baseStyle);
80 ensureInterpolationEffect(&element, baseStyle); 80 ensureInterpolationEffect(&element, baseStyle);
81 } 81 }
82 82
83 void KeyframeEffectModelBase::snapshotCompositableProperties(Element& element, c onst ComputedStyle* baseStyle) 83 void KeyframeEffectModelBase::snapshotCompositableProperties(Element& element, c onst ComputedStyle* baseStyle)
84 { 84 {
85 ensureKeyframeGroups(); 85 ensureKeyframeGroups();
86 for (CSSPropertyID id : CompositorAnimations::compositableProperties) { 86 for (CSSPropertyID id : CompositorAnimations::compositableProperties) {
87 PropertyHandle property = PropertyHandle(id); 87 PropertyHandle property = PropertyHandle(id);
88 if (!affects(property)) 88 if (!affects(property))
89 continue; 89 continue;
90 for (auto& keyframe : m_keyframeGroups->get(property)->m_keyframes) 90 for (auto& keyframe : m_keyframeGroups->get(property)->m_keyframes)
91 keyframe->populateAnimatableValue(id, element, baseStyle); 91 keyframe->populateAnimatableValue(id, element, baseStyle);
92 } 92 }
93 } 93 }
94 94
95 bool KeyframeEffectModelBase::updateNeutralKeyframeAnimatableValues(CSSPropertyI D property, PassRefPtrWillBeRawPtr<AnimatableValue> value) 95 bool KeyframeEffectModelBase::updateNeutralKeyframeAnimatableValues(CSSPropertyI D property, PassRefPtr<AnimatableValue> value)
96 { 96 {
97 ASSERT(CompositorAnimations::isCompositableProperty(property)); 97 ASSERT(CompositorAnimations::isCompositableProperty(property));
98 98
99 if (!value) 99 if (!value)
100 return false; 100 return false;
101 101
102 ensureKeyframeGroups(); 102 ensureKeyframeGroups();
103 auto& keyframes = m_keyframeGroups->get(PropertyHandle(property))->m_keyfram es; 103 auto& keyframes = m_keyframeGroups->get(PropertyHandle(property))->m_keyfram es;
104 ASSERT(keyframes.size() >= 2); 104 ASSERT(keyframes.size() >= 2);
105 105
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 || affects(PropertyHandle(CSSPropertyRotate)) 160 || affects(PropertyHandle(CSSPropertyRotate))
161 || affects(PropertyHandle(CSSPropertyScale)) 161 || affects(PropertyHandle(CSSPropertyScale))
162 || affects(PropertyHandle(CSSPropertyTranslate)); 162 || affects(PropertyHandle(CSSPropertyTranslate));
163 } 163 }
164 164
165 void KeyframeEffectModelBase::ensureKeyframeGroups() const 165 void KeyframeEffectModelBase::ensureKeyframeGroups() const
166 { 166 {
167 if (m_keyframeGroups) 167 if (m_keyframeGroups)
168 return; 168 return;
169 169
170 m_keyframeGroups = adoptPtrWillBeNoop(new KeyframeGroupMap); 170 m_keyframeGroups = adoptPtr(new KeyframeGroupMap);
171 for (const auto& keyframe : normalizedKeyframes(getFrames())) { 171 for (const auto& keyframe : normalizedKeyframes(getFrames())) {
172 for (const PropertyHandle& property : keyframe->properties()) { 172 for (const PropertyHandle& property : keyframe->properties()) {
173 if (property.isCSSProperty()) 173 if (property.isCSSProperty())
174 ASSERT_WITH_MESSAGE(!isShorthandProperty(property.cssProperty()) , "Web Animations: Encountered shorthand CSS property (%d) in normalized keyfram es.", property.cssProperty()); 174 ASSERT_WITH_MESSAGE(!isShorthandProperty(property.cssProperty()) , "Web Animations: Encountered shorthand CSS property (%d) in normalized keyfram es.", property.cssProperty());
175 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper ty); 175 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper ty);
176 PropertySpecificKeyframeGroup* group; 176 PropertySpecificKeyframeGroup* group;
177 if (groupIter == m_keyframeGroups->end()) 177 if (groupIter == m_keyframeGroups->end())
178 group = m_keyframeGroups->add(property, adoptPtrWillBeNoop(new P ropertySpecificKeyframeGroup)).storedValue->value.get(); 178 group = m_keyframeGroups->add(property, adoptPtr(new PropertySpe cificKeyframeGroup)).storedValue->value.get();
179 else 179 else
180 group = groupIter->value.get(); 180 group = groupIter->value.get();
181 181
182 group->appendKeyframe(keyframe->createPropertySpecificKeyframe(prope rty)); 182 group->appendKeyframe(keyframe->createPropertySpecificKeyframe(prope rty));
183 } 183 }
184 } 184 }
185 185
186 // Add synthetic keyframes. 186 // Add synthetic keyframes.
187 m_hasSyntheticKeyframes = false; 187 m_hasSyntheticKeyframes = false;
188 for (const auto& entry : *m_keyframeGroups) { 188 for (const auto& entry : *m_keyframeGroups) {
(...skipping 28 matching lines...) Expand all
217 ensureKeyframeGroups(); 217 ensureKeyframeGroups();
218 for (const auto& entry : *m_keyframeGroups) { 218 for (const auto& entry : *m_keyframeGroups) {
219 for (const auto& keyframe : entry.value->keyframes()) { 219 for (const auto& keyframe : entry.value->keyframes()) {
220 if (keyframe->composite() != EffectModel::CompositeReplace) 220 if (keyframe->composite() != EffectModel::CompositeReplace)
221 return false; 221 return false;
222 } 222 }
223 } 223 }
224 return true; 224 return true;
225 } 225 }
226 226
227 DEFINE_TRACE(KeyframeEffectModelBase)
228 {
229 visitor->trace(m_keyframes);
230 #if ENABLE(OILPAN)
231 visitor->trace(m_keyframeGroups);
232 #endif
233 visitor->trace(m_interpolationEffect);
234 EffectModel::trace(visitor);
235 }
236
237 Keyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, Pass RefPtr<TimingFunction> easing, EffectModel::CompositeOperation composite) 227 Keyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, Pass RefPtr<TimingFunction> easing, EffectModel::CompositeOperation composite)
238 : m_offset(offset) 228 : m_offset(offset)
239 , m_easing(easing) 229 , m_easing(easing)
240 , m_composite(composite) 230 , m_composite(composite)
241 { 231 {
242 } 232 }
243 233
244 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe(Pass OwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> keyframe) 234 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe(Pass OwnPtr<Keyframe::PropertySpecificKeyframe> keyframe)
245 { 235 {
246 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of fset()); 236 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of fset());
247 m_keyframes.append(keyframe); 237 m_keyframes.append(keyframe);
248 } 238 }
249 239
250 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::removeRedundantKeyf rames() 240 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::removeRedundantKeyf rames()
251 { 241 {
252 // As an optimization, removes keyframes in the following categories, as 242 // As an optimization, removes keyframes in the following categories, as
253 // they will never be used by sample(). 243 // they will never be used by sample().
254 // - End keyframes with the same offset as their neighbor 244 // - End keyframes with the same offset as their neighbor
(...skipping 22 matching lines...) Expand all
277 addedSyntheticKeyframe = true; 267 addedSyntheticKeyframe = true;
278 } 268 }
279 if (m_keyframes.last()->offset() != 1.0) { 269 if (m_keyframes.last()->offset() != 1.0) {
280 appendKeyframe(m_keyframes.last()->neutralKeyframe(1, easing)); 270 appendKeyframe(m_keyframes.last()->neutralKeyframe(1, easing));
281 addedSyntheticKeyframe = true; 271 addedSyntheticKeyframe = true;
282 } 272 }
283 273
284 return addedSyntheticKeyframe; 274 return addedSyntheticKeyframe;
285 } 275 }
286 276
287 DEFINE_TRACE(KeyframeEffectModelBase::PropertySpecificKeyframeGroup)
288 {
289 #if ENABLE(OILPAN)
290 visitor->trace(m_keyframes);
291 #endif
292 }
293
294 } // namespace 277 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698