Bug 1451469 - Complete hooking up of the sampler thread. r=botond,nical

This makes the APZ sampler thread be the render backend thread whenever
webrender is being used (not just when async scene building is enabled).

MozReview-Commit-ID: L9lmopd3pe7

--HG--
extra : rebase_source : a23793bf704a0bf3bc7ba6568ecfe5faa5720415
This commit is contained in:
Kartikaya Gupta 2018-04-16 17:39:26 -04:00
parent 5f5df795ef
commit 0ded9995cb
8 changed files with 47 additions and 42 deletions

View File

@ -20,6 +20,7 @@ namespace mozilla {
class TimeStamp;
namespace wr {
struct Transaction;
class TransactionWrapper;
struct WrTransformProperty;
struct WrWindowId;
@ -51,9 +52,11 @@ public:
* which thread it is.
*/
static void SetSamplerThread(const wr::WrWindowId& aWindowId);
static void SampleForWebRender(const wr::WrWindowId& aWindowId,
wr::Transaction* aTxn);
void SetSampleTime(const TimeStamp& aSampleTime);
bool PushStateToWR(wr::TransactionWrapper& aTxn);
void SampleForWebRender(wr::TransactionWrapper& aTxn);
bool SampleAnimations(const LayerMetricsWrapper& aLayer,
const TimeStamp& aSampleTime);

View File

@ -590,8 +590,8 @@ APZCTreeManager::UpdateHitTestingTree(LayersId aRootLayerTreeId,
aOriginatingLayersId, aPaintSequenceNumber);
}
bool
APZCTreeManager::PushStateToWR(wr::TransactionWrapper& aTxn,
void
APZCTreeManager::SampleForWebRender(wr::TransactionWrapper& aTxn,
const TimeStamp& aSampleTime)
{
AssertOnSamplerThread();
@ -648,7 +648,16 @@ APZCTreeManager::PushStateToWR(wr::TransactionWrapper& aTxn,
}
aTxn.AppendTransformProperties(scrollbarTransforms);
return activeAnimations;
if (activeAnimations) {
RefPtr<CompositorController> controller;
CompositorBridgeParent::CallWithIndirectShadowTree(mRootLayersId,
[&](LayerTreeState& aState) -> void {
controller = aState.GetCompositorController();
});
if (controller) {
controller->ScheduleRenderOnCompositorThread();
}
}
}
// Compute the clip region to be used for a layer with an APZC. This function

View File

@ -215,16 +215,13 @@ public:
/**
* Called when webrender is enabled, from the sampler thread. This function
* walks through the tree of APZC instances and tells webrender about the
* async scroll position. It also advances APZ animations to the specified
* sample time. In effect it is the webrender equivalent of (part of) the
* code in AsyncCompositionManager. If scrollbar transforms need updating
* to reflect the async scroll position, the updated transforms are appended
* to the provided transaction as well.
* Returns true if any APZ animations are in progress and we need to keep
* compositing.
* populates the provided transaction with any async scroll offsets needed.
* It also advances APZ animations to the specified sample time, and requests
* another composite if there are still active animations.
* In effect it is the webrender equivalent of (part of) the code in
* AsyncCompositionManager.
*/
bool PushStateToWR(wr::TransactionWrapper& aTxn,
void SampleForWebRender(wr::TransactionWrapper& aTxn,
const TimeStamp& aSampleTime);
/**

View File

@ -62,6 +62,16 @@ APZSampler::SetSamplerThread(const wr::WrWindowId& aWindowId)
}
}
/*static*/ void
APZSampler::SampleForWebRender(const wr::WrWindowId& aWindowId,
wr::Transaction* aTransaction)
{
if (RefPtr<APZSampler> sampler = GetSampler(aWindowId)) {
wr::TransactionWrapper txn(aTransaction);
sampler->SampleForWebRender(txn);
}
}
void
APZSampler::SetSampleTime(const TimeStamp& aSampleTime)
{
@ -70,11 +80,9 @@ APZSampler::SetSampleTime(const TimeStamp& aSampleTime)
mSampleTime = aSampleTime;
}
bool
APZSampler::PushStateToWR(wr::TransactionWrapper& aTxn)
void
APZSampler::SampleForWebRender(wr::TransactionWrapper& aTxn)
{
// This function will be removed eventually since we'll have WR pull
// the transforms from APZ instead.
AssertOnSamplerThread();
TimeStamp sampleTime;
{ // scope lock
@ -86,7 +94,7 @@ APZSampler::PushStateToWR(wr::TransactionWrapper& aTxn)
// anyway, so using Timestamp::Now() should be fine.
sampleTime = mSampleTime.IsNull() ? TimeStamp::Now() : mSampleTime;
}
return mApz->PushStateToWR(aTxn, sampleTime);
mApz->SampleForWebRender(aTxn, sampleTime);
}
bool
@ -247,12 +255,14 @@ APZSampler::GetSampler(const wr::WrWindowId& aWindowId)
void
apz_register_sampler(mozilla::wr::WrWindowId aWindowId)
{
mozilla::layers::APZSampler::SetSamplerThread(aWindowId);
}
void
apz_sample_transforms(mozilla::wr::WrWindowId aWindowId,
mozilla::wr::Transaction *aTransaction)
{
mozilla::layers::APZSampler::SampleForWebRender(aWindowId, aTransaction);
}
void

View File

@ -532,12 +532,12 @@ WebRenderBridgeParent::UpdateAPZScrollData(const wr::Epoch& aEpoch,
}
}
bool
WebRenderBridgeParent::PushAPZStateToWR(wr::TransactionBuilder& aTxn)
void
WebRenderBridgeParent::SetAPZSampleTime()
{
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
if (!cbp) {
return false;
return;
}
if (RefPtr<APZSampler> apz = cbp->GetAPZSampler()) {
TimeStamp animationTime = cbp->GetTestingTimeStamp().valueOr(
@ -549,13 +549,7 @@ WebRenderBridgeParent::PushAPZStateToWR(wr::TransactionBuilder& aTxn)
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);
}
return false;
}
mozilla::ipc::IPCResult
@ -1248,15 +1242,10 @@ WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::In
ScheduleGenerateFrame();
}
// We do this even if the arrays are empty, because it will clear out any
// previous properties stored on the WR side, which is desirable. Also, we
// must do this before the PushAPZStateToWR call which will append more
// properties, If we did this after that call, this would clobber those
// properties.
// previous properties store on the WR side, which is desirable.
txn.UpdateDynamicProperties(opacityArray, transformArray);
if (PushAPZStateToWR(txn)) {
ScheduleGenerateFrame();
}
SetAPZSampleTime();
wr::RenderThread::Get()->IncPendingFrameCount(mApi->GetId());

View File

@ -220,11 +220,8 @@ private:
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 transaction builder
// is populated with the property update details via AppendTransformProperties
bool PushAPZStateToWR(wr::TransactionBuilder& aTxn);
// Tell APZ what the subsequent sampling's timestamp should be.
void SetAPZSampleTime();
wr::Epoch GetNextWrEpoch();

View File

@ -1173,7 +1173,6 @@ pub extern "C" fn wr_transaction_scroll_layer(
scroll_id: u64,
new_scroll_origin: LayoutPoint
) {
assert!(unsafe { is_in_compositor_thread() });
let scroll_id = ExternalScrollId(scroll_id, pipeline_id);
txn.scroll_node_with_id(new_scroll_origin, scroll_id, ScrollClamping::NoClamping);
}

View File

@ -854,6 +854,7 @@ pref("gfx.compositor.glcontext.opaque", false);
#endif
pref("gfx.webrender.highlight-painted-layers", false);
pref("gfx.webrender.async-scene-build", false);
pref("gfx.webrender.blob-images", 1);
pref("gfx.webrender.blob.invalidation", true);
pref("gfx.webrender.hit-test", true);