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

Side by Side Diff: sky/engine/core/animation/InterpolableValue.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/InterpolableValue.h"
6
7 namespace blink {
8
9 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue);
10
11 PassOwnPtr<InterpolableValue> InterpolableNumber::interpolate(const Interpolable Value &to, const double progress) const
12 {
13 const InterpolableNumber& toNumber = toInterpolableNumber(to);
14 if (!progress)
15 return create(m_value);
16 if (progress == 1)
17 return create(toNumber.m_value);
18 return create(m_value * (1 - progress) + toNumber.m_value * progress);
19 }
20
21 PassOwnPtr<InterpolableValue> InterpolableBool::interpolate(const InterpolableVa lue &to, const double progress) const
22 {
23 if (progress < 0.5) {
24 return clone();
25 }
26 return to.clone();
27 }
28
29 PassOwnPtr<InterpolableValue> InterpolableList::interpolate(const InterpolableVa lue &to, const double progress) const
30 {
31 const InterpolableList& toList = toInterpolableList(to);
32 ASSERT(toList.m_size == m_size);
33
34 if (!progress) {
35 return create(*this);
36 }
37 if (progress == 1) {
38 return InterpolableList::create(toList);
39 }
40
41 OwnPtr<InterpolableList> result = create(m_size);
42 for (size_t i = 0; i < m_size; i++) {
43 ASSERT(m_values[i]);
44 ASSERT(toList.m_values[i]);
45 result->set(i, m_values[i]->interpolate(*(toList.m_values[i]), progress) );
46 }
47 return result.release();
48 }
49
50 PassOwnPtr<InterpolableValue> InterpolableAnimatableValue::interpolate(const Int erpolableValue &other, const double percentage) const
51 {
52 const InterpolableAnimatableValue& otherValue = toInterpolableAnimatableValu e(other);
53 if (!percentage)
54 return create(m_value);
55 if (percentage == 1)
56 return create(otherValue.m_value);
57 return create(AnimatableValue::interpolate(m_value.get(), otherValue.m_value .get(), percentage));
58 }
59
60 }
OLDNEW
« no previous file with comments | « sky/engine/core/animation/InterpolableValue.h ('k') | sky/engine/core/animation/InterpolableValueTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698