OLD | NEW |
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 Loading... |
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, HeapVector<Member<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, 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 return result; | 154 return result; |
155 } | 155 } |
156 | 156 |
157 | 157 |
158 void KeyframeEffectModelBase::ensureKeyframeGroups() const | 158 void KeyframeEffectModelBase::ensureKeyframeGroups() const |
159 { | 159 { |
160 if (m_keyframeGroups) | 160 if (m_keyframeGroups) |
161 return; | 161 return; |
162 | 162 |
163 m_keyframeGroups = adoptPtrWillBeNoop(new KeyframeGroupMap); | 163 m_keyframeGroups = new KeyframeGroupMap; |
164 for (const auto& keyframe : normalizedKeyframes(getFrames())) { | 164 for (const auto& keyframe : normalizedKeyframes(getFrames())) { |
165 for (const PropertyHandle& property : keyframe->properties()) { | 165 for (const PropertyHandle& property : keyframe->properties()) { |
166 if (property.isCSSProperty()) | 166 if (property.isCSSProperty()) |
167 ASSERT_WITH_MESSAGE(!isShorthandProperty(property.cssProperty())
, "Web Animations: Encountered shorthand CSS property (%d) in normalized keyfram
es.", property.cssProperty()); | 167 ASSERT_WITH_MESSAGE(!isShorthandProperty(property.cssProperty())
, "Web Animations: Encountered shorthand CSS property (%d) in normalized keyfram
es.", property.cssProperty()); |
168 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper
ty); | 168 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper
ty); |
169 PropertySpecificKeyframeGroup* group; | 169 PropertySpecificKeyframeGroup* group; |
170 if (groupIter == m_keyframeGroups->end()) | 170 if (groupIter == m_keyframeGroups->end()) |
171 group = m_keyframeGroups->add(property, adoptPtrWillBeNoop(new P
ropertySpecificKeyframeGroup)).storedValue->value.get(); | 171 group = m_keyframeGroups->add(property, new PropertySpecificKeyf
rameGroup).storedValue->value.get(); |
172 else | 172 else |
173 group = groupIter->value.get(); | 173 group = groupIter->value.get(); |
174 | 174 |
175 group->appendKeyframe(keyframe->createPropertySpecificKeyframe(prope
rty)); | 175 group->appendKeyframe(keyframe->createPropertySpecificKeyframe(prope
rty)); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 // Add synthetic keyframes. | 179 // Add synthetic keyframes. |
180 m_hasSyntheticKeyframes = false; | 180 m_hasSyntheticKeyframes = false; |
181 for (const auto& entry : *m_keyframeGroups) { | 181 for (const auto& entry : *m_keyframeGroups) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 if (keyframe->composite() != EffectModel::CompositeReplace) | 213 if (keyframe->composite() != EffectModel::CompositeReplace) |
214 return false; | 214 return false; |
215 } | 215 } |
216 } | 216 } |
217 return true; | 217 return true; |
218 } | 218 } |
219 | 219 |
220 DEFINE_TRACE(KeyframeEffectModelBase) | 220 DEFINE_TRACE(KeyframeEffectModelBase) |
221 { | 221 { |
222 visitor->trace(m_keyframes); | 222 visitor->trace(m_keyframes); |
223 #if ENABLE(OILPAN) | |
224 visitor->trace(m_keyframeGroups); | 223 visitor->trace(m_keyframeGroups); |
225 #endif | |
226 visitor->trace(m_interpolationEffect); | 224 visitor->trace(m_interpolationEffect); |
227 EffectModel::trace(visitor); | 225 EffectModel::trace(visitor); |
228 } | 226 } |
229 | 227 |
230 Keyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, Pass
RefPtr<TimingFunction> easing, EffectModel::CompositeOperation composite) | 228 Keyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, Pass
RefPtr<TimingFunction> easing, EffectModel::CompositeOperation composite) |
231 : m_offset(offset) | 229 : m_offset(offset) |
232 , m_easing(easing) | 230 , m_easing(easing) |
233 , m_composite(composite) | 231 , m_composite(composite) |
234 { | 232 { |
235 } | 233 } |
236 | 234 |
237 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe(Pass
OwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> keyframe) | 235 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe(Keyf
rame::PropertySpecificKeyframe* keyframe) |
238 { | 236 { |
239 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of
fset()); | 237 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of
fset()); |
240 m_keyframes.append(keyframe); | 238 m_keyframes.append(keyframe); |
241 } | 239 } |
242 | 240 |
243 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::removeRedundantKeyf
rames() | 241 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::removeRedundantKeyf
rames() |
244 { | 242 { |
245 // As an optimization, removes keyframes in the following categories, as | 243 // As an optimization, removes keyframes in the following categories, as |
246 // they will never be used by sample(). | 244 // they will never be used by sample(). |
247 // - End keyframes with the same offset as their neighbor | 245 // - End keyframes with the same offset as their neighbor |
(...skipping 24 matching lines...) Expand all Loading... |
272 if (m_keyframes.last()->offset() != 1.0) { | 270 if (m_keyframes.last()->offset() != 1.0) { |
273 appendKeyframe(m_keyframes.last()->neutralKeyframe(1, easing)); | 271 appendKeyframe(m_keyframes.last()->neutralKeyframe(1, easing)); |
274 addedSyntheticKeyframe = true; | 272 addedSyntheticKeyframe = true; |
275 } | 273 } |
276 | 274 |
277 return addedSyntheticKeyframe; | 275 return addedSyntheticKeyframe; |
278 } | 276 } |
279 | 277 |
280 DEFINE_TRACE(KeyframeEffectModelBase::PropertySpecificKeyframeGroup) | 278 DEFINE_TRACE(KeyframeEffectModelBase::PropertySpecificKeyframeGroup) |
281 { | 279 { |
282 #if ENABLE(OILPAN) | |
283 visitor->trace(m_keyframes); | 280 visitor->trace(m_keyframes); |
284 #endif | |
285 } | 281 } |
286 | 282 |
287 } // namespace | 283 } // namespace |
OLD | NEW |