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

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

Issue 19500005: [SVG] Refactoring accumulate logic for animateMotion (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 5 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/SVGAnimateMotionElement.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/SVGAnimateMotionElement.cpp
diff --git a/Source/core/svg/SVGAnimateMotionElement.cpp b/Source/core/svg/SVGAnimateMotionElement.cpp
index 86fc66111512d3600d54f0a594a948a9bc31b335..15ab56c1fa243fa904fe23654c33107a6c087807 100644
--- a/Source/core/svg/SVGAnimateMotionElement.cpp
+++ b/Source/core/svg/SVGAnimateMotionElement.cpp
@@ -231,18 +231,6 @@ bool SVGAnimateMotionElement::calculateFromAndByValues(const String& fromString,
return true;
}
-void SVGAnimateMotionElement::buildTransformForProgress(AffineTransform* transform, float percentage)
-{
- ASSERT(!m_animationPath.isEmpty());
-
- bool ok = false;
- float positionOnPath = m_animationPath.length() * percentage;
- FloatPoint position = m_animationPath.pointAtLength(positionOnPath, ok);
- if (!ok)
- return;
- transform->translate(position.x(), position.y());
-}
-
void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement*)
{
SVGElement* targetElement = this->targetElement();
@@ -273,19 +261,24 @@ void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned
return;
}
- buildTransformForProgress(transform, percentage);
-
- // Handle accumulate="sum".
- if (isAccumulated() && repeatCount) {
- for (unsigned i = 0; i < repeatCount; ++i)
- buildTransformForProgress(transform, 1);
- }
+ ASSERT(!m_animationPath.isEmpty());
bool ok = false;
float positionOnPath = m_animationPath.length() * percentage;
- float angle = m_animationPath.normalAngleAtLength(positionOnPath, ok);
+ FloatPoint position;
+ float angle;
+ ok = m_animationPath.pointAndNormalAtLength(positionOnPath, position, angle);
if (!ok)
return;
+
+ // Handle accumulate="sum".
+ if (isAccumulated() && repeatCount) {
+ FloatPoint positionAtEndOfDuration = m_animationPath.pointAtLength(m_animationPath.length(), ok);
+ if (ok)
+ position.move(positionAtEndOfDuration.x() * repeatCount, positionAtEndOfDuration.y() * repeatCount);
+ }
+
+ transform->translate(position.x(), position.y());
RotateMode rotateMode = this->rotateMode();
if (rotateMode != RotateAuto && rotateMode != RotateAutoReverse)
return;
« no previous file with comments | « Source/core/svg/SVGAnimateMotionElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698