Bug 1375497 - Make sure the WebRenderBridgeParent respects the testing time set in the CompositorBridgeParent. r?pchang
This allows testing code control over the animation steps running over in the
compositor, which is needed for the OMTA mochitests.
MozReview-Commit-ID: CXJcieSEoRl
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -1706,16 +1706,22 @@ CompositorBridgeParent::DeallocPWebRende
}
RefPtr<WebRenderBridgeParent>
CompositorBridgeParent::GetWebRenderBridgeParent() const
{
return mWrBridge;
}
+Maybe<TimeStamp>
+CompositorBridgeParent::GetTestingTimeStamp() const
+{
+ return mIsTesting ? Some(mTestTime) : Nothing();
+}
+
void
CompositorBridgeParent::SetWebRenderProfilerEnabled(bool aEnabled)
{
MonitorAutoLock lock(*sIndirectLayerTreesLock);
for (auto it = sIndirectLayerTrees.begin(); it != sIndirectLayerTrees.end(); it++) {
LayerTreeState* state = &it->second;
if (state->mWrBridge) {
state->mWrBridge->SetWebRenderProfilerEnabled(aEnabled);
--- a/gfx/layers/ipc/CompositorBridgeParent.h
+++ b/gfx/layers/ipc/CompositorBridgeParent.h
@@ -452,16 +452,17 @@ public:
}
PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const wr::PipelineId& aPipelineId,
const LayoutDeviceIntSize& aSize,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint32_t* aIdNamespace) override;
bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
RefPtr<WebRenderBridgeParent> GetWebRenderBridgeParent() const;
+ Maybe<TimeStamp> GetTestingTimeStamp() const;
static void SetWebRenderProfilerEnabled(bool aEnabled);
static CompositorBridgeParent* GetCompositorBridgeParentFromLayersId(const uint64_t& aLayersId);
#if defined(MOZ_WIDGET_ANDROID)
gfx::IntSize GetEGLSurfaceSize() {
return mEGLSurfaceSize;
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -401,17 +401,18 @@ WebRenderBridgeParent::UpdateAPZ()
bool
WebRenderBridgeParent::PushAPZStateToWR(nsTArray<WrTransformProperty>& aTransformArray)
{
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
if (!cbp) {
return false;
}
if (RefPtr<APZCTreeManager> apzc = cbp->GetAPZCTreeManager()) {
- TimeStamp animationTime = mCompositorScheduler->GetLastComposeTime();
+ TimeStamp animationTime = cbp->GetTestingTimeStamp().valueOr(
+ mCompositorScheduler->GetLastComposeTime());
TimeDuration frameInterval = cbp->GetVsyncInterval();
// As with the non-webrender codepath in AsyncCompositionManager, we want to
// use the timestamp for the next vsync when advancing animations.
if (frameInterval != TimeDuration::Forever()) {
animationTime += frameInterval;
}
return apzc->PushStateToWR(mApi, animationTime, aTransformArray);
}
@@ -834,22 +835,30 @@ WebRenderBridgeParent::RecvGetAPZTestDat
void
WebRenderBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
{
Destroy();
}
void
+WebRenderBridgeParent::AdvanceAnimations()
+{
+ TimeStamp animTime = mCompositorScheduler->GetLastComposeTime();
+ if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) {
+ animTime = cbp->GetTestingTimeStamp().valueOr(animTime);
+ }
+ AnimationHelper::SampleAnimations(mAnimStorage, animTime);
+}
+
+void
WebRenderBridgeParent::SampleAnimations(nsTArray<WrOpacityProperty>& aOpacityArray,
nsTArray<WrTransformProperty>& aTransformArray)
{
- AnimationHelper::SampleAnimations(mAnimStorage,
- mCompositorScheduler->
- GetLastComposeTime());
+ AdvanceAnimations();
// return the animated data if has
if (mAnimStorage->AnimatedValueCount()) {
for(auto iter = mAnimStorage->ConstAnimatedValueTableIter();
!iter.Done(); iter.Next()) {
AnimatedValue * value = iter.UserData();
if (value->mType == AnimatedValue::TRANSFORM) {
aTransformArray.AppendElement(
--- a/gfx/layers/wr/WebRenderBridgeParent.h
+++ b/gfx/layers/wr/WebRenderBridgeParent.h
@@ -209,16 +209,17 @@ private:
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const WrSize& aContentSize,
const ByteBuffer& dl,
const WrBuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData);
+ void AdvanceAnimations();
void SampleAnimations(nsTArray<WrOpacityProperty>& aOpacityArray,
nsTArray<WrTransformProperty>& aTransformArray);
CompositorBridgeParent* GetRootCompositorBridgeParent() const;
// Have APZ push the async scroll state to WR. Returns true if an APZ
// animation is in effect and we need to schedule another composition.
// If scrollbars need their transforms updated, the provided aTransformArray