Bug 1367911 - Extract a GetLayersId() helper. r?dvander draft
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 26 May 2017 10:34:22 -0400
changeset 585081 34ae25c2bbad58c25c4ea01570f82e089afea570
parent 585080 248f78f1d79acf9997bd4cc5c37e97e5fe7c5786
child 630628 71c080771acf9e0facb45ebc744b10b29cc3279d
push id61004
push userkgupta@mozilla.com
push dateFri, 26 May 2017 14:35:14 +0000
reviewersdvander
bugs1367911
milestone55.0a1
Bug 1367911 - Extract a GetLayersId() helper. r?dvander We're calling this often enough that it seems good to extract a named helper method. MozReview-Commit-ID: BgXfpMyyr54
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderBridgeParent.h
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -271,17 +271,17 @@ WebRenderBridgeParent::RecvDeleteImage(c
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvDeleteCompositorAnimations(InfallibleTArray<uint64_t>&& aIds)
 {
   if (mDestroyed) {
     return IPC_OK();
   }
 
-  uint64_t storageId = mWidget ? 0 : wr::AsUint64(mPipelineId);
+  uint64_t storageId = mWidget ? 0 : GetLayersId();
   CompositorAnimationStorage* storage =
     mCompositorBridge->GetAnimationStorage(storageId);
   MOZ_ASSERT(storage);
 
   for (uint32_t i = 0; i < aIds.Length(); i++) {
     storage->ClearById(aIds[i]);
   }
 
@@ -342,19 +342,18 @@ WebRenderBridgeParent::GetRootCompositor
     // This WebRenderBridgeParent is attached to the root
     // CompositorBridgeParent.
     return static_cast<CompositorBridgeParent*>(mCompositorBridge);
   }
 
   // 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);
+      CompositorBridgeParent::GetIndirectShadowTree(GetLayersId());
   MOZ_ASSERT(lts);
   return lts->mParent;
 }
 
 void
 WebRenderBridgeParent::UpdateAPZ()
 {
   CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
@@ -363,17 +362,17 @@ WebRenderBridgeParent::UpdateAPZ()
   }
   uint64_t rootLayersId = cbp->RootLayerTreeId();
   RefPtr<WebRenderBridgeParent> rootWrbp = cbp->GetWebRenderBridgeParent();
   if (!rootWrbp) {
     return;
   }
   if (RefPtr<APZCTreeManager> apzc = cbp->GetAPZCTreeManager()) {
     apzc->UpdateHitTestingTree(rootLayersId, rootWrbp->GetScrollData(),
-        mScrollData.IsFirstPaint(), wr::AsUint64(mPipelineId),
+        mScrollData.IsFirstPaint(), GetLayersId(),
         /* TODO: propagate paint sequence number */ 0);
   }
 }
 
 bool
 WebRenderBridgeParent::PushAPZStateToWR(nsTArray<WrTransformProperty>& aTransformArray)
 {
   CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
@@ -534,17 +533,17 @@ WebRenderBridgeParent::ProcessWebRenderC
           NS_ERROR("ReceiveCompositableUpdate failed");
         }
         break;
       }
       case WebRenderParentCommand::TOpAddCompositorAnimations: {
         const OpAddCompositorAnimations& op = cmd.get_OpAddCompositorAnimations();
         CompositorAnimations data(Move(op.data()));
         if (data.animations().Length()) {
-          uint64_t id = mWidget ? 0 : wr::AsUint64(mPipelineId);
+          uint64_t id = mWidget ? 0 : GetLayersId();
           CompositorAnimationStorage* storage =
             mCompositorBridge->GetAnimationStorage(id);
           if (storage) {
             storage->SetAnimations(data.id(), data.animations());
             // Store the default opacity
             if (op.opacity().type() == OptionalOpacity::Tfloat) {
               storage->SetAnimatedValue(data.id(), op.opacity().get_float());
             }
@@ -570,17 +569,17 @@ WebRenderBridgeParent::ProcessWebRenderC
   mApi->SetRootDisplayList(gfx::Color(0.3f, 0.f, 0.f, 1.f), aEpoch, LayerSize(aSize.width, aSize.height),
                            mPipelineId, aContentSize,
                            dlDesc, dl.mData, dl.mLength);
 
   ScheduleComposition();
   DeleteOldImages();
 
   if (ShouldParentObserveEpoch()) {
-    mCompositorBridge->ObserveLayerUpdate(wr::AsUint64(mPipelineId), GetChildLayerObserverEpoch(), true);
+    mCompositorBridge->ObserveLayerUpdate(GetLayersId(), GetChildLayerObserverEpoch(), true);
   }
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvDPGetSnapshot(PTextureParent* aTexture)
 {
   if (mDestroyed) {
     return IPC_OK();
@@ -708,17 +707,17 @@ WebRenderBridgeParent::RecvSetLayerObser
 {
   mChildLayerObserverEpoch = aLayerObserverEpoch;
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvClearCachedResources()
 {
-  mCompositorBridge->ObserveLayerUpdate(wr::AsUint64(mPipelineId), GetChildLayerObserverEpoch(), false);
+  mCompositorBridge->ObserveLayerUpdate(GetLayersId(), GetChildLayerObserverEpoch(), false);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvForceComposite()
 {
   if (mDestroyed) {
     return IPC_OK();
@@ -728,27 +727,27 @@ WebRenderBridgeParent::RecvForceComposit
 }
 
 already_AddRefed<AsyncPanZoomController>
 WebRenderBridgeParent::GetTargetAPZC(const FrameMetrics::ViewID& aScrollId)
 {
   RefPtr<AsyncPanZoomController> apzc;
   if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) {
     if (RefPtr<APZCTreeManager> apzctm = cbp->GetAPZCTreeManager()) {
-      apzc = apzctm->GetTargetAPZC(wr::AsUint64(mPipelineId), aScrollId);
+      apzc = apzctm->GetTargetAPZC(GetLayersId(), aScrollId);
     }
   }
   return apzc.forget();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvSetConfirmedTargetAPZC(const uint64_t& aBlockId,
                                                   nsTArray<ScrollableLayerGuid>&& aTargets)
 {
-  mCompositorBridge->SetConfirmedTargetAPZC(wr::AsUint64(mPipelineId), aBlockId, aTargets);
+  mCompositorBridge->SetConfirmedTargetAPZC(GetLayersId(), aBlockId, aTargets);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aScrollId,
                                                 const float& aX,
                                                 const float& aY)
 {
@@ -770,31 +769,31 @@ WebRenderBridgeParent::RecvSetAsyncZoom(
   }
   apzc->SetTestAsyncZoom(LayerToParentLayerScale(aZoom));
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvFlushApzRepaints()
 {
-  mCompositorBridge->FlushApzRepaints(wr::AsUint64(mPipelineId));
+  mCompositorBridge->FlushApzRepaints(GetLayersId());
   return IPC_OK();
 }
 
 void
 WebRenderBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   Destroy();
 }
 
 void
 WebRenderBridgeParent::SampleAnimations(nsTArray<WrOpacityProperty>& aOpacityArray,
                                         nsTArray<WrTransformProperty>& aTransformArray)
 {
-  uint64_t id = mWidget ? 0 : wr::AsUint64(mPipelineId);
+  uint64_t id = mWidget ? 0 : GetLayersId();
   CompositorAnimationStorage* storage =
     mCompositorBridge->GetAnimationStorage(id);
 
   AnimationHelper::SampleAnimations(storage,
                                     mCompositorScheduler->
                                       GetLastComposeTime());
 
   // return the animated data if has
@@ -910,16 +909,22 @@ WebRenderBridgeParent::FlushTransactionI
   }
   return id;
 }
 
 WebRenderBridgeParent::~WebRenderBridgeParent()
 {
 }
 
+uint64_t
+WebRenderBridgeParent::GetLayersId() const
+{
+  return wr::AsUint64(mPipelineId);
+}
+
 void
 WebRenderBridgeParent::DeleteOldImages()
 {
   for (wr::ImageKey key : mKeysToDelete) {
     mApi->DeleteImage(key);
   }
   mKeysToDelete.clear();
 }
--- a/gfx/layers/wr/WebRenderBridgeParent.h
+++ b/gfx/layers/wr/WebRenderBridgeParent.h
@@ -175,16 +175,17 @@ public:
 
   static uint32_t AllocIdNameSpace() {
     return ++sIdNameSpace;
   }
 
 private:
   virtual ~WebRenderBridgeParent();
 
+  uint64_t GetLayersId() const;
   void DeleteOldImages();
   void ProcessWebRenderCommands(const gfx::IntSize &aSize,
                                 InfallibleTArray<WebRenderParentCommand>& commands,
                                 const wr::Epoch& aEpoch,
                                 const WrSize& aContentSize,
                                 const ByteBuffer& dl,
                                 const WrBuiltDisplayListDescriptor& dlDesc);
   void ScheduleComposition();