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

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

Issue 177183007: Web Animations: Add InterpolableValue hierarchy. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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
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/InterpolableValue.h"
7
8 namespace WebCore {
9
10 PassOwnPtr<InterpolableValue> InterpolableNumber::interpolate(const Interpolable Value &to, const double progress) const
11 {
12 const InterpolableNumber* toNumber = toInterpolableNumber(&to);
13 if (!progress)
14 return create(m_value);
15 if (progress == 1)
16 return create(toNumber->m_value);
17 return create(m_value * (1 - progress) + toNumber->m_value * progress);
18 }
19
20 PassOwnPtr<InterpolableValue> InterpolableBool::interpolate(const InterpolableVa lue &to, const double progress) const
21 {
22 if (progress < 0.5) {
23 return clone();
24 }
25 return to.clone();
26 }
27
28 PassOwnPtr<InterpolableValue> InterpolableList::interpolate(const InterpolableVa lue &to, const double progress) const
29 {
30 const InterpolableList* toList = toInterpolableList(&to);
31 ASSERT(toList->m_size == m_size);
32
33 if (!progress) {
34 return create(*this);
35 }
36 if (progress == 1) {
37 return InterpolableList::create(*toList);
38 }
39
40 OwnPtr<InterpolableList> result = create(m_size);
41 for (size_t i = 0; i < m_size; i++) {
42 ASSERT(m_values.get()[i]);
43 ASSERT(toList->m_values.get()[i]);
44 result->set(i, m_values.get()[i]->interpolate(*(toList->m_values.get()[i ]), progress));
45 }
46 return result.release();
47 }
48
49 }
OLDNEW
« no previous file with comments | « Source/core/animation/InterpolableValue.h ('k') | Source/core/animation/InterpolableValueTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698