PassOwnPtr<InterpolationValue> PathInterpolationFunctions::convertValue(const InterpolationType& type, const SVGPathByteStream& byteStream) { SVGPathByteStreamSource pathSource(byteStream); size_t length = 0; PathCoordinates currentCoordinates; Vector<OwnPtr<InterpolableValue>> interpolablePathSegs; Vector<SVGPathSegType> pathSegTypes; while (pathSource.hasMoreData()) { const PathSegmentData segment = pathSource.parseSegment(); interpolablePathSegs.append(SVGPathSegInterpolationFunctions::consumePathSeg(segment, currentCoordinates)); pathSegTypes.append(segment.command); length++; } OwnPtr<InterpolableList> pathArgs = InterpolableList::create(length); for (size_t i = 0; i < interpolablePathSegs.size(); i++) pathArgs->set(i, interpolablePathSegs[i].release()); OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentIndexCount); result->set(PathArgsIndex, pathArgs.release()); result->set(PathNeutralIndex, InterpolableNumber::create(0)); return InterpolationValue::create(type, result.release(), SVGPathNonInterpolableValue::create(pathSegTypes)); }
InterpolationValue PathInterpolationFunctions::convertValue( const SVGPathByteStream& byteStream) { SVGPathByteStreamSource pathSource(byteStream); size_t length = 0; PathCoordinates currentCoordinates; Vector<std::unique_ptr<InterpolableValue>> interpolablePathSegs; Vector<SVGPathSegType> pathSegTypes; while (pathSource.hasMoreData()) { const PathSegmentData segment = pathSource.parseSegment(); interpolablePathSegs.push_back( SVGPathSegInterpolationFunctions::consumePathSeg(segment, currentCoordinates)); pathSegTypes.push_back(segment.command); length++; } std::unique_ptr<InterpolableList> pathArgs = InterpolableList::create(length); for (size_t i = 0; i < interpolablePathSegs.size(); i++) pathArgs->set(i, std::move(interpolablePathSegs[i])); std::unique_ptr<InterpolableList> result = InterpolableList::create(PathComponentIndexCount); result->set(PathArgsIndex, std::move(pathArgs)); result->set(PathNeutralIndex, InterpolableNumber::create(0)); return InterpolationValue(std::move(result), SVGPathNonInterpolableValue::create(pathSegTypes)); }
PassOwnPtr<InterpolationValue> SVGPathInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const { if (svgValue.type() != AnimatedPath) return nullptr; SVGPathByteStreamSource pathSource(toSVGPath(svgValue).byteStream()); size_t length = 0; PathCoordinates currentCoordinates; Vector<OwnPtr<InterpolableValue>> interpolablePathSegs; Vector<SVGPathSegType> pathSegTypes; while (pathSource.hasMoreData()) { const PathSegmentData segment = pathSource.parseSegment(); interpolablePathSegs.append(SVGPathSegInterpolationFunctions::consumePathSeg(segment, currentCoordinates)); pathSegTypes.append(segment.command); length++; } OwnPtr<InterpolableList> pathArgs = InterpolableList::create(length); for (size_t i = 0; i < interpolablePathSegs.size(); i++) pathArgs->set(i, interpolablePathSegs[i].release()); OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentIndexCount); result->set(PathArgsIndex, pathArgs.release()); result->set(PathNeutralIndex, InterpolableNumber::create(0)); return InterpolationValue::create(*this, result.release(), SVGPathNonInterpolableValue::create(pathSegTypes)); }