OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010, 2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010, 2012. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "config.h" | 20 #include "config.h" |
21 #include "core/svg/SVGPathUtilities.h" | 21 #include "core/svg/SVGPathUtilities.h" |
22 | 22 |
23 #include "core/svg/SVGPathBuilder.h" | 23 #include "core/svg/SVGPathBuilder.h" |
24 #include "core/svg/SVGPathByteStreamBuilder.h" | 24 #include "core/svg/SVGPathByteStreamBuilder.h" |
25 #include "core/svg/SVGPathByteStreamSource.h" | 25 #include "core/svg/SVGPathByteStreamSource.h" |
26 #include "core/svg/SVGPathParser.h" | 26 #include "core/svg/SVGPathParser.h" |
27 #include "core/svg/SVGPathStringBuilder.h" | 27 #include "core/svg/SVGPathStringBuilder.h" |
28 #include "core/svg/SVGPathStringSource.h" | 28 #include "core/svg/SVGPathStringSource.h" |
29 #include "core/svg/SVGPathTraversalStateBuilder.h" | |
30 #include "platform/graphics/PathTraversalState.h" | |
31 | 29 |
32 namespace blink { | 30 namespace blink { |
33 | 31 |
34 bool buildPathFromString(const String& d, Path& result) | 32 bool buildPathFromString(const String& d, Path& result) |
35 { | 33 { |
36 if (d.isEmpty()) | 34 if (d.isEmpty()) |
37 return true; | 35 return true; |
38 | 36 |
39 SVGPathBuilder builder(result); | 37 SVGPathBuilder builder(result); |
40 SVGPathStringSource source(d); | 38 SVGPathStringSource source(d); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 result.reserveInitialCapacity(d.length()); | 73 result.reserveInitialCapacity(d.length()); |
76 | 74 |
77 SVGPathByteStreamBuilder builder(result); | 75 SVGPathByteStreamBuilder builder(result); |
78 SVGPathStringSource source(d); | 76 SVGPathStringSource source(d); |
79 SVGPathParser parser(&source, &builder); | 77 SVGPathParser parser(&source, &builder); |
80 bool ok = parser.parsePathDataFromSource(UnalteredParsing); | 78 bool ok = parser.parsePathDataFromSource(UnalteredParsing); |
81 result.shrinkToFit(); | 79 result.shrinkToFit(); |
82 return ok; | 80 return ok; |
83 } | 81 } |
84 | 82 |
85 unsigned getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream& str
eam, float length) | |
86 { | |
87 if (stream.isEmpty()) | |
88 return 0; | |
89 | |
90 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalSegmentAtL
ength, length); | |
91 SVGPathByteStreamSource source(stream); | |
92 SVGPathParser parser(&source, &builder); | |
93 parser.parsePathDataFromSource(NormalizedParsing); | |
94 return builder.pathSegmentIndex(); | |
95 } | 83 } |
96 | |
97 float getTotalLengthOfSVGPathByteStream(const SVGPathByteStream& stream) | |
98 { | |
99 if (stream.isEmpty()) | |
100 return 0; | |
101 | |
102 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalTotalLengt
h); | |
103 SVGPathByteStreamSource source(stream); | |
104 SVGPathParser parser(&source, &builder); | |
105 parser.parsePathDataFromSource(NormalizedParsing); | |
106 return builder.totalLength(); | |
107 } | |
108 | |
109 FloatPoint getPointAtLengthOfSVGPathByteStream(const SVGPathByteStream& stream,
float length) | |
110 { | |
111 if (stream.isEmpty()) | |
112 return FloatPoint(); | |
113 | |
114 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalPointAtLen
gth, length); | |
115 SVGPathByteStreamSource source(stream); | |
116 SVGPathParser parser(&source, &builder); | |
117 parser.parsePathDataFromSource(NormalizedParsing); | |
118 return builder.currentPoint(); | |
119 } | |
120 | |
121 } | |
OLD | NEW |