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

Don't update intervals if current presentation time is not "interesting"

When the next "interesting" time is past the current presentation time,
we don't need to perform an interval update step, but can just update
the progress when updating the active animation stack.

Bug: 998526
Change-Id: I5bd1c0f7476dcd89bc1879cac5851fba6e5a67bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1844977Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#703323}
parent 17b507a9
......@@ -123,6 +123,7 @@ void SMILAnimationSandwich::UpdateActiveAnimationStack(
for (auto& animation : sandwich_) {
if (!animation->IsContributing(presentation_time))
continue;
animation->UpdateProgressState(presentation_time);
active_.push_back(animation);
}
// If we switched result element, clear the old one.
......
......@@ -513,9 +513,12 @@ void SMILTimeContainer::UpdateAnimationTimings(SMILTime presentation_time) {
while (latest_update_time_ < presentation_time) {
const SMILTime interesting_time = NextInterestingTime(latest_update_time_);
latest_update_time_ = std::min(presentation_time, interesting_time);
if (interesting_time <= presentation_time) {
latest_update_time_ = interesting_time;
UpdateIntervals(latest_update_time_);
} else {
latest_update_time_ = presentation_time;
}
}
}
......
......@@ -191,8 +191,7 @@ SVGSMILElement::SVGSMILElement(const QualifiedName& tag_name, Document& doc)
active_state_(kInactive),
restart_(kRestartAlways),
fill_(kFillRemove),
last_percent_(0),
last_repeat_(0),
last_progress_{0.0f, 0},
document_order_index_(0),
cached_dur_(kInvalidCachedTime),
cached_repeat_dur_(kInvalidCachedTime),
......@@ -257,8 +256,7 @@ void SVGSMILElement::Reset() {
is_waiting_for_first_interval_ = true;
interval_ = {SMILTime::Unresolved(), SMILTime::Unresolved()};
previous_interval_ = {SMILTime::Unresolved(), SMILTime::Unresolved()};
last_percent_ = 0;
last_repeat_ = 0;
last_progress_ = {0.0f, 0};
ResolveFirstInterval();
}
......@@ -1106,15 +1104,19 @@ void SVGSMILElement::UpdateActiveState(SMILTime elapsed) {
}
ProgressState progress_state = CalculateProgressState(elapsed);
if (progress_state.repeat && progress_state.repeat != last_repeat_) {
last_repeat_ = progress_state.repeat;
NotifyDependentsOnRepeat(last_repeat_, elapsed);
if (progress_state.repeat &&
progress_state.repeat != last_progress_.repeat) {
NotifyDependentsOnRepeat(progress_state.repeat, elapsed);
ScheduleRepeatEvents();
}
last_percent_ = progress_state.progress;
last_progress_ = progress_state;
}
}
void SVGSMILElement::UpdateProgressState(SMILTime presentation_time) {
last_progress_ = CalculateProgressState(presentation_time);
}
struct SVGSMILElement::NotifyDependentsInfo {
explicit NotifyDependentsInfo(const SMILInterval& interval)
: origin(SMILTimeOrigin::kSyncBase),
......
......@@ -87,13 +87,15 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests {
bool CurrentIntervalIsActive(SMILTime elapsed);
void UpdateInterval(SMILTime presentation_time);
void UpdateActiveState(SMILTime elapsed);
void UpdateProgressState(SMILTime presentation_time);
bool IsHigherPriorityThan(const SVGSMILElement* other,
SMILTime presentation_time) const;
SMILTime NextInterestingTime(SMILTime elapsed) const;
SMILTime NextProgressTime(SMILTime elapsed) const;
void UpdateAnimatedValue(SVGSMILElement* result_element) {
UpdateAnimation(last_percent_, last_repeat_, result_element);
UpdateAnimation(last_progress_.progress, last_progress_.repeat,
result_element);
}
void Reset();
......@@ -277,8 +279,7 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests {
unsigned active_state_ : 2;
unsigned restart_ : 2;
unsigned fill_ : 1;
float last_percent_;
unsigned last_repeat_;
ProgressState last_progress_;
Member<SMILTimeContainer> time_container_;
unsigned document_order_index_;
......
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