| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/core/animation/Interpolation.h" | |
| 6 | |
| 7 namespace blink { | |
| 8 | |
| 9 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Interpolation); | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) | |
| 14 { | |
| 15 if (start->isNumber()) | |
| 16 return end->isNumber(); | |
| 17 if (start->isBool()) | |
| 18 return end->isBool(); | |
| 19 if (start->isAnimatableValue()) | |
| 20 return end->isAnimatableValue(); | |
| 21 if (!(start->isList() && end->isList())) | |
| 22 return false; | |
| 23 const InterpolableList* startList = toInterpolableList(start); | |
| 24 const InterpolableList* endList = toInterpolableList(end); | |
| 25 if (startList->length() != endList->length()) | |
| 26 return false; | |
| 27 for (size_t i = 0; i < startList->length(); ++i) { | |
| 28 if (!typesMatch(startList->get(i), endList->get(i))) | |
| 29 return false; | |
| 30 } | |
| 31 return true; | |
| 32 } | |
| 33 | |
| 34 } | |
| 35 | |
| 36 Interpolation::Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int
erpolableValue> end) | |
| 37 : m_start(start) | |
| 38 , m_end(end) | |
| 39 , m_cachedFraction(0) | |
| 40 , m_cachedIteration(0) | |
| 41 , m_cachedValue(m_start->clone()) | |
| 42 { | |
| 43 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); | |
| 44 } | |
| 45 | |
| 46 void Interpolation::interpolate(int iteration, double fraction) const | |
| 47 { | |
| 48 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { | |
| 49 m_cachedValue = m_start->interpolate(*m_end, fraction); | |
| 50 m_cachedIteration = iteration; | |
| 51 m_cachedFraction = fraction; | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 } | |
| OLD | NEW |