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

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

Issue 1977763002: Remove OwnPtr::release() calls in core/ (part 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove static_pointer_cast<>s. Created 4 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/PathInterpolationFunctions.h" 5 #include "core/animation/PathInterpolationFunctions.h"
6 6
7 #include "core/animation/InterpolatedSVGPathSource.h" 7 #include "core/animation/InterpolatedSVGPathSource.h"
8 #include "core/animation/InterpolationEnvironment.h" 8 #include "core/animation/InterpolationEnvironment.h"
9 #include "core/animation/SVGPathSegInterpolationFunctions.h" 9 #include "core/animation/SVGPathSegInterpolationFunctions.h"
10 #include "core/css/CSSPathValue.h" 10 #include "core/css/CSSPathValue.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 while (pathSource.hasMoreData()) { 57 while (pathSource.hasMoreData()) {
58 const PathSegmentData segment = pathSource.parseSegment(); 58 const PathSegmentData segment = pathSource.parseSegment();
59 interpolablePathSegs.append(SVGPathSegInterpolationFunctions::consumePat hSeg(segment, currentCoordinates)); 59 interpolablePathSegs.append(SVGPathSegInterpolationFunctions::consumePat hSeg(segment, currentCoordinates));
60 pathSegTypes.append(segment.command); 60 pathSegTypes.append(segment.command);
61 length++; 61 length++;
62 } 62 }
63 63
64 OwnPtr<InterpolableList> pathArgs = InterpolableList::create(length); 64 OwnPtr<InterpolableList> pathArgs = InterpolableList::create(length);
65 for (size_t i = 0; i < interpolablePathSegs.size(); i++) 65 for (size_t i = 0; i < interpolablePathSegs.size(); i++)
66 pathArgs->set(i, interpolablePathSegs[i].release()); 66 pathArgs->set(i, std::move(interpolablePathSegs[i]));
67 67
68 OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentInde xCount); 68 OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentInde xCount);
69 result->set(PathArgsIndex, pathArgs.release()); 69 result->set(PathArgsIndex, std::move(pathArgs));
70 result->set(PathNeutralIndex, InterpolableNumber::create(0)); 70 result->set(PathNeutralIndex, InterpolableNumber::create(0));
71 71
72 return InterpolationValue(result.release(), SVGPathNonInterpolableValue::cre ate(pathSegTypes)); 72 return InterpolationValue(std::move(result), SVGPathNonInterpolableValue::cr eate(pathSegTypes));
73 } 73 }
74 74
75 InterpolationValue PathInterpolationFunctions::convertValue(const StylePath* sty lePath) 75 InterpolationValue PathInterpolationFunctions::convertValue(const StylePath* sty lePath)
76 { 76 {
77 if (stylePath) 77 if (stylePath)
78 return convertValue(stylePath->byteStream()); 78 return convertValue(stylePath->byteStream());
79 79
80 OwnPtr<SVGPathByteStream> emptyPath = SVGPathByteStream::create(); 80 OwnPtr<SVGPathByteStream> emptyPath = SVGPathByteStream::create();
81 return convertValue(*emptyPath); 81 return convertValue(*emptyPath);
82 } 82 }
(...skipping 24 matching lines...) Expand all
107 107
108 Vector<SVGPathSegType> m_pathSegTypes; 108 Vector<SVGPathSegType> m_pathSegTypes;
109 }; 109 };
110 110
111 InterpolationValue PathInterpolationFunctions::maybeConvertNeutral(const Interpo lationValue& underlying, InterpolationType::ConversionCheckers& conversionChecke rs) 111 InterpolationValue PathInterpolationFunctions::maybeConvertNeutral(const Interpo lationValue& underlying, InterpolationType::ConversionCheckers& conversionChecke rs)
112 { 112 {
113 conversionCheckers.append(UnderlyingPathSegTypesChecker::create(underlying)) ; 113 conversionCheckers.append(UnderlyingPathSegTypesChecker::create(underlying)) ;
114 OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentInde xCount); 114 OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentInde xCount);
115 result->set(PathArgsIndex, toInterpolableList(*underlying.interpolableValue) .get(PathArgsIndex)->cloneAndZero()); 115 result->set(PathArgsIndex, toInterpolableList(*underlying.interpolableValue) .get(PathArgsIndex)->cloneAndZero());
116 result->set(PathNeutralIndex, InterpolableNumber::create(1)); 116 result->set(PathNeutralIndex, InterpolableNumber::create(1));
117 return InterpolationValue(result.release(), underlying.nonInterpolableValue. get()); 117 return InterpolationValue(std::move(result), underlying.nonInterpolableValue .get());
118 } 118 }
119 119
120 static bool pathSegTypesMatch(const Vector<SVGPathSegType>& a, const Vector<SVGP athSegType>& b) 120 static bool pathSegTypesMatch(const Vector<SVGPathSegType>& a, const Vector<SVGP athSegType>& b)
121 { 121 {
122 if (a.size() != b.size()) 122 if (a.size() != b.size())
123 return false; 123 return false;
124 124
125 for (size_t i = 0; i < a.size(); i++) { 125 for (size_t i = 0; i < a.size(); i++) {
126 if (toAbsolutePathSegType(a[i]) != toAbsolutePathSegType(b[i])) 126 if (toAbsolutePathSegType(a[i]) != toAbsolutePathSegType(b[i]))
127 return false; 127 return false;
128 } 128 }
129 129
130 return true; 130 return true;
131 } 131 }
132 132
133 PairwiseInterpolationValue PathInterpolationFunctions::maybeMergeSingles(Interpo lationValue&& start, InterpolationValue&& end) 133 PairwiseInterpolationValue PathInterpolationFunctions::maybeMergeSingles(Interpo lationValue&& start, InterpolationValue&& end)
134 { 134 {
135 const Vector<SVGPathSegType>& startTypes = toSVGPathNonInterpolableValue(*st art.nonInterpolableValue).pathSegTypes(); 135 const Vector<SVGPathSegType>& startTypes = toSVGPathNonInterpolableValue(*st art.nonInterpolableValue).pathSegTypes();
136 const Vector<SVGPathSegType>& endTypes = toSVGPathNonInterpolableValue(*end. nonInterpolableValue).pathSegTypes(); 136 const Vector<SVGPathSegType>& endTypes = toSVGPathNonInterpolableValue(*end. nonInterpolableValue).pathSegTypes();
137 if (!pathSegTypesMatch(startTypes, endTypes)) 137 if (!pathSegTypesMatch(startTypes, endTypes))
138 return nullptr; 138 return nullptr;
139 139
140 return PairwiseInterpolationValue(start.interpolableValue.release(), end.int erpolableValue.release(), end.nonInterpolableValue.release()); 140 return PairwiseInterpolationValue(std::move(start.interpolableValue), std::m ove(end.interpolableValue), end.nonInterpolableValue.release());
141 } 141 }
142 142
143 void PathInterpolationFunctions::composite(UnderlyingValueOwner& underlyingValue Owner, double underlyingFraction, const InterpolationType& type, const Interpola tionValue& value) 143 void PathInterpolationFunctions::composite(UnderlyingValueOwner& underlyingValue Owner, double underlyingFraction, const InterpolationType& type, const Interpola tionValue& value)
144 { 144 {
145 const InterpolableList& list = toInterpolableList(*value.interpolableValue); 145 const InterpolableList& list = toInterpolableList(*value.interpolableValue);
146 double neutralComponent = toInterpolableNumber(list.get(PathNeutralIndex))-> value(); 146 double neutralComponent = toInterpolableNumber(list.get(PathNeutralIndex))-> value();
147 147
148 if (neutralComponent == 0) { 148 if (neutralComponent == 0) {
149 underlyingValueOwner.set(type, value); 149 underlyingValueOwner.set(type, value);
150 return; 150 return;
151 } 151 }
152 152
153 ASSERT(pathSegTypesMatch( 153 ASSERT(pathSegTypesMatch(
154 toSVGPathNonInterpolableValue(*underlyingValueOwner.value().nonInterpola bleValue).pathSegTypes(), 154 toSVGPathNonInterpolableValue(*underlyingValueOwner.value().nonInterpola bleValue).pathSegTypes(),
155 toSVGPathNonInterpolableValue(*value.nonInterpolableValue).pathSegTypes( ))); 155 toSVGPathNonInterpolableValue(*value.nonInterpolableValue).pathSegTypes( )));
156 underlyingValueOwner.mutableValue().interpolableValue->scaleAndAdd(neutralCo mponent, *value.interpolableValue); 156 underlyingValueOwner.mutableValue().interpolableValue->scaleAndAdd(neutralCo mponent, *value.interpolableValue);
157 underlyingValueOwner.mutableValue().nonInterpolableValue = value.nonInterpol ableValue.get(); 157 underlyingValueOwner.mutableValue().nonInterpolableValue = value.nonInterpol ableValue.get();
158 } 158 }
159 159
160 PassOwnPtr<SVGPathByteStream> PathInterpolationFunctions::appliedValue(const Int erpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableVa lue) 160 PassOwnPtr<SVGPathByteStream> PathInterpolationFunctions::appliedValue(const Int erpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableVa lue)
161 { 161 {
162 OwnPtr<SVGPathByteStream> pathByteStream = SVGPathByteStream::create(); 162 OwnPtr<SVGPathByteStream> pathByteStream = SVGPathByteStream::create();
163 InterpolatedSVGPathSource source( 163 InterpolatedSVGPathSource source(
164 toInterpolableList(*toInterpolableList(interpolableValue).get(PathArgsIn dex)), 164 toInterpolableList(*toInterpolableList(interpolableValue).get(PathArgsIn dex)),
165 toSVGPathNonInterpolableValue(nonInterpolableValue)->pathSegTypes()); 165 toSVGPathNonInterpolableValue(nonInterpolableValue)->pathSegTypes());
166 SVGPathByteStreamBuilder builder(*pathByteStream); 166 SVGPathByteStreamBuilder builder(*pathByteStream);
167 SVGPathParser::parsePath(source, builder); 167 SVGPathParser::parsePath(source, builder);
168 return pathByteStream.release(); 168 return pathByteStream;
169 } 169 }
170 170
171 } // namespace blink 171 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698