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 | |
22 #include "core/svg/SVGPathUtilities.h" | 21 #include "core/svg/SVGPathUtilities.h" |
23 | 22 |
24 #include "core/svg/SVGPathBlender.h" | 23 #include "core/svg/SVGPathBlender.h" |
25 #include "core/svg/SVGPathBuilder.h" | 24 #include "core/svg/SVGPathBuilder.h" |
26 #include "core/svg/SVGPathByteStreamBuilder.h" | 25 #include "core/svg/SVGPathByteStreamBuilder.h" |
27 #include "core/svg/SVGPathByteStreamSource.h" | 26 #include "core/svg/SVGPathByteStreamSource.h" |
28 #include "core/svg/SVGPathElement.h" | 27 #include "core/svg/SVGPathElement.h" |
29 #include "core/svg/SVGPathParser.h" | 28 #include "core/svg/SVGPathParser.h" |
30 #include "core/svg/SVGPathSegListBuilder.h" | 29 #include "core/svg/SVGPathSegListBuilder.h" |
31 #include "core/svg/SVGPathSegListSource.h" | 30 #include "core/svg/SVGPathSegListSource.h" |
32 #include "core/svg/SVGPathStringBuilder.h" | 31 #include "core/svg/SVGPathStringBuilder.h" |
33 #include "core/svg/SVGPathStringSource.h" | 32 #include "core/svg/SVGPathStringSource.h" |
34 #include "core/svg/SVGPathTraversalStateBuilder.h" | 33 #include "core/svg/SVGPathTraversalStateBuilder.h" |
35 #include "platform/graphics/PathTraversalState.h" | 34 #include "platform/graphics/PathTraversalState.h" |
36 | 35 |
37 namespace blink { | 36 namespace blink { |
38 | 37 |
39 bool buildPathFromString(const String& d, Path& result) | 38 bool buildPathFromString(const String& d, Path& result) |
40 { | 39 { |
41 if (d.isEmpty()) | 40 if (d.isEmpty()) |
42 return true; | 41 return true; |
43 | 42 |
44 SVGPathBuilder builder(result); | 43 SVGPathBuilder builder(result); |
45 OwnPtrWillBeRawPtr<SVGPathStringSource> source = SVGPathStringSource::create
(d); | 44 SVGPathStringSource source(d); |
46 SVGPathParser parser(source.get(), &builder); | 45 SVGPathParser parser(&source, &builder); |
47 return parser.parsePathDataFromSource(NormalizedParsing); | 46 return parser.parsePathDataFromSource(NormalizedParsing); |
48 } | 47 } |
49 | 48 |
50 bool buildPathFromByteStream(const SVGPathByteStream& stream, Path& result) | 49 bool buildPathFromByteStream(const SVGPathByteStream& stream, Path& result) |
51 { | 50 { |
52 if (stream.isEmpty()) | 51 if (stream.isEmpty()) |
53 return true; | 52 return true; |
54 | 53 |
55 SVGPathBuilder builder(result); | 54 SVGPathBuilder builder(result); |
56 SVGPathByteStreamSource source(stream); | 55 SVGPathByteStreamSource source(stream); |
(...skipping 17 matching lines...) Expand all Loading... |
74 bool buildSVGPathByteStreamFromString(const String& d, SVGPathByteStream& result
, PathParsingMode parsingMode) | 73 bool buildSVGPathByteStreamFromString(const String& d, SVGPathByteStream& result
, PathParsingMode parsingMode) |
75 { | 74 { |
76 result.clear(); | 75 result.clear(); |
77 if (d.isEmpty()) | 76 if (d.isEmpty()) |
78 return true; | 77 return true; |
79 | 78 |
80 // The string length is typically a minor overestimate of eventual byte stre
am size, so it avoids us a lot of reallocs. | 79 // The string length is typically a minor overestimate of eventual byte stre
am size, so it avoids us a lot of reallocs. |
81 result.reserveInitialCapacity(d.length()); | 80 result.reserveInitialCapacity(d.length()); |
82 | 81 |
83 SVGPathByteStreamBuilder builder(result); | 82 SVGPathByteStreamBuilder builder(result); |
84 OwnPtrWillBeRawPtr<SVGPathStringSource> source = SVGPathStringSource::create
(d); | 83 SVGPathStringSource source(d); |
85 SVGPathParser parser(source.get(), &builder); | 84 SVGPathParser parser(&source, &builder); |
86 bool ok = parser.parsePathDataFromSource(parsingMode); | 85 bool ok = parser.parsePathDataFromSource(parsingMode); |
87 result.shrinkToFit(); | 86 result.shrinkToFit(); |
88 return ok; | 87 return ok; |
89 } | 88 } |
90 | 89 |
91 bool addToSVGPathByteStream(SVGPathByteStream& fromStream, const SVGPathByteStre
am& byStream, unsigned repeatCount) | 90 bool addToSVGPathByteStream(SVGPathByteStream& fromStream, const SVGPathByteStre
am& byStream, unsigned repeatCount) |
92 { | 91 { |
93 if (fromStream.isEmpty() || byStream.isEmpty()) | 92 if (fromStream.isEmpty() || byStream.isEmpty()) |
94 return true; | 93 return true; |
95 | 94 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 PathTraversalState traversalState(PathTraversalState::TraversalPointAtLength
); | 138 PathTraversalState traversalState(PathTraversalState::TraversalPointAtLength
); |
140 SVGPathTraversalStateBuilder builder(traversalState, length); | 139 SVGPathTraversalStateBuilder builder(traversalState, length); |
141 SVGPathByteStreamSource source(stream); | 140 SVGPathByteStreamSource source(stream); |
142 SVGPathParser parser(&source, &builder); | 141 SVGPathParser parser(&source, &builder); |
143 bool ok = parser.parsePathDataFromSource(NormalizedParsing); | 142 bool ok = parser.parsePathDataFromSource(NormalizedParsing); |
144 point = builder.currentPoint(); | 143 point = builder.currentPoint(); |
145 return ok; | 144 return ok; |
146 } | 145 } |
147 | 146 |
148 } | 147 } |
OLD | NEW |