PathSegmentData SVGPathByteStreamSource::parseSegment() { ASSERT(hasMoreData()); PathSegmentData segment; segment.command = static_cast<SVGPathSegType>(readSVGSegmentType()); switch (segment.command) { case PathSegCurveToCubicRel: case PathSegCurveToCubicAbs: segment.point1 = readFloatPoint(); /* fall through */ case PathSegCurveToCubicSmoothRel: case PathSegCurveToCubicSmoothAbs: segment.point2 = readFloatPoint(); /* fall through */ case PathSegMoveToRel: case PathSegMoveToAbs: case PathSegLineToRel: case PathSegLineToAbs: case PathSegCurveToQuadraticSmoothRel: case PathSegCurveToQuadraticSmoothAbs: segment.targetPoint = readFloatPoint(); break; case PathSegLineToHorizontalRel: case PathSegLineToHorizontalAbs: segment.targetPoint.setX(readFloat()); break; case PathSegLineToVerticalRel: case PathSegLineToVerticalAbs: segment.targetPoint.setY(readFloat()); break; case PathSegClosePath: break; case PathSegCurveToQuadraticRel: case PathSegCurveToQuadraticAbs: segment.point1 = readFloatPoint(); segment.targetPoint = readFloatPoint(); break; case PathSegArcRel: case PathSegArcAbs: { segment.arcRadii() = readFloatPoint(); segment.setArcAngle(readFloat()); segment.arcLarge = readFlag(); segment.arcSweep = readFlag(); segment.targetPoint = readFloatPoint(); break; } default: ASSERT_NOT_REACHED(); } return segment; }
PathSegmentData consumeInterpolableArc(const InterpolableValue& value, SVGPathSegType segType, PathCoordinates& coordinates) { const InterpolableList& list = toInterpolableList(value); bool isAbsolute = isAbsolutePathSegType(segType); PathSegmentData segment; segment.command = segType; segment.targetPoint.setX(consumeInterpolableCoordinateAxis( list.get(0), isAbsolute, coordinates.currentX)); segment.targetPoint.setY(consumeInterpolableCoordinateAxis( list.get(1), isAbsolute, coordinates.currentY)); segment.arcRadii().setX(toInterpolableNumber(list.get(2))->value()); segment.arcRadii().setY(toInterpolableNumber(list.get(3))->value()); segment.setArcAngle(toInterpolableNumber(list.get(4))->value()); segment.arcLarge = toInterpolableBool(list.get(5))->value(); segment.arcSweep = toInterpolableBool(list.get(6))->value(); return segment; }