Commit a7db22cf authored by fs's avatar fs Committed by Commit bot

Replace SMILTime with double for elapsed time in SMILTimeContainer

We don't really make use of of the special properties of SMILTime for
this case, and using double means slightly less impedance mismatching.

BUG=631879

Review-Url: https://codereview.chromium.org/2261443002
Cr-Commit-Position: refs/heads/master@{#413345}
parent 07bf777c
...@@ -548,7 +548,7 @@ bool SVGSVGElement::animationsPaused() const ...@@ -548,7 +548,7 @@ bool SVGSVGElement::animationsPaused() const
float SVGSVGElement::getCurrentTime() const float SVGSVGElement::getCurrentTime() const
{ {
return narrowPrecisionToFloat(m_timeContainer->elapsed().value()); return narrowPrecisionToFloat(m_timeContainer->elapsed());
} }
void SVGSVGElement::setCurrentTime(float seconds) void SVGSVGElement::setCurrentTime(float seconds)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "core/frame/Settings.h" #include "core/frame/Settings.h"
#include "core/frame/UseCounter.h" #include "core/frame/UseCounter.h"
#include "core/svg/SVGSVGElement.h" #include "core/svg/SVGSVGElement.h"
#include "core/svg/animation/SMILTime.h"
#include "core/svg/animation/SVGSMILElement.h" #include "core/svg/animation/SVGSMILElement.h"
#include <algorithm> #include <algorithm>
...@@ -133,7 +134,7 @@ void SMILTimeContainer::notifyIntervalsChanged() ...@@ -133,7 +134,7 @@ void SMILTimeContainer::notifyIntervalsChanged()
scheduleWakeUp(0, SynchronizeAnimations); scheduleWakeUp(0, SynchronizeAnimations);
} }
SMILTime SMILTimeContainer::elapsed() const double SMILTimeContainer::elapsed() const
{ {
if (!isStarted()) if (!isStarted())
return 0; return 0;
...@@ -182,14 +183,14 @@ void SMILTimeContainer::start() ...@@ -182,14 +183,14 @@ void SMILTimeContainer::start()
// If the "presentation time" is non-zero, the timeline was modified via // If the "presentation time" is non-zero, the timeline was modified via
// setElapsed() before the document began. // setElapsed() before the document began.
// In this case pass on 'seekToTime=true' to updateAnimations() to issue a seek. // In this case pass on 'seekToTime=true' to updateAnimations() to issue a seek.
SMILTime earliestFireTime = updateAnimations(SMILTime(m_presentationTime), m_presentationTime ? true : false); SMILTime earliestFireTime = updateAnimations(m_presentationTime, m_presentationTime ? true : false);
if (!canScheduleFrame(earliestFireTime)) if (!canScheduleFrame(earliestFireTime))
return; return;
// If the timeline is running, and there are pending animation updates, // If the timeline is running, and there are pending animation updates,
// always perform the first update after the timeline was started using // always perform the first update after the timeline was started using
// the wake-up mechanism. // the wake-up mechanism.
SMILTime delay = earliestFireTime - m_presentationTime; double delayTime = earliestFireTime.value() - m_presentationTime;
scheduleWakeUp(std::max(initialFrameDelay, delay.value()), SynchronizeAnimations); scheduleWakeUp(std::max(initialFrameDelay, delayTime), SynchronizeAnimations);
} }
void SMILTimeContainer::pause() void SMILTimeContainer::pause()
...@@ -199,7 +200,7 @@ void SMILTimeContainer::pause() ...@@ -199,7 +200,7 @@ void SMILTimeContainer::pause()
DCHECK(!isPaused()); DCHECK(!isPaused());
if (isStarted()) { if (isStarted()) {
m_presentationTime = elapsed().value(); m_presentationTime = elapsed();
cancelAnimationFrame(); cancelAnimationFrame();
} }
// Update the flag after sampling elapsed(). // Update the flag after sampling elapsed().
...@@ -221,9 +222,9 @@ void SMILTimeContainer::resume() ...@@ -221,9 +222,9 @@ void SMILTimeContainer::resume()
scheduleWakeUp(0, SynchronizeAnimations); scheduleWakeUp(0, SynchronizeAnimations);
} }
void SMILTimeContainer::setElapsed(SMILTime time) void SMILTimeContainer::setElapsed(double elapsed)
{ {
m_presentationTime = time.value(); m_presentationTime = elapsed;
// If the document hasn't finished loading, |m_presentationTime| will be // If the document hasn't finished loading, |m_presentationTime| will be
// used as the start time to seek to once it's possible. // used as the start time to seek to once it's possible.
...@@ -253,7 +254,7 @@ void SMILTimeContainer::setElapsed(SMILTime time) ...@@ -253,7 +254,7 @@ void SMILTimeContainer::setElapsed(SMILTime time)
m_preventScheduledAnimationsChanges = false; m_preventScheduledAnimationsChanges = false;
#endif #endif
updateAnimationsAndScheduleFrameIfNeeded(time, true); updateAnimationsAndScheduleFrameIfNeeded(elapsed, true);
} }
void SMILTimeContainer::scheduleAnimationFrame(double delayTime) void SMILTimeContainer::scheduleAnimationFrame(double delayTime)
...@@ -362,7 +363,7 @@ void SMILTimeContainer::updateDocumentOrderIndexes() ...@@ -362,7 +363,7 @@ void SMILTimeContainer::updateDocumentOrderIndexes()
} }
struct PriorityCompare { struct PriorityCompare {
PriorityCompare(SMILTime elapsed) : m_elapsed(elapsed) {} PriorityCompare(double elapsed) : m_elapsed(elapsed) {}
bool operator()(const Member<SVGSMILElement>& a, const Member<SVGSMILElement>& b) bool operator()(const Member<SVGSMILElement>& a, const Member<SVGSMILElement>& b)
{ {
// FIXME: This should also consider possible timing relations between the elements. // FIXME: This should also consider possible timing relations between the elements.
...@@ -375,7 +376,7 @@ struct PriorityCompare { ...@@ -375,7 +376,7 @@ struct PriorityCompare {
return a->documentOrderIndex() < b->documentOrderIndex(); return a->documentOrderIndex() < b->documentOrderIndex();
return aBegin < bBegin; return aBegin < bBegin;
} }
SMILTime m_elapsed; double m_elapsed;
}; };
SVGSVGElement& SMILTimeContainer::ownerSVGElement() const SVGSVGElement& SMILTimeContainer::ownerSVGElement() const
...@@ -416,7 +417,7 @@ bool SMILTimeContainer::canScheduleFrame(SMILTime earliestFireTime) const ...@@ -416,7 +417,7 @@ bool SMILTimeContainer::canScheduleFrame(SMILTime earliestFireTime) const
return earliestFireTime.isFinite(); return earliestFireTime.isFinite();
} }
void SMILTimeContainer::updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed, bool seekToTime) void SMILTimeContainer::updateAnimationsAndScheduleFrameIfNeeded(double elapsed, bool seekToTime)
{ {
if (!document().isActive()) if (!document().isActive())
return; return;
...@@ -424,11 +425,11 @@ void SMILTimeContainer::updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapse ...@@ -424,11 +425,11 @@ void SMILTimeContainer::updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapse
SMILTime earliestFireTime = updateAnimations(elapsed, seekToTime); SMILTime earliestFireTime = updateAnimations(elapsed, seekToTime);
if (!canScheduleFrame(earliestFireTime)) if (!canScheduleFrame(earliestFireTime))
return; return;
SMILTime delay = earliestFireTime - elapsed; double delayTime = earliestFireTime.value() - elapsed;
scheduleAnimationFrame(delay.value()); scheduleAnimationFrame(delayTime);
} }
SMILTime SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) SMILTime SMILTimeContainer::updateAnimations(double elapsed, bool seekToTime)
{ {
ASSERT(document().isActive()); ASSERT(document().isActive());
SMILTime earliestFireTime = SMILTime::unresolved(); SMILTime earliestFireTime = SMILTime::unresolved();
...@@ -532,7 +533,7 @@ SMILTime SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) ...@@ -532,7 +533,7 @@ SMILTime SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime)
void SMILTimeContainer::advanceFrameForTesting() void SMILTimeContainer::advanceFrameForTesting()
{ {
setElapsed(elapsed().value() + initialFrameDelay); setElapsed(elapsed() + initialFrameDelay);
} }
DEFINE_TRACE(SMILTimeContainer) DEFINE_TRACE(SMILTimeContainer)
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#define SMILTimeContainer_h #define SMILTimeContainer_h
#include "core/dom/QualifiedName.h" #include "core/dom/QualifiedName.h"
#include "core/svg/animation/SMILTime.h"
#include "platform/Timer.h" #include "platform/Timer.h"
#include "platform/graphics/ImageAnimationPolicy.h" #include "platform/graphics/ImageAnimationPolicy.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
...@@ -39,6 +38,7 @@ ...@@ -39,6 +38,7 @@
namespace blink { namespace blink {
class Document; class Document;
class SMILTime;
class SVGElement; class SVGElement;
class SVGSMILElement; class SVGSMILElement;
class SVGSVGElement; class SVGSVGElement;
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
void unschedule(SVGSMILElement*, SVGElement*, const QualifiedName&); void unschedule(SVGSMILElement*, SVGElement*, const QualifiedName&);
void notifyIntervalsChanged(); void notifyIntervalsChanged();
SMILTime elapsed() const; double elapsed() const;
bool isPaused() const; bool isPaused() const;
bool isStarted() const; bool isStarted() const;
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
void start(); void start();
void pause(); void pause();
void resume(); void resume();
void setElapsed(SMILTime); void setElapsed(double);
void serviceAnimations(); void serviceAnimations();
bool hasAnimations() const; bool hasAnimations() const;
...@@ -106,8 +106,8 @@ private: ...@@ -106,8 +106,8 @@ private:
ImageAnimationPolicy animationPolicy() const; ImageAnimationPolicy animationPolicy() const;
bool handleAnimationPolicy(AnimationPolicyOnceAction); bool handleAnimationPolicy(AnimationPolicyOnceAction);
bool canScheduleFrame(SMILTime earliestFireTime) const; bool canScheduleFrame(SMILTime earliestFireTime) const;
void updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed, bool seekToTime = false); void updateAnimationsAndScheduleFrameIfNeeded(double elapsed, bool seekToTime = false);
SMILTime updateAnimations(SMILTime elapsed, bool seekToTime = false); SMILTime updateAnimations(double elapsed, bool seekToTime);
void serviceOnNextFrame(); void serviceOnNextFrame();
void scheduleWakeUp(double delayTime, FrameSchedulingState); void scheduleWakeUp(double delayTime, FrameSchedulingState);
bool hasPendingSynchronization() const; bool hasPendingSynchronization() const;
......
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