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

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

Issue 1120003002: [Oilpan] Migrate most classes under core/animations to Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 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 "config.h" 5 #include "config.h"
6 #include "core/animation/PathSVGInterpolation.h" 6 #include "core/animation/PathSVGInterpolation.h"
7 7
8 #include "core/svg/SVGPathElement.h" 8 #include "core/svg/SVGPathElement.h"
9 #include "core/svg/SVGPathSegArcAbs.h" 9 #include "core/svg/SVGPathSegArcAbs.h"
10 #include "core/svg/SVGPathSegArcRel.h" 10 #include "core/svg/SVGPathSegArcRel.h"
(...skipping 29 matching lines...) Expand all
40 SVGPathSegType absolutePathSegType(const SVGPathSeg& item) 40 SVGPathSegType absolutePathSegType(const SVGPathSeg& item)
41 { 41 {
42 return toAbsolutePathSegType(static_cast<SVGPathSegType>(item.pathSegType()) ); 42 return toAbsolutePathSegType(static_cast<SVGPathSegType>(item.pathSegType()) );
43 } 43 }
44 44
45 bool isAbsolutePathSegType(const SVGPathSeg& item) 45 bool isAbsolutePathSegType(const SVGPathSeg& item)
46 { 46 {
47 return isAbsolutePathSegType(static_cast<SVGPathSegType>(item.pathSegType()) ); 47 return isAbsolutePathSegType(static_cast<SVGPathSegType>(item.pathSegType()) );
48 } 48 }
49 49
50 PassOwnPtrWillBeRawPtr<InterpolableNumber> controlToInterpolableValue(double val ue, bool isAbsolute, double currentValue) 50 InterpolableNumber* controlToInterpolableValue(double value, bool isAbsolute, do uble currentValue)
51 { 51 {
52 if (isAbsolute) 52 if (isAbsolute)
53 return InterpolableNumber::create(value); 53 return InterpolableNumber::create(value);
54 return InterpolableNumber::create(currentValue + value); 54 return InterpolableNumber::create(currentValue + value);
55 } 55 }
56 56
57 double controlFromInterpolableValue(const InterpolableValue* number, bool isAbso lute, double currentValue) 57 double controlFromInterpolableValue(const InterpolableValue* number, bool isAbso lute, double currentValue)
58 { 58 {
59 double value = toInterpolableNumber(number)->value(); 59 double value = toInterpolableNumber(number)->value();
60 60
61 if (isAbsolute) 61 if (isAbsolute)
62 return value; 62 return value;
63 return value - currentValue; 63 return value - currentValue;
64 } 64 }
65 65
66 PassOwnPtrWillBeRawPtr<InterpolableNumber> specifiedToInterpolableValue(double v alue, bool isAbsolute, double& currentValue) 66 InterpolableNumber* specifiedToInterpolableValue(double value, bool isAbsolute, double& currentValue)
67 { 67 {
68 if (isAbsolute) 68 if (isAbsolute)
69 currentValue = value; 69 currentValue = value;
70 else 70 else
71 currentValue += value; 71 currentValue += value;
72 return InterpolableNumber::create(currentValue); 72 return InterpolableNumber::create(currentValue);
73 } 73 }
74 74
75 double specifiedFromInterpolableValue(const InterpolableValue* number, bool isAb solute, double& currentValue) 75 double specifiedFromInterpolableValue(const InterpolableValue* number, bool isAb solute, double& currentValue)
76 { 76 {
77 double previousValue = currentValue; 77 double previousValue = currentValue;
78 currentValue = toInterpolableNumber(number)->value(); 78 currentValue = toInterpolableNumber(number)->value();
79 79
80 if (isAbsolute) 80 if (isAbsolute)
81 return currentValue; 81 return currentValue;
82 return currentValue - previousValue; 82 return currentValue - previousValue;
83 } 83 }
84 84
85 PassOwnPtrWillBeRawPtr<InterpolableValue> pathSegClosePathToInterpolableValue(co nst SVGPathSeg& item, SubPathCoordinates& coordinates) 85 InterpolableValue* pathSegClosePathToInterpolableValue(const SVGPathSeg& item, S ubPathCoordinates& coordinates)
86 { 86 {
87 coordinates.currentX = coordinates.initialX; 87 coordinates.currentX = coordinates.initialX;
88 coordinates.currentY = coordinates.initialY; 88 coordinates.currentY = coordinates.initialY;
89 89
90 // arbitrary 90 // arbitrary
91 return InterpolableBool::create(false); 91 return InterpolableBool::create(false);
92 } 92 }
93 93
94 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegClosePathFromInterpolableValue(const I nterpolableValue&, SVGPathSegType, SubPathCoordinates& coordinates, SVGPathEleme nt* element) 94 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegClosePathFromInterpolableValue(const I nterpolableValue&, SVGPathSegType, SubPathCoordinates& coordinates, SVGPathEleme nt* element)
95 { 95 {
96 coordinates.currentX = coordinates.initialX; 96 coordinates.currentX = coordinates.initialX;
97 coordinates.currentY = coordinates.initialY; 97 coordinates.currentY = coordinates.initialY;
98 98
99 return SVGPathSegClosePath::create(element); 99 return SVGPathSegClosePath::create(element);
100 } 100 }
101 101
102 PassOwnPtrWillBeRawPtr<InterpolableValue> pathSegSingleCoordinateToInterpolableV alue(const SVGPathSegSingleCoordinate& item, SubPathCoordinates& coordinates) 102 InterpolableValue* pathSegSingleCoordinateToInterpolableValue(const SVGPathSegSi ngleCoordinate& item, SubPathCoordinates& coordinates)
103 { 103 {
104 bool isAbsolute = isAbsolutePathSegType(item); 104 bool isAbsolute = isAbsolutePathSegType(item);
105 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); 105 InterpolableList* result = InterpolableList::create(2);
106 result->set(0, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX)); 106 result->set(0, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX));
107 result->set(1, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY)); 107 result->set(1, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY));
108 108
109 if (absolutePathSegType(item) == PathSegMoveToAbs) { 109 if (absolutePathSegType(item) == PathSegMoveToAbs) {
110 // Any upcoming 'closepath' commands bring us back to the location we ha ve just moved to. 110 // Any upcoming 'closepath' commands bring us back to the location we ha ve just moved to.
111 coordinates.initialX = coordinates.currentX; 111 coordinates.initialX = coordinates.currentX;
112 coordinates.initialY = coordinates.currentY; 112 coordinates.initialY = coordinates.currentY;
113 } 113 }
114 114
115 return result.release(); 115 return result;
116 } 116 }
117 117
118 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegSingleCoordinateFromInterpolableValue( const InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coor dinates, SVGPathElement* element) 118 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegSingleCoordinateFromInterpolableValue( const InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coor dinates, SVGPathElement* element)
119 { 119 {
120 const InterpolableList& list = toInterpolableList(value); 120 const InterpolableList& list = toInterpolableList(value);
121 bool isAbsolute = isAbsolutePathSegType(segType); 121 bool isAbsolute = isAbsolutePathSegType(segType);
122 float x = specifiedFromInterpolableValue(list.get(0), isAbsolute, coordinate s.currentX); 122 float x = specifiedFromInterpolableValue(list.get(0), isAbsolute, coordinate s.currentX);
123 float y = specifiedFromInterpolableValue(list.get(1), isAbsolute, coordinate s.currentY); 123 float y = specifiedFromInterpolableValue(list.get(1), isAbsolute, coordinate s.currentY);
124 124
125 if (toAbsolutePathSegType(segType) == PathSegMoveToAbs) { 125 if (toAbsolutePathSegType(segType) == PathSegMoveToAbs) {
(...skipping 14 matching lines...) Expand all
140 case PathSegCurveToQuadraticSmoothAbs: 140 case PathSegCurveToQuadraticSmoothAbs:
141 return SVGPathSegCurvetoQuadraticSmoothAbs::create(element, x, y); 141 return SVGPathSegCurvetoQuadraticSmoothAbs::create(element, x, y);
142 case PathSegCurveToQuadraticSmoothRel: 142 case PathSegCurveToQuadraticSmoothRel:
143 return SVGPathSegCurvetoQuadraticSmoothRel::create(element, x, y); 143 return SVGPathSegCurvetoQuadraticSmoothRel::create(element, x, y);
144 default: 144 default:
145 ASSERT_NOT_REACHED(); 145 ASSERT_NOT_REACHED();
146 return nullptr; 146 return nullptr;
147 } 147 }
148 } 148 }
149 149
150 PassOwnPtrWillBeRawPtr<InterpolableValue> pathSegCurvetoCubicToInterpolableValue (const SVGPathSegCurvetoCubic& item, SubPathCoordinates& coordinates) 150 InterpolableValue* pathSegCurvetoCubicToInterpolableValue(const SVGPathSegCurvet oCubic& item, SubPathCoordinates& coordinates)
151 { 151 {
152 bool isAbsolute = isAbsolutePathSegType(item); 152 bool isAbsolute = isAbsolutePathSegType(item);
153 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(6); 153 InterpolableList* result = InterpolableList::create(6);
154 result->set(0, controlToInterpolableValue(item.x1(), isAbsolute, coordinates .currentX)); 154 result->set(0, controlToInterpolableValue(item.x1(), isAbsolute, coordinates .currentX));
155 result->set(1, controlToInterpolableValue(item.y1(), isAbsolute, coordinates .currentY)); 155 result->set(1, controlToInterpolableValue(item.y1(), isAbsolute, coordinates .currentY));
156 result->set(2, controlToInterpolableValue(item.x2(), isAbsolute, coordinates .currentX)); 156 result->set(2, controlToInterpolableValue(item.x2(), isAbsolute, coordinates .currentX));
157 result->set(3, controlToInterpolableValue(item.y2(), isAbsolute, coordinates .currentY)); 157 result->set(3, controlToInterpolableValue(item.y2(), isAbsolute, coordinates .currentY));
158 result->set(4, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX)); 158 result->set(4, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX));
159 result->set(5, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY)); 159 result->set(5, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY));
160 return result.release(); 160 return result;
161 } 161 }
162 162
163 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegCurvetoCubicFromInterpolableValue(cons t InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coordina tes, SVGPathElement* element) 163 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegCurvetoCubicFromInterpolableValue(cons t InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coordina tes, SVGPathElement* element)
164 { 164 {
165 const InterpolableList& list = toInterpolableList(value); 165 const InterpolableList& list = toInterpolableList(value);
166 bool isAbsolute = isAbsolutePathSegType(segType); 166 bool isAbsolute = isAbsolutePathSegType(segType);
167 float x1 = controlFromInterpolableValue(list.get(0), isAbsolute, coordinates .currentX); 167 float x1 = controlFromInterpolableValue(list.get(0), isAbsolute, coordinates .currentX);
168 float y1 = controlFromInterpolableValue(list.get(1), isAbsolute, coordinates .currentY); 168 float y1 = controlFromInterpolableValue(list.get(1), isAbsolute, coordinates .currentY);
169 float x2 = controlFromInterpolableValue(list.get(2), isAbsolute, coordinates .currentX); 169 float x2 = controlFromInterpolableValue(list.get(2), isAbsolute, coordinates .currentX);
170 float y2 = controlFromInterpolableValue(list.get(3), isAbsolute, coordinates .currentY); 170 float y2 = controlFromInterpolableValue(list.get(3), isAbsolute, coordinates .currentY);
171 float x = specifiedFromInterpolableValue(list.get(4), isAbsolute, coordinate s.currentX); 171 float x = specifiedFromInterpolableValue(list.get(4), isAbsolute, coordinate s.currentX);
172 float y = specifiedFromInterpolableValue(list.get(5), isAbsolute, coordinate s.currentY); 172 float y = specifiedFromInterpolableValue(list.get(5), isAbsolute, coordinate s.currentY);
173 173
174 switch (segType) { 174 switch (segType) {
175 case PathSegCurveToCubicAbs: 175 case PathSegCurveToCubicAbs:
176 return SVGPathSegCurvetoCubicAbs::create(element, x, y, x1, y1, x2, y2); 176 return SVGPathSegCurvetoCubicAbs::create(element, x, y, x1, y1, x2, y2);
177 case PathSegCurveToCubicRel: 177 case PathSegCurveToCubicRel:
178 return SVGPathSegCurvetoCubicRel::create(element, x, y, x1, y1, x2, y2); 178 return SVGPathSegCurvetoCubicRel::create(element, x, y, x1, y1, x2, y2);
179 default: 179 default:
180 ASSERT_NOT_REACHED(); 180 ASSERT_NOT_REACHED();
181 return nullptr; 181 return nullptr;
182 } 182 }
183 } 183 }
184 184
185 PassOwnPtrWillBeRawPtr<InterpolableValue> pathSegCurvetoQuadraticToInterpolableV alue(const SVGPathSegCurvetoQuadratic& item, SubPathCoordinates& coordinates) 185 InterpolableValue* pathSegCurvetoQuadraticToInterpolableValue(const SVGPathSegCu rvetoQuadratic& item, SubPathCoordinates& coordinates)
186 { 186 {
187 bool isAbsolute = isAbsolutePathSegType(item); 187 bool isAbsolute = isAbsolutePathSegType(item);
188 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(4); 188 InterpolableList* result = InterpolableList::create(4);
189 result->set(0, controlToInterpolableValue(item.x1(), isAbsolute, coordinates .currentX)); 189 result->set(0, controlToInterpolableValue(item.x1(), isAbsolute, coordinates .currentX));
190 result->set(1, controlToInterpolableValue(item.y1(), isAbsolute, coordinates .currentY)); 190 result->set(1, controlToInterpolableValue(item.y1(), isAbsolute, coordinates .currentY));
191 result->set(2, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX)); 191 result->set(2, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX));
192 result->set(3, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY)); 192 result->set(3, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY));
193 return result.release(); 193 return result;
194 } 194 }
195 195
196 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegCurvetoQuadraticFromInterpolableValue( const InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coor dinates, SVGPathElement* element) 196 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegCurvetoQuadraticFromInterpolableValue( const InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coor dinates, SVGPathElement* element)
197 { 197 {
198 const InterpolableList& list = toInterpolableList(value); 198 const InterpolableList& list = toInterpolableList(value);
199 bool isAbsolute = isAbsolutePathSegType(segType); 199 bool isAbsolute = isAbsolutePathSegType(segType);
200 float x1 = controlFromInterpolableValue(list.get(0), isAbsolute, coordinates .currentX); 200 float x1 = controlFromInterpolableValue(list.get(0), isAbsolute, coordinates .currentX);
201 float y1 = controlFromInterpolableValue(list.get(1), isAbsolute, coordinates .currentY); 201 float y1 = controlFromInterpolableValue(list.get(1), isAbsolute, coordinates .currentY);
202 float x = specifiedFromInterpolableValue(list.get(2), isAbsolute, coordinate s.currentX); 202 float x = specifiedFromInterpolableValue(list.get(2), isAbsolute, coordinate s.currentX);
203 float y = specifiedFromInterpolableValue(list.get(3), isAbsolute, coordinate s.currentY); 203 float y = specifiedFromInterpolableValue(list.get(3), isAbsolute, coordinate s.currentY);
204 switch (segType) { 204 switch (segType) {
205 case PathSegCurveToQuadraticAbs: 205 case PathSegCurveToQuadraticAbs:
206 return SVGPathSegCurvetoQuadraticAbs::create(element, x, y, x1, y1); 206 return SVGPathSegCurvetoQuadraticAbs::create(element, x, y, x1, y1);
207 case PathSegCurveToQuadraticRel: 207 case PathSegCurveToQuadraticRel:
208 return SVGPathSegCurvetoQuadraticRel::create(element, x, y, x1, y1); 208 return SVGPathSegCurvetoQuadraticRel::create(element, x, y, x1, y1);
209 default: 209 default:
210 ASSERT_NOT_REACHED(); 210 ASSERT_NOT_REACHED();
211 return nullptr; 211 return nullptr;
212 } 212 }
213 } 213 }
214 214
215 PassOwnPtrWillBeRawPtr<InterpolableValue> pathSegArcToInterpolableValue(const SV GPathSegArc& item, SubPathCoordinates& coordinates) 215 InterpolableValue* pathSegArcToInterpolableValue(const SVGPathSegArc& item, SubP athCoordinates& coordinates)
216 { 216 {
217 bool isAbsolute = isAbsolutePathSegType(item); 217 bool isAbsolute = isAbsolutePathSegType(item);
218 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(7); 218 InterpolableList* result = InterpolableList::create(7);
219 result->set(0, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX)); 219 result->set(0, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX));
220 result->set(1, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY)); 220 result->set(1, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY));
221 result->set(2, InterpolableNumber::create(item.r1())); 221 result->set(2, InterpolableNumber::create(item.r1()));
222 result->set(3, InterpolableNumber::create(item.r2())); 222 result->set(3, InterpolableNumber::create(item.r2()));
223 result->set(4, InterpolableNumber::create(item.angle())); 223 result->set(4, InterpolableNumber::create(item.angle()));
224 result->set(5, InterpolableBool::create(item.largeArcFlag())); 224 result->set(5, InterpolableBool::create(item.largeArcFlag()));
225 result->set(6, InterpolableBool::create(item.sweepFlag())); 225 result->set(6, InterpolableBool::create(item.sweepFlag()));
226 return result.release(); 226 return result;
227 } 227 }
228 228
229 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegArcFromInterpolableValue(const Interpo lableValue& value, SVGPathSegType segType, SubPathCoordinates& coordinates, SVGP athElement* element) 229 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegArcFromInterpolableValue(const Interpo lableValue& value, SVGPathSegType segType, SubPathCoordinates& coordinates, SVGP athElement* element)
230 { 230 {
231 const InterpolableList& list = toInterpolableList(value); 231 const InterpolableList& list = toInterpolableList(value);
232 bool isAbsolute = isAbsolutePathSegType(segType); 232 bool isAbsolute = isAbsolutePathSegType(segType);
233 float x = specifiedFromInterpolableValue(list.get(0), isAbsolute, coordinate s.currentX); 233 float x = specifiedFromInterpolableValue(list.get(0), isAbsolute, coordinate s.currentX);
234 float y = specifiedFromInterpolableValue(list.get(1), isAbsolute, coordinate s.currentY); 234 float y = specifiedFromInterpolableValue(list.get(1), isAbsolute, coordinate s.currentY);
235 float r1 = toInterpolableNumber(list.get(2))->value(); 235 float r1 = toInterpolableNumber(list.get(2))->value();
236 float r2 = toInterpolableNumber(list.get(3))->value(); 236 float r2 = toInterpolableNumber(list.get(3))->value();
237 float angle = toInterpolableNumber(list.get(4))->value(); 237 float angle = toInterpolableNumber(list.get(4))->value();
238 bool largeArcFlag = toInterpolableBool(list.get(5))->value(); 238 bool largeArcFlag = toInterpolableBool(list.get(5))->value();
239 bool sweepFlag = toInterpolableBool(list.get(6))->value(); 239 bool sweepFlag = toInterpolableBool(list.get(6))->value();
240 switch (segType) { 240 switch (segType) {
241 case PathSegArcAbs: 241 case PathSegArcAbs:
242 return SVGPathSegArcAbs::create(element, x, y, r1, r2, angle, largeArcFl ag, sweepFlag); 242 return SVGPathSegArcAbs::create(element, x, y, r1, r2, angle, largeArcFl ag, sweepFlag);
243 case PathSegArcRel: 243 case PathSegArcRel:
244 return SVGPathSegArcRel::create(element, x, y, r1, r2, angle, largeArcFl ag, sweepFlag); 244 return SVGPathSegArcRel::create(element, x, y, r1, r2, angle, largeArcFl ag, sweepFlag);
245 default: 245 default:
246 ASSERT_NOT_REACHED(); 246 ASSERT_NOT_REACHED();
247 return nullptr; 247 return nullptr;
248 } 248 }
249 } 249 }
250 250
251 PassOwnPtrWillBeRawPtr<InterpolableValue> pathSegLinetoHorizontalToInterpolableV alue(const SVGPathSegLinetoHorizontal& item, SubPathCoordinates& coordinates) 251 InterpolableValue* pathSegLinetoHorizontalToInterpolableValue(const SVGPathSegLi netoHorizontal& item, SubPathCoordinates& coordinates)
252 { 252 {
253 bool isAbsolute = isAbsolutePathSegType(item); 253 bool isAbsolute = isAbsolutePathSegType(item);
254 return specifiedToInterpolableValue(item.x(), isAbsolute, coordinates.curren tX); 254 return specifiedToInterpolableValue(item.x(), isAbsolute, coordinates.curren tX);
255 } 255 }
256 256
257 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegLinetoHorizontalFromInterpolableValue( const InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coor dinates, SVGPathElement* element) 257 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegLinetoHorizontalFromInterpolableValue( const InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coor dinates, SVGPathElement* element)
258 { 258 {
259 bool isAbsolute = isAbsolutePathSegType(segType); 259 bool isAbsolute = isAbsolutePathSegType(segType);
260 float x = specifiedFromInterpolableValue(&value, isAbsolute, coordinates.cur rentX); 260 float x = specifiedFromInterpolableValue(&value, isAbsolute, coordinates.cur rentX);
261 261
262 switch (segType) { 262 switch (segType) {
263 case PathSegLineToHorizontalAbs: 263 case PathSegLineToHorizontalAbs:
264 return SVGPathSegLinetoHorizontalAbs::create(element, x); 264 return SVGPathSegLinetoHorizontalAbs::create(element, x);
265 case PathSegLineToHorizontalRel: 265 case PathSegLineToHorizontalRel:
266 return SVGPathSegLinetoHorizontalRel::create(element, x); 266 return SVGPathSegLinetoHorizontalRel::create(element, x);
267 default: 267 default:
268 ASSERT_NOT_REACHED(); 268 ASSERT_NOT_REACHED();
269 return nullptr; 269 return nullptr;
270 } 270 }
271 } 271 }
272 272
273 PassOwnPtrWillBeRawPtr<InterpolableValue> pathSegLinetoVerticalToInterpolableVal ue(const SVGPathSegLinetoVertical& item, SubPathCoordinates& coordinates) 273 InterpolableValue* pathSegLinetoVerticalToInterpolableValue(const SVGPathSegLine toVertical& item, SubPathCoordinates& coordinates)
274 { 274 {
275 bool isAbsolute = isAbsolutePathSegType(item); 275 bool isAbsolute = isAbsolutePathSegType(item);
276 return specifiedToInterpolableValue(item.y(), isAbsolute, coordinates.curren tY); 276 return specifiedToInterpolableValue(item.y(), isAbsolute, coordinates.curren tY);
277 } 277 }
278 278
279 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegLinetoVerticalFromInterpolableValue(co nst InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coordi nates, SVGPathElement* element) 279 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegLinetoVerticalFromInterpolableValue(co nst InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& coordi nates, SVGPathElement* element)
280 { 280 {
281 bool isAbsolute = isAbsolutePathSegType(segType); 281 bool isAbsolute = isAbsolutePathSegType(segType);
282 float y = specifiedFromInterpolableValue(&value, isAbsolute, coordinates.cur rentY); 282 float y = specifiedFromInterpolableValue(&value, isAbsolute, coordinates.cur rentY);
283 283
284 switch (segType) { 284 switch (segType) {
285 case PathSegLineToVerticalAbs: 285 case PathSegLineToVerticalAbs:
286 return SVGPathSegLinetoVerticalAbs::create(element, y); 286 return SVGPathSegLinetoVerticalAbs::create(element, y);
287 case PathSegLineToVerticalRel: 287 case PathSegLineToVerticalRel:
288 return SVGPathSegLinetoVerticalRel::create(element, y); 288 return SVGPathSegLinetoVerticalRel::create(element, y);
289 default: 289 default:
290 ASSERT_NOT_REACHED(); 290 ASSERT_NOT_REACHED();
291 return nullptr; 291 return nullptr;
292 } 292 }
293 } 293 }
294 294
295 PassOwnPtrWillBeRawPtr<InterpolableValue> pathSegCurvetoCubicSmoothToInterpolabl eValue(const SVGPathSegCurvetoCubicSmooth& item, SubPathCoordinates& coordinates ) 295 InterpolableValue* pathSegCurvetoCubicSmoothToInterpolableValue(const SVGPathSeg CurvetoCubicSmooth& item, SubPathCoordinates& coordinates)
296 { 296 {
297 bool isAbsolute = isAbsolutePathSegType(item); 297 bool isAbsolute = isAbsolutePathSegType(item);
298 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(4); 298 InterpolableList* result = InterpolableList::create(4);
299 result->set(0, controlToInterpolableValue(item.x2(), isAbsolute, coordinates .currentX)); 299 result->set(0, controlToInterpolableValue(item.x2(), isAbsolute, coordinates .currentX));
300 result->set(1, controlToInterpolableValue(item.y2(), isAbsolute, coordinates .currentY)); 300 result->set(1, controlToInterpolableValue(item.y2(), isAbsolute, coordinates .currentY));
301 result->set(2, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX)); 301 result->set(2, specifiedToInterpolableValue(item.x(), isAbsolute, coordinate s.currentX));
302 result->set(3, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY)); 302 result->set(3, specifiedToInterpolableValue(item.y(), isAbsolute, coordinate s.currentY));
303 return result.release(); 303 return result;
304 } 304 }
305 305
306 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegCurvetoCubicSmoothFromInterpolableValu e(const InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& co ordinates, SVGPathElement* element) 306 PassRefPtrWillBeRawPtr<SVGPathSeg> pathSegCurvetoCubicSmoothFromInterpolableValu e(const InterpolableValue& value, SVGPathSegType segType, SubPathCoordinates& co ordinates, SVGPathElement* element)
307 { 307 {
308 const InterpolableList& list = toInterpolableList(value); 308 const InterpolableList& list = toInterpolableList(value);
309 bool isAbsolute = isAbsolutePathSegType(segType); 309 bool isAbsolute = isAbsolutePathSegType(segType);
310 float x2 = controlFromInterpolableValue(list.get(0), isAbsolute, coordinates .currentX); 310 float x2 = controlFromInterpolableValue(list.get(0), isAbsolute, coordinates .currentX);
311 float y2 = controlFromInterpolableValue(list.get(1), isAbsolute, coordinates .currentY); 311 float y2 = controlFromInterpolableValue(list.get(1), isAbsolute, coordinates .currentY);
312 float x = specifiedFromInterpolableValue(list.get(2), isAbsolute, coordinate s.currentX); 312 float x = specifiedFromInterpolableValue(list.get(2), isAbsolute, coordinate s.currentX);
313 float y = specifiedFromInterpolableValue(list.get(3), isAbsolute, coordinate s.currentY); 313 float y = specifiedFromInterpolableValue(list.get(3), isAbsolute, coordinate s.currentY);
314 switch (segType) { 314 switch (segType) {
315 case PathSegCurveToCubicSmoothAbs: 315 case PathSegCurveToCubicSmoothAbs:
316 return SVGPathSegCurvetoCubicSmoothAbs::create(element, x, y, x2, y2); 316 return SVGPathSegCurvetoCubicSmoothAbs::create(element, x, y, x2, y2);
317 case PathSegCurveToCubicSmoothRel: 317 case PathSegCurveToCubicSmoothRel:
318 return SVGPathSegCurvetoCubicSmoothRel::create(element, x, y, x2, y2); 318 return SVGPathSegCurvetoCubicSmoothRel::create(element, x, y, x2, y2);
319 default: 319 default:
320 ASSERT_NOT_REACHED(); 320 ASSERT_NOT_REACHED();
321 return nullptr; 321 return nullptr;
322 } 322 }
323 } 323 }
324 324
325 PassOwnPtrWillBeRawPtr<InterpolableValue> pathSegToInterpolableValue(const SVGPa thSeg& item, SubPathCoordinates& coordinates, SVGPathSegType* ptrSegType) 325 InterpolableValue* pathSegToInterpolableValue(const SVGPathSeg& item, SubPathCoo rdinates& coordinates, SVGPathSegType* ptrSegType)
326 { 326 {
327 SVGPathSegType segType = static_cast<SVGPathSegType>(item.pathSegType()); 327 SVGPathSegType segType = static_cast<SVGPathSegType>(item.pathSegType());
328 328
329 if (ptrSegType) 329 if (ptrSegType)
330 *ptrSegType = segType; 330 *ptrSegType = segType;
331 331
332 switch (segType) { 332 switch (segType) {
333 case PathSegClosePath: 333 case PathSegClosePath:
334 return pathSegClosePathToInterpolableValue(item, coordinates); 334 return pathSegClosePathToInterpolableValue(item, coordinates);
335 335
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 412
413 case PathSegUnknown: 413 case PathSegUnknown:
414 ASSERT_NOT_REACHED(); 414 ASSERT_NOT_REACHED();
415 } 415 }
416 ASSERT_NOT_REACHED(); 416 ASSERT_NOT_REACHED();
417 return nullptr; 417 return nullptr;
418 } 418 }
419 419
420 } // namespace 420 } // namespace
421 421
422 PassRefPtrWillBeRawPtr<PathSVGInterpolation> PathSVGInterpolation::maybeCreate(S VGPropertyBase* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedP ropertyBase> attribute) 422 PathSVGInterpolation* PathSVGInterpolation::maybeCreate(SVGPropertyBase* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute)
423 { 423 {
424 ASSERT(start->type() == SVGPathSegList::classType()); 424 ASSERT(start->type() == SVGPathSegList::classType());
425 ASSERT(end->type() == SVGPathSegList::classType()); 425 ASSERT(end->type() == SVGPathSegList::classType());
426 426
427 SVGPathSegList* startList = static_cast<SVGPathSegList*>(start); 427 SVGPathSegList* startList = static_cast<SVGPathSegList*>(start);
428 SVGPathSegList* endList = static_cast<SVGPathSegList*>(end); 428 SVGPathSegList* endList = static_cast<SVGPathSegList*>(end);
429 size_t length = startList->length(); 429 size_t length = startList->length();
430 if (length != endList->length()) 430 if (length != endList->length())
431 return nullptr; 431 return nullptr;
432 432
433 Vector<SVGPathSegType> pathSegTypes(length); 433 Vector<SVGPathSegType> pathSegTypes(length);
434 OwnPtrWillBeRawPtr<InterpolableList> startValue = InterpolableList::create(l ength); 434 InterpolableList* startValue = InterpolableList::create(length);
435 OwnPtrWillBeRawPtr<InterpolableList> endValue = InterpolableList::create(len gth); 435 InterpolableList* endValue = InterpolableList::create(length);
436 SubPathCoordinates startCoordinates; 436 SubPathCoordinates startCoordinates;
437 SubPathCoordinates endCoordinates; 437 SubPathCoordinates endCoordinates;
438 for (size_t i = 0; i < length; i++) { 438 for (size_t i = 0; i < length; i++) {
439 if (absolutePathSegType(*startList->at(i)) != absolutePathSegType(*endLi st->at(i))) 439 if (absolutePathSegType(*startList->at(i)) != absolutePathSegType(*endLi st->at(i)))
440 return nullptr; 440 return nullptr;
441 441
442 // Like Firefox SMIL, we use the final path seg type. 442 // Like Firefox SMIL, we use the final path seg type.
443 startValue->set(i, pathSegToInterpolableValue(*startList->at(i), startCo ordinates, nullptr)); 443 startValue->set(i, pathSegToInterpolableValue(*startList->at(i), startCo ordinates, nullptr));
444 endValue->set(i, pathSegToInterpolableValue(*endList->at(i), endCoordina tes, &pathSegTypes.at(i))); 444 endValue->set(i, pathSegToInterpolableValue(*endList->at(i), endCoordina tes, &pathSegTypes.at(i)));
445 } 445 }
446 446
447 return adoptRefWillBeNoop(new PathSVGInterpolation(startValue.release(), end Value.release(), attribute, pathSegTypes)); 447 return new PathSVGInterpolation(startValue, endValue, attribute, pathSegType s);
448 } 448 }
449 449
450 PassRefPtrWillBeRawPtr<SVGPropertyBase> PathSVGInterpolation::fromInterpolableVa lue(const InterpolableValue& value, const Vector<SVGPathSegType>& pathSegTypes, SVGPathElement* element) 450 PassRefPtrWillBeRawPtr<SVGPropertyBase> PathSVGInterpolation::fromInterpolableVa lue(const InterpolableValue& value, const Vector<SVGPathSegType>& pathSegTypes, SVGPathElement* element)
451 { 451 {
452 const InterpolableList& listValue = toInterpolableList(value); 452 const InterpolableList& listValue = toInterpolableList(value);
453 RefPtrWillBeRawPtr<SVGPathSegList> result = SVGPathSegList::create(element); 453 RefPtrWillBeRawPtr<SVGPathSegList> result = SVGPathSegList::create(element);
454 SubPathCoordinates coordinates; 454 SubPathCoordinates coordinates;
455 for (size_t i = 0; i < listValue.length(); i++) 455 for (size_t i = 0; i < listValue.length(); i++)
456 result->append(pathSegFromInterpolableValue(*listValue.get(i), pathSegTy pes.at(i), coordinates, element)); 456 result->append(pathSegFromInterpolableValue(*listValue.get(i), pathSegTy pes.at(i), coordinates, element));
457 return result.release(); 457 return result.release();
458 } 458 }
459 459
460 PassRefPtrWillBeRawPtr<SVGPropertyBase> PathSVGInterpolation::interpolatedValue( SVGElement& element) const 460 PassRefPtrWillBeRawPtr<SVGPropertyBase> PathSVGInterpolation::interpolatedValue( SVGElement& element) const
461 { 461 {
462 return fromInterpolableValue(*m_cachedValue, m_pathSegTypes, toSVGPathElemen t(&element)); 462 return fromInterpolableValue(*m_cachedValue, m_pathSegTypes, toSVGPathElemen t(&element));
463 } 463 }
464 464
465 } 465 }
OLDNEW
« no previous file with comments | « Source/core/animation/PathSVGInterpolation.h ('k') | Source/core/animation/PointSVGInterpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698