2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
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.
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.
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.
22 #include "core/svg/SVGPathByteStreamBuilder.h"
24 #include "core/svg/SVGPathSeg.h"
25 #include "wtf/OwnPtr.h"
29 SVGPathByteStreamBuilder::SVGPathByteStreamBuilder()
34 void SVGPathByteStreamBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoordinateMode mode)
37 writeSegmentType(mode == RelativeCoordinates ? PathSegMoveToRel : PathSegMoveToAbs);
38 writeFloatPoint(targetPoint);
41 void SVGPathByteStreamBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode mode)
44 writeSegmentType(mode == RelativeCoordinates ? PathSegLineToRel : PathSegLineToAbs);
45 writeFloatPoint(targetPoint);
48 void SVGPathByteStreamBuilder::lineToHorizontal(float x, PathCoordinateMode mode)
51 writeSegmentType(mode == RelativeCoordinates ? PathSegLineToHorizontalRel : PathSegLineToHorizontalAbs);
55 void SVGPathByteStreamBuilder::lineToVertical(float y, PathCoordinateMode mode)
58 writeSegmentType(mode == RelativeCoordinates ? PathSegLineToVerticalRel : PathSegLineToVerticalAbs);
62 void SVGPathByteStreamBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode)
65 writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToCubicRel : PathSegCurveToCubicAbs);
66 writeFloatPoint(point1);
67 writeFloatPoint(point2);
68 writeFloatPoint(targetPoint);
71 void SVGPathByteStreamBuilder::curveToCubicSmooth(const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode)
74 writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToCubicSmoothRel : PathSegCurveToCubicSmoothAbs);
75 writeFloatPoint(point2);
76 writeFloatPoint(targetPoint);
79 void SVGPathByteStreamBuilder::curveToQuadratic(const FloatPoint& point1, const FloatPoint& targetPoint, PathCoordinateMode mode)
82 writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToQuadraticRel : PathSegCurveToQuadraticAbs);
83 writeFloatPoint(point1);
84 writeFloatPoint(targetPoint);
87 void SVGPathByteStreamBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint, PathCoordinateMode mode)
90 writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToQuadraticSmoothRel : PathSegCurveToQuadraticSmoothAbs);
91 writeFloatPoint(targetPoint);
94 void SVGPathByteStreamBuilder::arcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode)
97 writeSegmentType(mode == RelativeCoordinates ? PathSegArcRel : PathSegArcAbs);
101 writeFlag(largeArcFlag);
102 writeFlag(sweepFlag);
103 writeFloatPoint(targetPoint);
106 void SVGPathByteStreamBuilder::closePath()
108 ASSERT(m_byteStream);
109 writeSegmentType(PathSegClosePath);
112 } // namespace WebCore