Bug 1451469 - Set the sample time on APZSampler. r=botond,nical

When sampling APZ transforms from rust code, we will need a timestamp at
which to sample the transforms. It's not obvious what the right
timestamp is to use here, and this will almost certainly be revisited
when we are hooking up OMTA in bug 1453360. For now we just stash the
most recent composite timestamp on the APZSampler and use that when
sampling. This seems to work fine.

MozReview-Commit-ID: KinsXO9tEJH

--HG--
extra : rebase_source : ffce8a9ac6720eea8583b03a613545ac5e9b48bf
This commit is contained in:
Kartikaya Gupta 2018-04-16 17:39:26 -04:00
Родитель adaebffdd8
Коммит 5f5df795ef
3 изменённых файлов: 29 добавлений и 6 удалений

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

@ -52,8 +52,8 @@ public:
*/
static void SetSamplerThread(const wr::WrWindowId& aWindowId);
bool PushStateToWR(wr::TransactionWrapper& aTxn,
const TimeStamp& aSampleTime);
void SetSampleTime(const TimeStamp& aSampleTime);
bool PushStateToWR(wr::TransactionWrapper& aTxn);
bool SampleAnimations(const LayerMetricsWrapper& aLayer,
const TimeStamp& aSampleTime);
@ -125,6 +125,9 @@ private:
mutable bool mSamplerThreadQueried;
#endif
Mutex mSampleTimeLock;
// Can only be accessed or modified while holding mSampleTimeLock.
TimeStamp mSampleTime;
};
} // namespace layers

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

@ -27,6 +27,7 @@ APZSampler::APZSampler(const RefPtr<APZCTreeManager>& aApz)
#ifdef DEBUG
, mSamplerThreadQueried(false)
#endif
, mSampleTimeLock("APZSampler::mSampleTimeLock")
{
MOZ_ASSERT(aApz);
mApz->SetSampler(this);
@ -61,13 +62,31 @@ APZSampler::SetSamplerThread(const wr::WrWindowId& aWindowId)
}
}
void
APZSampler::SetSampleTime(const TimeStamp& aSampleTime)
{
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
MutexAutoLock lock(mSampleTimeLock);
mSampleTime = aSampleTime;
}
bool
APZSampler::PushStateToWR(wr::TransactionWrapper& aTxn,
const TimeStamp& aSampleTime)
APZSampler::PushStateToWR(wr::TransactionWrapper& aTxn)
{
// This function will be removed eventually since we'll have WR pull
// the transforms from APZ instead.
return mApz->PushStateToWR(aTxn, aSampleTime);
AssertOnSamplerThread();
TimeStamp sampleTime;
{ // scope lock
MutexAutoLock lock(mSampleTimeLock);
// If mSampleTime is null we're in a startup phase where the
// WebRenderBridgeParent hasn't yet provided us with a sample time.
// If we're that early there probably aren't any APZ animations happening
// anyway, so using Timestamp::Now() should be fine.
sampleTime = mSampleTime.IsNull() ? TimeStamp::Now() : mSampleTime;
}
return mApz->PushStateToWR(aTxn, sampleTime);
}
bool

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

@ -548,11 +548,12 @@ WebRenderBridgeParent::PushAPZStateToWR(wr::TransactionBuilder& aTxn)
if (frameInterval != TimeDuration::Forever()) {
animationTime += frameInterval;
}
apz->SetSampleTime(animationTime);
// The TransactionWrapper shares the underlying transaction object with
// aTxn. When we exit this scope the TransactionWrapper is destroyed but
// the underlying transaction lives on in aTxn.
wr::TransactionWrapper txn(aTxn.Raw());
return apz->PushStateToWR(txn, animationTime);
return apz->PushStateToWR(txn);
}
return false;
}