| 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 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 { | 46 { |
| 47 if (stream.isEmpty()) | 47 if (stream.isEmpty()) |
| 48 return true; | 48 return true; |
| 49 | 49 |
| 50 SVGPathBuilder builder(result); | 50 SVGPathBuilder builder(result); |
| 51 SVGPathByteStreamSource source(stream); | 51 SVGPathByteStreamSource source(stream); |
| 52 SVGPathParser parser(&source, &builder); | 52 SVGPathParser parser(&source, &builder); |
| 53 return parser.parsePathDataFromSource(NormalizedParsing); | 53 return parser.parsePathDataFromSource(NormalizedParsing); |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool buildStringFromByteStream(const SVGPathByteStream& stream, String& result,
PathParsingMode parsingMode) | 56 String buildStringFromByteStream(const SVGPathByteStream& stream, PathParsingMod
e parsingMode) |
| 57 { | 57 { |
| 58 if (stream.isEmpty()) | 58 if (stream.isEmpty()) |
| 59 return true; | 59 return String(); |
| 60 | 60 |
| 61 SVGPathStringBuilder builder; | 61 SVGPathStringBuilder builder; |
| 62 SVGPathByteStreamSource source(stream); | 62 SVGPathByteStreamSource source(stream); |
| 63 SVGPathParser parser(&source, &builder); | 63 SVGPathParser parser(&source, &builder); |
| 64 bool ok = parser.parsePathDataFromSource(parsingMode); | 64 parser.parsePathDataFromSource(parsingMode); |
| 65 result = builder.result(); | 65 return builder.result(); |
| 66 return ok; | |
| 67 } | 66 } |
| 68 | 67 |
| 69 bool buildSVGPathByteStreamFromString(const String& d, SVGPathByteStream& result
, PathParsingMode parsingMode) | 68 bool buildByteStreamFromString(const String& d, SVGPathByteStream& result) |
| 70 { | 69 { |
| 71 result.clear(); | 70 result.clear(); |
| 72 if (d.isEmpty()) | 71 if (d.isEmpty()) |
| 73 return true; | 72 return true; |
| 74 | 73 |
| 75 // The string length is typically a minor overestimate of eventual byte stre
am size, so it avoids us a lot of reallocs. | 74 // The string length is typically a minor overestimate of eventual byte stre
am size, so it avoids us a lot of reallocs. |
| 76 result.reserveInitialCapacity(d.length()); | 75 result.reserveInitialCapacity(d.length()); |
| 77 | 76 |
| 78 SVGPathByteStreamBuilder builder(result); | 77 SVGPathByteStreamBuilder builder(result); |
| 79 SVGPathStringSource source(d); | 78 SVGPathStringSource source(d); |
| 80 SVGPathParser parser(&source, &builder); | 79 SVGPathParser parser(&source, &builder); |
| 81 bool ok = parser.parsePathDataFromSource(parsingMode); | 80 bool ok = parser.parsePathDataFromSource(UnalteredParsing); |
| 82 result.shrinkToFit(); | 81 result.shrinkToFit(); |
| 83 return ok; | 82 return ok; |
| 84 } | 83 } |
| 85 | 84 |
| 86 unsigned getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream& str
eam, float length) | 85 unsigned getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream& str
eam, float length) |
| 87 { | 86 { |
| 88 if (stream.isEmpty()) | 87 if (stream.isEmpty()) |
| 89 return 0; | 88 return 0; |
| 90 | 89 |
| 91 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalSegmentAtL
ength, length); | 90 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalSegmentAtL
ength, length); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 113 return FloatPoint(); | 112 return FloatPoint(); |
| 114 | 113 |
| 115 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalPointAtLen
gth, length); | 114 SVGPathTraversalStateBuilder builder(PathTraversalState::TraversalPointAtLen
gth, length); |
| 116 SVGPathByteStreamSource source(stream); | 115 SVGPathByteStreamSource source(stream); |
| 117 SVGPathParser parser(&source, &builder); | 116 SVGPathParser parser(&source, &builder); |
| 118 parser.parsePathDataFromSource(NormalizedParsing); | 117 parser.parsePathDataFromSource(NormalizedParsing); |
| 119 return builder.currentPoint(); | 118 return builder.currentPoint(); |
| 120 } | 119 } |
| 121 | 120 |
| 122 } | 121 } |
| OLD | NEW |