-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[SVG] Refactoring accumulate logic for animateMotion #48748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SVG] Refactoring accumulate logic for animateMotion #48748
Conversation
|
EWS run on previous version of this PR (hash 3d56fa8) Details |
| buildTransformForProgress(transform, 1); | ||
| for (unsigned i = 0; i < repeatCount; ++i) { | ||
| float positionAtEndOfDuration = m_animationPath.length() * 1; | ||
| auto endTraversalState = m_animationPath.traversalStateAtLength(positionAtEndOfDuration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the inputs to m_animationPath.traversalStateAtLength() depend on i, so isn't this repeating identical work each time through the loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smfr - good spot! now removed it, I think forgot to tackle it in first go.
https://bugs.webkit.org/show_bug.cgi?id=296723 Reviewed by NOBODY (OOPS!). Inspired by: https://chromium.googlesource.com/chromium/src/+/629e8ce3ef3deaf9b8fe705aba73061f7b2caa05 This removes helper function `buildTransformForProgress`, which only had one use case and inlines the logic near call site. This patch is just simpification of accumulate logic and paves way for future work. * Source/WebCore/svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::calculateAnimatedValue): (WebCore::SVGAnimateMotionElement::buildTransformForProgress): Deleted. * Source/WebCore/svg/SVGAnimateMotionElement.h:
3d56fa8 to
9e9fd42
Compare
|
EWS run on current version of this PR (hash 9e9fd42) Details |
| return true; | ||
| } | ||
|
|
||
| void SVGAnimateMotionElement::buildTransformForProgress(AffineTransform* transform, float percentage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you deleted this function, the code is duplicated below. Please keep this method and add a new parameter unsigned repeatCount to it and make it return PathTraversalState.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively you can split this into two functions:
static PathTraversalState traversalStateAtPositionOnPath(const Path& path, float percentage)
{
}
static void buildTransformForProgress(AffineTransform& transform, const PathTraversalState& traversalState, unsigned repeatCount)
{
}
| buildTransformForProgress(transform, percentage); | ||
| ASSERT(!m_animationPath.isEmpty()); | ||
| float positionOnPath = m_animationPath.length() * percentage; | ||
| auto traversalState = m_animationPath.traversalStateAtLength(positionOnPath); | ||
| if (!traversalState.success()) | ||
| return; | ||
| FloatPoint position = traversalState.current(); | ||
| transform->translate(position); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just call
auto traversalState = buildTransformForProgress(*transform, percentage, 1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With two separate functions, you can alternatively call:
auto traversalState = traversalStateAtPositionOnPath(m_animationPath, percentage);
buildTransformForProgress(*transform, traversalState, 1);
| for (unsigned i = 0; i < repeatCount; ++i) | ||
| buildTransformForProgress(transform, 1); | ||
| float pathLength = m_animationPath.length(); | ||
| auto endTraversalState = m_animationPath.traversalStateAtLength(pathLength); | ||
| if (endTraversalState.success()) { | ||
| FloatPoint endPoint = endTraversalState.current(); | ||
| transform->translate(endPoint.x() * repeatCount, endPoint.y() * repeatCount); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just call
buildTransformForProgress(*transform, 1, repeatCount);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With two separate functions, you can alternatively call:
buildTransformForProgress(*transform, traversalStateAtPositionOnPath(m_animationPath, 1), repeatCount);
|
I was trying to do it to solve - https://bugs.webkit.org/show_bug.cgi?id=257907 but I manage to fix the bug without needing this. So closing this PR. |
9e9fd42
9e9fd42