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

Side by Side Diff: third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 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
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 "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 11
11 namespace blink { 12 namespace blink {
12 13
13 void InvalidatableInterpolation::interpolate(int, double fraction) 14 void InvalidatableInterpolation::interpolate(int, double fraction)
14 { 15 {
15 if (fraction == m_currentFraction) 16 if (fraction == m_currentFraction)
16 return; 17 return;
17 18
18 if (m_currentFraction == 0 || m_currentFraction == 1 || fraction == 0 || fra ction == 1) 19 if (m_currentFraction == 0 || m_currentFraction == 1 || fraction == 0 || fra ction == 1)
19 clearCache(); 20 clearCache();
20 21
21 m_currentFraction = fraction; 22 m_currentFraction = fraction;
22 if (m_isCached && m_cachedPairConversion) 23 if (m_isCached && m_cachedPairConversion)
23 m_cachedPairConversion->interpolateValue(fraction, m_cachedValue); 24 m_cachedPairConversion->interpolateValue(fraction, m_cachedValue);
24 // We defer the interpolation to ensureValidInterpolation() if m_cachedPairC onversion is null. 25 // We defer the interpolation to ensureValidInterpolation() if m_cachedPairC onversion is null.
25 } 26 }
26 27
27 PassOwnPtr<PairwisePrimitiveInterpolation> InvalidatableInterpolation::maybeConv ertPairwise(const InterpolationEnvironment& environment, const UnderlyingValueOw ner& underlyingValueOwner) const 28 std::unique_ptr<PairwisePrimitiveInterpolation> InvalidatableInterpolation::mayb eConvertPairwise(const InterpolationEnvironment& environment, const UnderlyingVa lueOwner& underlyingValueOwner) const
28 { 29 {
29 ASSERT(m_currentFraction != 0 && m_currentFraction != 1); 30 ASSERT(m_currentFraction != 0 && m_currentFraction != 1);
30 for (const auto& interpolationType : m_interpolationTypes) { 31 for (const auto& interpolationType : m_interpolationTypes) {
31 if ((m_startKeyframe->isNeutral() || m_endKeyframe->isNeutral()) && (!un derlyingValueOwner || underlyingValueOwner.type() != *interpolationType)) 32 if ((m_startKeyframe->isNeutral() || m_endKeyframe->isNeutral()) && (!un derlyingValueOwner || underlyingValueOwner.type() != *interpolationType))
32 continue; 33 continue;
33 ConversionCheckers conversionCheckers; 34 ConversionCheckers conversionCheckers;
34 PairwiseInterpolationValue result = interpolationType->maybeConvertPairw ise(*m_startKeyframe, *m_endKeyframe, environment, underlyingValueOwner.value(), conversionCheckers); 35 PairwiseInterpolationValue result = interpolationType->maybeConvertPairw ise(*m_startKeyframe, *m_endKeyframe, environment, underlyingValueOwner.value(), conversionCheckers);
35 addConversionCheckers(*interpolationType, conversionCheckers); 36 addConversionCheckers(*interpolationType, conversionCheckers);
36 if (result) { 37 if (result) {
37 return PairwisePrimitiveInterpolation::create(*interpolationType, 38 return PairwisePrimitiveInterpolation::create(*interpolationType,
38 std::move(result.startInterpolableValue), 39 std::move(result.startInterpolableValue),
39 std::move(result.endInterpolableValue), 40 std::move(result.endInterpolableValue),
40 result.nonInterpolableValue.release()); 41 result.nonInterpolableValue.release());
41 } 42 }
42 } 43 }
43 return nullptr; 44 return nullptr;
44 } 45 }
45 46
46 PassOwnPtr<TypedInterpolationValue> InvalidatableInterpolation::convertSingleKey frame(const PropertySpecificKeyframe& keyframe, const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const 47 std::unique_ptr<TypedInterpolationValue> InvalidatableInterpolation::convertSing leKeyframe(const PropertySpecificKeyframe& keyframe, const InterpolationEnvironm ent& environment, const UnderlyingValueOwner& underlyingValueOwner) const
47 { 48 {
48 if (keyframe.isNeutral() && !underlyingValueOwner) 49 if (keyframe.isNeutral() && !underlyingValueOwner)
49 return nullptr; 50 return nullptr;
50 for (const auto& interpolationType : m_interpolationTypes) { 51 for (const auto& interpolationType : m_interpolationTypes) {
51 if (keyframe.isNeutral() && underlyingValueOwner.type() != *interpolatio nType) 52 if (keyframe.isNeutral() && underlyingValueOwner.type() != *interpolatio nType)
52 continue; 53 continue;
53 ConversionCheckers conversionCheckers; 54 ConversionCheckers conversionCheckers;
54 InterpolationValue result = interpolationType->maybeConvertSingle(keyfra me, environment, underlyingValueOwner.value(), conversionCheckers); 55 InterpolationValue result = interpolationType->maybeConvertSingle(keyfra me, environment, underlyingValueOwner.value(), conversionCheckers);
55 addConversionCheckers(*interpolationType, conversionCheckers); 56 addConversionCheckers(*interpolationType, conversionCheckers);
56 if (result) 57 if (result)
57 return TypedInterpolationValue::create(*interpolationType, std::move (result.interpolableValue), result.nonInterpolableValue.release()); 58 return TypedInterpolationValue::create(*interpolationType, std::move (result.interpolableValue), result.nonInterpolableValue.release());
58 } 59 }
59 ASSERT(keyframe.isNeutral()); 60 ASSERT(keyframe.isNeutral());
60 return nullptr; 61 return nullptr;
61 } 62 }
62 63
63 void InvalidatableInterpolation::addConversionCheckers(const InterpolationType& type, ConversionCheckers& conversionCheckers) const 64 void InvalidatableInterpolation::addConversionCheckers(const InterpolationType& type, ConversionCheckers& conversionCheckers) const
64 { 65 {
65 for (size_t i = 0; i < conversionCheckers.size(); i++) { 66 for (size_t i = 0; i < conversionCheckers.size(); i++) {
66 conversionCheckers[i]->setType(type); 67 conversionCheckers[i]->setType(type);
67 m_conversionCheckers.append(std::move(conversionCheckers[i])); 68 m_conversionCheckers.append(std::move(conversionCheckers[i]));
68 } 69 }
69 } 70 }
70 71
71 PassOwnPtr<TypedInterpolationValue> InvalidatableInterpolation::maybeConvertUnde rlyingValue(const InterpolationEnvironment& environment) const 72 std::unique_ptr<TypedInterpolationValue> InvalidatableInterpolation::maybeConver tUnderlyingValue(const InterpolationEnvironment& environment) const
72 { 73 {
73 for (const auto& interpolationType : m_interpolationTypes) { 74 for (const auto& interpolationType : m_interpolationTypes) {
74 InterpolationValue result = interpolationType->maybeConvertUnderlyingVal ue(environment); 75 InterpolationValue result = interpolationType->maybeConvertUnderlyingVal ue(environment);
75 if (result) 76 if (result)
76 return TypedInterpolationValue::create(*interpolationType, std::move (result.interpolableValue), result.nonInterpolableValue.release()); 77 return TypedInterpolationValue::create(*interpolationType, std::move (result.interpolableValue), result.nonInterpolableValue.release());
77 } 78 }
78 return nullptr; 79 return nullptr;
79 } 80 }
80 81
81 bool InvalidatableInterpolation::dependsOnUnderlyingValue() const 82 bool InvalidatableInterpolation::dependsOnUnderlyingValue() const
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 { 119 {
119 ASSERT(!std::isnan(m_currentFraction)); 120 ASSERT(!std::isnan(m_currentFraction));
120 if (isCacheValid(environment, underlyingValueOwner)) 121 if (isCacheValid(environment, underlyingValueOwner))
121 return m_cachedValue.get(); 122 return m_cachedValue.get();
122 clearCache(); 123 clearCache();
123 if (m_currentFraction == 0) { 124 if (m_currentFraction == 0) {
124 m_cachedValue = convertSingleKeyframe(*m_startKeyframe, environment, und erlyingValueOwner); 125 m_cachedValue = convertSingleKeyframe(*m_startKeyframe, environment, und erlyingValueOwner);
125 } else if (m_currentFraction == 1) { 126 } else if (m_currentFraction == 1) {
126 m_cachedValue = convertSingleKeyframe(*m_endKeyframe, environment, under lyingValueOwner); 127 m_cachedValue = convertSingleKeyframe(*m_endKeyframe, environment, under lyingValueOwner);
127 } else { 128 } else {
128 OwnPtr<PairwisePrimitiveInterpolation> pairwiseConversion = maybeConvert Pairwise(environment, underlyingValueOwner); 129 std::unique_ptr<PairwisePrimitiveInterpolation> pairwiseConversion = may beConvertPairwise(environment, underlyingValueOwner);
129 if (pairwiseConversion) { 130 if (pairwiseConversion) {
130 m_cachedValue = pairwiseConversion->initialValue(); 131 m_cachedValue = pairwiseConversion->initialValue();
131 m_cachedPairConversion = std::move(pairwiseConversion); 132 m_cachedPairConversion = std::move(pairwiseConversion);
132 } else { 133 } else {
133 m_cachedPairConversion = FlipPrimitiveInterpolation::create( 134 m_cachedPairConversion = FlipPrimitiveInterpolation::create(
134 convertSingleKeyframe(*m_startKeyframe, environment, underlyingV alueOwner), 135 convertSingleKeyframe(*m_startKeyframe, environment, underlyingV alueOwner),
135 convertSingleKeyframe(*m_endKeyframe, environment, underlyingVal ueOwner)); 136 convertSingleKeyframe(*m_endKeyframe, environment, underlyingVal ueOwner));
136 } 137 }
137 m_cachedPairConversion->interpolateValue(m_currentFraction, m_cachedValu e); 138 m_cachedPairConversion->interpolateValue(m_currentFraction, m_cachedValu e);
138 } 139 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 underlyingValueOwner.set(currentValue); 203 underlyingValueOwner.set(currentValue);
203 else 204 else
204 currentValue->type().composite(underlyingValueOwner, underlyingFract ion, currentValue->value(), currentInterpolation.m_currentFraction); 205 currentValue->type().composite(underlyingValueOwner, underlyingFract ion, currentValue->value(), currentInterpolation.m_currentFraction);
205 } 206 }
206 207
207 if (shouldApply && underlyingValueOwner) 208 if (shouldApply && underlyingValueOwner)
208 underlyingValueOwner.type().apply(*underlyingValueOwner.value().interpol ableValue, underlyingValueOwner.value().nonInterpolableValue.get(), environment) ; 209 underlyingValueOwner.type().apply(*underlyingValueOwner.value().interpol ableValue, underlyingValueOwner.value().nonInterpolableValue.get(), environment) ;
209 } 210 }
210 211
211 } // namespace blink 212 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698