OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef InvalidatableStyleInterpolation_h | 5 #ifndef InvalidatableStyleInterpolation_h |
6 #define InvalidatableStyleInterpolation_h | 6 #define InvalidatableStyleInterpolation_h |
7 | 7 |
8 #include "core/animation/InterpolationType.h" | 8 #include "core/animation/InterpolationType.h" |
9 #include "core/animation/InterpolationValue.h" | 9 #include "core/animation/InterpolationValue.h" |
10 #include "core/animation/PrimitiveInterpolation.h" | 10 #include "core/animation/PrimitiveInterpolation.h" |
11 #include "core/animation/StyleInterpolation.h" | 11 #include "core/animation/StyleInterpolation.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 // TODO(alancutter): This class will replace *StyleInterpolation, SVGInterpolati
on, Interpolation. | 15 // TODO(alancutter): This class will replace *StyleInterpolation, SVGInterpolati
on, Interpolation. |
16 // For now it needs to distinguish itself during the refactor and temporarily ha
s an ugly name. | 16 // For now it needs to distinguish itself during the refactor and temporarily ha
s an ugly name. |
17 // TODO(alancutter): Make this class generic for any animation environment so it
can be reused for SVG animations. | 17 class CORE_EXPORT InvalidatableStyleInterpolation : public Interpolation { |
18 class CORE_EXPORT InvalidatableStyleInterpolation : public StyleInterpolation { | |
19 public: | 18 public: |
20 static PassRefPtr<InvalidatableStyleInterpolation> create( | 19 static PassRefPtr<InvalidatableStyleInterpolation> create( |
21 const Vector<const InterpolationType*>& InterpolationTypes, | 20 const Vector<const InterpolationType*>& InterpolationTypes, |
22 const CSSPropertySpecificKeyframe& startKeyframe, | 21 const PropertySpecificKeyframe& startKeyframe, |
23 const CSSPropertySpecificKeyframe& endKeyframe) | 22 const PropertySpecificKeyframe& endKeyframe) |
24 { | 23 { |
25 return adoptRef(new InvalidatableStyleInterpolation(InterpolationTypes,
startKeyframe, endKeyframe)); | 24 return adoptRef(new InvalidatableStyleInterpolation(InterpolationTypes,
startKeyframe, endKeyframe)); |
26 } | 25 } |
27 | 26 |
| 27 PropertyHandle property() const final { return m_interpolationTypes.first()-
>property(); } |
28 virtual void interpolate(int iteration, double fraction); | 28 virtual void interpolate(int iteration, double fraction); |
29 bool dependsOnUnderlyingValue() const; | 29 bool dependsOnUnderlyingValue() const; |
30 virtual void apply(StyleResolverState&) const { ASSERT_NOT_REACHED(); } | 30 virtual void apply(InterpolationEnvironment&) const { ASSERT_NOT_REACHED();
} |
31 static void applyStack(const ActiveInterpolations&, StyleResolverState&); | 31 static void applyStack(const ActiveInterpolations&, InterpolationEnvironment
&); |
32 | 32 |
33 virtual bool isInvalidatableStyleInterpolation() const { return true; } | 33 virtual bool isInvalidatableStyleInterpolation() const { return true; } |
34 | 34 |
35 private: | 35 private: |
36 InvalidatableStyleInterpolation( | 36 InvalidatableStyleInterpolation( |
37 const Vector<const InterpolationType*>& interpolationTypes, | 37 const Vector<const InterpolationType*>& interpolationTypes, |
38 const CSSPropertySpecificKeyframe& startKeyframe, | 38 const PropertySpecificKeyframe& startKeyframe, |
39 const CSSPropertySpecificKeyframe& endKeyframe) | 39 const PropertySpecificKeyframe& endKeyframe) |
40 : StyleInterpolation(nullptr, nullptr, interpolationTypes.first()->prope
rty()) | 40 : Interpolation(nullptr, nullptr) |
41 , m_interpolationTypes(interpolationTypes) | 41 , m_interpolationTypes(interpolationTypes) |
42 , m_startKeyframe(&startKeyframe) | 42 , m_startKeyframe(&startKeyframe) |
43 , m_endKeyframe(&endKeyframe) | 43 , m_endKeyframe(&endKeyframe) |
44 , m_currentFraction(std::numeric_limits<double>::quiet_NaN()) | 44 , m_currentFraction(std::numeric_limits<double>::quiet_NaN()) |
45 , m_isCached(false) | 45 , m_isCached(false) |
46 { } | 46 { } |
47 | 47 |
48 PassOwnPtr<InterpolationValue> maybeConvertUnderlyingValue(const StyleResolv
erState&) const; | 48 PassOwnPtr<InterpolationValue> maybeConvertUnderlyingValue(const Interpolati
onEnvironment&) const; |
49 const InterpolationValue* ensureValidInterpolation(const StyleResolverState&
, const UnderlyingValue&) const; | 49 const InterpolationValue* ensureValidInterpolation(const InterpolationEnviro
nment&, const UnderlyingValue&) const; |
50 void clearCache() const; | 50 void clearCache() const; |
51 bool isCacheValid(const StyleResolverState&, const UnderlyingValue&) const; | 51 bool isCacheValid(const InterpolationEnvironment&, const UnderlyingValue&) c
onst; |
52 bool isNeutralKeyframeActive() const; | 52 bool isNeutralKeyframeActive() const; |
53 PassOwnPtr<PairwisePrimitiveInterpolation> maybeConvertPairwise(const StyleR
esolverState*, const UnderlyingValue&) const; | 53 PassOwnPtr<PairwisePrimitiveInterpolation> maybeConvertPairwise(const Interp
olationEnvironment*, const UnderlyingValue&) const; |
54 PassOwnPtr<InterpolationValue> convertSingleKeyframe(const CSSPropertySpecif
icKeyframe&, const StyleResolverState&, const UnderlyingValue&) const; | 54 PassOwnPtr<InterpolationValue> convertSingleKeyframe(const PropertySpecificK
eyframe&, const InterpolationEnvironment&, const UnderlyingValue&) const; |
55 void setFlagIfInheritUsed(StyleResolverState&) const; | 55 void setFlagIfInheritUsed(InterpolationEnvironment&) const; |
56 double underlyingFraction() const; | 56 double underlyingFraction() const; |
57 | 57 |
58 const Vector<const InterpolationType*>& m_interpolationTypes; | 58 const Vector<const InterpolationType*>& m_interpolationTypes; |
59 const CSSPropertySpecificKeyframe* m_startKeyframe; | 59 const PropertySpecificKeyframe* m_startKeyframe; |
60 const CSSPropertySpecificKeyframe* m_endKeyframe; | 60 const PropertySpecificKeyframe* m_endKeyframe; |
61 double m_currentFraction; | 61 double m_currentFraction; |
62 mutable bool m_isCached; | 62 mutable bool m_isCached; |
63 mutable OwnPtr<PrimitiveInterpolation> m_cachedPairConversion; | 63 mutable OwnPtr<PrimitiveInterpolation> m_cachedPairConversion; |
64 mutable InterpolationType::ConversionCheckers m_conversionCheckers; | 64 mutable InterpolationType::ConversionCheckers m_conversionCheckers; |
65 mutable OwnPtr<InterpolationValue> m_cachedValue; | 65 mutable OwnPtr<InterpolationValue> m_cachedValue; |
66 }; | 66 }; |
67 | 67 |
68 DEFINE_TYPE_CASTS(InvalidatableStyleInterpolation, Interpolation, value, value->
isInvalidatableStyleInterpolation(), value.isInvalidatableStyleInterpolation()); | 68 DEFINE_TYPE_CASTS(InvalidatableStyleInterpolation, Interpolation, value, value->
isInvalidatableStyleInterpolation(), value.isInvalidatableStyleInterpolation()); |
69 | 69 |
70 } // namespace blink | 70 } // namespace blink |
71 | 71 |
72 #endif // InvalidatableStyleInterpolation_h | 72 #endif // InvalidatableStyleInterpolation_h |
OLD | NEW |