mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1617179 - Extract a helper method across WR and non-WR codepaths. r=botond
The operations of recording checkerboard events and advancing the animations across all APZs are conceptually linked. This patch extracts a helper that does these operations in a single function, that is then called from both the WR and non-WR codepaths. This will allow us to expand this code a bit without having to duplicate it in multiple places. Differential Revision: https://phabricator.services.mozilla.com/D67374 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
8b9b6fdab2
commit
803fabf7da
@ -67,8 +67,7 @@ class APZSampler {
|
||||
wr::RenderRoot aRenderRoot,
|
||||
const wr::WrPipelineIdEpochs* aEpochsBeingRendered);
|
||||
|
||||
bool SampleAnimations(const LayerMetricsWrapper& aLayer,
|
||||
const TimeStamp& aSampleTime);
|
||||
bool AdvanceAnimations(const TimeStamp& aSampleTime);
|
||||
|
||||
/**
|
||||
* Compute the updated shadow transform for a scroll thumb layer that
|
||||
|
@ -788,8 +788,6 @@ void APZCTreeManager::SampleForWebRender(
|
||||
apzc->GetGuid().mScrollId,
|
||||
wr::ToLayoutPoint(asyncScrollDelta));
|
||||
|
||||
apzc->ReportCheckerboard(aSampleTime);
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
// Send the root frame metrics to java through the UIController
|
||||
RefPtr<UiCompositorControllerParent> uiController =
|
||||
@ -866,15 +864,8 @@ void APZCTreeManager::SampleForWebRender(
|
||||
// sampling all async transforms, because AdvanceAnimations() updates
|
||||
// the effective scroll offset to the value it should have for the *next*
|
||||
// composite after this one (if the APZ frame delay is enabled).
|
||||
bool activeAnimations = false;
|
||||
for (const auto& mapping : mApzcMap) {
|
||||
AsyncPanZoomController* apzc = mapping.second;
|
||||
if (apzc->GetRenderRoot() != aRenderRoot) {
|
||||
// If this APZC belongs to a different render root, skip over it
|
||||
continue;
|
||||
}
|
||||
activeAnimations |= apzc->AdvanceAnimations(aSampleTime);
|
||||
}
|
||||
bool activeAnimations =
|
||||
AdvanceAnimationsInternal(lock, Some(aRenderRoot), aSampleTime);
|
||||
if (activeAnimations) {
|
||||
RefPtr<CompositorController> controller;
|
||||
CompositorBridgeParent::CallWithIndirectShadowTree(
|
||||
@ -888,6 +879,28 @@ void APZCTreeManager::SampleForWebRender(
|
||||
}
|
||||
}
|
||||
|
||||
bool APZCTreeManager::AdvanceAnimations(Maybe<wr::RenderRoot> aRenderRoot,
|
||||
const TimeStamp& aSampleTime) {
|
||||
MutexAutoLock lock(mMapLock);
|
||||
return AdvanceAnimationsInternal(lock, std::move(aRenderRoot), aSampleTime);
|
||||
}
|
||||
|
||||
bool APZCTreeManager::AdvanceAnimationsInternal(
|
||||
const MutexAutoLock& aProofOfMapLock, Maybe<wr::RenderRoot> aRenderRoot,
|
||||
const TimeStamp& aSampleTime) {
|
||||
bool activeAnimations = false;
|
||||
for (const auto& mapping : mApzcMap) {
|
||||
AsyncPanZoomController* apzc = mapping.second;
|
||||
if (aRenderRoot && apzc->GetRenderRoot() != *aRenderRoot) {
|
||||
// If this APZC belongs to a different render root, skip over it
|
||||
continue;
|
||||
}
|
||||
apzc->ReportCheckerboard(aSampleTime);
|
||||
activeAnimations |= apzc->AdvanceAnimations(aSampleTime);
|
||||
}
|
||||
return activeAnimations;
|
||||
}
|
||||
|
||||
// Compute the clip region to be used for a layer with an APZC. This function
|
||||
// is only called for layers which actually have scrollable metrics and an APZC.
|
||||
template <class ScrollNode>
|
||||
|
@ -204,6 +204,14 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
|
||||
wr::RenderRoot aRenderRoot,
|
||||
const wr::WrPipelineIdEpochs* aEpochsBeingRendered);
|
||||
|
||||
/**
|
||||
* Walk through all the APZCs and do the sampling steps needed when
|
||||
* advancing to the next frame. The APZCs walked can be restricted to a
|
||||
* specific render root by providing that as the first argument.
|
||||
*/
|
||||
bool AdvanceAnimations(Maybe<wr::RenderRoot> aRenderRoot,
|
||||
const TimeStamp& aSampleTime);
|
||||
|
||||
/**
|
||||
* Refer to the documentation of APZInputBridge::ReceiveInputEvent() and
|
||||
* APZEventResult.
|
||||
@ -743,6 +751,10 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
|
||||
static already_AddRefed<GeckoContentController> GetContentController(
|
||||
LayersId aLayersId);
|
||||
|
||||
bool AdvanceAnimationsInternal(const MutexAutoLock& aProofOfMapLock,
|
||||
Maybe<wr::RenderRoot> aRenderRoot,
|
||||
const TimeStamp& aSampleTime);
|
||||
|
||||
protected:
|
||||
/* The input queue where input events are held until we know enough to
|
||||
* figure out where they're going. Protected so gtests can access it.
|
||||
|
@ -99,26 +99,10 @@ void APZSampler::SampleForWebRender(
|
||||
mApz->SampleForWebRender(aTxn, sampleTime, aRenderRoot, aEpochsBeingRendered);
|
||||
}
|
||||
|
||||
bool APZSampler::SampleAnimations(const LayerMetricsWrapper& aLayer,
|
||||
const TimeStamp& aSampleTime) {
|
||||
bool APZSampler::AdvanceAnimations(const TimeStamp& aSampleTime) {
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
AssertOnSamplerThread();
|
||||
|
||||
// TODO: eventually we can drop the aLayer argument and just walk the APZ
|
||||
// tree directly in mApz.
|
||||
|
||||
bool activeAnimations = false;
|
||||
|
||||
ForEachNodePostOrder<ForwardIterator>(
|
||||
aLayer,
|
||||
[&activeAnimations, &aSampleTime](LayerMetricsWrapper aLayerMetrics) {
|
||||
if (AsyncPanZoomController* apzc = aLayerMetrics.GetApzc()) {
|
||||
apzc->ReportCheckerboard(aSampleTime);
|
||||
activeAnimations |= apzc->AdvanceAnimations(aSampleTime);
|
||||
}
|
||||
});
|
||||
|
||||
return activeAnimations;
|
||||
return mApz->AdvanceAnimations(Nothing(), aSampleTime);
|
||||
}
|
||||
|
||||
LayerToParentLayerMatrix4x4 APZSampler::ComputeTransformForScrollThumb(
|
||||
|
@ -1490,8 +1490,7 @@ bool AsyncCompositionManager::TransformShadowTree(
|
||||
|
||||
bool apzAnimating = false;
|
||||
if (RefPtr<APZSampler> apz = mCompositorBridge->GetAPZSampler()) {
|
||||
apzAnimating =
|
||||
apz->SampleAnimations(LayerMetricsWrapper(root), nextFrame);
|
||||
apzAnimating = apz->AdvanceAnimations(nextFrame);
|
||||
}
|
||||
wantNextFrame |= apzAnimating;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user