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

Unified Diff: Source/core/animation/InterpolableValue.cpp

Issue 238313003: Web Animations API: Reuse cached InterpolableValue during interpolation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/InterpolableValue.h ('k') | Source/core/animation/Interpolation.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/InterpolableValue.cpp
diff --git a/Source/core/animation/InterpolableValue.cpp b/Source/core/animation/InterpolableValue.cpp
index 67bcfb8aa68320cd7388f64b4fff11ce474abfe9..ed84e275a5f2e89e129256a2eed5f202252404a4 100644
--- a/Source/core/animation/InterpolableValue.cpp
+++ b/Source/core/animation/InterpolableValue.cpp
@@ -4,48 +4,43 @@
#include "config.h"
#include "core/animation/InterpolableValue.h"
+#include "platform/animation/AnimationUtilities.h"
namespace blink {
DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue);
-PassOwnPtrWillBeRawPtr<InterpolableValue> InterpolableNumber::interpolate(const InterpolableValue &to, const double progress) const
+void InterpolableNumber::assignInterpolation(const InterpolableValue& from, const InterpolableValue& to, const double progress)
{
+ const InterpolableNumber& fromNumber = toInterpolableNumber(from);
const InterpolableNumber& toNumber = toInterpolableNumber(to);
- if (!progress)
- return create(m_value);
- if (progress == 1)
- return create(toNumber.m_value);
- return create(m_value * (1 - progress) + toNumber.m_value * progress);
+ if (progress == 0)
+ m_value = fromNumber.m_value;
+ else if (progress == 1)
+ m_value = toNumber.m_value;
+ else
+ m_value = blend(fromNumber.m_value, toNumber.m_value, progress);
}
-PassOwnPtrWillBeRawPtr<InterpolableValue> InterpolableBool::interpolate(const InterpolableValue &to, const double progress) const
+void InterpolableBool::assignInterpolation(const InterpolableValue& from, const InterpolableValue& to, const double progress)
{
- if (progress < 0.5) {
- return clone();
- }
- return to.clone();
+ const InterpolableBool& fromBool = toInterpolableBool(from);
+ const InterpolableBool& toBool = toInterpolableBool(to);
+ if (progress < 0.5)
+ m_value = fromBool.m_value;
+ else
+ m_value = toBool.m_value;
}
-PassOwnPtrWillBeRawPtr<InterpolableValue> InterpolableList::interpolate(const InterpolableValue &to, const double progress) const
+void InterpolableList::assignInterpolation(const InterpolableValue& from, const InterpolableValue& to, const double progress)
{
+ const InterpolableList& fromList = toInterpolableList(from);
const InterpolableList& toList = toInterpolableList(to);
+ ASSERT(fromList.m_size == m_size);
ASSERT(toList.m_size == m_size);
- if (!progress) {
- return create(*this);
- }
- if (progress == 1) {
- return InterpolableList::create(toList);
- }
-
- OwnPtrWillBeRawPtr<InterpolableList> result = create(m_size);
- for (size_t i = 0; i < m_size; i++) {
- ASSERT(m_values[i]);
- ASSERT(toList.m_values[i]);
- result->set(i, m_values[i]->interpolate(*(toList.m_values[i]), progress));
- }
- return result.release();
+ for (size_t i = 0; i < m_size; ++i)
+ m_values.at(i)->assignInterpolation(*fromList.m_values.at(i), *toList.m_values.at(i), progress);
}
void InterpolableList::trace(Visitor* visitor)
@@ -56,14 +51,16 @@ void InterpolableList::trace(Visitor* visitor)
InterpolableValue::trace(visitor);
}
-PassOwnPtrWillBeRawPtr<InterpolableValue> InterpolableAnimatableValue::interpolate(const InterpolableValue &other, const double percentage) const
+void InterpolableAnimatableValue::assignInterpolation(const InterpolableValue& from, const InterpolableValue& to, const double progress)
{
- const InterpolableAnimatableValue& otherValue = toInterpolableAnimatableValue(other);
- if (!percentage)
- return create(m_value);
- if (percentage == 1)
- return create(otherValue.m_value);
- return create(AnimatableValue::interpolate(m_value.get(), otherValue.m_value.get(), percentage));
+ const InterpolableAnimatableValue& fromValue = toInterpolableAnimatableValue(from);
+ const InterpolableAnimatableValue& toValue = toInterpolableAnimatableValue(to);
+ if (progress == 0)
+ m_value = fromValue.m_value;
+ else if (progress == 1)
+ m_value = toValue.m_value;
+ else
+ m_value = AnimatableValue::interpolate(fromValue.m_value.get(), toValue.m_value.get(), progress);
}
void InterpolableAnimatableValue::trace(Visitor* visitor)
« no previous file with comments | « Source/core/animation/InterpolableValue.h ('k') | Source/core/animation/Interpolation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698