OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/animation/InterpolationEffect.h" | 6 #include "core/animation/InterpolationEffect.h" |
7 | 7 |
8 namespace blink { | 8 namespace blink { |
9 | 9 |
10 PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > In
terpolationEffect::getActiveInterpolations(double fraction, double iterationDura
tion) const | 10 void InterpolationEffect::getActiveInterpolations(double fraction, double iterat
ionDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolatio
n>>>& result) const |
11 { | 11 { |
| 12 if (!result) |
| 13 result = adoptPtrWillBeNoop(new WillBeHeapVector<RefPtrWillBeMember<Inte
rpolation> >()); |
12 | 14 |
13 WillBeHeapVector<RefPtrWillBeMember<Interpolation> >* result = new WillBeHea
pVector<RefPtrWillBeMember<Interpolation> >(); | 15 size_t existingSize = result->size(); |
| 16 size_t resultIndex = 0; |
14 | 17 |
15 for (size_t i = 0; i < m_interpolations.size(); ++i) { | 18 for (size_t i = 0; i < m_interpolations.size(); ++i) { |
16 const InterpolationRecord* record = m_interpolations[i].get(); | 19 const InterpolationRecord* record = m_interpolations[i].get(); |
17 if (fraction >= record->m_applyFrom && fraction < record->m_applyTo) { | 20 if (fraction >= record->m_applyFrom && fraction < record->m_applyTo) { |
18 RefPtrWillBeRawPtr<Interpolation> interpolation = record->m_interpol
ation; | 21 RefPtrWillBeRawPtr<Interpolation> interpolation = record->m_interpol
ation; |
19 double localFraction = (fraction - record->m_start) / (record->m_end
- record->m_start); | 22 double localFraction = (fraction - record->m_start) / (record->m_end
- record->m_start); |
20 if (record->m_easing) | 23 if (record->m_easing) |
21 localFraction = record->m_easing->evaluate(localFraction, accura
cyForDuration(iterationDuration)); | 24 localFraction = record->m_easing->evaluate(localFraction, accura
cyForDuration(iterationDuration)); |
22 interpolation->interpolate(0, localFraction); | 25 interpolation->interpolate(0, localFraction); |
23 result->append(interpolation); | 26 if (resultIndex < existingSize) |
| 27 (*result)[resultIndex++] = interpolation; |
| 28 else |
| 29 result->append(interpolation); |
24 } | 30 } |
25 } | 31 } |
26 | 32 if (resultIndex < existingSize) |
27 return adoptPtrWillBeNoop(result); | 33 result->shrink(resultIndex); |
28 } | 34 } |
29 | 35 |
30 void InterpolationEffect::InterpolationRecord::trace(Visitor* visitor) | 36 void InterpolationEffect::InterpolationRecord::trace(Visitor* visitor) |
31 { | 37 { |
32 visitor->trace(m_interpolation); | 38 visitor->trace(m_interpolation); |
33 } | 39 } |
34 | 40 |
35 void InterpolationEffect::trace(Visitor* visitor) | 41 void InterpolationEffect::trace(Visitor* visitor) |
36 { | 42 { |
37 #if ENABLE_OILPAN | 43 #if ENABLE_OILPAN |
38 visitor->trace(m_interpolations); | 44 visitor->trace(m_interpolations); |
39 #endif | 45 #endif |
40 } | 46 } |
41 | 47 |
42 } | 48 } |
OLD | NEW |