Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: Source/core/animation/InvalidatableStyleInterpolation.cpp

Issue 1153943003: Add foundation for removing AnimatableValues from StyleInterpolation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: PassOwnPtr Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/animation/InvalidatableStyleInterpolation.h"
7
8 #include "core/animation/StringKeyframe.h"
9
10 namespace blink {
11
12 InvalidatableStyleInterpolation::InvalidatableStyleInterpolation(
13 const Vector<const AnimationType*>& animationTypes,
14 PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> startKeyframe,
15 PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> endKeyframe)
16 : StyleInterpolation(nullptr, nullptr, animationTypes.first()->property())
17 , m_animationTypes(animationTypes)
18 , m_startKeyframe(startKeyframe)
19 , m_endKeyframe(endKeyframe)
20 , m_cachedConversion(nullptr)
21 {
22 maybeCachePairwiseConversion(nullptr);
shans 2015/06/04 00:15:15 should be doing the convertSingleKeyframe fallback
alancutter (OOO until 2018) 2015/06/11 04:15:13 If pairwise conversion fails here we hold off unti
23 interpolate(0, 0);
24 }
25
26 bool InvalidatableStyleInterpolation::maybeCachePairwiseConversion(const StyleRe solverState* state) const
27 {
28 for (const auto& animationType : m_animationTypes) {
29 OwnPtrWillBeRawPtr<PairwiseAnimationConversion> pairwiseConversion = ani mationType->maybeConvertPairwise(*m_startKeyframe, *m_endKeyframe, state);
30 if (pairwiseConversion) {
31 m_cachedValue.type = animationType;
32 pairwiseConversion->initialiseAnimationValue(m_cachedValue);
33 m_cachedConversion = pairwiseConversion.release();
34 return true;
35 }
36 }
37 return false;
38 }
39
40 void InvalidatableStyleInterpolation::interpolate(int, double fraction)
41 {
42 m_currentFraction = fraction;
43 if (m_cachedConversion)
44 m_cachedConversion->interpolate(fraction, m_cachedValue);
45 else
46 m_cachedValue.clear();
shans 2015/06/04 00:15:15 Is this right? I thought we always needed a way to
alancutter (OOO until 2018) 2015/06/11 04:15:13 interpolate() may be called prior to apply(). Some
47 }
48
49 static PassOwnPtrWillBeRawPtr<AnimationConversionHalf> convertSingleKeyframe(con st Vector<const AnimationType*>& animationTypes, const CSSPropertySpecificKeyfra me& keyframe, const StyleResolverState& state)
50 {
51 for (const auto& animationType : animationTypes) {
52 OwnPtrWillBeRawPtr<AnimationConversionHalf> result = animationType->mayb eConvertSingle(keyframe, &state);
53 if (result) {
54 result->type = animationType;
shans 2015/06/04 00:15:15 This isn't the right way to do this! result was *j
alancutter (OOO until 2018) 2015/06/11 04:15:13 Done.
55 return result.release();
56 }
57 }
58 ASSERT_NOT_REACHED();
59 return nullptr;
60 }
61
62 void InvalidatableStyleInterpolation::validateCache(const StyleResolverState& st ate) const
63 {
64 if (m_cachedConversion && !m_cachedConversion->isInvalid(state))
65 return;
66 if (!maybeCachePairwiseConversion(&state))
67 m_cachedConversion = DefaultAnimationConversion::create(convertSingleKey frame(m_animationTypes, *m_startKeyframe, state), convertSingleKeyframe(m_animat ionTypes, *m_endKeyframe, state));
68 m_cachedConversion->interpolate(m_currentFraction, m_cachedValue);
69 }
70
71 void InvalidatableStyleInterpolation::apply(StyleResolverState& state) const
72 {
73 validateCache(state);
74 if (m_cachedValue)
75 m_cachedValue.type->apply(*m_cachedValue.interpolableValue, m_cachedValu e.nonInterpolableValue.get(), state);
76 }
77
78 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698