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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "core/svg/SVGPathSegLinetoVerticalAbs.h" | 45 #include "core/svg/SVGPathSegLinetoVerticalAbs.h" |
46 #include "core/svg/SVGPathSegLinetoVerticalRel.h" | 46 #include "core/svg/SVGPathSegLinetoVerticalRel.h" |
47 #include "core/svg/SVGPathSegMovetoAbs.h" | 47 #include "core/svg/SVGPathSegMovetoAbs.h" |
48 #include "core/svg/SVGPathSegMovetoRel.h" | 48 #include "core/svg/SVGPathSegMovetoRel.h" |
49 | 49 |
50 namespace blink { | 50 namespace blink { |
51 | 51 |
52 SVGPathSegListBuilder::SVGPathSegListBuilder() | 52 SVGPathSegListBuilder::SVGPathSegListBuilder() |
53 : m_pathElement(0) | 53 : m_pathElement(0) |
54 , m_pathSegList(nullptr) | 54 , m_pathSegList(nullptr) |
55 , m_pathSegRole(PathSegUndefinedRole) | |
56 { | 55 { |
57 } | 56 } |
58 | 57 |
59 void SVGPathSegListBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoor
dinateMode mode) | 58 void SVGPathSegListBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoor
dinateMode mode) |
60 { | 59 { |
61 ASSERT(m_pathElement); | 60 ASSERT(m_pathElement); |
62 ASSERT(m_pathSegList); | 61 ASSERT(m_pathSegList); |
63 if (mode == AbsoluteCoordinates) | 62 if (mode == AbsoluteCoordinates) |
64 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegMovetoAbs::create(m
_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y())); | 63 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegMovetoAbs::create(m
_pathElement, targetPoint.x(), targetPoint.y())); |
65 else | 64 else |
66 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegMovetoRel::create(m
_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y())); | 65 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegMovetoRel::create(m
_pathElement, targetPoint.x(), targetPoint.y())); |
67 } | 66 } |
68 | 67 |
69 void SVGPathSegListBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinate
Mode mode) | 68 void SVGPathSegListBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinate
Mode mode) |
70 { | 69 { |
71 ASSERT(m_pathElement); | 70 ASSERT(m_pathElement); |
72 ASSERT(m_pathSegList); | 71 ASSERT(m_pathSegList); |
73 if (mode == AbsoluteCoordinates) | 72 if (mode == AbsoluteCoordinates) |
74 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoAbs::create(m
_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y())); | 73 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoAbs::create(m
_pathElement, targetPoint.x(), targetPoint.y())); |
75 else | 74 else |
76 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoRel::create(m
_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y())); | 75 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoRel::create(m
_pathElement, targetPoint.x(), targetPoint.y())); |
77 } | 76 } |
78 | 77 |
79 void SVGPathSegListBuilder::lineToHorizontal(float x, PathCoordinateMode mode) | 78 void SVGPathSegListBuilder::lineToHorizontal(float x, PathCoordinateMode mode) |
80 { | 79 { |
81 ASSERT(m_pathElement); | 80 ASSERT(m_pathElement); |
82 ASSERT(m_pathSegList); | 81 ASSERT(m_pathSegList); |
83 if (mode == AbsoluteCoordinates) | 82 if (mode == AbsoluteCoordinates) |
84 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoHorizontalAbs
::create(m_pathElement, m_pathSegRole, x)); | 83 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoHorizontalAbs
::create(m_pathElement, x)); |
85 else | 84 else |
86 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoHorizontalRel
::create(m_pathElement, m_pathSegRole, x)); | 85 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoHorizontalRel
::create(m_pathElement, x)); |
87 } | 86 } |
88 | 87 |
89 void SVGPathSegListBuilder::lineToVertical(float y, PathCoordinateMode mode) | 88 void SVGPathSegListBuilder::lineToVertical(float y, PathCoordinateMode mode) |
90 { | 89 { |
91 ASSERT(m_pathElement); | 90 ASSERT(m_pathElement); |
92 ASSERT(m_pathSegList); | 91 ASSERT(m_pathSegList); |
93 if (mode == AbsoluteCoordinates) | 92 if (mode == AbsoluteCoordinates) |
94 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoVerticalAbs::
create(m_pathElement, m_pathSegRole, y)); | 93 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoVerticalAbs::
create(m_pathElement, y)); |
95 else | 94 else |
96 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoVerticalRel::
create(m_pathElement, m_pathSegRole, y)); | 95 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoVerticalRel::
create(m_pathElement, y)); |
97 } | 96 } |
98 | 97 |
99 void SVGPathSegListBuilder::curveToCubic(const FloatPoint& point1, const FloatPo
int& point2, const FloatPoint& targetPoint, PathCoordinateMode mode) | 98 void SVGPathSegListBuilder::curveToCubic(const FloatPoint& point1, const FloatPo
int& point2, const FloatPoint& targetPoint, PathCoordinateMode mode) |
100 { | 99 { |
101 ASSERT(m_pathElement); | 100 ASSERT(m_pathElement); |
102 ASSERT(m_pathSegList); | 101 ASSERT(m_pathSegList); |
103 if (mode == AbsoluteCoordinates) | 102 if (mode == AbsoluteCoordinates) |
104 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicAbs::cr
eate(m_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y(), point1.x(),
point1.y(), point2.x(), point2.y())); | 103 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicAbs::cr
eate(m_pathElement, targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), po
int2.x(), point2.y())); |
105 else | 104 else |
106 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicRel::cr
eate(m_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y(), point1.x(),
point1.y(), point2.x(), point2.y())); | 105 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicRel::cr
eate(m_pathElement, targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), po
int2.x(), point2.y())); |
107 } | 106 } |
108 | 107 |
109 void SVGPathSegListBuilder::curveToCubicSmooth(const FloatPoint& point2, const F
loatPoint& targetPoint, PathCoordinateMode mode) | 108 void SVGPathSegListBuilder::curveToCubicSmooth(const FloatPoint& point2, const F
loatPoint& targetPoint, PathCoordinateMode mode) |
110 { | 109 { |
111 ASSERT(m_pathElement); | 110 ASSERT(m_pathElement); |
112 ASSERT(m_pathSegList); | 111 ASSERT(m_pathSegList); |
113 if (mode == AbsoluteCoordinates) | 112 if (mode == AbsoluteCoordinates) |
114 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicSmoothA
bs::create(m_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y(), point
2.x(), point2.y())); | 113 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicSmoothA
bs::create(m_pathElement, targetPoint.x(), targetPoint.y(), point2.x(), point2.y
())); |
115 else | 114 else |
116 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicSmoothR
el::create(m_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y(), point
2.x(), point2.y())); | 115 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicSmoothR
el::create(m_pathElement, targetPoint.x(), targetPoint.y(), point2.x(), point2.y
())); |
117 } | 116 } |
118 | 117 |
119 void SVGPathSegListBuilder::curveToQuadratic(const FloatPoint& point1, const Flo
atPoint& targetPoint, PathCoordinateMode mode) | 118 void SVGPathSegListBuilder::curveToQuadratic(const FloatPoint& point1, const Flo
atPoint& targetPoint, PathCoordinateMode mode) |
120 { | 119 { |
121 ASSERT(m_pathElement); | 120 ASSERT(m_pathElement); |
122 ASSERT(m_pathSegList); | 121 ASSERT(m_pathSegList); |
123 if (mode == AbsoluteCoordinates) | 122 if (mode == AbsoluteCoordinates) |
124 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticAbs
::create(m_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y(), point1.
x(), point1.y())); | 123 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticAbs
::create(m_pathElement, targetPoint.x(), targetPoint.y(), point1.x(), point1.y()
)); |
125 else | 124 else |
126 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticRel
::create(m_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y(), point1.
x(), point1.y())); | 125 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticRel
::create(m_pathElement, targetPoint.x(), targetPoint.y(), point1.x(), point1.y()
)); |
127 } | 126 } |
128 | 127 |
129 void SVGPathSegListBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint
, PathCoordinateMode mode) | 128 void SVGPathSegListBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint
, PathCoordinateMode mode) |
130 { | 129 { |
131 ASSERT(m_pathElement); | 130 ASSERT(m_pathElement); |
132 ASSERT(m_pathSegList); | 131 ASSERT(m_pathSegList); |
133 if (mode == AbsoluteCoordinates) | 132 if (mode == AbsoluteCoordinates) |
134 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticSmo
othAbs::create(m_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y())); | 133 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticSmo
othAbs::create(m_pathElement, targetPoint.x(), targetPoint.y())); |
135 else | 134 else |
136 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticSmo
othRel::create(m_pathElement, m_pathSegRole, targetPoint.x(), targetPoint.y())); | 135 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticSmo
othRel::create(m_pathElement, targetPoint.x(), targetPoint.y())); |
137 } | 136 } |
138 | 137 |
139 void SVGPathSegListBuilder::arcTo(float r1, float r2, float angle, bool largeArc
Flag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode) | 138 void SVGPathSegListBuilder::arcTo(float r1, float r2, float angle, bool largeArc
Flag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode) |
140 { | 139 { |
141 ASSERT(m_pathElement); | 140 ASSERT(m_pathElement); |
142 ASSERT(m_pathSegList); | 141 ASSERT(m_pathSegList); |
143 if (mode == AbsoluteCoordinates) | 142 if (mode == AbsoluteCoordinates) |
144 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegArcAbs::create(m_pa
thElement, m_pathSegRole, targetPoint.x(), targetPoint.y(), r1, r2, angle, large
ArcFlag, sweepFlag)); | 143 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegArcAbs::create(m_pa
thElement, targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepF
lag)); |
145 else | 144 else |
146 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegArcRel::create(m_pa
thElement, m_pathSegRole, targetPoint.x(), targetPoint.y(), r1, r2, angle, large
ArcFlag, sweepFlag)); | 145 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegArcRel::create(m_pa
thElement, targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepF
lag)); |
147 } | 146 } |
148 | 147 |
149 void SVGPathSegListBuilder::closePath() | 148 void SVGPathSegListBuilder::closePath() |
150 { | 149 { |
151 ASSERT(m_pathElement); | 150 ASSERT(m_pathElement); |
152 ASSERT(m_pathSegList); | 151 ASSERT(m_pathSegList); |
153 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegClosePath::create(m_pat
hElement, m_pathSegRole)); | 152 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegClosePath::create(m_pat
hElement)); |
154 } | 153 } |
155 | 154 |
156 } | 155 } |
OLD | NEW |