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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.back()->offset())) | 146 if (isNull(result.back()->offset())) |
147 result.back()->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.front()->setOffset(0); |
151 | 151 |
152 size_t lastIndex = 0; | 152 size_t lastIndex = 0; |
153 lastOffset = result.first()->offset(); | 153 lastOffset = result.front()->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) |
158 result[lastIndex + j]->setOffset( | 158 result[lastIndex + j]->setOffset( |
159 lastOffset + (offset - lastOffset) * j / (i - lastIndex)); | 159 lastOffset + (offset - lastOffset) * j / (i - lastIndex)); |
160 lastIndex = i; | 160 lastIndex = i; |
161 lastOffset = offset; | 161 lastOffset = offset; |
162 } | 162 } |
163 } | 163 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 DCHECK_GE(m_keyframes.size(), 2U); | 294 DCHECK_GE(m_keyframes.size(), 2U); |
295 } | 295 } |
296 | 296 |
297 bool KeyframeEffectModelBase::PropertySpecificKeyframeGroup:: | 297 bool KeyframeEffectModelBase::PropertySpecificKeyframeGroup:: |
298 addSyntheticKeyframeIfRequired( | 298 addSyntheticKeyframeIfRequired( |
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.front()->offset() != 0.0) { |
305 m_keyframes.insert(0, m_keyframes.first()->neutralKeyframe( | 305 m_keyframes.insert(0, m_keyframes.front()->neutralKeyframe( |
306 0, std::move(zeroOffsetEasing))); | 306 0, std::move(zeroOffsetEasing))); |
307 addedSyntheticKeyframe = true; | 307 addedSyntheticKeyframe = true; |
308 } | 308 } |
309 if (m_keyframes.back()->offset() != 1.0) { | 309 if (m_keyframes.back()->offset() != 1.0) { |
310 appendKeyframe(m_keyframes.back()->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 |