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 #include "core/animation/InvalidatableInterpolation.h" | 5 #include "core/animation/InvalidatableInterpolation.h" |
6 | 6 |
7 #include "core/animation/InterpolationEnvironment.h" | 7 #include "core/animation/InterpolationEnvironment.h" |
8 #include "core/animation/StringKeyframe.h" | 8 #include "core/animation/StringKeyframe.h" |
9 #include "core/css/resolver/StyleResolverState.h" | 9 #include "core/css/resolver/StyleResolverState.h" |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 void InvalidatableInterpolation::interpolate(int, double fraction) { | 14 void InvalidatableInterpolation::interpolate(int, double fraction) { |
15 if (fraction == m_currentFraction) | 15 if (fraction == m_currentFraction) |
16 return; | 16 return; |
17 | 17 |
18 if (m_currentFraction == 0 || m_currentFraction == 1 || fraction == 0 || | 18 if (m_currentFraction == 0 || m_currentFraction == 1 || fraction == 0 || |
19 fraction == 1) | 19 fraction == 1) |
20 clearCache(); | 20 clearCache(); |
21 | 21 |
22 m_currentFraction = fraction; | 22 m_currentFraction = fraction; |
23 if (m_isCached && m_cachedPairConversion) | 23 if (m_isCached && m_cachedPairConversion) |
24 m_cachedPairConversion->interpolateValue(fraction, m_cachedValue); | 24 m_cachedPairConversion->interpolateValue(fraction, m_cachedValue); |
25 // We defer the interpolation to ensureValidInterpolation() if m_cachedPairCon
version is null. | 25 // We defer the interpolation to ensureValidInterpolation() if |
| 26 // m_cachedPairConversion is null. |
26 } | 27 } |
27 | 28 |
28 std::unique_ptr<PairwisePrimitiveInterpolation> | 29 std::unique_ptr<PairwisePrimitiveInterpolation> |
29 InvalidatableInterpolation::maybeConvertPairwise( | 30 InvalidatableInterpolation::maybeConvertPairwise( |
30 const InterpolationEnvironment& environment, | 31 const InterpolationEnvironment& environment, |
31 const UnderlyingValueOwner& underlyingValueOwner) const { | 32 const UnderlyingValueOwner& underlyingValueOwner) const { |
32 DCHECK(m_currentFraction != 0 && m_currentFraction != 1); | 33 DCHECK(m_currentFraction != 0 && m_currentFraction != 1); |
33 for (const auto& interpolationType : m_interpolationTypes) { | 34 for (const auto& interpolationType : m_interpolationTypes) { |
34 if ((m_startKeyframe->isNeutral() || m_endKeyframe->isNeutral()) && | 35 if ((m_startKeyframe->isNeutral() || m_endKeyframe->isNeutral()) && |
35 (!underlyingValueOwner || | 36 (!underlyingValueOwner || |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 118 } |
118 | 119 |
119 bool InvalidatableInterpolation::isCacheValid( | 120 bool InvalidatableInterpolation::isCacheValid( |
120 const InterpolationEnvironment& environment, | 121 const InterpolationEnvironment& environment, |
121 const UnderlyingValueOwner& underlyingValueOwner) const { | 122 const UnderlyingValueOwner& underlyingValueOwner) const { |
122 if (!m_isCached) | 123 if (!m_isCached) |
123 return false; | 124 return false; |
124 if (isNeutralKeyframeActive()) { | 125 if (isNeutralKeyframeActive()) { |
125 if (m_cachedPairConversion && m_cachedPairConversion->isFlip()) | 126 if (m_cachedPairConversion && m_cachedPairConversion->isFlip()) |
126 return false; | 127 return false; |
127 // Pairwise interpolation can never happen between different InterpolationTy
pes, neutral values always represent the underlying value. | 128 // Pairwise interpolation can never happen between different |
| 129 // InterpolationTypes, neutral values always represent the underlying value. |
128 if (!underlyingValueOwner || !m_cachedValue || | 130 if (!underlyingValueOwner || !m_cachedValue || |
129 m_cachedValue->type() != underlyingValueOwner.type()) | 131 m_cachedValue->type() != underlyingValueOwner.type()) |
130 return false; | 132 return false; |
131 } | 133 } |
132 for (const auto& checker : m_conversionCheckers) { | 134 for (const auto& checker : m_conversionCheckers) { |
133 if (!checker->isValid(environment, underlyingValueOwner.value())) | 135 if (!checker->isValid(environment, underlyingValueOwner.value())) |
134 return false; | 136 return false; |
135 } | 137 } |
136 return true; | 138 return true; |
137 } | 139 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 currentInterpolation.m_currentFraction); | 251 currentInterpolation.m_currentFraction); |
250 } | 252 } |
251 | 253 |
252 if (shouldApply && underlyingValueOwner) | 254 if (shouldApply && underlyingValueOwner) |
253 underlyingValueOwner.type().apply( | 255 underlyingValueOwner.type().apply( |
254 *underlyingValueOwner.value().interpolableValue, | 256 *underlyingValueOwner.value().interpolableValue, |
255 underlyingValueOwner.value().nonInterpolableValue.get(), environment); | 257 underlyingValueOwner.value().nonInterpolableValue.get(), environment); |
256 } | 258 } |
257 | 259 |
258 } // namespace blink | 260 } // namespace blink |
OLD | NEW |