Bug 1444374 - Make the LayerTransactionParent's mId always nonzero. r=mattwoodrow
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 09 Mar 2018 08:45:26 -0500
changeset 407549 1f3e61483a941d157267b46bd55bce431e147c1d
parent 407548 eb7464de4a573c47604847aa8897eaabc0cc72ec
child 407550 9df46d48a21c10d54492d6a276ec182a9a93f02e
push id33611
push userbtara@mozilla.com
push dateMon, 12 Mar 2018 09:52:50 +0000
treeherdermozilla-central@e29b54201696 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1444374
milestone60.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 1444374 - Make the LayerTransactionParent's mId always nonzero. r=mattwoodrow We can easily populate the mId with the correct layers id, which is the root layer tree id from the CompositorBridgeParent. This eliminates a bunch of special-case handling. MozReview-Commit-ID: FEkboAGEhYO
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/layers/ipc/LayerTransactionParent.h
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -1384,56 +1384,51 @@ CompositorBridgeParent::RecvGetFrameUnif
 
 void
 CompositorBridgeParent::SetTestAsyncScrollOffset(
     const uint64_t& aLayersId,
     const FrameMetrics::ViewID& aScrollId,
     const CSSPoint& aPoint)
 {
   if (mApzSampler) {
-    uint64_t layersId = (aLayersId == 0 ? mRootLayerTreeID : aLayersId);
-    mApzSampler->SetTestAsyncScrollOffset(layersId, aScrollId, aPoint);
+    MOZ_ASSERT(aLayersId != 0);
+    mApzSampler->SetTestAsyncScrollOffset(aLayersId, aScrollId, aPoint);
   }
 }
 
 void
 CompositorBridgeParent::SetTestAsyncZoom(
     const uint64_t& aLayersId,
     const FrameMetrics::ViewID& aScrollId,
     const LayerToParentLayerScale& aZoom)
 {
   if (mApzSampler) {
-    uint64_t layersId = (aLayersId == 0 ? mRootLayerTreeID : aLayersId);
-    mApzSampler->SetTestAsyncZoom(layersId, aScrollId, aZoom);
+    MOZ_ASSERT(aLayersId != 0);
+    mApzSampler->SetTestAsyncZoom(aLayersId, aScrollId, aZoom);
   }
 }
 
 void
 CompositorBridgeParent::FlushApzRepaints(const uint64_t& aLayersId)
 {
   MOZ_ASSERT(mApzcTreeManager);
-  uint64_t layersId = aLayersId;
-  if (layersId == 0) {
-    // The request is coming from the parent-process layer tree, so we should
-    // use the compositor's root layer tree id.
-    layersId = mRootLayerTreeID;
-  }
+  MOZ_ASSERT(aLayersId != 0);
   RefPtr<CompositorBridgeParent> self = this;
   APZThreadUtils::RunOnControllerThread(NS_NewRunnableFunction(
     "layers::CompositorBridgeParent::FlushApzRepaints",
-    [=]() { self->mApzcTreeManager->FlushApzRepaints(layersId); }));
+    [=]() { self->mApzcTreeManager->FlushApzRepaints(aLayersId); }));
 }
 
 void
 CompositorBridgeParent::GetAPZTestData(const uint64_t& aLayersId,
                                        APZTestData* aOutData)
 {
-  uint64_t layersId = (aLayersId == 0 ? mRootLayerTreeID : aLayersId);
   if (mApzSampler) {
-    mApzSampler->GetAPZTestData(layersId, aOutData);
+    MOZ_ASSERT(aLayersId != 0);
+    mApzSampler->GetAPZTestData(aLayersId, aOutData);
   }
 }
 
 void
 CompositorBridgeParent::SetConfirmedTargetAPZC(const uint64_t& aLayersId,
                                                const uint64_t& aInputBlockId,
                                                const nsTArray<ScrollableLayerGuid>& aTargets)
 {
@@ -1585,24 +1580,24 @@ CompositorBridgeParent::AllocPLayerTrans
                                                      const uint64_t& aId)
 {
   MOZ_ASSERT(aId == 0);
 
   InitializeLayerManager(aBackendHints);
 
   if (!mLayerManager) {
     NS_WARNING("Failed to initialise Compositor");
-    LayerTransactionParent* p = new LayerTransactionParent(/* aManager */ nullptr, this, /* aAnimStorage */ nullptr, 0);
+    LayerTransactionParent* p = new LayerTransactionParent(/* aManager */ nullptr, this, /* aAnimStorage */ nullptr, mRootLayerTreeID);
     p->AddIPDLReference();
     return p;
   }
 
   mCompositionManager = new AsyncCompositionManager(this, mLayerManager);
 
-  LayerTransactionParent* p = new LayerTransactionParent(mLayerManager, this, GetAnimationStorage(), 0);
+  LayerTransactionParent* p = new LayerTransactionParent(mLayerManager, this, GetAnimationStorage(), mRootLayerTreeID);
   p->AddIPDLReference();
   return p;
 }
 
 bool
 CompositorBridgeParent::DeallocPLayerTransactionParent(PLayerTransactionParent* actor)
 {
   static_cast<LayerTransactionParent*>(actor)->ReleaseIPDLReference();
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -54,16 +54,17 @@ LayerTransactionParent::LayerTransaction
   , mAnimStorage(aAnimStorage)
   , mId(aId)
   , mChildEpoch(0)
   , mParentEpoch(0)
   , mPendingTransaction(0)
   , mDestroyed(false)
   , mIPCOpen(false)
 {
+  MOZ_ASSERT(mId != 0);
 }
 
 LayerTransactionParent::~LayerTransactionParent()
 {
 }
 
 void
 LayerTransactionParent::SetLayerManager(HostLayerManager* aLayerManager, CompositorAnimationStorage* aAnimStorage)
--- a/gfx/layers/ipc/LayerTransactionParent.h
+++ b/gfx/layers/ipc/LayerTransactionParent.h
@@ -182,20 +182,16 @@ private:
 
   // Hold the root because it might be grafted under various
   // containers in the "real" layer tree
   RefPtr<Layer> mRoot;
 
   // Mapping from LayerHandles to Layers.
   nsRefPtrHashtable<nsUint64HashKey, Layer> mLayerMap;
 
-  // When this is nonzero, it refers to a layer tree owned by the
-  // compositor thread.  It is always true that
-  //   mId != 0 => mRoot == null
-  // because the "real tree" is owned by the compositor.
   uint64_t mId;
 
   // These fields keep track of the latest epoch values in the child and the
   // parent. mChildEpoch is the latest epoch value received from the child.
   // mParentEpoch is the latest epoch value that we have told TabParent about
   // (via ObserveLayerUpdate).
   uint64_t mChildEpoch;
   uint64_t mParentEpoch;