Cleanup and simplification of SVG path-related classes
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Oct 2015 03:34:08 +0000 (03:34 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Oct 2015 03:34:08 +0000 (03:34 +0000)
commit898b05ec8a2bc18a2fa1a7ef07e0467c50c90e44
treef15e84e0096bb317838f80c56d1e4f206a62a9bc
parentca23acfe1a7c53b961ea7959660daca8c7f0128c
Cleanup and simplification of SVG path-related classes
https://bugs.webkit.org/show_bug.cgi?id=150011

Reviewed by Zalan Bujtas.

Many SVG path-related subclasses were stateful, but only because code in
SVGPathUtilities kept global copies around for no reason. A microbenchmark
showed that there was no benefit to keeping global singletons of SVGPathBuilder,
SVGPathSegListBuilder, SVGPathByteStreamBuilder, SVGPathStringBuilder,
SVGPathTraversalStateBuilder, SVGPathParser and SVGPathBlender.

Making these classes not be re-usable makes the code much simpler, allowing
their SVGPathSources, SVGPathConsumers, SVGPathByteStream etc. to be stored
by reference, and eliminating the cleanup() function which created annoying
ordering issues.

Code that uses SVGPathParser and SVGPathBlender is further simplified by having
these classes expose only static functions, hiding any internal statefulness.

* svg/SVGPathBlender.cpp: Remove the m_progress member variable and instead
pass progress to the various blend functions, as we do for other blend functions.
Expose two only static functions. Pointers to references.
(WebCore::SVGPathBlender::addAnimatedPath):
(WebCore::SVGPathBlender::blendAnimatedPath):
(WebCore::SVGPathBlender::SVGPathBlender):
(WebCore::SVGPathBlender::blendAnimatedDimensonalFloat):
(WebCore::SVGPathBlender::blendAnimatedFloatPoint):
(WebCore::SVGPathBlender::blendMoveToSegment):
(WebCore::SVGPathBlender::blendLineToSegment):
(WebCore::SVGPathBlender::blendLineToHorizontalSegment):
(WebCore::SVGPathBlender::blendLineToVerticalSegment):
(WebCore::SVGPathBlender::blendCurveToCubicSegment):
(WebCore::SVGPathBlender::blendCurveToCubicSmoothSegment):
(WebCore::SVGPathBlender::blendCurveToQuadraticSegment):
(WebCore::SVGPathBlender::blendCurveToQuadraticSmoothSegment):
(WebCore::SVGPathBlender::blendArcToSegment):
(WebCore::SVGPathBlender::cleanup): Deleted.
* svg/SVGPathBlender.h: Make the constructor take a ref to the destination Path,
which is stored by reference.
* svg/SVGPathBuilder.cpp:
(WebCore::SVGPathBuilder::SVGPathBuilder):
(WebCore::SVGPathBuilder::moveTo):
(WebCore::SVGPathBuilder::lineTo):
(WebCore::SVGPathBuilder::curveToCubic):
(WebCore::SVGPathBuilder::closePath):
* svg/SVGPathBuilder.h:
(WebCore::SVGPathBuilder::setCurrentPath): Deleted.
* svg/SVGPathByteStreamBuilder.cpp: References, assertions removed.
(WebCore::SVGPathByteStreamBuilder::SVGPathByteStreamBuilder):
* svg/SVGPathByteStreamBuilder.h:
(WebCore::SVGPathByteStreamBuilder::writeType):
(WebCore::SVGPathByteStreamBuilder::setCurrentByteStream): Deleted.
* svg/SVGPathConsumer.h:
* svg/SVGPathElement.cpp:
* svg/SVGPathParser.cpp: Expose some static helper functions for parsing
to byte streams and strings. References.
(WebCore::SVGPathParser::parse):
(WebCore::SVGPathParser::parseToByteStream):
(WebCore::SVGPathParser::parseToString):
(WebCore::SVGPathParser::SVGPathParser):
(WebCore::SVGPathParser::parseClosePathSegment):
(WebCore::SVGPathParser::parseMoveToSegment):
(WebCore::SVGPathParser::parseLineToSegment):
(WebCore::SVGPathParser::parseLineToHorizontalSegment):
(WebCore::SVGPathParser::parseLineToVerticalSegment):
(WebCore::SVGPathParser::parseCurveToCubicSegment):
(WebCore::SVGPathParser::parseCurveToCubicSmoothSegment):
(WebCore::SVGPathParser::parseCurveToQuadraticSegment):
(WebCore::SVGPathParser::parseCurveToQuadraticSmoothSegment):
(WebCore::SVGPathParser::parseArcToSegment):
(WebCore::SVGPathParser::parsePathData):
(WebCore::SVGPathParser::decomposeArcToCubic):
(WebCore::SVGPathParser::parsePathDataFromSource): Deleted.
(WebCore::SVGPathParser::cleanup): Deleted.
* svg/SVGPathParser.h:
(WebCore::SVGPathParser::setCurrentConsumer): Deleted.
(WebCore::SVGPathParser::setCurrentSource): Deleted.
* svg/SVGPathSegListBuilder.cpp:
(WebCore::SVGPathSegListBuilder::SVGPathSegListBuilder):
(WebCore::SVGPathSegListBuilder::moveTo):
(WebCore::SVGPathSegListBuilder::lineTo):
(WebCore::SVGPathSegListBuilder::lineToHorizontal):
(WebCore::SVGPathSegListBuilder::lineToVertical):
(WebCore::SVGPathSegListBuilder::curveToCubic):
(WebCore::SVGPathSegListBuilder::curveToCubicSmooth):
(WebCore::SVGPathSegListBuilder::curveToQuadratic):
(WebCore::SVGPathSegListBuilder::curveToQuadraticSmooth):
(WebCore::SVGPathSegListBuilder::arcTo):
(WebCore::SVGPathSegListBuilder::closePath):
* svg/SVGPathSegListBuilder.h:
(WebCore::SVGPathSegListBuilder::setCurrentSVGPathElement): Deleted.
(WebCore::SVGPathSegListBuilder::setCurrentSVGPathSegList): Deleted.
(WebCore::SVGPathSegListBuilder::setCurrentSVGPathSegRole): Deleted.
* svg/SVGPathStringBuilder.cpp:
(WebCore::SVGPathStringBuilder::cleanup): Deleted.
* svg/SVGPathStringBuilder.h:
* svg/SVGPathTraversalStateBuilder.cpp:
(WebCore::SVGPathTraversalStateBuilder::SVGPathTraversalStateBuilder):
(WebCore::SVGPathTraversalStateBuilder::moveTo):
(WebCore::SVGPathTraversalStateBuilder::lineTo):
(WebCore::SVGPathTraversalStateBuilder::curveToCubic):
(WebCore::SVGPathTraversalStateBuilder::closePath):
(WebCore::SVGPathTraversalStateBuilder::continueConsuming):
(WebCore::SVGPathTraversalStateBuilder::totalLength):
(WebCore::SVGPathTraversalStateBuilder::currentPoint):
(WebCore::SVGPathTraversalStateBuilder::setDesiredLength): Deleted.
* svg/SVGPathTraversalStateBuilder.h:
(WebCore::SVGPathTraversalStateBuilder::pathSegmentIndex):
(WebCore::SVGPathTraversalStateBuilder::setCurrentTraversalState): Deleted.
* svg/SVGPathUtilities.cpp: Remove globals accessors, making things on the stack
instead. Use SVGPathParser helper functions where possible.
(WebCore::buildPathFromString):
(WebCore::buildSVGPathByteStreamFromSVGPathSegList):
(WebCore::appendSVGPathByteStreamFromSVGPathSeg):
(WebCore::buildPathFromByteStream):
(WebCore::buildSVGPathSegListFromByteStream):
(WebCore::buildStringFromByteStream):
(WebCore::buildStringFromSVGPathSegList):
(WebCore::buildSVGPathByteStreamFromString):
(WebCore::buildAnimatedSVGPathByteStream):
(WebCore::addToSVGPathByteStream):
(WebCore::getSVGPathSegAtLengthFromSVGPathByteStream):
(WebCore::getTotalLengthOfSVGPathByteStream):
(WebCore::getPointAtLengthOfSVGPathByteStream):
(WebCore::buildStringFromPath):
(WebCore::globalSVGPathBuilder): Deleted.
(WebCore::globalSVGPathSegListBuilder): Deleted.
(WebCore::globalSVGPathByteStreamBuilder): Deleted.
(WebCore::globalSVGPathStringBuilder): Deleted.
(WebCore::globalSVGPathTraversalStateBuilder): Deleted.
(WebCore::globalSVGPathParser): Deleted.
(WebCore::globalSVGPathBlender): Deleted.
* svg/SVGPathUtilities.h:
* svg/SVGToOTFFontConversion.cpp: CFFBuilder no longer inherits from SVGPathBuilder.
It did nothing with the Path, re-implemented all the functions, and only made use of
the m_current member var, so just make it inherit from SVGPathConsumer, and have
its own m_current.
(WebCore::SVGToOTFFontConverter::transcodeGlyphPaths):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190849 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGPathBlender.cpp
Source/WebCore/svg/SVGPathBlender.h
Source/WebCore/svg/SVGPathBuilder.cpp
Source/WebCore/svg/SVGPathBuilder.h
Source/WebCore/svg/SVGPathByteStreamBuilder.cpp
Source/WebCore/svg/SVGPathByteStreamBuilder.h
Source/WebCore/svg/SVGPathConsumer.h
Source/WebCore/svg/SVGPathElement.cpp
Source/WebCore/svg/SVGPathParser.cpp
Source/WebCore/svg/SVGPathParser.h
Source/WebCore/svg/SVGPathSegListBuilder.cpp
Source/WebCore/svg/SVGPathSegListBuilder.h
Source/WebCore/svg/SVGPathStringBuilder.cpp
Source/WebCore/svg/SVGPathStringBuilder.h
Source/WebCore/svg/SVGPathTraversalStateBuilder.cpp
Source/WebCore/svg/SVGPathTraversalStateBuilder.h
Source/WebCore/svg/SVGPathUtilities.cpp
Source/WebCore/svg/SVGPathUtilities.h
Source/WebCore/svg/SVGToOTFFontConversion.cpp