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