1 | /* |
2 | * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
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 |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #include "config.h" |
21 | #include "SVGPathByteStreamSource.h" |
22 | |
23 | namespace WebCore { |
24 | |
25 | SVGPathByteStreamSource::SVGPathByteStreamSource(const SVGPathByteStream& stream) |
26 | { |
27 | m_streamCurrent = stream.begin(); |
28 | m_streamEnd = stream.end(); |
29 | } |
30 | |
31 | bool SVGPathByteStreamSource::hasMoreData() const |
32 | { |
33 | return m_streamCurrent < m_streamEnd; |
34 | } |
35 | |
36 | bool SVGPathByteStreamSource::parseSVGSegmentType(SVGPathSegType& pathSegType) |
37 | { |
38 | pathSegType = static_cast<SVGPathSegType>(readSVGSegmentType()); |
39 | return true; |
40 | } |
41 | |
42 | SVGPathSegType SVGPathByteStreamSource::nextCommand(SVGPathSegType) |
43 | { |
44 | return static_cast<SVGPathSegType>(readSVGSegmentType()); |
45 | } |
46 | |
47 | bool SVGPathByteStreamSource::parseMoveToSegment(FloatPoint& targetPoint) |
48 | { |
49 | targetPoint = readFloatPoint(); |
50 | return true; |
51 | } |
52 | |
53 | bool SVGPathByteStreamSource::parseLineToSegment(FloatPoint& targetPoint) |
54 | { |
55 | targetPoint = readFloatPoint(); |
56 | return true; |
57 | } |
58 | |
59 | bool SVGPathByteStreamSource::parseLineToHorizontalSegment(float& x) |
60 | { |
61 | x = readFloat(); |
62 | return true; |
63 | } |
64 | |
65 | bool SVGPathByteStreamSource::parseLineToVerticalSegment(float& y) |
66 | { |
67 | y = readFloat(); |
68 | return true; |
69 | } |
70 | |
71 | bool SVGPathByteStreamSource::parseCurveToCubicSegment(FloatPoint& point1, FloatPoint& point2, FloatPoint& targetPoint) |
72 | { |
73 | point1 = readFloatPoint(); |
74 | point2 = readFloatPoint(); |
75 | targetPoint = readFloatPoint(); |
76 | return true; |
77 | } |
78 | |
79 | bool SVGPathByteStreamSource::parseCurveToCubicSmoothSegment(FloatPoint& point2, FloatPoint& targetPoint) |
80 | { |
81 | point2 = readFloatPoint(); |
82 | targetPoint = readFloatPoint(); |
83 | return true; |
84 | } |
85 | |
86 | bool SVGPathByteStreamSource::parseCurveToQuadraticSegment(FloatPoint& point1, FloatPoint& targetPoint) |
87 | { |
88 | point1 = readFloatPoint(); |
89 | targetPoint = readFloatPoint(); |
90 | return true; |
91 | } |
92 | |
93 | bool SVGPathByteStreamSource::parseCurveToQuadraticSmoothSegment(FloatPoint& targetPoint) |
94 | { |
95 | targetPoint = readFloatPoint(); |
96 | return true; |
97 | } |
98 | |
99 | bool SVGPathByteStreamSource::parseArcToSegment(float& rx, float& ry, float& angle, bool& largeArc, bool& sweep, FloatPoint& targetPoint) |
100 | { |
101 | rx = readFloat(); |
102 | ry = readFloat(); |
103 | angle = readFloat(); |
104 | largeArc = readFlag(); |
105 | sweep = readFlag(); |
106 | targetPoint = readFloatPoint(); |
107 | return true; |
108 | } |
109 | |
110 | } |
111 | |