OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2002, 2003 The Karbon Developers | 2 * Copyright (C) 2002, 2003 The Karbon Developers |
3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> | 3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> |
4 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org> | 4 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org> |
5 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | 5 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 if (!m_source->hasMoreData()) | 42 if (!m_source->hasMoreData()) |
43 return true; | 43 return true; |
44 | 44 |
45 SVGPathSegType command = m_source->peekSegmentType(); | 45 SVGPathSegType command = m_source->peekSegmentType(); |
46 // Path must start with moveTo. | 46 // Path must start with moveTo. |
47 return command == PathSegMoveToAbs || command == PathSegMoveToRel; | 47 return command == PathSegMoveToAbs || command == PathSegMoveToRel; |
48 } | 48 } |
49 | 49 |
50 void SVGPathParser::emitMoveToSegment(PathSegmentData& segment) | 50 void SVGPathParser::emitMoveToSegment(PathSegmentData& segment) |
51 { | 51 { |
52 if (m_pathParsingMode == UnalteredParsing) { | |
53 m_consumer->moveTo(segment.targetPoint, m_mode); | |
54 return; | |
55 } | |
56 if (m_mode == RelativeCoordinates) | 52 if (m_mode == RelativeCoordinates) |
57 m_currentPoint += segment.targetPoint; | 53 m_currentPoint += segment.targetPoint; |
58 else | 54 else |
59 m_currentPoint = segment.targetPoint; | 55 m_currentPoint = segment.targetPoint; |
60 m_subPathPoint = m_currentPoint; | 56 m_subPathPoint = m_currentPoint; |
61 m_consumer->moveTo(m_currentPoint, AbsoluteCoordinates); | 57 m_consumer->moveTo(m_currentPoint, AbsoluteCoordinates); |
62 } | 58 } |
63 | 59 |
64 void SVGPathParser::emitLineToSegment(PathSegmentData& segment) | 60 void SVGPathParser::emitLineToSegment(PathSegmentData& segment) |
65 { | 61 { |
66 if (m_pathParsingMode == UnalteredParsing) { | |
67 m_consumer->lineTo(segment.targetPoint, m_mode); | |
68 return; | |
69 } | |
70 if (m_mode == RelativeCoordinates) | 62 if (m_mode == RelativeCoordinates) |
71 m_currentPoint += segment.targetPoint; | 63 m_currentPoint += segment.targetPoint; |
72 else | 64 else |
73 m_currentPoint = segment.targetPoint; | 65 m_currentPoint = segment.targetPoint; |
74 m_consumer->lineTo(m_currentPoint, AbsoluteCoordinates); | 66 m_consumer->lineTo(m_currentPoint, AbsoluteCoordinates); |
75 } | 67 } |
76 | 68 |
77 void SVGPathParser::emitLineToHorizontalSegment(PathSegmentData& segment) | 69 void SVGPathParser::emitLineToHorizontalSegment(PathSegmentData& segment) |
78 { | 70 { |
79 if (m_pathParsingMode == UnalteredParsing) { | |
80 m_consumer->lineToHorizontal(segment.targetPoint.x(), m_mode); | |
81 return; | |
82 } | |
83 if (m_mode == RelativeCoordinates) | 71 if (m_mode == RelativeCoordinates) |
84 m_currentPoint += segment.targetPoint; | 72 m_currentPoint += segment.targetPoint; |
85 else | 73 else |
86 m_currentPoint.setX(segment.targetPoint.x()); | 74 m_currentPoint.setX(segment.targetPoint.x()); |
87 m_consumer->lineTo(m_currentPoint, AbsoluteCoordinates); | 75 m_consumer->lineTo(m_currentPoint, AbsoluteCoordinates); |
88 } | 76 } |
89 | 77 |
90 void SVGPathParser::emitLineToVerticalSegment(PathSegmentData& segment) | 78 void SVGPathParser::emitLineToVerticalSegment(PathSegmentData& segment) |
91 { | 79 { |
92 if (m_pathParsingMode == UnalteredParsing) { | |
93 m_consumer->lineToVertical(segment.targetPoint.y(), m_mode); | |
94 return; | |
95 } | |
96 if (m_mode == RelativeCoordinates) | 80 if (m_mode == RelativeCoordinates) |
97 m_currentPoint += segment.targetPoint; | 81 m_currentPoint += segment.targetPoint; |
98 else | 82 else |
99 m_currentPoint.setY(segment.targetPoint.y()); | 83 m_currentPoint.setY(segment.targetPoint.y()); |
100 m_consumer->lineTo(m_currentPoint, AbsoluteCoordinates); | 84 m_consumer->lineTo(m_currentPoint, AbsoluteCoordinates); |
101 } | 85 } |
102 | 86 |
103 void SVGPathParser::emitCurveToCubicSegment(PathSegmentData& segment) | 87 void SVGPathParser::emitCurveToCubicSegment(PathSegmentData& segment) |
104 { | 88 { |
105 if (m_pathParsingMode == UnalteredParsing) { | |
106 m_consumer->curveToCubic(segment.point1, segment.point2, segment.targetP
oint, m_mode); | |
107 return; | |
108 } | |
109 if (m_mode == RelativeCoordinates) { | 89 if (m_mode == RelativeCoordinates) { |
110 segment.point1 += m_currentPoint; | 90 segment.point1 += m_currentPoint; |
111 segment.point2 += m_currentPoint; | 91 segment.point2 += m_currentPoint; |
112 segment.targetPoint += m_currentPoint; | 92 segment.targetPoint += m_currentPoint; |
113 } | 93 } |
114 m_consumer->curveToCubic(segment.point1, segment.point2, segment.targetPoint
, AbsoluteCoordinates); | 94 m_consumer->curveToCubic(segment.point1, segment.point2, segment.targetPoint
, AbsoluteCoordinates); |
115 | 95 |
116 m_controlPoint = segment.point2; | 96 m_controlPoint = segment.point2; |
117 m_currentPoint = segment.targetPoint; | 97 m_currentPoint = segment.targetPoint; |
118 } | 98 } |
119 | 99 |
120 static FloatPoint reflectedPoint(const FloatPoint& reflectIn, const FloatPoint&
pointToReflect) | 100 static FloatPoint reflectedPoint(const FloatPoint& reflectIn, const FloatPoint&
pointToReflect) |
121 { | 101 { |
122 return FloatPoint(2 * reflectIn.x() - pointToReflect.x(), 2 * reflectIn.y()
- pointToReflect.y()); | 102 return FloatPoint(2 * reflectIn.x() - pointToReflect.x(), 2 * reflectIn.y()
- pointToReflect.y()); |
123 } | 103 } |
124 | 104 |
125 void SVGPathParser::emitCurveToCubicSmoothSegment(PathSegmentData& segment) | 105 void SVGPathParser::emitCurveToCubicSmoothSegment(PathSegmentData& segment) |
126 { | 106 { |
127 if (m_pathParsingMode == UnalteredParsing) { | |
128 m_consumer->curveToCubicSmooth(segment.point2, segment.targetPoint, m_mo
de); | |
129 return; | |
130 } | |
131 if (m_lastCommand != PathSegCurveToCubicAbs | 107 if (m_lastCommand != PathSegCurveToCubicAbs |
132 && m_lastCommand != PathSegCurveToCubicRel | 108 && m_lastCommand != PathSegCurveToCubicRel |
133 && m_lastCommand != PathSegCurveToCubicSmoothAbs | 109 && m_lastCommand != PathSegCurveToCubicSmoothAbs |
134 && m_lastCommand != PathSegCurveToCubicSmoothRel) | 110 && m_lastCommand != PathSegCurveToCubicSmoothRel) |
135 m_controlPoint = m_currentPoint; | 111 m_controlPoint = m_currentPoint; |
136 | 112 |
137 FloatPoint point1 = reflectedPoint(m_currentPoint, m_controlPoint); | 113 FloatPoint point1 = reflectedPoint(m_currentPoint, m_controlPoint); |
138 if (m_mode == RelativeCoordinates) { | 114 if (m_mode == RelativeCoordinates) { |
139 segment.point2 += m_currentPoint; | 115 segment.point2 += m_currentPoint; |
140 segment.targetPoint += m_currentPoint; | 116 segment.targetPoint += m_currentPoint; |
141 } | 117 } |
142 | 118 |
143 m_consumer->curveToCubic(point1, segment.point2, segment.targetPoint, Absolu
teCoordinates); | 119 m_consumer->curveToCubic(point1, segment.point2, segment.targetPoint, Absolu
teCoordinates); |
144 | 120 |
145 m_controlPoint = segment.point2; | 121 m_controlPoint = segment.point2; |
146 m_currentPoint = segment.targetPoint; | 122 m_currentPoint = segment.targetPoint; |
147 } | 123 } |
148 | 124 |
149 // Blend the points with a ratio (1/3):(2/3). | 125 // Blend the points with a ratio (1/3):(2/3). |
150 static FloatPoint blendPoints(const FloatPoint& p1, const FloatPoint& p2) | 126 static FloatPoint blendPoints(const FloatPoint& p1, const FloatPoint& p2) |
151 { | 127 { |
152 const float oneOverThree = 1 / 3.f; | 128 const float oneOverThree = 1 / 3.f; |
153 return FloatPoint((p1.x() + 2 * p2.x()) * oneOverThree, (p1.y() + 2 * p2.y()
) * oneOverThree); | 129 return FloatPoint((p1.x() + 2 * p2.x()) * oneOverThree, (p1.y() + 2 * p2.y()
) * oneOverThree); |
154 } | 130 } |
155 | 131 |
156 void SVGPathParser::emitCurveToQuadraticSegment(PathSegmentData& segment) | 132 void SVGPathParser::emitCurveToQuadraticSegment(PathSegmentData& segment) |
157 { | 133 { |
158 if (m_pathParsingMode == UnalteredParsing) { | |
159 m_consumer->curveToQuadratic(segment.point1, segment.targetPoint, m_mode
); | |
160 return; | |
161 } | |
162 m_controlPoint = segment.point1; | 134 m_controlPoint = segment.point1; |
163 | 135 |
164 if (m_mode == RelativeCoordinates) { | 136 if (m_mode == RelativeCoordinates) { |
165 m_controlPoint += m_currentPoint; | 137 m_controlPoint += m_currentPoint; |
166 segment.targetPoint += m_currentPoint; | 138 segment.targetPoint += m_currentPoint; |
167 } | 139 } |
168 segment.point1 = blendPoints(m_currentPoint, m_controlPoint); | 140 segment.point1 = blendPoints(m_currentPoint, m_controlPoint); |
169 FloatPoint point2 = blendPoints(segment.targetPoint, m_controlPoint); | 141 FloatPoint point2 = blendPoints(segment.targetPoint, m_controlPoint); |
170 | 142 |
171 m_consumer->curveToCubic(segment.point1, point2, segment.targetPoint, Absolu
teCoordinates); | 143 m_consumer->curveToCubic(segment.point1, point2, segment.targetPoint, Absolu
teCoordinates); |
172 | 144 |
173 m_currentPoint = segment.targetPoint; | 145 m_currentPoint = segment.targetPoint; |
174 } | 146 } |
175 | 147 |
176 void SVGPathParser::emitCurveToQuadraticSmoothSegment(PathSegmentData& segment) | 148 void SVGPathParser::emitCurveToQuadraticSmoothSegment(PathSegmentData& segment) |
177 { | 149 { |
178 if (m_pathParsingMode == UnalteredParsing) { | |
179 m_consumer->curveToQuadraticSmooth(segment.targetPoint, m_mode); | |
180 return; | |
181 } | |
182 if (m_lastCommand != PathSegCurveToQuadraticAbs | 150 if (m_lastCommand != PathSegCurveToQuadraticAbs |
183 && m_lastCommand != PathSegCurveToQuadraticRel | 151 && m_lastCommand != PathSegCurveToQuadraticRel |
184 && m_lastCommand != PathSegCurveToQuadraticSmoothAbs | 152 && m_lastCommand != PathSegCurveToQuadraticSmoothAbs |
185 && m_lastCommand != PathSegCurveToQuadraticSmoothRel) | 153 && m_lastCommand != PathSegCurveToQuadraticSmoothRel) |
186 m_controlPoint = m_currentPoint; | 154 m_controlPoint = m_currentPoint; |
187 | 155 |
188 if (m_mode == RelativeCoordinates) | 156 if (m_mode == RelativeCoordinates) |
189 segment.targetPoint += m_currentPoint; | 157 segment.targetPoint += m_currentPoint; |
190 | 158 |
191 m_controlPoint = reflectedPoint(m_currentPoint, m_controlPoint); | 159 m_controlPoint = reflectedPoint(m_currentPoint, m_controlPoint); |
192 FloatPoint point1 = blendPoints(m_currentPoint, m_controlPoint); | 160 FloatPoint point1 = blendPoints(m_currentPoint, m_controlPoint); |
193 FloatPoint point2 = blendPoints(segment.targetPoint, m_controlPoint); | 161 FloatPoint point2 = blendPoints(segment.targetPoint, m_controlPoint); |
194 | 162 |
195 m_consumer->curveToCubic(point1, point2, segment.targetPoint, AbsoluteCoordi
nates); | 163 m_consumer->curveToCubic(point1, point2, segment.targetPoint, AbsoluteCoordi
nates); |
196 | 164 |
197 m_currentPoint = segment.targetPoint; | 165 m_currentPoint = segment.targetPoint; |
198 } | 166 } |
199 | 167 |
200 void SVGPathParser::emitArcToSegment(PathSegmentData& segment) | 168 void SVGPathParser::emitArcToSegment(PathSegmentData& segment) |
201 { | 169 { |
202 if (m_pathParsingMode == UnalteredParsing) { | |
203 m_consumer->arcTo(segment.arcRadii().x(), segment.arcRadii().y(), segmen
t.arcAngle(), segment.arcLarge, segment.arcSweep, segment.targetPoint, m_mode); | |
204 return; | |
205 } | |
206 | |
207 // If rx = 0 or ry = 0 then this arc is treated as a straight line segment (
a "lineto") joining the endpoints. | 170 // If rx = 0 or ry = 0 then this arc is treated as a straight line segment (
a "lineto") joining the endpoints. |
208 // http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters | 171 // http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters |
209 // If the current point and target point for the arc are identical, it shoul
d be treated as a zero length | 172 // If the current point and target point for the arc are identical, it shoul
d be treated as a zero length |
210 // path. This ensures continuity in animations. | 173 // path. This ensures continuity in animations. |
211 float rx = fabsf(segment.arcRadii().x()); | 174 float rx = fabsf(segment.arcRadii().x()); |
212 float ry = fabsf(segment.arcRadii().y()); | 175 float ry = fabsf(segment.arcRadii().y()); |
213 | 176 |
214 if (m_mode == RelativeCoordinates) | 177 if (m_mode == RelativeCoordinates) |
215 segment.targetPoint += m_currentPoint; | 178 segment.targetPoint += m_currentPoint; |
216 | 179 |
217 if (!rx || !ry || segment.targetPoint == m_currentPoint) { | 180 if (!rx || !ry || segment.targetPoint == m_currentPoint) { |
218 m_consumer->lineTo(segment.targetPoint, AbsoluteCoordinates); | 181 m_consumer->lineTo(segment.targetPoint, AbsoluteCoordinates); |
219 m_currentPoint = segment.targetPoint; | 182 m_currentPoint = segment.targetPoint; |
220 return; | 183 return; |
221 } | 184 } |
222 | 185 |
223 float angle = segment.arcAngle(); | 186 float angle = segment.arcAngle(); |
224 FloatPoint point1 = m_currentPoint; | 187 FloatPoint point1 = m_currentPoint; |
225 m_currentPoint = segment.targetPoint; | 188 m_currentPoint = segment.targetPoint; |
226 if (!decomposeArcToCubic(angle, rx, ry, point1, segment.targetPoint, segment
.arcLarge, segment.arcSweep)) | 189 if (!decomposeArcToCubic(angle, rx, ry, point1, segment.targetPoint, segment
.arcLarge, segment.arcSweep)) |
227 m_consumer->lineTo(segment.targetPoint, AbsoluteCoordinates); | 190 m_consumer->lineTo(segment.targetPoint, AbsoluteCoordinates); |
228 } | 191 } |
229 | 192 |
230 bool SVGPathParser::parsePathDataFromSource(PathParsingMode pathParsingMode, boo
l checkForInitialMoveTo) | 193 bool SVGPathParser::parsePathDataFromSource(PathParsingMode pathParsingMode, boo
l checkForInitialMoveTo) |
231 { | 194 { |
232 ASSERT(m_source); | 195 ASSERT(m_source); |
233 ASSERT(m_consumer); | 196 ASSERT(m_consumer); |
234 | 197 |
235 m_pathParsingMode = pathParsingMode; | |
236 | |
237 m_controlPoint = FloatPoint(); | 198 m_controlPoint = FloatPoint(); |
238 m_currentPoint = FloatPoint(); | 199 m_currentPoint = FloatPoint(); |
239 m_subPathPoint = FloatPoint(); | 200 m_subPathPoint = FloatPoint(); |
240 | 201 |
241 if (checkForInitialMoveTo && !initialCommandIsMoveTo()) | 202 if (checkForInitialMoveTo && !initialCommandIsMoveTo()) |
242 return false; | 203 return false; |
243 | 204 |
244 m_lastCommand = PathSegUnknown; | 205 m_lastCommand = PathSegUnknown; |
245 while (m_source->hasMoreData()) { | 206 while (m_source->hasMoreData()) { |
246 PathSegmentData segment = m_source->parseSegment(); | 207 PathSegmentData segment = m_source->parseSegment(); |
247 if (segment.command == PathSegUnknown) | 208 if (segment.command == PathSegUnknown) |
248 return false; | 209 return false; |
249 | 210 |
250 m_mode = AbsoluteCoordinates; | 211 if (pathParsingMode == NormalizedParsing) { |
| 212 m_mode = AbsoluteCoordinates; |
251 | 213 |
252 switch (segment.command) { | 214 switch (segment.command) { |
253 case PathSegMoveToRel: | 215 case PathSegMoveToRel: |
254 m_mode = RelativeCoordinates; | 216 m_mode = RelativeCoordinates; |
255 case PathSegMoveToAbs: | 217 case PathSegMoveToAbs: |
256 emitMoveToSegment(segment); | 218 emitMoveToSegment(segment); |
257 break; | 219 break; |
258 case PathSegLineToRel: | 220 case PathSegLineToRel: |
259 m_mode = RelativeCoordinates; | 221 m_mode = RelativeCoordinates; |
260 case PathSegLineToAbs: | 222 case PathSegLineToAbs: |
261 emitLineToSegment(segment); | 223 emitLineToSegment(segment); |
262 break; | 224 break; |
263 case PathSegLineToHorizontalRel: | 225 case PathSegLineToHorizontalRel: |
264 m_mode = RelativeCoordinates; | 226 m_mode = RelativeCoordinates; |
265 case PathSegLineToHorizontalAbs: | 227 case PathSegLineToHorizontalAbs: |
266 emitLineToHorizontalSegment(segment); | 228 emitLineToHorizontalSegment(segment); |
267 break; | 229 break; |
268 case PathSegLineToVerticalRel: | 230 case PathSegLineToVerticalRel: |
269 m_mode = RelativeCoordinates; | 231 m_mode = RelativeCoordinates; |
270 case PathSegLineToVerticalAbs: | 232 case PathSegLineToVerticalAbs: |
271 emitLineToVerticalSegment(segment); | 233 emitLineToVerticalSegment(segment); |
272 break; | 234 break; |
273 case PathSegClosePath: | 235 case PathSegClosePath: |
274 m_consumer->closePath(); | 236 m_consumer->closePath(); |
275 // Reset m_currentPoint for the next path. | 237 // Reset m_currentPoint for the next path. |
276 if (m_pathParsingMode == NormalizedParsing) | |
277 m_currentPoint = m_subPathPoint; | 238 m_currentPoint = m_subPathPoint; |
278 break; | 239 break; |
279 case PathSegCurveToCubicRel: | 240 case PathSegCurveToCubicRel: |
280 m_mode = RelativeCoordinates; | 241 m_mode = RelativeCoordinates; |
281 case PathSegCurveToCubicAbs: | 242 case PathSegCurveToCubicAbs: |
282 emitCurveToCubicSegment(segment); | 243 emitCurveToCubicSegment(segment); |
283 break; | 244 break; |
284 case PathSegCurveToCubicSmoothRel: | 245 case PathSegCurveToCubicSmoothRel: |
285 m_mode = RelativeCoordinates; | 246 m_mode = RelativeCoordinates; |
286 case PathSegCurveToCubicSmoothAbs: | 247 case PathSegCurveToCubicSmoothAbs: |
287 emitCurveToCubicSmoothSegment(segment); | 248 emitCurveToCubicSmoothSegment(segment); |
288 break; | 249 break; |
289 case PathSegCurveToQuadraticRel: | 250 case PathSegCurveToQuadraticRel: |
290 m_mode = RelativeCoordinates; | 251 m_mode = RelativeCoordinates; |
291 case PathSegCurveToQuadraticAbs: | 252 case PathSegCurveToQuadraticAbs: |
292 emitCurveToQuadraticSegment(segment); | 253 emitCurveToQuadraticSegment(segment); |
293 break; | 254 break; |
294 case PathSegCurveToQuadraticSmoothRel: | 255 case PathSegCurveToQuadraticSmoothRel: |
295 m_mode = RelativeCoordinates; | 256 m_mode = RelativeCoordinates; |
296 case PathSegCurveToQuadraticSmoothAbs: | 257 case PathSegCurveToQuadraticSmoothAbs: |
297 emitCurveToQuadraticSmoothSegment(segment); | 258 emitCurveToQuadraticSmoothSegment(segment); |
298 break; | 259 break; |
299 case PathSegArcRel: | 260 case PathSegArcRel: |
300 m_mode = RelativeCoordinates; | 261 m_mode = RelativeCoordinates; |
301 case PathSegArcAbs: | 262 case PathSegArcAbs: |
302 emitArcToSegment(segment); | 263 emitArcToSegment(segment); |
303 break; | 264 break; |
304 default: | 265 default: |
305 ASSERT_NOT_REACHED(); | 266 ASSERT_NOT_REACHED(); |
| 267 } |
| 268 } else { |
| 269 PathCoordinateMode mode = AbsoluteCoordinates; |
| 270 |
| 271 switch (segment.command) { |
| 272 case PathSegMoveToRel: |
| 273 mode = RelativeCoordinates; |
| 274 case PathSegMoveToAbs: |
| 275 m_consumer->moveTo(segment.targetPoint, mode); |
| 276 break; |
| 277 case PathSegLineToRel: |
| 278 mode = RelativeCoordinates; |
| 279 case PathSegLineToAbs: |
| 280 m_consumer->lineTo(segment.targetPoint, mode); |
| 281 break; |
| 282 case PathSegLineToHorizontalRel: |
| 283 mode = RelativeCoordinates; |
| 284 case PathSegLineToHorizontalAbs: |
| 285 m_consumer->lineToHorizontal(segment.targetPoint.x(), mode); |
| 286 break; |
| 287 case PathSegLineToVerticalRel: |
| 288 mode = RelativeCoordinates; |
| 289 case PathSegLineToVerticalAbs: |
| 290 m_consumer->lineToVertical(segment.targetPoint.y(), mode); |
| 291 break; |
| 292 case PathSegClosePath: |
| 293 m_consumer->closePath(); |
| 294 break; |
| 295 case PathSegCurveToCubicRel: |
| 296 mode = RelativeCoordinates; |
| 297 case PathSegCurveToCubicAbs: |
| 298 m_consumer->curveToCubic(segment.point1, segment.point2, segment
.targetPoint, mode); |
| 299 break; |
| 300 case PathSegCurveToCubicSmoothRel: |
| 301 mode = RelativeCoordinates; |
| 302 case PathSegCurveToCubicSmoothAbs: |
| 303 m_consumer->curveToCubicSmooth(segment.point2, segment.targetPoi
nt, mode); |
| 304 break; |
| 305 case PathSegCurveToQuadraticRel: |
| 306 mode = RelativeCoordinates; |
| 307 case PathSegCurveToQuadraticAbs: |
| 308 m_consumer->curveToQuadratic(segment.point1, segment.targetPoint
, mode); |
| 309 break; |
| 310 case PathSegCurveToQuadraticSmoothRel: |
| 311 mode = RelativeCoordinates; |
| 312 case PathSegCurveToQuadraticSmoothAbs: |
| 313 m_consumer->curveToQuadraticSmooth(segment.targetPoint, mode); |
| 314 break; |
| 315 case PathSegArcRel: |
| 316 mode = RelativeCoordinates; |
| 317 case PathSegArcAbs: |
| 318 m_consumer->arcTo(segment.arcRadii().x(), segment.arcRadii().y()
, segment.arcAngle(), segment.arcLarge, segment.arcSweep, segment.targetPoint, m
ode); |
| 319 break; |
| 320 default: |
| 321 ASSERT_NOT_REACHED(); |
| 322 } |
306 } | 323 } |
| 324 |
307 if (!m_consumer->continueConsuming()) | 325 if (!m_consumer->continueConsuming()) |
308 return true; | 326 return true; |
309 | 327 |
310 m_lastCommand = segment.command; | 328 m_lastCommand = segment.command; |
311 | 329 |
312 if (m_lastCommand != PathSegCurveToCubicAbs | 330 if (m_lastCommand != PathSegCurveToCubicAbs |
313 && m_lastCommand != PathSegCurveToCubicRel | 331 && m_lastCommand != PathSegCurveToCubicRel |
314 && m_lastCommand != PathSegCurveToCubicSmoothAbs | 332 && m_lastCommand != PathSegCurveToCubicSmoothAbs |
315 && m_lastCommand != PathSegCurveToCubicSmoothRel | 333 && m_lastCommand != PathSegCurveToCubicSmoothRel |
316 && m_lastCommand != PathSegCurveToQuadraticAbs | 334 && m_lastCommand != PathSegCurveToQuadraticAbs |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 point2 = targetPoint; | 423 point2 = targetPoint; |
406 point2.move(t * sinEndTheta, -t * cosEndTheta); | 424 point2.move(t * sinEndTheta, -t * cosEndTheta); |
407 | 425 |
408 m_consumer->curveToCubic(pointTransform.mapPoint(point1), pointTransform
.mapPoint(point2), | 426 m_consumer->curveToCubic(pointTransform.mapPoint(point1), pointTransform
.mapPoint(point2), |
409 pointTransform.mapPoint(targetPoint), AbsoluteC
oordinates); | 427 pointTransform.mapPoint(targetPoint), AbsoluteC
oordinates); |
410 } | 428 } |
411 return true; | 429 return true; |
412 } | 430 } |
413 | 431 |
414 } | 432 } |
OLD | NEW |