mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
VBlankAnimatorUpdater: Use the timestamp provided by VBlankAttachment
This commit is contained in:
parent
425f1858b5
commit
11403080ba
3 changed files with 25 additions and 3 deletions
|
|
@ -62,6 +62,11 @@ void AnimatorUpdater::removeAnimator (const Animator& animator)
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimatorUpdater::update()
|
void AnimatorUpdater::update()
|
||||||
|
{
|
||||||
|
update (Time::getMillisecondCounterHiRes());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimatorUpdater::update (double timestampMs)
|
||||||
{
|
{
|
||||||
if (reentrancyGuard)
|
if (reentrancyGuard)
|
||||||
{
|
{
|
||||||
|
|
@ -74,8 +79,6 @@ void AnimatorUpdater::update()
|
||||||
|
|
||||||
const ScopedValueSetter setter { reentrancyGuard, true };
|
const ScopedValueSetter setter { reentrancyGuard, true };
|
||||||
|
|
||||||
const auto timestampMs = Time::getMillisecondCounterHiRes();
|
|
||||||
|
|
||||||
for (currentIterator = animators.begin(); currentIterator != animators.end();)
|
for (currentIterator = animators.begin(); currentIterator != animators.end();)
|
||||||
{
|
{
|
||||||
auto& current = *currentIterator;
|
auto& current = *currentIterator;
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,24 @@ public:
|
||||||
|
|
||||||
/** Calls Animator::update() for all registered Animators that are still alive. References to
|
/** Calls Animator::update() for all registered Animators that are still alive. References to
|
||||||
deleted Animators are removed.
|
deleted Animators are removed.
|
||||||
|
|
||||||
|
Uses Time::getMillisecondCounterHiRes() to calculate the necessary timestamp. Consider using
|
||||||
|
a VBlankAnimatorUpdater instead for using timestamps that are synchronised across all
|
||||||
|
VBlankAnimatorUpdater instances.
|
||||||
*/
|
*/
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
/** Calls Animator::update() for all registered Animators that are still alive. References to
|
||||||
|
deleted Animators are removed.
|
||||||
|
|
||||||
|
The supplied timestamp should be monotonically increasing for correct behaviour. Ideally
|
||||||
|
this should be a timestamp supplied by a VBlankAttachment. Consider using the
|
||||||
|
VBlankAnimatorUpdater class, which takes care of supplying the right timestamp.
|
||||||
|
|
||||||
|
@see VBlankAnimatorUpdater
|
||||||
|
*/
|
||||||
|
void update (double timestampMs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct JUCE_API Entry
|
struct JUCE_API Entry
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,11 @@ public:
|
||||||
/** Constructs a VBlankAnimatorUpdater that is synchronised to the refresh rate of the monitor
|
/** Constructs a VBlankAnimatorUpdater that is synchronised to the refresh rate of the monitor
|
||||||
that the provided Component is being displayed on.
|
that the provided Component is being displayed on.
|
||||||
*/
|
*/
|
||||||
explicit VBlankAnimatorUpdater (Component* c) : vBlankAttachment (c, [this] { update(); })
|
explicit VBlankAnimatorUpdater (Component* c)
|
||||||
|
: vBlankAttachment (c, [this] (double timestampSec)
|
||||||
|
{
|
||||||
|
update (timestampSec * 1000.0);
|
||||||
|
})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue