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 InterpolationType_h | 5 #ifndef InterpolationType_h |
6 #define InterpolationType_h | 6 #define InterpolationType_h |
7 | 7 |
8 #include "core/animation/InterpolationValue.h" | 8 #include "core/animation/InterpolationValue.h" |
9 #include "core/animation/Keyframe.h" | 9 #include "core/animation/Keyframe.h" |
10 #include "core/animation/PairwiseInterpolationValue.h" | 10 #include "core/animation/PairwiseInterpolationValue.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return nullptr; | 70 return nullptr; |
71 return maybeMergeSingles(std::move(start), std::move(end)); | 71 return maybeMergeSingles(std::move(start), std::move(end)); |
72 } | 72 } |
73 | 73 |
74 virtual InterpolationValue maybeConvertSingle( | 74 virtual InterpolationValue maybeConvertSingle( |
75 const PropertySpecificKeyframe&, | 75 const PropertySpecificKeyframe&, |
76 const InterpolationEnvironment&, | 76 const InterpolationEnvironment&, |
77 const InterpolationValue& underlying, | 77 const InterpolationValue& underlying, |
78 ConversionCheckers&) const = 0; | 78 ConversionCheckers&) const = 0; |
79 | 79 |
| 80 virtual PairwiseInterpolationValue maybeMergeSingles( |
| 81 InterpolationValue&& start, |
| 82 InterpolationValue&& end) const { |
| 83 DCHECK(!start.nonInterpolableValue); |
| 84 DCHECK(!end.nonInterpolableValue); |
| 85 return PairwiseInterpolationValue(std::move(start.interpolableValue), |
| 86 std::move(end.interpolableValue), |
| 87 nullptr); |
| 88 } |
| 89 |
80 virtual InterpolationValue maybeConvertUnderlyingValue( | 90 virtual InterpolationValue maybeConvertUnderlyingValue( |
81 const InterpolationEnvironment&) const = 0; | 91 const InterpolationEnvironment&) const = 0; |
82 | 92 |
83 virtual void composite(UnderlyingValueOwner& underlyingValueOwner, | 93 virtual void composite(UnderlyingValueOwner& underlyingValueOwner, |
84 double underlyingFraction, | 94 double underlyingFraction, |
85 const InterpolationValue& value, | 95 const InterpolationValue& value, |
86 double interpolationFraction) const { | 96 double interpolationFraction) const { |
87 DCHECK(!underlyingValueOwner.value().nonInterpolableValue); | 97 DCHECK(!underlyingValueOwner.value().nonInterpolableValue); |
88 DCHECK(!value.nonInterpolableValue); | 98 DCHECK(!value.nonInterpolableValue); |
89 underlyingValueOwner.mutableValue().interpolableValue->scaleAndAdd( | 99 underlyingValueOwner.mutableValue().interpolableValue->scaleAndAdd( |
90 underlyingFraction, *value.interpolableValue); | 100 underlyingFraction, *value.interpolableValue); |
91 } | 101 } |
92 | 102 |
93 virtual void apply(const InterpolableValue&, | 103 virtual void apply(const InterpolableValue&, |
94 const NonInterpolableValue*, | 104 const NonInterpolableValue*, |
95 InterpolationEnvironment&) const = 0; | 105 InterpolationEnvironment&) const = 0; |
96 | 106 |
97 // Implement reference equality checking via pointer equality checking as | 107 // Implement reference equality checking via pointer equality checking as |
98 // these are singletons. | 108 // these are singletons. |
99 bool operator==(const InterpolationType& other) const { | 109 bool operator==(const InterpolationType& other) const { |
100 return this == &other; | 110 return this == &other; |
101 } | 111 } |
102 bool operator!=(const InterpolationType& other) const { | 112 bool operator!=(const InterpolationType& other) const { |
103 return this != &other; | 113 return this != &other; |
104 } | 114 } |
105 | 115 |
106 protected: | 116 protected: |
107 InterpolationType(PropertyHandle property) : m_property(property) {} | 117 InterpolationType(PropertyHandle property) : m_property(property) {} |
108 | 118 |
109 virtual PairwiseInterpolationValue maybeMergeSingles( | |
110 InterpolationValue&& start, | |
111 InterpolationValue&& end) const { | |
112 DCHECK(!start.nonInterpolableValue); | |
113 DCHECK(!end.nonInterpolableValue); | |
114 return PairwiseInterpolationValue(std::move(start.interpolableValue), | |
115 std::move(end.interpolableValue), | |
116 nullptr); | |
117 } | |
118 | |
119 const PropertyHandle m_property; | 119 const PropertyHandle m_property; |
120 }; | 120 }; |
121 | 121 |
122 } // namespace blink | 122 } // namespace blink |
123 | 123 |
124 #endif // InterpolationType_h | 124 #endif // InterpolationType_h |
OLD | NEW |