Bug 1361497 - Refactoring to simplify getting the root CompositorBridgeParent and APZCTreeManager. r=jrmuizel

This allows for some code reuse in upcoming patches where we need to get
a hold of the APZCTreeManager.

MozReview-Commit-ID: 8oGiGH07fnF
This commit is contained in:
Kartikaya Gupta 2017-05-12 13:58:17 -04:00
Родитель 3ba2f96414
Коммит a5c9d69f63
4 изменённых файлов: 33 добавлений и 23 удалений

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

@ -1629,6 +1629,12 @@ CompositorBridgeParent::DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aA
return true; return true;
} }
RefPtr<WebRenderBridgeParent>
CompositorBridgeParent::GetWebRenderBridgeParent() const
{
return mWrBridge;
}
void void
CompositorBridgeParent::SetWebRenderProfilerEnabled(bool aEnabled) CompositorBridgeParent::SetWebRenderProfilerEnabled(bool aEnabled)
{ {

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

@ -452,6 +452,8 @@ public:
TextureFactoryIdentifier* aTextureFactoryIdentifier, TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint32_t* aIdNamespace) override; uint32_t* aIdNamespace) override;
bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override; bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
RefPtr<WebRenderBridgeParent> GetWebRenderBridgeParent() const;
static void SetWebRenderProfilerEnabled(bool aEnabled); static void SetWebRenderProfilerEnabled(bool aEnabled);
static CompositorBridgeParent* GetCompositorBridgeParentFromLayersId(const uint64_t& aLayersId); static CompositorBridgeParent* GetCompositorBridgeParentFromLayersId(const uint64_t& aLayersId);

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

@ -330,38 +330,38 @@ WebRenderBridgeParent::HandleDPEnd(const gfx::IntSize& aSize,
UpdateAPZ(); UpdateAPZ();
} }
void CompositorBridgeParent*
WebRenderBridgeParent::UpdateAPZ() WebRenderBridgeParent::GetRootCompositorBridgeParent() const
{ {
if (!mCompositorBridge) { if (!mCompositorBridge) {
return; return nullptr;
} }
CompositorBridgeParent* cbp;
uint64_t rootLayersId;
WebRenderBridgeParent* rootWrbp;
if (mWidget) { if (mWidget) {
// This WebRenderBridgeParent is attached to the root // This WebRenderBridgeParent is attached to the root
// CompositorBridgeParent. // CompositorBridgeParent.
cbp = static_cast<CompositorBridgeParent*>(mCompositorBridge); return static_cast<CompositorBridgeParent*>(mCompositorBridge);
rootLayersId = wr::AsUint64(mPipelineId);
rootWrbp = this;
} else {
// This WebRenderBridgeParent is attached to a
// CrossProcessCompositorBridgeParent so we have an extra level of
// indirection to unravel.
uint64_t layersId = wr::AsUint64(mPipelineId);
CompositorBridgeParent::LayerTreeState* lts =
CompositorBridgeParent::GetIndirectShadowTree(layersId);
MOZ_ASSERT(lts);
cbp = lts->mParent;
rootLayersId = cbp->RootLayerTreeId();
lts = CompositorBridgeParent::GetIndirectShadowTree(rootLayersId);
MOZ_ASSERT(lts);
rootWrbp = lts->mWrBridge.get();
} }
MOZ_ASSERT(cbp); // Otherwise, this WebRenderBridgeParent is attached to a
// CrossProcessCompositorBridgeParent so we have an extra level of
// indirection to unravel.
uint64_t layersId = wr::AsUint64(mPipelineId);
CompositorBridgeParent::LayerTreeState* lts =
CompositorBridgeParent::GetIndirectShadowTree(layersId);
MOZ_ASSERT(lts);
return lts->mParent;
}
void
WebRenderBridgeParent::UpdateAPZ()
{
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
if (!cbp) {
return;
}
uint64_t rootLayersId = cbp->RootLayerTreeId();
RefPtr<WebRenderBridgeParent> rootWrbp = cbp->GetWebRenderBridgeParent();
if (!rootWrbp) { if (!rootWrbp) {
return; return;
} }

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

@ -188,6 +188,8 @@ private:
void SampleAnimations(nsTArray<WrOpacityProperty>& aOpacityArray, void SampleAnimations(nsTArray<WrOpacityProperty>& aOpacityArray,
nsTArray<WrTransformProperty>& aTransformArray); nsTArray<WrTransformProperty>& aTransformArray);
CompositorBridgeParent* GetRootCompositorBridgeParent() const;
private: private:
struct PendingTransactionId { struct PendingTransactionId {
PendingTransactionId(wr::Epoch aEpoch, uint64_t aId) PendingTransactionId(wr::Epoch aEpoch, uint64_t aId)