本文整理汇总了C++中UpdateTiming函数的典型用法代码示例。如果您正苦于以下问题:C++ UpdateTiming函数的具体用法?C++ UpdateTiming怎么用?C++ UpdateTiming使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UpdateTiming函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FinishPendingAt
void
Animation::Tick()
{
// Finish pending if we have a pending ready time, but only if we also
// have an active timeline.
if (mPendingState != PendingState::NotPending &&
!mPendingReadyTime.IsNull() &&
mTimeline &&
!mTimeline->GetCurrentTime().IsNull()) {
// Even though mPendingReadyTime is initialized using TimeStamp::Now()
// during the *previous* tick of the refresh driver, it can still be
// ahead of the *current* timeline time when we are using the
// vsync timer so we need to clamp it to the timeline time.
mPendingReadyTime.SetValue(std::min(mTimeline->GetCurrentTime().Value(),
mPendingReadyTime.Value()));
FinishPendingAt(mPendingReadyTime.Value());
mPendingReadyTime.SetNull();
}
if (IsPossiblyOrphanedPendingAnimation()) {
MOZ_ASSERT(mTimeline && !mTimeline->GetCurrentTime().IsNull(),
"Orphaned pending animtaions should have an active timeline");
FinishPendingAt(mTimeline->GetCurrentTime().Value());
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
// Update layers if we are newly finished.
if (mEffect &&
!mEffect->Properties().IsEmpty() &&
!mFinishedAtLastComposeStyle &&
PlayState() == AnimationPlayState::Finished) {
PostUpdate();
}
}
示例2: MOZ_ASSERT
void
Animation::ResumeAt(const TimeDuration& aReadyTime)
{
// This method is only expected to be called for an animation that is
// waiting to play. We can easily adapt it to handle other states
// but it's currently not necessary.
MOZ_ASSERT(mPendingState == PendingState::PlayPending,
"Expected to resume a play-pending animation");
MOZ_ASSERT(mHoldTime.IsNull() != mStartTime.IsNull(),
"An animation in the play-pending state should have either a"
" resolved hold time or resolved start time (but not both)");
// If we aborted a pending pause operation we will already have a start time
// we should use. In all other cases, we resolve it from the ready time.
if (mStartTime.IsNull()) {
if (mPlaybackRate != 0) {
mStartTime.SetValue(aReadyTime -
(mHoldTime.Value().MultDouble(1 / mPlaybackRate)));
mHoldTime.SetNull();
} else {
mStartTime.SetValue(aReadyTime);
}
}
mPendingState = PendingState::NotPending;
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
if (mReady) {
mReady->MaybeResolve(this);
}
}
示例3: GetCurrentTime
// https://w3c.github.io/web-animations/#set-the-current-time
void
Animation::SetCurrentTime(const TimeDuration& aSeekTime)
{
// Return early if the current time has not changed. However, if we
// are pause-pending, then setting the current time to any value
// including the current value has the effect of aborting the
// pause so we should not return early in that case.
if (mPendingState != PendingState::PausePending &&
Nullable<TimeDuration>(aSeekTime) == GetCurrentTime()) {
return;
}
AutoMutationBatchForAnimation mb(*this);
SilentlySetCurrentTime(aSeekTime);
if (mPendingState == PendingState::PausePending) {
// Finish the pause operation
mHoldTime.SetValue(aSeekTime);
mStartTime.SetNull();
if (mReady) {
mReady->MaybeResolve(this);
}
CancelPendingTasks();
}
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Async);
if (IsRelevant()) {
nsNodeUtils::AnimationChanged(this);
}
PostUpdate();
}
示例4: CancelPendingTasks
// https://w3c.github.io/web-animations/#cancel-an-animation
void
Animation::CancelNoUpdate()
{
if (mPendingState != PendingState::NotPending) {
CancelPendingTasks();
if (mReady) {
mReady->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
}
}
if (mFinished) {
mFinished->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
}
ResetFinishedPromise();
DispatchPlaybackEvent(NS_LITERAL_STRING("cancel"));
mHoldTime.SetNull();
mStartTime.SetNull();
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
if (mTimeline) {
mTimeline->RemoveAnimation(this);
}
}
示例5: mb
// https://w3c.github.io/web-animations/#set-the-animation-playback-rate
void
Animation::SetPlaybackRate(double aPlaybackRate)
{
if (aPlaybackRate == mPlaybackRate) {
return;
}
AutoMutationBatchForAnimation mb(*this);
Nullable<TimeDuration> previousTime = GetCurrentTime();
mPlaybackRate = aPlaybackRate;
if (!previousTime.IsNull()) {
SetCurrentTime(previousTime.Value());
}
// In the case where GetCurrentTime() returns the same result before and
// after updating mPlaybackRate, SetCurrentTime will return early since,
// as far as it can tell, nothing has changed.
// As a result, we need to perform the following updates here:
// - update timing (since, if the sign of the playback rate has changed, our
// finished state may have changed),
// - dispatch a change notification for the changed playback rate, and
// - update the playback rate on animations on layers.
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Async);
if (IsRelevant()) {
nsNodeUtils::AnimationChanged(this);
}
PostUpdate();
}
示例6: FinishPendingAt
void
Animation::Tick()
{
// Since we are not guaranteed to get only one call per refresh driver tick,
// it's possible that mPendingReadyTime is set to a time in the future.
// In that case, we should wait until the next refresh driver tick before
// resuming.
if (mPendingState != PendingState::NotPending &&
!mPendingReadyTime.IsNull() &&
mTimeline &&
!mTimeline->GetCurrentTime().IsNull() &&
mPendingReadyTime.Value() <= mTimeline->GetCurrentTime().Value()) {
FinishPendingAt(mPendingReadyTime.Value());
mPendingReadyTime.SetNull();
}
if (IsPossiblyOrphanedPendingAnimation()) {
MOZ_ASSERT(mTimeline && !mTimeline->GetCurrentTime().IsNull(),
"Orphaned pending animtaions should have an active timeline");
FinishPendingAt(mTimeline->GetCurrentTime().Value());
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
// FIXME: Detect the no-change case and don't request a restyle at all
// FIXME: Detect changes to IsPlaying() state and request RestyleType::Layer
// so that layers get updated immediately
AnimationCollection* collection = GetCollection();
if (collection) {
collection->RequestRestyle(CanThrottle() ?
AnimationCollection::RestyleType::Throttled :
AnimationCollection::RestyleType::Standard);
}
}
示例7: MOZ_ASSERT
void
Animation::NotifyEffectTimingUpdated()
{
MOZ_ASSERT(mEffect,
"We should only update timing effect when we have a target "
"effect");
UpdateTiming(Animation::SeekFlag::NoSeek,
Animation::SyncNotifyFlag::Async);
}
示例8: EffectEnd
// https://w3c.github.io/web-animations/#finish-an-animation
void
Animation::Finish(ErrorResult& aRv)
{
if (mPlaybackRate == 0 ||
(mPlaybackRate > 0 && EffectEnd() == TimeDuration::Forever())) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
AutoMutationBatchForAnimation mb(*this);
// Seek to the end
TimeDuration limit =
mPlaybackRate > 0 ? TimeDuration(EffectEnd()) : TimeDuration(0);
bool didChange = GetCurrentTime() != Nullable<TimeDuration>(limit);
SilentlySetCurrentTime(limit);
// If we are paused or play-pending we need to fill in the start time in
// order to transition to the finished state.
//
// We only do this, however, if we have an active timeline. If we have an
// inactive timeline we can't transition into the finished state just like
// we can't transition to the running state (this finished state is really
// a substate of the running state).
if (mStartTime.IsNull() &&
mTimeline &&
!mTimeline->GetCurrentTime().IsNull()) {
mStartTime.SetValue(mTimeline->GetCurrentTime().Value() -
limit.MultDouble(1.0 / mPlaybackRate));
didChange = true;
}
// If we just resolved the start time for a pause or play-pending
// animation, we need to clear the task. We don't do this as a branch of
// the above however since we can have a play-pending animation with a
// resolved start time if we aborted a pause operation.
if (!mStartTime.IsNull() &&
(mPendingState == PendingState::PlayPending ||
mPendingState == PendingState::PausePending)) {
if (mPendingState == PendingState::PausePending) {
mHoldTime.SetNull();
}
CancelPendingTasks();
didChange = true;
if (mReady) {
mReady->MaybeResolve(this);
}
}
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Sync);
if (didChange && IsRelevant()) {
nsNodeUtils::AnimationChanged(this);
}
PostUpdate();
}
示例9: mb
// https://w3c.github.io/web-animations/#pause-an-animation
void
Animation::DoPause(ErrorResult& aRv)
{
if (IsPausedOrPausing()) {
return;
}
AutoMutationBatchForAnimation mb(*this);
// If we are transitioning from idle, fill in the current time
if (GetCurrentTime().IsNull()) {
if (mPlaybackRate >= 0.0) {
mHoldTime.SetValue(TimeDuration(0));
} else {
if (EffectEnd() == TimeDuration::Forever()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
mHoldTime.SetValue(TimeDuration(EffectEnd()));
}
}
bool reuseReadyPromise = false;
if (mPendingState == PendingState::PlayPending) {
CancelPendingTasks();
reuseReadyPromise = true;
}
if (!reuseReadyPromise) {
// Clear ready promise. We'll create a new one lazily.
mReady = nullptr;
}
mPendingState = PendingState::PausePending;
nsIDocument* doc = GetRenderedDocument();
if (doc) {
PendingAnimationTracker* tracker =
doc->GetOrCreatePendingAnimationTracker();
tracker->AddPausePending(*this);
} else {
TriggerOnNextTick(Nullable<TimeDuration>());
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
if (IsRelevant()) {
nsNodeUtils::AnimationChanged(this);
}
}
示例10: CancelPendingTasks
// http://w3c.github.io/web-animations/#pause-an-animation
void
Animation::DoPause(ErrorResult& aRv)
{
if (IsPausedOrPausing()) {
return;
}
// If we are transitioning from idle, fill in the current time
if (GetCurrentTime().IsNull()) {
if (mPlaybackRate >= 0.0) {
mHoldTime.SetValue(TimeDuration(0));
} else {
if (EffectEnd() == TimeDuration::Forever()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
mHoldTime.SetValue(TimeDuration(EffectEnd()));
}
}
bool reuseReadyPromise = false;
if (mPendingState == PendingState::PlayPending) {
CancelPendingTasks();
reuseReadyPromise = true;
}
// Mark this as no longer running on the compositor so that next time
// we update animations we won't throttle them and will have a chance
// to remove the animation from any layer it might be on.
mIsRunningOnCompositor = false;
if (!reuseReadyPromise) {
// Clear ready promise. We'll create a new one lazily.
mReady = nullptr;
}
mPendingState = PendingState::PausePending;
nsIDocument* doc = GetRenderedDocument();
if (doc) {
PendingAnimationTracker* tracker =
doc->GetOrCreatePendingAnimationTracker();
tracker->AddPausePending(*this);
} else {
TriggerOnNextTick(Nullable<TimeDuration>());
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
}
示例11: kungFuDeathGrip
void
Animation::SetEffect(KeyframeEffectReadOnly* aEffect)
{
RefPtr<Animation> kungFuDeathGrip(this);
if (mEffect == aEffect) {
return;
}
if (mEffect) {
mEffect->SetAnimation(nullptr);
}
mEffect = aEffect;
if (mEffect) {
mEffect->SetAnimation(this);
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
}
示例12: UpdateTiming
void MouseHelper::UpdateState(bool isLeftButtonDown, int mouseX, int mouseY, bool drawCursor)
{
bool currentWasLeftButtonDown = isLeftButtonDown;
// If we're in full-screen mode, then we need to account for the screen scale.
if (gIsFullscreen)
{
mouseX = (int)(mouseX / gScreenScale);
mouseY = (int)(mouseY / gScreenScale);
}
previousMousePosition.SetX(mouseX);
previousMousePosition.SetY(mouseY);
UpdateTiming();
if (!currentWasLeftButtonDown && previousWasLeftButtonDown)
{
// If a click is still possible now that the button has gone up,
// and we weren't already expecting a double-click,
// then we have a click, and we'll start considering the possibility
// of a double-click. If on the other hand a double-click was expected,
// then we now have a double-click.
clicked = clickPossible && !doubleClickPossible;
doubleClicked = clickPossible && doubleClickPossible;
doubleClickPossible = clickPossible && !doubleClickPossible;
clickPossible = false;
if (doubleClickPossible)
{
initialClickTime = SDL_GetTicks();
}
}
else if (currentWasLeftButtonDown && !previousWasLeftButtonDown)
{
initialLeftButtonDownTime = SDL_GetTicks();
initialLeftButtonDownPosition = previousMousePosition;
clickPossible = true;
doubleClickWasPossible = doubleClickPossible;
}
previousWasLeftButtonDown = currentWasLeftButtonDown;
MouseHelper::drawCursor = drawCursor;
}
示例13: MOZ_ASSERT
void
Animation::PauseAt(const TimeDuration& aReadyTime)
{
MOZ_ASSERT(mPendingState == PendingState::PausePending,
"Expected to pause a pause-pending animation");
if (!mStartTime.IsNull()) {
mHoldTime.SetValue((aReadyTime - mStartTime.Value())
.MultDouble(mPlaybackRate));
}
mStartTime.SetNull();
mPendingState = PendingState::NotPending;
UpdateTiming();
if (mReady) {
mReady->MaybeResolve(this);
}
}
示例14: UpdateTiming
// https://w3c.github.io/web-animations/#setting-the-timeline
void
Animation::SetTimelineNoUpdate(AnimationTimeline* aTimeline)
{
RefPtr<AnimationTimeline> oldTimeline = mTimeline;
if (mTimeline == aTimeline) {
return;
}
if (mTimeline) {
mTimeline->RemoveAnimation(this);
}
mTimeline = aTimeline;
if (!mStartTime.IsNull()) {
mHoldTime.SetNull();
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
}
示例15: SilentlySetCurrentTime
// Implements http://w3c.github.io/web-animations/#set-the-current-time
void
Animation::SetCurrentTime(const TimeDuration& aSeekTime)
{
SilentlySetCurrentTime(aSeekTime);
if (mPendingState == PendingState::PausePending) {
// Finish the pause operation
mHoldTime.SetValue(aSeekTime);
mStartTime.SetNull();
if (mReady) {
mReady->MaybeResolve(this);
}
CancelPendingTasks();
}
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Async);
PostUpdate();
}