Bug 1367911 - Extract a GetLayersId() helper. r=dvander
authorKartikaya Gupta <kgupta@mozilla.com>
Sun, 28 May 2017 07:51:53 -0400
changeset 361241 577082fce7bf8cd2eefdfad0078438a6d47fe14f
parent 361240 a7a313dc31abd2662b4971089fe6c78b9dcb45ac
child 361242 73a610ae4080b4598337654d6344d184e915f18c
push id31921
push userryanvm@gmail.com
push dateTue, 30 May 2017 16:13:51 +0000
treeherdermozilla-central@c3cd8c58fa87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1367911
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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: gIwdyfafOq
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();