Bug 1456679 - Make SampleAnimations return boolean to tell there is any animations even if the animation in delay phase. r=kats

If the animation is in delay phase, we shouldn't produce any values for the
animation but we have to make sure subsequent ticks happen in order to the time
when the animation starts.  So what we should do here is that

1) Make AnimationHelper::SampleAnimations() return boolean, return true if
   there is any animation.
2) Schedule the next tick if AnimationHelper::SampleAnimations return true

This setup is equivalent to what we do non-WebRender.

So that we don't need to set non-animated value as AnimatedValue for delay
phase to make subsequent ticks happen for the delay phase animations.  The
non-animated value will be dropped in the next patch.

MozReview-Commit-ID: IwltLGgvT7K

--HG--
extra : rebase_source : 9854b182134adf3060260849741142841721d65b
This commit is contained in:
Hiroyuki Ikezoe 2018-04-26 08:28:44 +09:00
parent 60c3c10391
commit 861eb6a9fb
4 changed files with 27 additions and 13 deletions

View File

@ -546,15 +546,16 @@ AnimationHelper::GetNextCompositorAnimationsId()
return nextId;
}
void
bool
AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
TimeStamp aTime)
{
MOZ_ASSERT(aStorage);
bool isAnimating = false;
// Do nothing if there are no compositor animations
if (!aStorage->AnimationsCount()) {
return;
return isAnimating;
}
//Sample the animations in CompositorAnimationStorage
@ -565,6 +566,7 @@ AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
continue;
}
isAnimating = true;
RefPtr<RawServoAnimationValue> animationValue;
InfallibleTArray<AnimData> animationData;
AnimationHelper::SetAnimations(*animations,
@ -626,6 +628,8 @@ AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
MOZ_ASSERT_UNREACHABLE("Unhandled animated property");
}
}
return isAnimating;
}
} // namespace layers

View File

@ -248,8 +248,13 @@ public:
* Sample animation based a given time stamp |aTime| and the animation
* data inside CompositorAnimationStorage |aStorage|. The animated values
* after sampling will be stored in CompositorAnimationStorage as well.
*
* Returns true if there is any animation.
* Note that even if there are only in-delay phase animations (i.e. not
* visually effective), this function returns true to ensure we composite
* again on the next tick.
*/
static void
static bool
SampleAnimations(CompositorAnimationStorage* aStorage,
TimeStamp aTime);
};

View File

@ -1176,7 +1176,7 @@ WebRenderBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
Destroy();
}
void
bool
WebRenderBridgeParent::AdvanceAnimations()
{
if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) {
@ -1187,15 +1187,15 @@ WebRenderBridgeParent::AdvanceAnimations()
// refresh mode, on the testing mode animations on the compositor are
// synchronously composed, so we don't need to worry about the time gap
// between the main thread and compositor thread.
AnimationHelper::SampleAnimations(mAnimStorage, *testingTimeStamp);
return;
return AnimationHelper::SampleAnimations(mAnimStorage, *testingTimeStamp);
}
}
TimeStamp lastComposeTime = mCompositorScheduler->GetLastComposeTime();
// if we have already mPreviousTimeStamp, use it since on the compositor the
// time in the previous tick is more closer to the main-thread tick time.
AnimationHelper::SampleAnimations(mAnimStorage,
const bool isAnimating =
AnimationHelper::SampleAnimations(mAnimStorage,
!mPreviousFrameTimeStamp.IsNull()
? mPreviousFrameTimeStamp
: lastComposeTime);
@ -1205,13 +1205,15 @@ WebRenderBridgeParent::AdvanceAnimations()
// started animations.
mPreviousFrameTimeStamp =
mAnimStorage->AnimatedValueCount() ? lastComposeTime : TimeStamp();
return isAnimating;
}
void
bool
WebRenderBridgeParent::SampleAnimations(nsTArray<wr::WrOpacityProperty>& aOpacityArray,
nsTArray<wr::WrTransformProperty>& aTransformArray)
{
AdvanceAnimations();
const bool isAnimating = AdvanceAnimations();
// return the animated data if has
if (mAnimStorage->AnimatedValueCount()) {
@ -1227,6 +1229,8 @@ WebRenderBridgeParent::SampleAnimations(nsTArray<wr::WrOpacityProperty>& aOpacit
}
}
}
return isAnimating;
}
void
@ -1273,8 +1277,7 @@ WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::In
nsTArray<wr::WrOpacityProperty> opacityArray;
nsTArray<wr::WrTransformProperty> transformArray;
SampleAnimations(opacityArray, transformArray);
if (!transformArray.IsEmpty() || !opacityArray.IsEmpty()) {
if (SampleAnimations(opacityArray, transformArray)) {
ScheduleGenerateFrame();
}
// We do this even if the arrays are empty, because it will clear out any

View File

@ -214,8 +214,10 @@ private:
bool ShouldParentObserveEpoch();
mozilla::ipc::IPCResult HandleShutdown();
void AdvanceAnimations();
void SampleAnimations(nsTArray<wr::WrOpacityProperty>& aOpacityArray,
// Returns true if there is any animation (including animations in delay
// phase).
bool AdvanceAnimations();
bool SampleAnimations(nsTArray<wr::WrOpacityProperty>& aOpacityArray,
nsTArray<wr::WrTransformProperty>& aTransformArray);
CompositorBridgeParent* GetRootCompositorBridgeParent() const;