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

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

Issue 1014023003: Simplify SVGPathBlender::blendArcToSegment (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 | « Source/core/svg/SVGPathBlender.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGPathBlender.cpp
diff --git a/Source/core/svg/SVGPathBlender.cpp b/Source/core/svg/SVGPathBlender.cpp
index 9af2501581a0e748a4388d67931759b040a672cc..d2517d3f3dbde8f0b8bd712c35fc1e9d1b1e5877 100644
--- a/Source/core/svg/SVGPathBlender.cpp
+++ b/Source/core/svg/SVGPathBlender.cpp
@@ -77,17 +77,20 @@ float SVGPathBlender::blendAnimatedDimensonalFloat(float from, float to, FloatBl
return m_toMode == AbsoluteCoordinates ? animValue + currentValue : animValue - currentValue;
}
-FloatPoint SVGPathBlender::blendAnimatedFloatPoint(const FloatPoint& fromPoint, const FloatPoint& toPoint)
+FloatPoint SVGPathBlender::blendAnimatedFloatPointSameCoordinates(const FloatPoint& fromPoint, const FloatPoint& toPoint)
{
if (m_addTypesCount) {
- ASSERT(m_fromMode == m_toMode);
FloatPoint repeatedToPoint = toPoint;
repeatedToPoint.scale(m_addTypesCount, m_addTypesCount);
return fromPoint + repeatedToPoint;
}
+ return blendFloatPoint(fromPoint, toPoint, m_progress);
+}
+FloatPoint SVGPathBlender::blendAnimatedFloatPoint(const FloatPoint& fromPoint, const FloatPoint& toPoint)
+{
if (m_fromMode == m_toMode)
- return blendFloatPoint(fromPoint, toPoint, m_progress);
+ return blendAnimatedFloatPointSameCoordinates(fromPoint, toPoint);
// Transform toPoint to the coordinate mode of fromPoint
FloatPoint animatedPoint = toPoint;
@@ -255,26 +258,26 @@ bool SVGPathBlender::blendArcToSegment()
|| !m_toSource->parseArcToSegment(toRx, toRy, toAngle, toLargeArc, toSweep, toTargetPoint))
return false;
+ ASSERT(!m_addTypesCount || m_fromMode == m_toMode);
+
+ FloatPoint blendedRadii = blendAnimatedFloatPointSameCoordinates(FloatPoint(fromRx, fromRy), FloatPoint(toRx, toRy));
+ float blendedAngle = blendAnimatedFloatPointSameCoordinates(FloatPoint(fromAngle, 0), FloatPoint(toAngle, 0)).x();
+ bool blendedLargeArc;
+ bool blendedSweep;
+
if (m_addTypesCount) {
- ASSERT(m_fromMode == m_toMode);
- FloatPoint scaledToTargetPoint = toTargetPoint;
- scaledToTargetPoint.scale(m_addTypesCount, m_addTypesCount);
- m_consumer->arcTo(fromRx + toRx * m_addTypesCount,
- fromRy + toRy * m_addTypesCount,
- fromAngle + toAngle * m_addTypesCount,
- fromLargeArc || toLargeArc,
- fromSweep || toSweep,
- fromTargetPoint + scaledToTargetPoint,
- m_fromMode);
+ blendedLargeArc = fromLargeArc || toLargeArc;
+ blendedSweep = fromSweep || toSweep;
} else {
- m_consumer->arcTo(blend(fromRx, toRx, m_progress),
- blend(fromRy, toRy, m_progress),
- blend(fromAngle, toAngle, m_progress),
- m_isInFirstHalfOfAnimation ? fromLargeArc : toLargeArc,
- m_isInFirstHalfOfAnimation ? fromSweep : toSweep,
- blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint),
- m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode);
+ blendedLargeArc = m_isInFirstHalfOfAnimation ? fromLargeArc : toLargeArc;
+ blendedSweep = m_isInFirstHalfOfAnimation ? fromSweep : toSweep;
}
+
+ m_consumer->arcTo(
+ blendedRadii.x(), blendedRadii.y(), blendedAngle, blendedLargeArc, blendedSweep,
+ blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint),
+ m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode);
+
m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint;
m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;
return true;
« no previous file with comments | « Source/core/svg/SVGPathBlender.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698