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

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: More comprehensive non-negative length layout tests 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..4263933a12dd3f8fc7f93bf9cc43962151613d2b 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,42 @@ 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 == m_compositeEnd) {
+ if (m_compositeStart == AnimationEffect::CompositeReplace)
+ m_cachedUnderlyingFraction = 0;
+ else if (m_compositeStart == AnimationEffect::CompositeAdd)
+ m_cachedUnderlyingFraction = 1;
+ }
alancutter (OOO until 2018) 2015/02/12 05:55:45 Shouldn't this just be "if start == add: UF = 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 = blend(1.0, 0.0, fraction);
alancutter (OOO until 2018) 2015/02/12 05:55:45 Just use 1 - fraction.
+ else if (m_compositeStart == AnimationEffect::CompositeReplace && m_compositeEnd == AnimationEffect::CompositeAdd)
+ m_cachedUnderlyingFraction = blend(0.0, 1.0, fraction);
alancutter (OOO until 2018) 2015/02/12 05:55:45 Just use fraction.
}
}

Powered by Google App Engine
This is Rietveld 408576698