Chromium Code Reviews| 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, 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 Loading... | |
| 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 Loading... | |
| 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) | 227 DEFINE_TRACE(KeyframeEffectModelBase) |
|
sof
2015/09/02 13:02:12
Can just elide this one?
| |
| 228 { | 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); | 229 EffectModel::trace(visitor); |
| 235 } | 230 } |
| 236 | 231 |
| 237 Keyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, Pass RefPtr<TimingFunction> easing, EffectModel::CompositeOperation composite) | 232 Keyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, Pass RefPtr<TimingFunction> easing, EffectModel::CompositeOperation composite) |
| 238 : m_offset(offset) | 233 : m_offset(offset) |
| 239 , m_easing(easing) | 234 , m_easing(easing) |
| 240 , m_composite(composite) | 235 , m_composite(composite) |
| 241 { | 236 { |
| 242 } | 237 } |
| 243 | 238 |
| 244 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe(Pass OwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> keyframe) | 239 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe(Pass OwnPtr<Keyframe::PropertySpecificKeyframe> keyframe) |
| 245 { | 240 { |
| 246 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of fset()); | 241 ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->of fset()); |
| 247 m_keyframes.append(keyframe); | 242 m_keyframes.append(keyframe); |
| 248 } | 243 } |
| 249 | 244 |
| 250 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::removeRedundantKeyf rames() | 245 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::removeRedundantKeyf rames() |
| 251 { | 246 { |
| 252 // As an optimization, removes keyframes in the following categories, as | 247 // As an optimization, removes keyframes in the following categories, as |
| 253 // they will never be used by sample(). | 248 // they will never be used by sample(). |
| 254 // - End keyframes with the same offset as their neighbor | 249 // - End keyframes with the same offset as their neighbor |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 277 addedSyntheticKeyframe = true; | 272 addedSyntheticKeyframe = true; |
| 278 } | 273 } |
| 279 if (m_keyframes.last()->offset() != 1.0) { | 274 if (m_keyframes.last()->offset() != 1.0) { |
| 280 appendKeyframe(m_keyframes.last()->neutralKeyframe(1, easing)); | 275 appendKeyframe(m_keyframes.last()->neutralKeyframe(1, easing)); |
| 281 addedSyntheticKeyframe = true; | 276 addedSyntheticKeyframe = true; |
| 282 } | 277 } |
| 283 | 278 |
| 284 return addedSyntheticKeyframe; | 279 return addedSyntheticKeyframe; |
| 285 } | 280 } |
| 286 | 281 |
| 287 DEFINE_TRACE(KeyframeEffectModelBase::PropertySpecificKeyframeGroup) | |
| 288 { | |
| 289 #if ENABLE(OILPAN) | |
| 290 visitor->trace(m_keyframes); | |
| 291 #endif | |
| 292 } | |
| 293 | |
| 294 } // namespace | 282 } // namespace |
| OLD | NEW |