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

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

Issue 143573004: [wip] interpolable value refactor. NOT FOR LANDING. Base URL: https://chromium.googlesource.com/chromium/blink.git@interpolationWrap
Patch Set: Created 6 years, 11 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
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.h ('k') | Source/core/animation/KeyframeEffectModelTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/KeyframeEffectModel.cpp
diff --git a/Source/core/animation/KeyframeEffectModel.cpp b/Source/core/animation/KeyframeEffectModel.cpp
index f3c0bd09ceaef2f68e845cdf58e49bbc32cfbbc9..d566939e1036c745d585d223d457b3c2ed88f24e 100644
--- a/Source/core/animation/KeyframeEffectModel.cpp
+++ b/Source/core/animation/KeyframeEffectModel.cpp
@@ -38,28 +38,6 @@ namespace {
using namespace WebCore;
-class ReplaceCompositableValue : public AnimationEffect::CompositableValue {
-public:
- static PassRefPtr<ReplaceCompositableValue> create(const AnimatableValue* value)
- {
- return adoptRef(new ReplaceCompositableValue(value));
- }
- virtual bool dependsOnUnderlyingValue() const
- {
- return false;
- }
- virtual PassRefPtr<AnimatableValue> compositeOnto(const AnimatableValue* underlyingValue) const
- {
- return PassRefPtr<AnimatableValue>(m_value);
- }
-private:
- ReplaceCompositableValue(const AnimatableValue* value)
- : m_value(const_cast<AnimatableValue*>(value))
- {
- }
- RefPtr<AnimatableValue> m_value;
-};
-
class AddCompositableValue : public AnimationEffect::CompositableValue {
public:
static PassRefPtr<AddCompositableValue> create(const AnimatableValue* value)
@@ -181,15 +159,14 @@ PropertySet KeyframeEffectModel::properties() const
return result;
}
-PassOwnPtr<AnimationEffect::CompositableValueList> KeyframeEffectModel::sample(int iteration, double fraction) const
+PassOwnPtr<Vector<RefPtr<Interpolation> > > KeyframeEffectModel::sample(int iteration, double fraction) const
{
ASSERT(iteration >= 0);
ASSERT(!isNull(fraction));
- const_cast<KeyframeEffectModel*>(this)->ensureKeyframeGroups();
- OwnPtr<CompositableValueList> map = adoptPtr(new CompositableValueList());
- for (KeyframeGroupMap::const_iterator iter = m_keyframeGroups->begin(); iter != m_keyframeGroups->end(); ++iter)
- map->append(std::make_pair(iter->key, iter->value->sample(iteration, fraction)));
- return map.release();
+ ensureKeyframeGroups();
+ ensureInterpolationEffect();
+
+ return m_interpolationEffect->getActiveInterpolations(fraction);
}
KeyframeEffectModel::KeyframeVector KeyframeEffectModel::normalizedKeyframes() const
@@ -247,11 +224,35 @@ void KeyframeEffectModel::ensureKeyframeGroups() const
}
}
+void KeyframeEffectModel::ensureInterpolationEffect() const
+{
+ if (m_interpolationEffect)
+ return;
+ m_interpolationEffect = InterpolationEffect::create();
+
+ for (KeyframeGroupMap::const_iterator iter = m_keyframeGroups->begin(); iter != m_keyframeGroups->end(); ++iter)
+ {
+ const PropertySpecificKeyframeVector& keyframes = iter->value->keyframes();
+ ASSERT(keyframes[0]->value()->isAnimatableValue());
+ const AnimatableValue* start;
+ const AnimatableValue* end = toAnimatableValue(keyframes[0]->value());
+ for (size_t i = 0; i < keyframes.size() - 1; i++) {
+ ASSERT(keyframes[i+1]->value()->isAnimatableValue());
+ start = end;
+ end = toAnimatableValue(keyframes[i+1]->value());
+ m_interpolationEffect->addInterpolation(
+ LegacyStyleInterpolation::create(
+ AnimatableValue::takeConstRef(start),
+ AnimatableValue::takeConstRef(end), iter->key),
+ keyframes[i]->offset(), keyframes[i+1]->offset());
+ }
+ }
+}
KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, const AnimatableValue* value, CompositeOperation composite)
: m_offset(offset)
, m_value(composite == AnimationEffect::CompositeReplace ?
- static_cast<PassRefPtr<CompositableValue> >(ReplaceCompositableValue::create(value)) :
+ AnimatableValue::takeConstRef(value) :
static_cast<PassRefPtr<CompositableValue> >(AddCompositableValue::create(value)))
{
}
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.h ('k') | Source/core/animation/KeyframeEffectModelTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698