| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 DCHECK_LE(offset, 1); | 136 DCHECK_LE(offset, 1); |
| 137 DCHECK_GE(offset, lastOffset); | 137 DCHECK_GE(offset, lastOffset); |
| 138 lastOffset = offset; | 138 lastOffset = offset; |
| 139 } | 139 } |
| 140 result.append(keyframe->clone()); | 140 result.append(keyframe->clone()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 if (result.isEmpty()) | 143 if (result.isEmpty()) |
| 144 return result; | 144 return result; |
| 145 | 145 |
| 146 if (isNull(result.last()->offset())) | 146 if (isNull(result.back()->offset())) |
| 147 result.last()->setOffset(1); | 147 result.back()->setOffset(1); |
| 148 | 148 |
| 149 if (result.size() > 1 && isNull(result[0]->offset())) | 149 if (result.size() > 1 && isNull(result[0]->offset())) |
| 150 result.first()->setOffset(0); | 150 result.first()->setOffset(0); |
| 151 | 151 |
| 152 size_t lastIndex = 0; | 152 size_t lastIndex = 0; |
| 153 lastOffset = result.first()->offset(); | 153 lastOffset = result.first()->offset(); |
| 154 for (size_t i = 1; i < result.size(); ++i) { | 154 for (size_t i = 1; i < result.size(); ++i) { |
| 155 double offset = result[i]->offset(); | 155 double offset = result[i]->offset(); |
| 156 if (!isNull(offset)) { | 156 if (!isNull(offset)) { |
| 157 for (size_t j = 1; j < i - lastIndex; ++j) | 157 for (size_t j = 1; j < i - lastIndex; ++j) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 double offset, | 265 double offset, |
| 266 PassRefPtr<TimingFunction> easing, | 266 PassRefPtr<TimingFunction> easing, |
| 267 EffectModel::CompositeOperation composite) | 267 EffectModel::CompositeOperation composite) |
| 268 : m_offset(offset), m_easing(easing), m_composite(composite) { | 268 : m_offset(offset), m_easing(easing), m_composite(composite) { |
| 269 DCHECK(!isNull(offset)); | 269 DCHECK(!isNull(offset)); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe( | 272 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe( |
| 273 PassRefPtr<Keyframe::PropertySpecificKeyframe> keyframe) { | 273 PassRefPtr<Keyframe::PropertySpecificKeyframe> keyframe) { |
| 274 DCHECK(m_keyframes.isEmpty() || | 274 DCHECK(m_keyframes.isEmpty() || |
| 275 m_keyframes.last()->offset() <= keyframe->offset()); | 275 m_keyframes.back()->offset() <= keyframe->offset()); |
| 276 m_keyframes.append(keyframe); | 276 m_keyframes.append(keyframe); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup:: | 279 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup:: |
| 280 removeRedundantKeyframes() { | 280 removeRedundantKeyframes() { |
| 281 // As an optimization, removes interior keyframes that have the same offset | 281 // As an optimization, removes interior keyframes that have the same offset |
| 282 // as both their neighbours, as they will never be used by sample(). | 282 // as both their neighbours, as they will never be used by sample(). |
| 283 // Note that synthetic keyframes must be added before this method is | 283 // Note that synthetic keyframes must be added before this method is |
| 284 // called. | 284 // called. |
| 285 DCHECK_GE(m_keyframes.size(), 2U); | 285 DCHECK_GE(m_keyframes.size(), 2U); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 299 PassRefPtr<TimingFunction> zeroOffsetEasing) { | 299 PassRefPtr<TimingFunction> zeroOffsetEasing) { |
| 300 DCHECK(!m_keyframes.isEmpty()); | 300 DCHECK(!m_keyframes.isEmpty()); |
| 301 | 301 |
| 302 bool addedSyntheticKeyframe = false; | 302 bool addedSyntheticKeyframe = false; |
| 303 | 303 |
| 304 if (m_keyframes.first()->offset() != 0.0) { | 304 if (m_keyframes.first()->offset() != 0.0) { |
| 305 m_keyframes.insert(0, m_keyframes.first()->neutralKeyframe( | 305 m_keyframes.insert(0, m_keyframes.first()->neutralKeyframe( |
| 306 0, std::move(zeroOffsetEasing))); | 306 0, std::move(zeroOffsetEasing))); |
| 307 addedSyntheticKeyframe = true; | 307 addedSyntheticKeyframe = true; |
| 308 } | 308 } |
| 309 if (m_keyframes.last()->offset() != 1.0) { | 309 if (m_keyframes.back()->offset() != 1.0) { |
| 310 appendKeyframe(m_keyframes.last()->neutralKeyframe(1, nullptr)); | 310 appendKeyframe(m_keyframes.back()->neutralKeyframe(1, nullptr)); |
| 311 addedSyntheticKeyframe = true; | 311 addedSyntheticKeyframe = true; |
| 312 } | 312 } |
| 313 | 313 |
| 314 return addedSyntheticKeyframe; | 314 return addedSyntheticKeyframe; |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace blink | 317 } // namespace blink |
| OLD | NEW |