| 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/Interpolation.h" | 6 #include "core/animation/Interpolation.h" |
| 7 | 7 |
| 8 namespace blink { | 8 namespace blink { |
| 9 | 9 |
| 10 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Interpolation); | |
| 11 | |
| 12 namespace { | 10 namespace { |
| 13 | 11 |
| 14 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) | 12 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) |
| 15 { | 13 { |
| 16 if (start->isNumber()) | 14 if (start->isNumber()) |
| 17 return end->isNumber(); | 15 return end->isNumber(); |
| 18 if (start->isBool()) | 16 if (start->isBool()) |
| 19 return end->isBool(); | 17 return end->isBool(); |
| 20 if (start->isAnimatableValue()) | 18 if (start->isAnimatableValue()) |
| 21 return end->isAnimatableValue(); | 19 return end->isAnimatableValue(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 Interpolation::Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa
ssOwnPtrWillBeRawPtr<InterpolableValue> end) | 35 Interpolation::Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa
ssOwnPtrWillBeRawPtr<InterpolableValue> end) |
| 38 : m_start(start) | 36 : m_start(start) |
| 39 , m_end(end) | 37 , m_end(end) |
| 40 , m_cachedFraction(0) | 38 , m_cachedFraction(0) |
| 41 , m_cachedIteration(0) | 39 , m_cachedIteration(0) |
| 42 , m_cachedValue(m_start->clone()) | 40 , m_cachedValue(m_start->clone()) |
| 43 { | 41 { |
| 44 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); | 42 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); |
| 45 } | 43 } |
| 46 | 44 |
| 45 Interpolation::~Interpolation() |
| 46 { |
| 47 } |
| 48 |
| 47 void Interpolation::interpolate(int iteration, double fraction) const | 49 void Interpolation::interpolate(int iteration, double fraction) const |
| 48 { | 50 { |
| 49 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { | 51 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { |
| 50 m_start->interpolate(*m_end, fraction, *m_cachedValue); | 52 m_start->interpolate(*m_end, fraction, *m_cachedValue); |
| 51 m_cachedIteration = iteration; | 53 m_cachedIteration = iteration; |
| 52 m_cachedFraction = fraction; | 54 m_cachedFraction = fraction; |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 | 57 |
| 56 void Interpolation::trace(Visitor* visitor) | 58 void Interpolation::trace(Visitor* visitor) |
| 57 { | 59 { |
| 58 visitor->trace(m_start); | 60 visitor->trace(m_start); |
| 59 visitor->trace(m_end); | 61 visitor->trace(m_end); |
| 60 visitor->trace(m_cachedValue); | 62 visitor->trace(m_cachedValue); |
| 61 } | 63 } |
| 62 | 64 |
| 63 } | 65 } |
| OLD | NEW |