OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> |
| 4 * |
| 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. |
| 9 * |
| 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. |
| 14 * |
| 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. |
| 19 */ |
| 20 |
| 21 #ifndef SVGPathData_h |
| 22 #define SVGPathData_h |
| 23 |
| 24 #include "platform/geometry/FloatPoint.h" |
| 25 #include "wtf/Allocator.h" |
| 26 |
| 27 namespace blink { |
| 28 |
| 29 enum SVGPathSegType { |
| 30 PathSegUnknown = 0, |
| 31 PathSegClosePath = 1, |
| 32 PathSegMoveToAbs = 2, |
| 33 PathSegMoveToRel = 3, |
| 34 PathSegLineToAbs = 4, |
| 35 PathSegLineToRel = 5, |
| 36 PathSegCurveToCubicAbs = 6, |
| 37 PathSegCurveToCubicRel = 7, |
| 38 PathSegCurveToQuadraticAbs = 8, |
| 39 PathSegCurveToQuadraticRel = 9, |
| 40 PathSegArcAbs = 10, |
| 41 PathSegArcRel = 11, |
| 42 PathSegLineToHorizontalAbs = 12, |
| 43 PathSegLineToHorizontalRel = 13, |
| 44 PathSegLineToVerticalAbs = 14, |
| 45 PathSegLineToVerticalRel = 15, |
| 46 PathSegCurveToCubicSmoothAbs = 16, |
| 47 PathSegCurveToCubicSmoothRel = 17, |
| 48 PathSegCurveToQuadraticSmoothAbs = 18, |
| 49 PathSegCurveToQuadraticSmoothRel = 19 |
| 50 }; |
| 51 |
| 52 static inline SVGPathSegType toAbsolutePathSegType(const SVGPathSegType type) |
| 53 { |
| 54 // Clear the LSB to get the absolute command. |
| 55 return type >= PathSegMoveToAbs ? static_cast<SVGPathSegType>(type & ~1u) :
type; |
| 56 } |
| 57 |
| 58 static inline bool isAbsolutePathSegType(const SVGPathSegType type) |
| 59 { |
| 60 // For commands with an ordinal >= PathSegMoveToAbs, and odd number => relat
ive command. |
| 61 return type < PathSegMoveToAbs || type % 2 == 0; |
| 62 } |
| 63 |
| 64 struct PathSegmentData { |
| 65 STACK_ALLOCATED(); |
| 66 PathSegmentData() |
| 67 : command(PathSegUnknown) |
| 68 , arcSweep(false) |
| 69 , arcLarge(false) |
| 70 { |
| 71 } |
| 72 |
| 73 const FloatPoint& arcRadii() const { return point1; } |
| 74 FloatPoint& arcRadii() { return point1; } |
| 75 |
| 76 float arcAngle() const { return point2.x(); } |
| 77 void setArcAngle(float angle) { point2.setX(angle); } |
| 78 |
| 79 float r1() const { return arcRadii().x(); } |
| 80 float r2() const { return arcRadii().y(); } |
| 81 |
| 82 bool largeArcFlag() const { return arcLarge; } |
| 83 bool sweepFlag() const { return arcSweep; } |
| 84 |
| 85 float x() const { return targetPoint.x(); } |
| 86 float y() const { return targetPoint.y(); } |
| 87 |
| 88 float x1() const { return point1.x(); } |
| 89 float y1() const { return point1.y(); } |
| 90 |
| 91 float x2() const { return point2.x(); } |
| 92 float y2() const { return point2.y(); } |
| 93 |
| 94 SVGPathSegType command; |
| 95 FloatPoint targetPoint; |
| 96 FloatPoint point1; |
| 97 FloatPoint point2; |
| 98 bool arcSweep; |
| 99 bool arcLarge; |
| 100 }; |
| 101 |
| 102 } // namespace blink |
| 103 |
| 104 #endif // SVGPathData_h |
OLD | NEW |