Commit 17116919 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Sink is-to-animation check out of SVGAnimationElement::IsAccumulated

'to' animation is sufficiently special that we may as well treat
separately altogether. Sink that part of the check out and clean up code
using IsAccumulated().

Bug: 1017723, 231517
Change-Id: I27c63a423fa3ac24896bd4cf8f15f5aa101c4499
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886813
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710701}
parent 9fc93d85
...@@ -209,8 +209,11 @@ void SVGAnimateMotionElement::CalculateAnimatedValue(float percentage, ...@@ -209,8 +209,11 @@ void SVGAnimateMotionElement::CalculateAnimatedValue(float percentage,
if (GetAnimationMode() != kPathAnimation) { if (GetAnimationMode() != kPathAnimation) {
FloatPoint to_point_at_end_of_duration = to_point_; FloatPoint to_point_at_end_of_duration = to_point_;
if (IsAccumulated() && repeat_count && has_to_point_at_end_of_duration_) if (GetAnimationMode() != kToAnimation) {
to_point_at_end_of_duration = to_point_at_end_of_duration_; if (repeat_count && IsAccumulated() && has_to_point_at_end_of_duration_) {
to_point_at_end_of_duration = to_point_at_end_of_duration_;
}
}
float animated_x = 0; float animated_x = 0;
AnimateAdditiveNumber(percentage, repeat_count, from_point_.X(), AnimateAdditiveNumber(percentage, repeat_count, from_point_.X(),
...@@ -234,7 +237,7 @@ void SVGAnimateMotionElement::CalculateAnimatedValue(float percentage, ...@@ -234,7 +237,7 @@ void SVGAnimateMotionElement::CalculateAnimatedValue(float percentage,
animation_path_.PointAndNormalAtLength(position_on_path, position, angle); animation_path_.PointAndNormalAtLength(position_on_path, position, angle);
// Handle accumulate="sum". // Handle accumulate="sum".
if (IsAccumulated() && repeat_count) { if (repeat_count && IsAccumulated()) {
FloatPoint position_at_end_of_duration = FloatPoint position_at_end_of_duration =
animation_path_.PointAtLength(animation_path_.length()); animation_path_.PointAtLength(animation_path_.length());
position.Move(position_at_end_of_duration.X() * repeat_count, position.Move(position_at_end_of_duration.X() * repeat_count,
......
...@@ -331,7 +331,7 @@ bool SVGAnimationElement::IsAdditive() const { ...@@ -331,7 +331,7 @@ bool SVGAnimationElement::IsAdditive() const {
bool SVGAnimationElement::IsAccumulated() const { bool SVGAnimationElement::IsAccumulated() const {
DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum")); DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum"));
const AtomicString& value = FastGetAttribute(svg_names::kAccumulateAttr); const AtomicString& value = FastGetAttribute(svg_names::kAccumulateAttr);
return value == sum && GetAnimationMode() != kToAnimation; return value == sum;
} }
void SVGAnimationElement::CalculateKeyTimesForCalcModePaced() { void SVGAnimationElement::CalculateKeyTimesForCalcModePaced() {
...@@ -630,7 +630,8 @@ void SVGAnimationElement::UpdateAnimation(float percent, ...@@ -630,7 +630,8 @@ void SVGAnimationElement::UpdateAnimation(float percent,
if (CheckAnimationParameters()) { if (CheckAnimationParameters()) {
animation_valid_ = AnimationValidity::kValid; animation_valid_ = AnimationValidity::kValid;
if (IsAdditive() || IsAccumulated()) { if (IsAdditive() ||
(IsAccumulated() && GetAnimationMode() != kToAnimation)) {
UseCounter::Count(&GetDocument(), UseCounter::Count(&GetDocument(),
WebFeature::kSVGSMILAdditiveAnimation); WebFeature::kSVGSMILAdditiveAnimation);
} }
...@@ -675,8 +676,9 @@ void SVGAnimationElement::UpdateAnimation(float percent, ...@@ -675,8 +676,9 @@ void SVGAnimationElement::UpdateAnimation(float percent,
} }
bool SVGAnimationElement::OverwritesUnderlyingAnimationValue() const { bool SVGAnimationElement::OverwritesUnderlyingAnimationValue() const {
return !IsAdditive() && !IsAccumulated() && if (IsAdditive() || IsAccumulated())
GetAnimationMode() != kToAnimation && return false;
return GetAnimationMode() != kToAnimation &&
GetAnimationMode() != kByAnimation && GetAnimationMode() != kByAnimation &&
GetAnimationMode() != kNoAnimation; GetAnimationMode() != kNoAnimation;
} }
......
...@@ -87,14 +87,13 @@ class CORE_EXPORT SVGAnimationElement : public SVGSMILElement { ...@@ -87,14 +87,13 @@ class CORE_EXPORT SVGAnimationElement : public SVGSMILElement {
number = percentage < 0.5 ? from_number : to_number; number = percentage < 0.5 ? from_number : to_number;
else else
number = (to_number - from_number) * percentage + from_number; number = (to_number - from_number) * percentage + from_number;
if (GetAnimationMode() != kToAnimation) {
if (IsAccumulated() && repeat_count) if (repeat_count && IsAccumulated())
number += to_at_end_of_duration_number * repeat_count; number += to_at_end_of_duration_number * repeat_count;
if (IsAdditive())
if (IsAdditive() && GetAnimationMode() != kToAnimation) number += animated_number;
animated_number += number; }
else animated_number = number;
animated_number = number;
} }
protected: protected:
......
...@@ -167,17 +167,19 @@ void SVGPath::CalculateAnimatedValue( ...@@ -167,17 +167,19 @@ void SVGPath::CalculateAnimatedValue(
std::unique_ptr<SVGPathByteStream> new_stream = std::unique_ptr<SVGPathByteStream> new_stream =
BlendPathByteStreams(*from_stream, to_stream, percentage); BlendPathByteStreams(*from_stream, to_stream, percentage);
// Handle additive='sum'. if (!is_to_animation) {
if (animation_element.IsAdditive() && !is_to_animation) { // Handle additive='sum'.
new_stream = if (animation_element.IsAdditive()) {
ConditionallyAddPathByteStreams(std::move(new_stream), ByteStream()); new_stream =
} ConditionallyAddPathByteStreams(std::move(new_stream), ByteStream());
}
// Handle accumulate='sum'. // Handle accumulate='sum'.
if (animation_element.IsAccumulated() && repeat_count) { if (repeat_count && animation_element.IsAccumulated()) {
new_stream = ConditionallyAddPathByteStreams( new_stream = ConditionallyAddPathByteStreams(
std::move(new_stream), std::move(new_stream),
ToSVGPath(to_at_end_of_duration_value)->ByteStream(), repeat_count); ToSVGPath(to_at_end_of_duration_value)->ByteStream(), repeat_count);
}
} }
path_value_ = MakeGarbageCollected<CSSPathValue>(std::move(new_stream)); path_value_ = MakeGarbageCollected<CSSPathValue>(std::move(new_stream));
} }
......
...@@ -483,17 +483,20 @@ void SVGTransformList::CalculateAnimatedValue( ...@@ -483,17 +483,20 @@ void SVGTransformList::CalculateAnimatedValue(
effective_from = MakeGarbageCollected<SVGTransform>( effective_from = MakeGarbageCollected<SVGTransform>(
to_transform->TransformType(), SVGTransform::kConstructZeroTransform); to_transform->TransformType(), SVGTransform::kConstructZeroTransform);
// Never resize the animatedTransformList to the toList size, instead either
// clear the list or append to it.
bool is_to_animation = animation_element.GetAnimationMode() == kToAnimation;
if (!IsEmpty() && (!animation_element.IsAdditive() || is_to_animation))
Clear();
SVGTransform* current_transform = SVGTransform* current_transform =
SVGTransformDistance(effective_from, to_transform) SVGTransformDistance(effective_from, to_transform)
.ScaledDistance(percentage) .ScaledDistance(percentage)
.AddToSVGTransform(effective_from); .AddToSVGTransform(effective_from);
if (animation_element.IsAccumulated() && repeat_count) { if (animation_element.GetAnimationMode() == kToAnimation) {
Initialize(current_transform);
return;
}
// Never resize the animatedTransformList to the toList size, instead either
// clear the list or append to it.
if (!IsEmpty() && !animation_element.IsAdditive())
Clear();
if (repeat_count && animation_element.IsAccumulated()) {
SVGTransform* effective_to_at_end = SVGTransform* effective_to_at_end =
!to_at_end_of_duration_list->IsEmpty() !to_at_end_of_duration_list->IsEmpty()
? to_at_end_of_duration_list->at(0) ? to_at_end_of_duration_list->at(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment