Bug 927349 part 9 - Add PendingPlayerTracker::StartPendingPlayers; r=jwatt

This commit is contained in:
Brian Birtles 2014-12-22 09:35:41 +09:00
Родитель fb0d9d7187
Коммит 0dcad886e1
2 изменённых файлов: 38 добавлений и 0 удалений

Просмотреть файл

@ -5,6 +5,8 @@
#include "PendingPlayerTracker.h"
#include "mozilla/dom/AnimationTimeline.h"
using namespace mozilla;
namespace mozilla {
@ -32,4 +34,36 @@ PendingPlayerTracker::IsWaitingToPlay(dom::AnimationPlayer const& aPlayer) const
return mPlayPendingSet.Contains(const_cast<dom::AnimationPlayer*>(&aPlayer));
}
PLDHashOperator
StartPlayerAtTime(nsRefPtrHashKey<dom::AnimationPlayer>* aKey,
void* aReadyTime)
{
dom::AnimationPlayer* player = aKey->GetKey();
// For animations that are waiting until their first frame has rendered
// before starting, we record the moment when they finish painting
// as the "ready time" and make any pending layer animations start at
// that time.
//
// Here we fast-forward the player's timeline to the same "ready time" and
// then tell the player to start at the timeline's current time.
//
// Redundant calls to FastForward with the same ready time are ignored by
// AnimationTimeline.
dom::AnimationTimeline* timeline = player->Timeline();
timeline->FastForward(*static_cast<const TimeStamp*>(aReadyTime));
player->StartNow();
return PL_DHASH_NEXT;
}
void
PendingPlayerTracker::StartPendingPlayers(const TimeStamp& aReadyTime)
{
mPlayPendingSet.EnumerateEntries(StartPlayerAtTime,
const_cast<TimeStamp*>(&aReadyTime));
mPlayPendingSet.Clear();
}
} // namespace mozilla

Просмотреть файл

@ -22,6 +22,10 @@ public:
void RemovePlayPending(dom::AnimationPlayer& aPlayer);
bool IsWaitingToPlay(dom::AnimationPlayer const& aPlayer) const;
// Causes any pending players to resume at |aReadyTime| by first
// fast-forwarding their timeline to the corresponding time.
void StartPendingPlayers(const TimeStamp& aReadyTime);
private:
~PendingPlayerTracker() { }