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

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: Make ConversionInvalidators independent of the InterpolationPrimitive conversion result 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 const CSSPropertySpecificKeyframe& startKeyframe,
15 const CSSPropertySpecificKeyframe& endKeyframe)
16 : StyleInterpolation(nullptr, nullptr, animationTypes.first()->property())
17 , m_animationTypes(animationTypes)
18 , m_startKeyframe(startKeyframe)
19 , m_endKeyframe(endKeyframe)
20 {
21 maybeCachePairwiseConversion(nullptr);
22 interpolate(0, 0);
23 }
24
25 bool InvalidatableStyleInterpolation::maybeCachePairwiseConversion(const StyleRe solverState* state) const
26 {
27 for (const auto& animationType : m_animationTypes) {
28 OwnPtrWillBeRawPtr<PairwiseInterpolationPrimitive> pairwiseConversion = animationType->maybeConvertPairwise(m_startKeyframe, m_endKeyframe, state, m_con versionInvalidators);
29 if (pairwiseConversion) {
30 m_cachedValue.type = animationType;
31 pairwiseConversion->initialiseAnimationValue(m_cachedValue);
32 m_cachedConversion = pairwiseConversion.release();
33 return true;
34 }
35 }
36 return false;
37 }
38
39 void InvalidatableStyleInterpolation::interpolate(int, double fraction)
40 {
41 m_currentFraction = fraction;
42 if (m_cachedConversion)
43 m_cachedConversion->interpolate(fraction, m_cachedValue);
shans 2015/06/22 11:43:21 comment inline that interpolation is deferred to v
alancutter (OOO until 2018) 2015/06/23 05:05:33 Done.
44 }
45
46 PassOwnPtrWillBeRawPtr<FlipInterpolationPrimitive::Side> InvalidatableStyleInter polation::convertSingleKeyframe(const CSSPropertySpecificKeyframe& keyframe, con st StyleResolverState& state) const
47 {
48 for (const auto& animationType : m_animationTypes) {
49 OwnPtrWillBeRawPtr<FlipInterpolationPrimitive::Side> result = animationT ype->maybeConvertSingle(keyframe, &state, m_conversionInvalidators);
50 if (result)
51 return result.release();
52 }
53 ASSERT_NOT_REACHED();
54 return nullptr;
55 }
56
57 bool InvalidatableStyleInterpolation::isCacheValid(const StyleResolverState& sta te) const
58 {
59 for (const auto& invalidator : m_conversionInvalidators) {
60 if (invalidator->isInvalid(state))
61 return false;
62 }
63 return true;
64 }
65
66 void InvalidatableStyleInterpolation::ensureValidCache(const StyleResolverState& state) const
67 {
68 if (m_cachedConversion && isCacheValid(state))
69 return;
70 m_conversionInvalidators.clear();
71 if (!maybeCachePairwiseConversion(&state)) {
72 m_cachedConversion = FlipInterpolationPrimitive::create(
73 convertSingleKeyframe(m_startKeyframe, state),
74 convertSingleKeyframe(m_endKeyframe, state));
75 }
76 m_cachedConversion->interpolate(m_currentFraction, m_cachedValue);
shans 2015/06/22 11:43:21 It's slightly weird to see interpolate called insi
alancutter (OOO until 2018) 2015/06/23 05:05:33 We may have already interpolated, this also checks
77 }
shans 2015/06/22 11:43:22 Is this method going to blow out as we have more P
alancutter (OOO until 2018) 2015/06/23 05:05:33 We will not be adding more PrimitiveInterpolation
78
79 void InvalidatableStyleInterpolation::apply(StyleResolverState& state) const
80 {
81 ensureValidCache(state);
82 m_cachedValue.type->apply(*m_cachedValue.interpolableValue, m_cachedValue.no nInterpolableValue.get(), state);
83 }
84
85 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698