Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: sky/engine/core/animation/Interpolation.cpp

Issue 1229273004: Remove Animations and Transitions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « sky/engine/core/animation/Interpolation.h ('k') | sky/engine/core/animation/InterpolationEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698