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

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

Issue 1019853003: Add helper for computing the reflected control point for smooth segments (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGPathParser.cpp
diff --git a/Source/core/svg/SVGPathParser.cpp b/Source/core/svg/SVGPathParser.cpp
index 430a3623add4a79f1bbad4ce5eabf5489c817c2e..74204f56b5f85dc5e452c4f89bfc05f4371ea97f 100644
--- a/Source/core/svg/SVGPathParser.cpp
+++ b/Source/core/svg/SVGPathParser.cpp
@@ -143,6 +143,11 @@ bool SVGPathParser::parseCurveToCubicSegment()
return true;
}
+static FloatPoint reflectedPoint(const FloatPoint& reflectIn, const FloatPoint& pointToReflect)
+{
+ return FloatPoint(2 * reflectIn.x() - pointToReflect.x(), 2 * reflectIn.y() - pointToReflect.y());
+}
+
bool SVGPathParser::parseCurveToCubicSmoothSegment()
{
FloatPoint point2;
@@ -160,9 +165,7 @@ bool SVGPathParser::parseCurveToCubicSmoothSegment()
&& m_lastCommand != PathSegCurveToCubicSmoothRel)
m_controlPoint = m_currentPoint;
- FloatPoint point1 = m_currentPoint;
- point1.scale(2, 2);
- point1.move(-m_controlPoint.x(), -m_controlPoint.y());
+ FloatPoint point1 = reflectedPoint(m_currentPoint, m_controlPoint);
if (m_mode == RelativeCoordinates) {
point2 += m_currentPoint;
targetPoint += m_currentPoint;
@@ -222,9 +225,7 @@ bool SVGPathParser::parseCurveToQuadraticSmoothSegment()
&& m_lastCommand != PathSegCurveToQuadraticSmoothRel)
m_controlPoint = m_currentPoint;
- FloatPoint cubicPoint = m_currentPoint;
- cubicPoint.scale(2, 2);
- cubicPoint.move(-m_controlPoint.x(), -m_controlPoint.y());
+ FloatPoint cubicPoint = reflectedPoint(m_currentPoint, m_controlPoint);
FloatPoint point1(m_currentPoint.x() + 2 * cubicPoint.x(), m_currentPoint.y() + 2 * cubicPoint.y());
FloatPoint point2(targetPoint.x() + 2 * cubicPoint.x(), targetPoint.y() + 2 * cubicPoint.y());
if (m_mode == RelativeCoordinates) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698