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 InvalidatableInterpolation_h | 5 #ifndef InvalidatableInterpolation_h |
6 #define InvalidatableInterpolation_h | 6 #define InvalidatableInterpolation_h |
7 | 7 |
8 #include "core/animation/InterpolationType.h" | 8 #include "core/animation/InterpolationType.h" |
| 9 #include "core/animation/InterpolationTypesMap.h" |
9 #include "core/animation/PrimitiveInterpolation.h" | 10 #include "core/animation/PrimitiveInterpolation.h" |
10 #include "core/animation/PropertyInterpolationTypesMapping.h" | |
11 #include "core/animation/StyleInterpolation.h" | 11 #include "core/animation/StyleInterpolation.h" |
12 #include "core/animation/TypedInterpolationValue.h" | 12 #include "core/animation/TypedInterpolationValue.h" |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 // TODO(alancutter): This class will replace *StyleInterpolation and | 17 // TODO(alancutter): This class will replace *StyleInterpolation and |
18 // Interpolation. For now it needs to distinguish itself during the refactor and | 18 // Interpolation. For now it needs to distinguish itself during the refactor and |
19 // temporarily has an ugly name. | 19 // temporarily has an ugly name. |
20 class CORE_EXPORT InvalidatableInterpolation : public Interpolation { | 20 class CORE_EXPORT InvalidatableInterpolation : public Interpolation { |
21 public: | 21 public: |
22 static PassRefPtr<InvalidatableInterpolation> create( | 22 static PassRefPtr<InvalidatableInterpolation> create( |
23 PropertyHandle property, | 23 PropertyHandle property, |
24 const InterpolationTypes& interpolationTypes, | |
25 PassRefPtr<PropertySpecificKeyframe> startKeyframe, | 24 PassRefPtr<PropertySpecificKeyframe> startKeyframe, |
26 PassRefPtr<PropertySpecificKeyframe> endKeyframe) { | 25 PassRefPtr<PropertySpecificKeyframe> endKeyframe) { |
27 return adoptRef(new InvalidatableInterpolation(property, interpolationTypes, | 26 return adoptRef(new InvalidatableInterpolation( |
28 std::move(startKeyframe), | 27 property, std::move(startKeyframe), std::move(endKeyframe))); |
29 std::move(endKeyframe))); | |
30 } | 28 } |
31 | 29 |
32 PropertyHandle getProperty() const final { return m_property; } | 30 PropertyHandle getProperty() const final { return m_property; } |
33 virtual void interpolate(int iteration, double fraction); | 31 virtual void interpolate(int iteration, double fraction); |
34 bool dependsOnUnderlyingValue() const final; | 32 bool dependsOnUnderlyingValue() const final; |
35 virtual void apply(InterpolationEnvironment&) const { NOTREACHED(); } | 33 virtual void apply(InterpolationEnvironment&) const { NOTREACHED(); } |
36 static void applyStack(const ActiveInterpolations&, | 34 static void applyStack(const ActiveInterpolations&, |
37 InterpolationEnvironment&); | 35 InterpolationEnvironment&); |
38 | 36 |
39 virtual bool isInvalidatableInterpolation() const { return true; } | 37 virtual bool isInvalidatableInterpolation() const { return true; } |
40 | 38 |
41 private: | 39 private: |
42 InvalidatableInterpolation(PropertyHandle property, | 40 InvalidatableInterpolation(PropertyHandle property, |
43 const InterpolationTypes& interpolationTypes, | |
44 PassRefPtr<PropertySpecificKeyframe> startKeyframe, | 41 PassRefPtr<PropertySpecificKeyframe> startKeyframe, |
45 PassRefPtr<PropertySpecificKeyframe> endKeyframe) | 42 PassRefPtr<PropertySpecificKeyframe> endKeyframe) |
46 : Interpolation(nullptr, nullptr), | 43 : Interpolation(nullptr, nullptr), |
47 m_property(property), | 44 m_property(property), |
48 m_interpolationTypes(interpolationTypes), | 45 m_interpolationTypes(nullptr), |
| 46 m_interpolationTypesVersion(0), |
49 m_startKeyframe(startKeyframe), | 47 m_startKeyframe(startKeyframe), |
50 m_endKeyframe(endKeyframe), | 48 m_endKeyframe(endKeyframe), |
51 m_currentFraction(std::numeric_limits<double>::quiet_NaN()), | 49 m_currentFraction(std::numeric_limits<double>::quiet_NaN()), |
52 m_isConversionCached(false) {} | 50 m_isConversionCached(false) {} |
53 | 51 |
54 using ConversionCheckers = InterpolationType::ConversionCheckers; | 52 using ConversionCheckers = InterpolationType::ConversionCheckers; |
55 | 53 |
56 std::unique_ptr<TypedInterpolationValue> maybeConvertUnderlyingValue( | 54 std::unique_ptr<TypedInterpolationValue> maybeConvertUnderlyingValue( |
57 const InterpolationEnvironment&) const; | 55 const InterpolationEnvironment&) const; |
58 const TypedInterpolationValue* ensureValidConversion( | 56 const TypedInterpolationValue* ensureValidConversion( |
59 const InterpolationEnvironment&, | 57 const InterpolationEnvironment&, |
60 const UnderlyingValueOwner&) const; | 58 const UnderlyingValueOwner&) const; |
| 59 void ensureValidInterpolationTypes(const InterpolationEnvironment&) const; |
61 void clearConversionCache() const; | 60 void clearConversionCache() const; |
62 bool isConversionCacheValid(const InterpolationEnvironment&, | 61 bool isConversionCacheValid(const InterpolationEnvironment&, |
63 const UnderlyingValueOwner&) const; | 62 const UnderlyingValueOwner&) const; |
64 bool isNeutralKeyframeActive() const; | 63 bool isNeutralKeyframeActive() const; |
65 std::unique_ptr<PairwisePrimitiveInterpolation> maybeConvertPairwise( | 64 std::unique_ptr<PairwisePrimitiveInterpolation> maybeConvertPairwise( |
66 const InterpolationEnvironment&, | 65 const InterpolationEnvironment&, |
67 const UnderlyingValueOwner&) const; | 66 const UnderlyingValueOwner&) const; |
68 std::unique_ptr<TypedInterpolationValue> convertSingleKeyframe( | 67 std::unique_ptr<TypedInterpolationValue> convertSingleKeyframe( |
69 const PropertySpecificKeyframe&, | 68 const PropertySpecificKeyframe&, |
70 const InterpolationEnvironment&, | 69 const InterpolationEnvironment&, |
71 const UnderlyingValueOwner&) const; | 70 const UnderlyingValueOwner&) const; |
72 void addConversionCheckers(const InterpolationType&, | 71 void addConversionCheckers(const InterpolationType&, |
73 ConversionCheckers&) const; | 72 ConversionCheckers&) const; |
74 void setFlagIfInheritUsed(InterpolationEnvironment&) const; | 73 void setFlagIfInheritUsed(InterpolationEnvironment&) const; |
75 double underlyingFraction() const; | 74 double underlyingFraction() const; |
76 | 75 |
77 const PropertyHandle m_property; | 76 const PropertyHandle m_property; |
78 const InterpolationTypes& m_interpolationTypes; | 77 mutable const InterpolationTypes* m_interpolationTypes; |
| 78 mutable size_t m_interpolationTypesVersion; |
79 RefPtr<PropertySpecificKeyframe> m_startKeyframe; | 79 RefPtr<PropertySpecificKeyframe> m_startKeyframe; |
80 RefPtr<PropertySpecificKeyframe> m_endKeyframe; | 80 RefPtr<PropertySpecificKeyframe> m_endKeyframe; |
81 double m_currentFraction; | 81 double m_currentFraction; |
82 mutable bool m_isConversionCached; | 82 mutable bool m_isConversionCached; |
83 mutable std::unique_ptr<PrimitiveInterpolation> m_cachedPairConversion; | 83 mutable std::unique_ptr<PrimitiveInterpolation> m_cachedPairConversion; |
84 mutable ConversionCheckers m_conversionCheckers; | 84 mutable ConversionCheckers m_conversionCheckers; |
85 mutable std::unique_ptr<TypedInterpolationValue> m_cachedValue; | 85 mutable std::unique_ptr<TypedInterpolationValue> m_cachedValue; |
86 }; | 86 }; |
87 | 87 |
88 DEFINE_TYPE_CASTS(InvalidatableInterpolation, | 88 DEFINE_TYPE_CASTS(InvalidatableInterpolation, |
89 Interpolation, | 89 Interpolation, |
90 value, | 90 value, |
91 value->isInvalidatableInterpolation(), | 91 value->isInvalidatableInterpolation(), |
92 value.isInvalidatableInterpolation()); | 92 value.isInvalidatableInterpolation()); |
93 | 93 |
94 } // namespace blink | 94 } // namespace blink |
95 | 95 |
96 #endif // InvalidatableInterpolation_h | 96 #endif // InvalidatableInterpolation_h |
OLD | NEW |