| 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 |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include "core/svg/SVGPathParser.h" | 24 #include "core/svg/SVGPathParser.h" |
| 25 | 25 |
| 26 #include "core/svg/SVGPathConsumer.h" | 26 #include "core/svg/SVGPathConsumer.h" |
| 27 #include "core/svg/SVGPathSource.h" | |
| 28 #include "platform/transforms/AffineTransform.h" | 27 #include "platform/transforms/AffineTransform.h" |
| 29 #include "wtf/MathExtras.h" | 28 #include "wtf/MathExtras.h" |
| 30 | 29 |
| 31 namespace blink { | 30 namespace blink { |
| 32 | 31 |
| 33 bool SVGPathParser::initialCommandIsMoveTo() | |
| 34 { | |
| 35 // If the path is empty it is still valid, so return true. | |
| 36 if (!m_source->hasMoreData()) | |
| 37 return true; | |
| 38 | |
| 39 SVGPathSegType command = m_source->peekSegmentType(); | |
| 40 // Path must start with moveTo. | |
| 41 return command == PathSegMoveToAbs || command == PathSegMoveToRel; | |
| 42 } | |
| 43 | |
| 44 bool SVGPathParser::parsePath() | |
| 45 { | |
| 46 while (m_source->hasMoreData()) { | |
| 47 PathSegmentData segment = m_source->parseSegment(); | |
| 48 if (segment.command == PathSegUnknown) | |
| 49 return false; | |
| 50 | |
| 51 m_consumer->emitSegment(segment); | |
| 52 } | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 static FloatPoint reflectedPoint(const FloatPoint& reflectIn, const FloatPoint&
pointToReflect) | 32 static FloatPoint reflectedPoint(const FloatPoint& reflectIn, const FloatPoint&
pointToReflect) |
| 57 { | 33 { |
| 58 return FloatPoint(2 * reflectIn.x() - pointToReflect.x(), 2 * reflectIn.y()
- pointToReflect.y()); | 34 return FloatPoint(2 * reflectIn.x() - pointToReflect.x(), 2 * reflectIn.y()
- pointToReflect.y()); |
| 59 } | 35 } |
| 60 | 36 |
| 61 // Blend the points with a ratio (1/3):(2/3). | 37 // Blend the points with a ratio (1/3):(2/3). |
| 62 static FloatPoint blendPoints(const FloatPoint& p1, const FloatPoint& p2) | 38 static FloatPoint blendPoints(const FloatPoint& p1, const FloatPoint& p2) |
| 63 { | 39 { |
| 64 const float oneOverThree = 1 / 3.f; | 40 const float oneOverThree = 1 / 3.f; |
| 65 return FloatPoint((p1.x() + 2 * p2.x()) * oneOverThree, (p1.y() + 2 * p2.y()
) * oneOverThree); | 41 return FloatPoint((p1.x() + 2 * p2.x()) * oneOverThree, (p1.y() + 2 * p2.y()
) * oneOverThree); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 cubicSegment.point1 = pointTransform.mapPoint(point1); | 267 cubicSegment.point1 = pointTransform.mapPoint(point1); |
| 292 cubicSegment.point2 = pointTransform.mapPoint(point2); | 268 cubicSegment.point2 = pointTransform.mapPoint(point2); |
| 293 cubicSegment.targetPoint = pointTransform.mapPoint(targetPoint); | 269 cubicSegment.targetPoint = pointTransform.mapPoint(targetPoint); |
| 294 | 270 |
| 295 m_consumer->emitSegment(cubicSegment); | 271 m_consumer->emitSegment(cubicSegment); |
| 296 } | 272 } |
| 297 return true; | 273 return true; |
| 298 } | 274 } |
| 299 | 275 |
| 300 } // namespace blink | 276 } // namespace blink |
| OLD | NEW |