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

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

Issue 863863004: Implemented additive animations for length (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed AnimationStackTest Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/animation/Interpolation.cpp
diff --git a/Source/core/animation/Interpolation.cpp b/Source/core/animation/Interpolation.cpp
index b1aaee7cc40da8ffb9c617dc4173d0b7b1fba886..5ebc9dcac7ca5dfa324e51f94c14890d434075e1 100644
--- a/Source/core/animation/Interpolation.cpp
+++ b/Source/core/animation/Interpolation.cpp
@@ -5,6 +5,8 @@
#include "config.h"
#include "core/animation/Interpolation.h"
+#include "platform/animation/AnimationUtilities.h"
+
namespace blink {
namespace {
@@ -35,9 +37,12 @@ bool typesMatch(const InterpolableValue* start, const InterpolableValue* end)
Interpolation::Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end)
: m_start(start)
, m_end(end)
+ , m_compositeStart(AnimationEffect::CompositeReplace)
+ , m_compositeEnd(AnimationEffect::CompositeReplace)
, m_cachedFraction(0)
, m_cachedIteration(0)
, m_cachedValue(m_start->clone())
+ , m_cachedUnderlyingFraction(0)
{
RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get()));
}
@@ -46,12 +51,38 @@ Interpolation::~Interpolation()
{
}
+Interpolation::Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end,
+ AnimationEffect::CompositeOperation compositeStart, AnimationEffect::CompositeOperation compositeEnd)
+ : m_start(start)
+ , m_end(end)
+ , m_compositeStart(compositeStart)
+ , m_compositeEnd(compositeEnd)
+ , m_cachedFraction(0)
+ , m_cachedIteration(0)
+ , m_cachedValue(m_start->clone())
+ , m_cachedUnderlyingFraction(0)
+{
+ RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get()));
+
+ if (m_compositeStart == AnimationEffect::CompositeAdd)
+ m_cachedUnderlyingFraction = 1;
+}
+
void Interpolation::interpolate(int iteration, double fraction) const
{
if (m_cachedFraction != fraction || m_cachedIteration != iteration) {
m_start->interpolate(*m_end, fraction, *m_cachedValue);
m_cachedIteration = iteration;
m_cachedFraction = fraction;
+
+ if (m_compositeStart == AnimationEffect::CompositeReplace && m_compositeEnd == AnimationEffect::CompositeReplace)
+ m_cachedUnderlyingFraction = 0;
+ else if (m_compositeStart == AnimationEffect::CompositeAdd && m_compositeEnd == AnimationEffect::CompositeAdd)
+ m_cachedUnderlyingFraction = 1;
+ else if (m_compositeStart == AnimationEffect::CompositeAdd && m_compositeEnd == AnimationEffect::CompositeReplace)
+ m_cachedUnderlyingFraction = 1 - fraction;
+ else if (m_compositeStart == AnimationEffect::CompositeReplace && m_compositeEnd == AnimationEffect::CompositeAdd)
+ m_cachedUnderlyingFraction = fraction;
}
}

Powered by Google App Engine
This is Rietveld 408576698