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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 PropertySet keyframeProperties = keyframe->properties(); | 198 PropertySet keyframeProperties = keyframe->properties(); |
| 199 for (PropertySet::const_iterator propertyIter = keyframeProperties.begin (); propertyIter != keyframeProperties.end(); ++propertyIter) { | 199 for (PropertySet::const_iterator propertyIter = keyframeProperties.begin (); propertyIter != keyframeProperties.end(); ++propertyIter) { |
| 200 CSSPropertyID property = *propertyIter; | 200 CSSPropertyID property = *propertyIter; |
| 201 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper ty); | 201 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper ty); |
| 202 PropertySpecificKeyframeGroup* group; | 202 PropertySpecificKeyframeGroup* group; |
| 203 if (groupIter == m_keyframeGroups->end()) | 203 if (groupIter == m_keyframeGroups->end()) |
| 204 group = m_keyframeGroups->add(property, adoptPtr(new PropertySpe cificKeyframeGroup)).storedValue->value.get(); | 204 group = m_keyframeGroups->add(property, adoptPtr(new PropertySpe cificKeyframeGroup)).storedValue->value.get(); |
| 205 else | 205 else |
| 206 group = groupIter->value.get(); | 206 group = groupIter->value.get(); |
| 207 | 207 |
| 208 ASSERT(keyframe->composite() == AnimationEffect::CompositeReplace); | |
| 208 group->appendKeyframe(adoptPtr( | 209 group->appendKeyframe(adoptPtr( |
| 209 new PropertySpecificKeyframe(keyframe->offset(), keyframe->easin g(), keyframe->propertyValue(property), keyframe->composite()))); | 210 new PropertySpecificKeyframe(keyframe->offset(), keyframe->easin g(), keyframe->propertyValue(property), keyframe->composite()))); |
| 210 } | 211 } |
| 211 } | 212 } |
| 212 | 213 |
| 213 // Add synthetic keyframes. | 214 // Add synthetic keyframes. |
| 214 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_ keyframeGroups->end(); ++iter) { | 215 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_ keyframeGroups->end(); ++iter) { |
| 215 iter->value->addSyntheticKeyframeIfRequired(); | 216 iter->value->addSyntheticKeyframeIfRequired(); |
| 216 iter->value->removeRedundantKeyframes(); | 217 iter->value->removeRedundantKeyframes(); |
| 217 } | 218 } |
| 218 } | 219 } |
| 219 | 220 |
| 220 void KeyframeEffectModel::ensureInterpolationEffect() const | 221 void KeyframeEffectModel::ensureInterpolationEffect() const |
| 221 { | 222 { |
| 222 if (m_interpolationEffect) | 223 if (m_interpolationEffect) |
| 223 return; | 224 return; |
| 224 m_interpolationEffect = InterpolationEffect::create(); | 225 m_interpolationEffect = InterpolationEffect::create(); |
| 225 | 226 |
| 226 for (KeyframeGroupMap::const_iterator iter = m_keyframeGroups->begin(); iter != m_keyframeGroups->end(); ++iter) { | 227 for (KeyframeGroupMap::const_iterator iter = m_keyframeGroups->begin(); iter != m_keyframeGroups->end(); ++iter) { |
| 227 const PropertySpecificKeyframeVector& keyframes = iter->value->keyframes (); | 228 const PropertySpecificKeyframeVector& keyframes = iter->value->keyframes (); |
| 228 const AnimatableValue* start; | 229 const AnimatableValue* start; |
| 229 const AnimatableValue* end = keyframes[0]->value(); | 230 const AnimatableValue* end = keyframes[0]->value(); |
|
shans
2014/03/19 09:06:20
Assert that end is CompositeReplace
| |
| 230 for (size_t i = 0; i < keyframes.size() - 1; i++) { | 231 for (size_t i = 0; i < keyframes.size() - 1; i++) { |
| 231 start = end; | 232 start = end; |
| 232 end = keyframes[i + 1]->value(); | 233 end = keyframes[i + 1]->value(); |
|
shans
2014/03/19 09:06:20
Assert that end is CompositeReplace
| |
| 233 double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limit s<double>::infinity()); | 234 double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limit s<double>::infinity()); |
| 234 double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<dou ble>::infinity() : keyframes[i + 1]->offset(); | 235 double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<dou ble>::infinity() : keyframes[i + 1]->offset(); |
| 235 if (applyTo == 1) | 236 if (applyTo == 1) |
| 236 applyTo = std::numeric_limits<double>::infinity(); | 237 applyTo = std::numeric_limits<double>::infinity(); |
| 237 m_interpolationEffect->addInterpolation( | 238 m_interpolationEffect->addInterpolation( |
| 238 LegacyStyleInterpolation::create( | 239 LegacyStyleInterpolation::create( |
| 239 AnimatableValue::takeConstRef(start), | 240 AnimatableValue::takeConstRef(start), |
| 240 AnimatableValue::takeConstRef(end), iter->key), | 241 AnimatableValue::takeConstRef(end), iter->key), |
| 241 keyframes[i]->easing(), keyframes[i]->offset(), keyframes[i + 1] ->offset(), applyFrom, applyTo); | 242 keyframes[i]->easing(), keyframes[i]->offset(), keyframes[i + 1] ->offset(), applyFrom, applyTo); |
| 242 } | 243 } |
| 243 } | 244 } |
| 244 } | 245 } |
| 245 | 246 |
| 246 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, Composit eOperation composite) | 247 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, Composit eOperation composite) |
| 247 : m_offset(offset) | 248 : m_offset(offset) |
| 248 , m_easing(easing) | 249 , m_easing(easing) |
| 249 { | 250 { |
| 250 ASSERT(composite == AnimationEffect::CompositeReplace); | |
| 251 m_value = AnimatableValue::takeConstRef(value); | 251 m_value = AnimatableValue::takeConstRef(value); |
|
shans
2014/03/19 09:06:20
Store composite in an m_composite member variable
| |
| 252 } | 252 } |
| 253 | 253 |
| 254 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, PassRefPtr<AnimatableValue> value) | 254 KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double o ffset, PassRefPtr<TimingFunction> easing, PassRefPtr<AnimatableValue> value) |
| 255 : m_offset(offset) | 255 : m_offset(offset) |
| 256 , m_easing(easing) | 256 , m_easing(easing) |
| 257 , m_value(value) | 257 , m_value(value) |
| 258 { | 258 { |
| 259 ASSERT(!isNull(m_offset)); | 259 ASSERT(!isNull(m_offset)); |
| 260 } | 260 } |
| 261 | 261 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 286 bool hasSameOffsetAsNextNeighbor = i == static_cast<int>(m_keyframes.siz e() - 1) || m_keyframes[i + 1]->offset() == offset; | 286 bool hasSameOffsetAsNextNeighbor = i == static_cast<int>(m_keyframes.siz e() - 1) || m_keyframes[i + 1]->offset() == offset; |
| 287 if (hasSameOffsetAsPreviousNeighbor && hasSameOffsetAsNextNeighbor) | 287 if (hasSameOffsetAsPreviousNeighbor && hasSameOffsetAsNextNeighbor) |
| 288 m_keyframes.remove(i); | 288 m_keyframes.remove(i); |
| 289 } | 289 } |
| 290 ASSERT(m_keyframes.size() >= 2); | 290 ASSERT(m_keyframes.size() >= 2); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void KeyframeEffectModel::PropertySpecificKeyframeGroup::addSyntheticKeyframeIfR equired() | 293 void KeyframeEffectModel::PropertySpecificKeyframeGroup::addSyntheticKeyframeIfR equired() |
| 294 { | 294 { |
| 295 ASSERT(!m_keyframes.isEmpty()); | 295 ASSERT(!m_keyframes.isEmpty()); |
| 296 double offset = m_keyframes.first()->offset(); | 296 if (m_keyframes.first()->offset() != 0.0) |
| 297 bool allOffsetsEqual = true; | 297 m_keyframes.insert(0, adoptPtr(new PropertySpecificKeyframe(0, nullptr, AnimatableValue::neutralValue(), CompositeAdd))); |
| 298 for (PropertySpecificKeyframeVector::const_iterator iter = m_keyframes.begin () + 1; iter != m_keyframes.end(); ++iter) { | 298 if (m_keyframes.last()->offset() != 1.0) |
| 299 if ((*iter)->offset() != offset) { | 299 appendKeyframe(adoptPtr(new PropertySpecificKeyframe(1, nullptr, Animata bleValue::neutralValue(), CompositeAdd))); |
| 300 allOffsetsEqual = false; | |
| 301 break; | |
| 302 } | |
| 303 } | |
| 304 if (!allOffsetsEqual) | |
| 305 return; | |
| 306 | |
| 307 if (!offset) | |
| 308 appendKeyframe(m_keyframes.first()->cloneWithOffset(1.0)); | |
| 309 else | |
| 310 m_keyframes.insert(0, adoptPtr(new PropertySpecificKeyframe(0.0, nullptr , AnimatableValue::neutralValue(), CompositeAdd))); | |
| 311 } | 300 } |
| 312 | 301 |
| 313 void KeyframeEffectModel::trace(Visitor* visitor) | 302 void KeyframeEffectModel::trace(Visitor* visitor) |
| 314 { | 303 { |
| 315 visitor->trace(m_keyframes); | 304 visitor->trace(m_keyframes); |
| 316 } | 305 } |
| 317 | 306 |
| 318 } // namespace | 307 } // namespace |
| OLD | NEW |