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

Simplify SVGAngle::CalculateAnimatedValue

For cases which doesn't actually perform any interpolation (non-'angle')
we can just take the "discrete animation" code-path.

Bug: 1017723
Change-Id: I00acc3de71132245b93fe9d6b2a6469492ddf770
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1884670Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#710024}
parent 3311b93e
...@@ -375,9 +375,11 @@ void SVGAngle::Add(SVGPropertyBase* other, SVGElement*) { ...@@ -375,9 +375,11 @@ void SVGAngle::Add(SVGPropertyBase* other, SVGElement*) {
void SVGAngle::Assign(const SVGAngle& other) { void SVGAngle::Assign(const SVGAngle& other) {
SVGMarkerOrientType other_orient_type = other.OrientType()->EnumValue(); SVGMarkerOrientType other_orient_type = other.OrientType()->EnumValue();
if (other_orient_type == kSVGMarkerOrientAngle) if (other_orient_type == kSVGMarkerOrientAngle) {
NewValueSpecifiedUnits(other.UnitType(), other.ValueInSpecifiedUnits()); NewValueSpecifiedUnits(other.UnitType(), other.ValueInSpecifiedUnits());
else return;
}
value_in_specified_units_ = 0;
orient_type_->SetEnumValue(other_orient_type); orient_type_->SetEnumValue(other_orient_type);
} }
...@@ -396,39 +398,20 @@ void SVGAngle::CalculateAnimatedValue( ...@@ -396,39 +398,20 @@ void SVGAngle::CalculateAnimatedValue(
SVGMarkerOrientType from_orient_type = from_angle->OrientType()->EnumValue(); SVGMarkerOrientType from_orient_type = from_angle->OrientType()->EnumValue();
SVGMarkerOrientType to_orient_type = to_angle->OrientType()->EnumValue(); SVGMarkerOrientType to_orient_type = to_angle->OrientType()->EnumValue();
if (from_orient_type != to_orient_type) { // We can only interpolate between two SVGAngles with orient-type 'angle',
// Fall back to discrete animation. // all other cases will use discrete animation.
if (from_orient_type != to_orient_type ||
from_orient_type != kSVGMarkerOrientAngle) {
Assign(percentage < 0.5f ? *from_angle : *to_angle); Assign(percentage < 0.5f ? *from_angle : *to_angle);
return; return;
} }
switch (from_orient_type) {
// From 'auto' to 'auto', or 'auto-start-reverse' to 'auto-start-reverse'
case kSVGMarkerOrientAuto:
case kSVGMarkerOrientAutoStartReverse:
OrientType()->SetEnumValue(from_orient_type);
return;
// Regular from angle to angle animation, with all features like additive
// etc.
case kSVGMarkerOrientAngle: {
float animated_value = Value(); float animated_value = Value();
SVGAngle* to_at_end_of_duration_angle = ToSVGAngle(to_at_end_of_duration);
animation_element.AnimateAdditiveNumber( animation_element.AnimateAdditiveNumber(
percentage, repeat_count, from_angle->Value(), to_angle->Value(), percentage, repeat_count, from_angle->Value(), to_angle->Value(),
to_at_end_of_duration_angle->Value(), animated_value); ToSVGAngle(to_at_end_of_duration)->Value(), animated_value);
OrientType()->SetEnumValue(kSVGMarkerOrientAngle); OrientType()->SetEnumValue(kSVGMarkerOrientAngle);
SetValue(animated_value); SetValue(animated_value);
}
return;
// If the enumeration value is not angle or auto, its unknown.
default:
value_in_specified_units_ = 0;
OrientType()->SetEnumValue(kSVGMarkerOrientUnknown);
return;
}
} }
float SVGAngle::CalculateDistance(SVGPropertyBase* other, SVGElement*) { float SVGAngle::CalculateDistance(SVGPropertyBase* other, SVGElement*) {
......
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