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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 { | 239 { |
240 float rx; | 240 float rx; |
241 float ry; | 241 float ry; |
242 float angle; | 242 float angle; |
243 bool largeArc; | 243 bool largeArc; |
244 bool sweep; | 244 bool sweep; |
245 FloatPoint targetPoint; | 245 FloatPoint targetPoint; |
246 if (!m_source->parseArcToSegment(rx, ry, angle, largeArc, sweep, targetPoint )) | 246 if (!m_source->parseArcToSegment(rx, ry, angle, largeArc, sweep, targetPoint )) |
247 return false; | 247 return false; |
248 | 248 |
249 if (m_pathParsingMode == UnalteredParsing) { | |
250 m_consumer->arcTo(rx, ry, angle, largeArc, sweep, targetPoint, m_mode); | |
251 return true; | |
252 } | |
253 | |
kouhei (in TOK)
2015/03/17 01:57:46
Nit: Might want to add ASSERT(m_pathParsingMode ==
fs
2015/03/17 09:28:28
With the follow-ups I have this is going to be mor
| |
249 // If rx = 0 or ry = 0 then this arc is treated as a straight line segment ( a "lineto") joining the endpoints. | 254 // If rx = 0 or ry = 0 then this arc is treated as a straight line segment ( a "lineto") joining the endpoints. |
250 // http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters | 255 // http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters |
251 // If the current point and target point for the arc are identical, it shoul d be treated as a zero length | 256 // If the current point and target point for the arc are identical, it shoul d be treated as a zero length |
252 // path. This ensures continuity in animations. | 257 // path. This ensures continuity in animations. |
253 rx = fabsf(rx); | 258 rx = fabsf(rx); |
254 ry = fabsf(ry); | 259 ry = fabsf(ry); |
255 bool arcIsZeroLength = false; | 260 bool arcIsZeroLength = false; |
256 if (m_pathParsingMode == NormalizedParsing) { | 261 if (m_mode == RelativeCoordinates) |
262 arcIsZeroLength = targetPoint == FloatPoint::zero(); | |
263 else | |
264 arcIsZeroLength = targetPoint == m_currentPoint; | |
265 if (!rx || !ry || arcIsZeroLength) { | |
257 if (m_mode == RelativeCoordinates) | 266 if (m_mode == RelativeCoordinates) |
258 arcIsZeroLength = targetPoint == FloatPoint::zero(); | 267 m_currentPoint += targetPoint; |
259 else | 268 else |
260 arcIsZeroLength = targetPoint == m_currentPoint; | 269 m_currentPoint = targetPoint; |
261 } | 270 m_consumer->lineTo(m_currentPoint, AbsoluteCoordinates); |
262 if (!rx || !ry || arcIsZeroLength) { | |
263 if (m_pathParsingMode == NormalizedParsing) { | |
264 if (m_mode == RelativeCoordinates) | |
265 m_currentPoint += targetPoint; | |
266 else | |
267 m_currentPoint = targetPoint; | |
268 m_consumer->lineTo(m_currentPoint, AbsoluteCoordinates); | |
269 } else | |
270 m_consumer->lineTo(targetPoint, m_mode); | |
271 return true; | 271 return true; |
272 } | 272 } |
273 | 273 |
274 if (m_pathParsingMode == NormalizedParsing) { | 274 FloatPoint point1 = m_currentPoint; |
275 FloatPoint point1 = m_currentPoint; | 275 if (m_mode == RelativeCoordinates) |
276 if (m_mode == RelativeCoordinates) | 276 targetPoint += m_currentPoint; |
277 targetPoint += m_currentPoint; | 277 m_currentPoint = targetPoint; |
278 m_currentPoint = targetPoint; | 278 return decomposeArcToCubic(angle, rx, ry, point1, targetPoint, largeArc, swe ep); |
279 return decomposeArcToCubic(angle, rx, ry, point1, targetPoint, largeArc, sweep); | |
280 } | |
281 m_consumer->arcTo(rx, ry, angle, largeArc, sweep, targetPoint, m_mode); | |
282 return true; | |
283 } | 279 } |
284 | 280 |
285 bool SVGPathParser::parsePathDataFromSource(PathParsingMode pathParsingMode, boo l checkForInitialMoveTo) | 281 bool SVGPathParser::parsePathDataFromSource(PathParsingMode pathParsingMode, boo l checkForInitialMoveTo) |
286 { | 282 { |
287 ASSERT(m_source); | 283 ASSERT(m_source); |
288 ASSERT(m_consumer); | 284 ASSERT(m_consumer); |
289 | 285 |
290 m_pathParsingMode = pathParsingMode; | 286 m_pathParsingMode = pathParsingMode; |
291 | 287 |
292 m_controlPoint = FloatPoint(); | 288 m_controlPoint = FloatPoint(); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 point2 = targetPoint; | 473 point2 = targetPoint; |
478 point2.move(t * sinEndTheta, -t * cosEndTheta); | 474 point2.move(t * sinEndTheta, -t * cosEndTheta); |
479 | 475 |
480 m_consumer->curveToCubic(pointTransform.mapPoint(point1), pointTransform .mapPoint(point2), | 476 m_consumer->curveToCubic(pointTransform.mapPoint(point1), pointTransform .mapPoint(point2), |
481 pointTransform.mapPoint(targetPoint), AbsoluteC oordinates); | 477 pointTransform.mapPoint(targetPoint), AbsoluteC oordinates); |
482 } | 478 } |
483 return true; | 479 return true; |
484 } | 480 } |
485 | 481 |
486 } | 482 } |
OLD | NEW |