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

Side by Side Diff: Source/core/animation/Interpolation.cpp

Issue 182383011: Web Animations: Add Interpolation class. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@interpolableValue
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/core/animation/Interpolation.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h"
6 #include "core/animation/Interpolation.h"
7
8 namespace WebCore {
9
10 namespace {
11
12 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end)
13 {
14 if (start->isNumber())
15 return end->isNumber();
16 if (start->isBool())
17 return end->isBool();
18 if (!(start->isList() && end->isList()))
19 return false;
20 const InterpolableList* startList = toInterpolableList(start);
21 const InterpolableList* endList = toInterpolableList(end);
22 if (startList->length() != endList->length())
23 return false;
24 for (size_t i = 0; i < startList->length(); ++i) {
25 if (!typesMatch(startList->get(i), endList->get(i)))
26 return false;
27 }
28 return true;
29 }
30
31 }
32
33 Interpolation::Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int erpolableValue> end)
34 : m_start(start)
35 , m_end(end)
36 , m_cachedFraction(0)
37 , m_cachedValue(m_start->clone())
38 {
39 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get()));
40 }
41
42 void Interpolation::interpolate(double fraction) const
43 {
44 if (m_cachedFraction != fraction) {
45 m_cachedValue = m_start->interpolate(*m_end, fraction);
46 m_cachedFraction = fraction;
47 }
48 }
49
50 }
OLDNEW
« no previous file with comments | « Source/core/animation/Interpolation.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698