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 15 matching lines...) Expand all Loading... | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/animation/KeyframeEffectModel.h" | 32 #include "core/animation/KeyframeEffectModel.h" |
| 33 | 33 |
| 34 #include "core/StylePropertyShorthand.h" | 34 #include "core/StylePropertyShorthand.h" |
| 35 #include "core/animation/AnimationNode.h" | 35 #include "core/animation/AnimationNode.h" |
| 36 #include "core/animation/CompositorAnimations.h" | |
| 37 #include "core/animation/css/CSSAnimatableValueFactory.h" | |
| 38 #include "core/animation/css/CSSPropertyEquality.h" | |
| 39 #include "core/css/resolver/StyleResolver.h" | |
| 36 #include "platform/animation/AnimationUtilities.h" | 40 #include "platform/animation/AnimationUtilities.h" |
| 37 #include "platform/geometry/FloatBox.h" | 41 #include "platform/geometry/FloatBox.h" |
| 38 #include "platform/transforms/TransformationMatrix.h" | 42 #include "platform/transforms/TransformationMatrix.h" |
| 39 #include "wtf/text/StringHash.h" | 43 #include "wtf/text/StringHash.h" |
| 40 | 44 |
| 41 namespace blink { | 45 namespace blink { |
| 42 | 46 |
| 43 PropertySet KeyframeEffectModelBase::properties() const | 47 PropertySet KeyframeEffectModelBase::properties() const |
| 44 { | 48 { |
| 45 PropertySet result; | 49 PropertySet result; |
| 46 for (const auto& keyframe : m_keyframes) { | 50 for (const auto& keyframe : m_keyframes) { |
| 47 for (const auto& property : keyframe->properties()) | 51 for (const auto& property : keyframe->properties()) |
| 48 result.add(property); | 52 result.add(property); |
| 49 } | 53 } |
| 50 return result; | 54 return result; |
| 51 } | 55 } |
| 52 | 56 |
| 53 void KeyframeEffectModelBase::sample(int iteration, double fraction, double iter ationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolat ion>>>& result) const | 57 void KeyframeEffectModelBase::sample(int iteration, double fraction, double iter ationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolat ion>>>& result) const |
| 54 { | 58 { |
| 55 ASSERT(iteration >= 0); | 59 ASSERT(iteration >= 0); |
| 56 ASSERT(!isNull(fraction)); | 60 ASSERT(!isNull(fraction)); |
| 57 ensureKeyframeGroups(); | 61 ensureKeyframeGroups(); |
| 58 ensureInterpolationEffect(); | 62 ensureInterpolationEffect(); |
| 59 | 63 |
| 60 return m_interpolationEffect->getActiveInterpolations(fraction, iterationDur ation, result); | 64 return m_interpolationEffect->getActiveInterpolations(fraction, iterationDur ation, result); |
| 61 } | 65 } |
| 62 | 66 |
| 67 void KeyframeEffectModelBase::snapshotCompositableProperties(const Element* elem ent, const RenderStyle& style) | |
| 68 { | |
| 69 ensureKeyframeGroups(); | |
| 70 for (CSSPropertyID property : CompositorAnimations::CompositableProperties) { | |
| 71 if (affects(property)) { | |
| 72 for (auto& keyframe : m_keyframeGroups->get(property)->m_keyframes) { | |
| 73 auto& stringKeyframe = toStringPropertySpecificKeyframe(*keyfram e); | |
| 74 if (!stringKeyframe.value()) { | |
| 75 stringKeyframe.setAnimatableValue(CSSAnimatableValueFactory: :create(property, style)); | |
| 76 } else { | |
| 77 ASSERT(!stringKeyframe.getAnimatableValue()); | |
| 78 stringKeyframe.setAnimatableValue(StyleResolver::createAnima tableValueSnapshot(const_cast<Element&>(*element), property, *stringKeyframe.val ue())); | |
| 79 } | |
| 80 } | |
| 81 } | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 void KeyframeEffectModelBase::updateNeutralKeyframeAnimatableValues(CSSPropertyI D property, PassRefPtrWillBeRawPtr<AnimatableValue> value) | |
| 86 { | |
| 87 ASSERT(CompositorAnimations::isCompositableProperty(property)); | |
| 88 | |
| 89 if (!value) | |
| 90 return; | |
| 91 | |
| 92 ensureKeyframeGroups(); | |
| 93 auto& keyframes = m_keyframeGroups->get(property)->m_keyframes; | |
| 94 | |
| 95 ASSERT(keyframes.size() >= 2); | |
| 96 if (!toStringPropertySpecificKeyframe(*keyframes[0]).value()) | |
|
dstockwell
2015/02/05 23:04:52
ASSERT that start or end is a neutral keyframe
FIX
shend
2015/02/06 03:16:25
Done.
| |
| 97 toStringPropertySpecificKeyframe(*keyframes[0]).setAnimatableValue(value ); | |
| 98 if (!toStringPropertySpecificKeyframe(*keyframes[keyframes.size() - 1]).valu e()) | |
| 99 toStringPropertySpecificKeyframe(*keyframes[keyframes.size() - 1]).setAn imatableValue(value); | |
| 100 } | |
| 101 | |
| 102 void KeyframeEffectModelBase::setNeutralKeyframeEasings(RefPtrWillBeRawPtr<Timin gFunction> easing) | |
| 103 { | |
| 104 ensureKeyframeGroups(); | |
| 105 for (const auto& entry : *m_keyframeGroups) { | |
| 106 auto& keyframes = entry.value->keyframes(); | |
| 107 | |
| 108 ASSERT(keyframes.size() >= 2); | |
| 109 if (!toStringPropertySpecificKeyframe(*keyframes[0]).value()) | |
| 110 toStringPropertySpecificKeyframe(*keyframes[0]).setEasing(easing); | |
| 111 if (!toStringPropertySpecificKeyframe(*keyframes[keyframes.size() - 1]). value()) | |
| 112 toStringPropertySpecificKeyframe(*keyframes[keyframes.size() - 1]).s etEasing(easing); | |
| 113 } | |
| 114 } | |
| 115 | |
| 63 KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyfr ames(const KeyframeVector& keyframes) | 116 KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyfr ames(const KeyframeVector& keyframes) |
| 64 { | 117 { |
| 65 double lastOffset = 0; | 118 double lastOffset = 0; |
| 66 KeyframeVector result; | 119 KeyframeVector result; |
| 67 result.reserveCapacity(keyframes.size()); | 120 result.reserveCapacity(keyframes.size()); |
| 68 | 121 |
| 69 for (const auto& keyframe : keyframes) { | 122 for (const auto& keyframe : keyframes) { |
| 70 double offset = keyframe->offset(); | 123 double offset = keyframe->offset(); |
| 71 if (!isNull(offset)) { | 124 if (!isNull(offset)) { |
| 72 ASSERT(offset >= 0); | 125 ASSERT(offset >= 0); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 } | 186 } |
| 134 | 187 |
| 135 void KeyframeEffectModelBase::ensureInterpolationEffect(Element* element) const | 188 void KeyframeEffectModelBase::ensureInterpolationEffect(Element* element) const |
| 136 { | 189 { |
| 137 if (m_interpolationEffect) | 190 if (m_interpolationEffect) |
| 138 return; | 191 return; |
| 139 m_interpolationEffect = InterpolationEffect::create(); | 192 m_interpolationEffect = InterpolationEffect::create(); |
| 140 | 193 |
| 141 for (const auto& entry : *m_keyframeGroups) { | 194 for (const auto& entry : *m_keyframeGroups) { |
| 142 const PropertySpecificKeyframeVector& keyframes = entry.value->keyframes (); | 195 const PropertySpecificKeyframeVector& keyframes = entry.value->keyframes (); |
| 143 ASSERT(keyframes[0]->composite() == AnimationEffect::CompositeReplace); | 196 ASSERT(keyframes[0]->composite() == AnimationEffect::CompositeReplace || keyframes[0]->composite() == AnimationEffect::CompositeAdd); |
| 144 for (size_t i = 0; i < keyframes.size() - 1; i++) { | 197 for (size_t i = 0; i < keyframes.size() - 1; i++) { |
| 145 ASSERT(keyframes[i + 1]->composite() == AnimationEffect::CompositeRe place); | 198 ASSERT(keyframes[i + 1]->composite() == AnimationEffect::CompositeRe place || keyframes[i + 1]->composite() == AnimationEffect::CompositeAdd); |
| 146 double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limit s<double>::infinity()); | 199 double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limit s<double>::infinity()); |
| 147 double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<dou ble>::infinity() : keyframes[i + 1]->offset(); | 200 double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<dou ble>::infinity() : keyframes[i + 1]->offset(); |
| 148 if (applyTo == 1) | 201 if (applyTo == 1) |
| 149 applyTo = std::numeric_limits<double>::infinity(); | 202 applyTo = std::numeric_limits<double>::infinity(); |
| 150 | 203 |
| 151 m_interpolationEffect->addInterpolationsFromKeyframes(entry.key, ele ment, *keyframes[i], *keyframes[i + 1], applyFrom, applyTo); | 204 m_interpolationEffect->addInterpolationsFromKeyframes(entry.key, ele ment, *keyframes[i], *keyframes[i + 1], applyFrom, applyTo); |
| 152 } | 205 } |
| 153 } | 206 } |
| 154 } | 207 } |
| 155 | 208 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 } | 279 } |
| 227 | 280 |
| 228 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::trace(Visitor* visi tor) | 281 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::trace(Visitor* visi tor) |
| 229 { | 282 { |
| 230 #if ENABLE(OILPAN) | 283 #if ENABLE(OILPAN) |
| 231 visitor->trace(m_keyframes); | 284 visitor->trace(m_keyframes); |
| 232 #endif | 285 #endif |
| 233 } | 286 } |
| 234 | 287 |
| 235 } // namespace | 288 } // namespace |
| OLD | NEW |