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/SVGPathBlender.h" | |
24 #include "core/svg/SVGPathBuilder.h" | 23 #include "core/svg/SVGPathBuilder.h" |
25 #include "core/svg/SVGPathByteStreamBuilder.h" | 24 #include "core/svg/SVGPathByteStreamBuilder.h" |
26 #include "core/svg/SVGPathByteStreamSource.h" | 25 #include "core/svg/SVGPathByteStreamSource.h" |
27 #include "core/svg/SVGPathElement.h" | |
28 #include "core/svg/SVGPathParser.h" | 26 #include "core/svg/SVGPathParser.h" |
29 #include "core/svg/SVGPathStringBuilder.h" | 27 #include "core/svg/SVGPathStringBuilder.h" |
30 #include "core/svg/SVGPathStringSource.h" | 28 #include "core/svg/SVGPathStringSource.h" |
31 #include "core/svg/SVGPathTraversalStateBuilder.h" | 29 #include "core/svg/SVGPathTraversalStateBuilder.h" |
32 #include "platform/graphics/PathTraversalState.h" | 30 #include "platform/graphics/PathTraversalState.h" |
33 | 31 |
34 namespace blink { | 32 namespace blink { |
35 | 33 |
36 bool buildPathFromString(const String& d, Path& result) | 34 bool buildPathFromString(const String& d, Path& result) |
37 { | 35 { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 result.reserveInitialCapacity(d.length()); | 76 result.reserveInitialCapacity(d.length()); |
79 | 77 |
80 SVGPathByteStreamBuilder builder(result); | 78 SVGPathByteStreamBuilder builder(result); |
81 SVGPathStringSource source(d); | 79 SVGPathStringSource source(d); |
82 SVGPathParser parser(&source, &builder); | 80 SVGPathParser parser(&source, &builder); |
83 bool ok = parser.parsePathDataFromSource(parsingMode); | 81 bool ok = parser.parsePathDataFromSource(parsingMode); |
84 result.shrinkToFit(); | 82 result.shrinkToFit(); |
85 return ok; | 83 return ok; |
86 } | 84 } |
87 | 85 |
88 bool addToSVGPathByteStream(SVGPathByteStream& fromStream, const SVGPathByteStre
am& byStream, unsigned repeatCount) | |
89 { | |
90 if (fromStream.isEmpty() || byStream.isEmpty()) | |
91 return true; | |
92 | |
93 OwnPtr<SVGPathByteStream> fromStreamCopy = fromStream.copy(); | |
94 fromStream.clear(); | |
95 | |
96 SVGPathByteStreamBuilder builder(fromStream); | |
97 SVGPathByteStreamSource fromSource(*fromStreamCopy); | |
98 SVGPathByteStreamSource bySource(byStream); | |
99 SVGPathBlender blender(&fromSource, &bySource, &builder); | |
100 return blender.addAnimatedPath(repeatCount); | |
101 } | |
102 | |
103 unsigned getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream& str
eam, float length) | 86 unsigned getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream& str
eam, float length) |
104 { | 87 { |
105 if (stream.isEmpty()) | 88 if (stream.isEmpty()) |
106 return 0; | 89 return 0; |
107 | 90 |
108 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalSegmentAtL
ength, length); | 91 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalSegmentAtL
ength, length); |
109 SVGPathByteStreamSource source(stream); | 92 SVGPathByteStreamSource source(stream); |
110 SVGPathParser parser(&source, &builder); | 93 SVGPathParser parser(&source, &builder); |
111 parser.parsePathDataFromSource(NormalizedParsing); | 94 parser.parsePathDataFromSource(NormalizedParsing); |
112 return builder.pathSegmentIndex(); | 95 return builder.pathSegmentIndex(); |
(...skipping 17 matching lines...) Expand all Loading... |
130 return FloatPoint(); | 113 return FloatPoint(); |
131 | 114 |
132 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalPointAtLen
gth, length); | 115 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalPointAtLen
gth, length); |
133 SVGPathByteStreamSource source(stream); | 116 SVGPathByteStreamSource source(stream); |
134 SVGPathParser parser(&source, &builder); | 117 SVGPathParser parser(&source, &builder); |
135 parser.parsePathDataFromSource(NormalizedParsing); | 118 parser.parsePathDataFromSource(NormalizedParsing); |
136 return builder.currentPoint(); | 119 return builder.currentPoint(); |
137 } | 120 } |
138 | 121 |
139 } | 122 } |
OLD | NEW |