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

Unified Diff: Source/core/animation/InvalidatableStyleInterpolation.h

Issue 1153943003: Add foundation for removing AnimatableValues from StyleInterpolation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing header file Created 5 years, 7 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/InvalidatableStyleInterpolation.h
diff --git a/Source/core/animation/InvalidatableStyleInterpolation.h b/Source/core/animation/InvalidatableStyleInterpolation.h
new file mode 100644
index 0000000000000000000000000000000000000000..a4f19e86b86ebc24e9cd46d35fd1940eb63181a8
--- /dev/null
+++ b/Source/core/animation/InvalidatableStyleInterpolation.h
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef InvalidatableStyleInterpolation_h
+#define InvalidatableStyleInterpolation_h
+
+#include "core/animation/AnimationType.h"
+#include "core/animation/AnimationValue.h"
+#include "core/animation/InterpolationInvalidators.h"
+#include "core/animation/StyleInterpolation.h"
+
+namespace blink {
+
+// TODO(alancutter): This class will replace *StyleInterpolation, SVGInterpolation, Interpolation.
+// For now it needs to distinguish itself during the refactor and temporarily has an ugly name.
+// TODO(alancutter): Make this class generic for any animation environment so it can be reused for SVG animations.
+class CORE_EXPORT InvalidatableStyleInterpolation : public StyleInterpolation {
+public:
+ static PassRefPtrWillBeRawPtr<InvalidatableStyleInterpolation> create(
+ const Vector<const AnimationType*>& applicableTypes,
+ PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> startKeyframe,
+ PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> endKeyframe)
+ {
+ return adoptRefWillBeNoop(new InvalidatableStyleInterpolation(applicableTypes, startKeyframe, endKeyframe));
+ }
+
+ virtual void interpolate(int iteration, double fraction);
+ void validateCache(const StyleResolverState&) const;
+ virtual void apply(StyleResolverState&) const;
+
+ virtual bool isInvalidatableStyleInterpolation() const { return true; }
+
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ StyleInterpolation::trace(visitor);
+ visitor->trace(m_startKeyframe);
+ visitor->trace(m_endKeyframe);
+ visitor->trace(m_cachedConversion);
+ visitor->trace(m_cachedValue);
+ }
+
+ class CachedConversion : public NoBaseWillBeGarbageCollectedFinalized<CachedConversion> {
+ public:
+ virtual ~CachedConversion() { }
+ bool isInvalid(const StyleResolverState& state) const { return m_invalidators && m_invalidators->chainIsInvalid(state); }
+ virtual void interpolate(double fraction, AnimationValue& result) const = 0;
+ DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_invalidators); }
+ protected:
+ CachedConversion(PassRefPtrWillBeRawPtr<InterpolationInvalidators> isInvalid) : m_invalidators(isInvalid) { }
+ RefPtrWillBeMember<InterpolationInvalidators> m_invalidators;
+ };
+
+private:
+ InvalidatableStyleInterpolation(
+ const Vector<const AnimationType*>& applicableTypes,
+ PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> startKeyframe,
+ PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> endKeyframe);
+
+ bool maybeCachePairwiseConversion(const StyleResolverState*) const;
+ void cacheDefaultConversion(const StyleResolverState&) const;
+ AnimationValue convertSingleKeyframe(const StyleResolverState&, const CSSPropertySpecificKeyframe&, RefPtrWillBeRawPtr<InterpolationInvalidators>& resultIsInvalid) const;
+
+ const Vector<const AnimationType*>& m_applicableTypes;
+ const RefPtrWillBeMember<CSSPropertySpecificKeyframe> m_startKeyframe;
+ const RefPtrWillBeMember<CSSPropertySpecificKeyframe> m_endKeyframe;
+ double m_currentFraction;
+ mutable OwnPtrWillBeMember<CachedConversion> m_cachedConversion;
+ mutable AnimationValue m_cachedValue;
+};
+
+DEFINE_TYPE_CASTS(InvalidatableStyleInterpolation, Interpolation, value, value->isInvalidatableStyleInterpolation(), value.isInvalidatableStyleInterpolation());
+
+} // namespace blink
+
+#endif // InvalidatableStyleInterpolation_h

Powered by Google App Engine
This is Rietveld 408576698