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 22 #if ENABLE(SVG) 23 #include "SVGPathByteStreamSource.h" 24 25 namespace WebCore { 26 27 SVGPathByteStreamSource::SVGPathByteStreamSource(SVGPathByteStream* stream) 28 : m_stream(stream) 29 { 30 ASSERT(stream); 31 m_streamCurrent = stream->begin(); 32 m_streamEnd = stream->end(); 33 } 34 35 bool SVGPathByteStreamSource::hasMoreData() const 36 { 37 return m_streamCurrent < m_streamEnd; 38 } 39 40 bool SVGPathByteStreamSource::parseSVGSegmentType(SVGPathSegType& pathSegType) 41 { 42 pathSegType = static_cast<SVGPathSegType>(readSVGSegmentType()); 43 return true; 44 } 45 46 SVGPathSegType SVGPathByteStreamSource::nextCommand(SVGPathSegType) 47 { 48 return static_cast<SVGPathSegType>(readSVGSegmentType()); 49 } 50 51 bool SVGPathByteStreamSource::parseMoveToSegment(FloatPoint& targetPoint) 52 { 53 targetPoint = readFloatPoint(); 54 return true; 55 } 56 57 bool SVGPathByteStreamSource::parseLineToSegment(FloatPoint& targetPoint) 58 { 59 targetPoint = readFloatPoint(); 60 return true; 61 } 62 63 bool SVGPathByteStreamSource::parseLineToHorizontalSegment(float& x) 64 { 65 x = readFloat(); 66 return true; 67 } 68 69 bool SVGPathByteStreamSource::parseLineToVerticalSegment(float& y) 70 { 71 y = readFloat(); 72 return true; 73 } 74 75 bool SVGPathByteStreamSource::parseCurveToCubicSegment(FloatPoint& point1, FloatPoint& point2, FloatPoint& targetPoint) 76 { 77 point1 = readFloatPoint(); 78 point2 = readFloatPoint(); 79 targetPoint = readFloatPoint(); 80 return true; 81 } 82 83 bool SVGPathByteStreamSource::parseCurveToCubicSmoothSegment(FloatPoint& point2, FloatPoint& targetPoint) 84 { 85 point2 = readFloatPoint(); 86 targetPoint = readFloatPoint(); 87 return true; 88 } 89 90 bool SVGPathByteStreamSource::parseCurveToQuadraticSegment(FloatPoint& point1, FloatPoint& targetPoint) 91 { 92 point1 = readFloatPoint(); 93 targetPoint = readFloatPoint(); 94 return true; 95 } 96 97 bool SVGPathByteStreamSource::parseCurveToQuadraticSmoothSegment(FloatPoint& targetPoint) 98 { 99 targetPoint = readFloatPoint(); 100 return true; 101 } 102 103 bool SVGPathByteStreamSource::parseArcToSegment(float& rx, float& ry, float& angle, bool& largeArc, bool& sweep, FloatPoint& targetPoint) 104 { 105 rx = readFloat(); 106 ry = readFloat(); 107 angle = readFloat(); 108 largeArc = readFlag(); 109 sweep = readFlag(); 110 targetPoint = readFloatPoint(); 111 return true; 112 } 113 114 } 115 116 #endif // ENABLE(SVG) 117