Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(922)

Unified Diff: Source/core/svg/SVGPathByteStreamSource.cpp

Issue 1023993002: Rework the SVGPathSource interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Blender fixups. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGPathByteStreamSource.h ('k') | Source/core/svg/SVGPathParser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGPathByteStreamSource.cpp
diff --git a/Source/core/svg/SVGPathByteStreamSource.cpp b/Source/core/svg/SVGPathByteStreamSource.cpp
index 98b99b8a01103a365466d1b1ac5261c1bc6a4221..5511d57e0d9bf0664946530c924ff82286f02b69 100644
--- a/Source/core/svg/SVGPathByteStreamSource.cpp
+++ b/Source/core/svg/SVGPathByteStreamSource.cpp
@@ -27,78 +27,66 @@ bool SVGPathByteStreamSource::hasMoreData() const
return m_streamCurrent < m_streamEnd;
}
-bool SVGPathByteStreamSource::parseSVGSegmentType(SVGPathSegType& pathSegType)
+SVGPathSegType SVGPathByteStreamSource::peekSegmentType()
{
- pathSegType = static_cast<SVGPathSegType>(readSVGSegmentType());
- return true;
+ ASSERT(hasMoreData());
+ ASSERT(m_streamCurrent + sizeof(unsigned short) <= m_streamEnd);
+ unsigned short commandBytes;
+ memcpy(&commandBytes, m_streamCurrent, sizeof(commandBytes));
+ return static_cast<SVGPathSegType>(commandBytes);
}
-SVGPathSegType SVGPathByteStreamSource::nextCommand(SVGPathSegType)
+PathSegmentData SVGPathByteStreamSource::parseSegment()
{
- return static_cast<SVGPathSegType>(readSVGSegmentType());
-}
-
-bool SVGPathByteStreamSource::parseMoveToSegment(FloatPoint& targetPoint)
-{
- targetPoint = readFloatPoint();
- return true;
-}
-
-bool SVGPathByteStreamSource::parseLineToSegment(FloatPoint& targetPoint)
-{
- targetPoint = readFloatPoint();
- return true;
-}
-
-bool SVGPathByteStreamSource::parseLineToHorizontalSegment(float& x)
-{
- x = readFloat();
- return true;
-}
-
-bool SVGPathByteStreamSource::parseLineToVerticalSegment(float& y)
-{
- y = readFloat();
- return true;
-}
+ ASSERT(hasMoreData());
+ PathSegmentData segment;
+ segment.command = static_cast<SVGPathSegType>(readSVGSegmentType());
-bool SVGPathByteStreamSource::parseCurveToCubicSegment(FloatPoint& point1, FloatPoint& point2, FloatPoint& targetPoint)
-{
- point1 = readFloatPoint();
- point2 = readFloatPoint();
- targetPoint = readFloatPoint();
- return true;
-}
-
-bool SVGPathByteStreamSource::parseCurveToCubicSmoothSegment(FloatPoint& point2, FloatPoint& targetPoint)
-{
- point2 = readFloatPoint();
- targetPoint = readFloatPoint();
- return true;
-}
-
-bool SVGPathByteStreamSource::parseCurveToQuadraticSegment(FloatPoint& point1, FloatPoint& targetPoint)
-{
- point1 = readFloatPoint();
- targetPoint = readFloatPoint();
- return true;
-}
-
-bool SVGPathByteStreamSource::parseCurveToQuadraticSmoothSegment(FloatPoint& targetPoint)
-{
- targetPoint = readFloatPoint();
- return true;
-}
-
-bool SVGPathByteStreamSource::parseArcToSegment(float& rx, float& ry, float& angle, bool& largeArc, bool& sweep, FloatPoint& targetPoint)
-{
- rx = readFloat();
- ry = readFloat();
- angle = readFloat();
- largeArc = readFlag();
- sweep = readFlag();
- targetPoint = readFloatPoint();
- return true;
+ 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.point1 = readFloatPoint(); // rx and ry
+ segment.point2.setX(readFloat()); // angle
+ segment.arcLarge = readFlag();
+ segment.arcSweep = readFlag();
+ segment.targetPoint = readFloatPoint();
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return segment;
}
}
« no previous file with comments | « Source/core/svg/SVGPathByteStreamSource.h ('k') | Source/core/svg/SVGPathParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698