Chromium Code Reviews| 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..cec47e471ed89fa0ad1aa15819611aacfc827d8c |
| --- /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/InterpolationIsInvalid.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_isInvalid || m_isInvalid->checkChain(state); } |
|
Eric Willigers
2015/05/27 04:26:35
m_isInvalid && m_isInvalid->checkChain(state);
Pe
alancutter (OOO until 2018)
2015/05/27 08:27:48
Done.
|
| + virtual void interpolate(double fraction, AnimationValue& result) const = 0; |
| + DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_isInvalid); } |
| + protected: |
| + CachedConversion(PassRefPtrWillBeRawPtr<InterpolationIsInvalid> isInvalid) : m_isInvalid(isInvalid) { } |
| + RefPtrWillBeMember<InterpolationIsInvalid> m_isInvalid; |
| + }; |
| + |
| +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<InterpolationIsInvalid>& 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 |