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

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

Issue 1214593003: Move AnimationValue onto the heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
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 "config.h" 5 #include "config.h"
6 #include "core/animation/InvalidatableStyleInterpolation.h" 6 #include "core/animation/InvalidatableStyleInterpolation.h"
7 7
8 #include "core/animation/StringKeyframe.h" 8 #include "core/animation/StringKeyframe.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 InvalidatableStyleInterpolation::InvalidatableStyleInterpolation( 12 InvalidatableStyleInterpolation::InvalidatableStyleInterpolation(
13 const Vector<const AnimationType*>& animationTypes, 13 const Vector<const AnimationType*>& animationTypes,
14 const CSSPropertySpecificKeyframe& startKeyframe, 14 const CSSPropertySpecificKeyframe& startKeyframe,
15 const CSSPropertySpecificKeyframe& endKeyframe) 15 const CSSPropertySpecificKeyframe& endKeyframe)
16 : StyleInterpolation(nullptr, nullptr, animationTypes.first()->property()) 16 : StyleInterpolation(nullptr, nullptr, animationTypes.first()->property())
17 , m_animationTypes(animationTypes) 17 , m_animationTypes(animationTypes)
18 , m_startKeyframe(startKeyframe) 18 , m_startKeyframe(startKeyframe)
19 , m_endKeyframe(endKeyframe) 19 , m_endKeyframe(endKeyframe)
20 { 20 {
21 maybeCachePairwiseConversion(nullptr); 21 maybeCachePairwiseConversion(nullptr);
22 interpolate(0, 0); 22 interpolate(0, 0);
23 } 23 }
24 24
25 bool InvalidatableStyleInterpolation::maybeCachePairwiseConversion(const StyleRe solverState* state) const 25 bool InvalidatableStyleInterpolation::maybeCachePairwiseConversion(const StyleRe solverState* state) const
26 { 26 {
27 for (const auto& animationType : m_animationTypes) { 27 for (const auto& animationType : m_animationTypes) {
28 OwnPtrWillBeRawPtr<PairwisePrimitiveInterpolation> pairwiseConversion = animationType->maybeConvertPairwise(m_startKeyframe, m_endKeyframe, state, m_con versionCheckers); 28 OwnPtrWillBeRawPtr<PairwisePrimitiveInterpolation> pairwiseConversion = animationType->maybeConvertPairwise(m_startKeyframe, m_endKeyframe, state, m_con versionCheckers);
29 if (pairwiseConversion) { 29 if (pairwiseConversion) {
30 m_cachedValue.type = animationType; 30 m_cachedValue = pairwiseConversion->initialValue();
31 pairwiseConversion->initializeAnimationValue(m_cachedValue);
32 m_cachedConversion = pairwiseConversion.release(); 31 m_cachedConversion = pairwiseConversion.release();
33 return true; 32 return true;
34 } 33 }
35 } 34 }
36 return false; 35 return false;
37 } 36 }
38 37
39 void InvalidatableStyleInterpolation::interpolate(int, double fraction) 38 void InvalidatableStyleInterpolation::interpolate(int, double fraction)
40 { 39 {
41 m_currentFraction = fraction; 40 m_currentFraction = fraction;
42 if (m_cachedConversion) 41 if (m_cachedConversion)
43 m_cachedConversion->interpolate(fraction, m_cachedValue); 42 m_cachedConversion->interpolate(fraction, m_cachedValue);
44 // We defer the interpolation to ensureValidInterpolation() if m_cachedConve rsion is null. 43 // We defer the interpolation to ensureValidInterpolation() if m_cachedConve rsion is null.
45 } 44 }
46 45
47 PassOwnPtrWillBeRawPtr<FlipPrimitiveInterpolation::Side> InvalidatableStyleInter polation::convertSingleKeyframe(const CSSPropertySpecificKeyframe& keyframe, con st StyleResolverState& state) const 46 PassOwnPtrWillBeRawPtr<AnimationValue> InvalidatableStyleInterpolation::convertS ingleKeyframe(const CSSPropertySpecificKeyframe& keyframe, const StyleResolverSt ate& state) const
48 { 47 {
49 for (const auto& animationType : m_animationTypes) { 48 for (const auto& animationType : m_animationTypes) {
50 OwnPtrWillBeRawPtr<FlipPrimitiveInterpolation::Side> result = animationT ype->maybeConvertSingle(keyframe, &state, m_conversionCheckers); 49 OwnPtrWillBeRawPtr<AnimationValue> result = animationType->maybeConvertS ingle(keyframe, &state, m_conversionCheckers);
51 if (result) 50 if (result)
52 return result.release(); 51 return result.release();
53 } 52 }
54 ASSERT_NOT_REACHED(); 53 ASSERT_NOT_REACHED();
55 return nullptr; 54 return nullptr;
56 } 55 }
57 56
58 bool InvalidatableStyleInterpolation::isCacheValid(const StyleResolverState& sta te) const 57 bool InvalidatableStyleInterpolation::isCacheValid(const StyleResolverState& sta te) const
59 { 58 {
60 for (const auto& checker : m_conversionCheckers) { 59 for (const auto& checker : m_conversionCheckers) {
(...skipping 12 matching lines...) Expand all
73 m_cachedConversion = FlipPrimitiveInterpolation::create( 72 m_cachedConversion = FlipPrimitiveInterpolation::create(
74 convertSingleKeyframe(m_startKeyframe, state), 73 convertSingleKeyframe(m_startKeyframe, state),
75 convertSingleKeyframe(m_endKeyframe, state)); 74 convertSingleKeyframe(m_endKeyframe, state));
76 } 75 }
77 m_cachedConversion->interpolate(m_currentFraction, m_cachedValue); 76 m_cachedConversion->interpolate(m_currentFraction, m_cachedValue);
78 } 77 }
79 78
80 void InvalidatableStyleInterpolation::apply(StyleResolverState& state) const 79 void InvalidatableStyleInterpolation::apply(StyleResolverState& state) const
81 { 80 {
82 ensureValidInterpolation(state); 81 ensureValidInterpolation(state);
83 m_cachedValue.type->apply(*m_cachedValue.interpolableValue, m_cachedValue.no nInterpolableValue.get(), state); 82 m_cachedValue->type().apply(m_cachedValue->interpolableValue(), m_cachedValu e->nonInterpolableValue(), state);
84 } 83 }
85 84
86 } // namespace blink 85 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/InvalidatableStyleInterpolation.h ('k') | Source/core/animation/PrimitiveInterpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698