Use CompositableHandle in ImageNotification. (bug 1323957 part 3, r=mattwoodrow)
authorDavid Anderson <dvander@alliedmods.net>
Tue, 17 Jan 2017 18:47:06 -0800
changeset 377055 d531b1b53676413afd775208c3cb67c062838a8d
parent 377054 b930d01d6aee9f296e875f024c56ba09579f738d
child 377056 58db09989d0509a721ad4ae60c24753fba767716
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1323957
milestone53.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
Use CompositableHandle in ImageNotification. (bug 1323957 part 3, r=mattwoodrow)
gfx/ipc/GfxMessageUtils.h
gfx/layers/composite/CompositableHost.h
gfx/layers/composite/ImageHost.cpp
gfx/layers/ipc/ImageBridgeChild.cpp
gfx/layers/ipc/ImageBridgeParent.cpp
gfx/layers/ipc/ImageBridgeParent.h
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/layers/ipc/LayersMessages.ipdlh
gfx/layers/ipc/ShadowLayers.cpp
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -709,16 +709,29 @@ struct ParamTraits<mozilla::layers::Laye
   static void Write(Message* msg, const paramType& param) {
     WriteParam(msg, param.mHandle);
   }
   static bool Read(const Message* msg, PickleIterator* iter, paramType* result) {
     return ReadParam(msg, iter, &result->mHandle);
   }
 };
 
+template<>
+struct ParamTraits<mozilla::layers::CompositableHandle>
+{
+  typedef mozilla::layers::CompositableHandle paramType;
+
+  static void Write(Message* msg, const paramType& param) {
+    WriteParam(msg, param.mHandle);
+  }
+  static bool Read(const Message* msg, PickleIterator* iter, paramType* result) {
+    return ReadParam(msg, iter, &result->mHandle);
+  }
+};
+
 // Helper class for reading bitfields.
 // If T has bitfields members, derive ParamTraits<T> from BitfieldHelper<T>.
 template <typename ParamType>
 struct BitfieldHelper
 {
   // We need this helper because we can't get the address of a bitfield to
   // pass directly to ReadParam. So instead we read it into a temporary bool
   // and set the bitfield using a setter function
--- a/gfx/layers/composite/CompositableHost.h
+++ b/gfx/layers/composite/CompositableHost.h
@@ -44,25 +44,24 @@ class ThebesBufferData;
 class TiledContentHost;
 class CompositableParentManager;
 class PCompositableParent;
 struct EffectChain;
 
 struct AsyncCompositableRef
 {
   AsyncCompositableRef()
-   : mProcessId(mozilla::ipc::kInvalidProcessId),
-     mAsyncId(0)
+   : mProcessId(mozilla::ipc::kInvalidProcessId)
   {}
-  AsyncCompositableRef(base::ProcessId aProcessId, uint64_t aAsyncId)
-   : mProcessId(aProcessId), mAsyncId(aAsyncId)
+  AsyncCompositableRef(base::ProcessId aProcessId, const CompositableHandle& aHandle)
+   : mProcessId(aProcessId), mHandle(aHandle)
   {}
-  explicit operator bool() const { return !!mAsyncId; }
+  explicit operator bool() const { return !!mHandle; }
   base::ProcessId mProcessId;
-  uint64_t mAsyncId;
+  CompositableHandle mHandle;
 };
 
 /**
  * The compositor-side counterpart to CompositableClient. Responsible for
  * updating textures and data about textures from IPC and how textures are
  * composited (tiling, double buffering, etc.).
  *
  * Update (for images/canvases) and UpdateThebes (for Thebes) are called during
--- a/gfx/layers/composite/ImageHost.cpp
+++ b/gfx/layers/composite/ImageHost.cpp
@@ -345,17 +345,17 @@ ImageHost::Composite(LayerComposite* aLa
       diagnosticFlags |= DiagnosticFlags::YCBCR;
     }
 
     if (mLastFrameID != img->mFrameID || mLastProducerID != img->mProducerID) {
       if (mAsyncRef) {
         ImageCompositeNotificationInfo info;
         info.mImageBridgeProcessId = mAsyncRef.mProcessId;
         info.mNotification = ImageCompositeNotification(
-          mAsyncRef.mAsyncId,
+          mAsyncRef.mHandle,
           img->mTimeStamp, GetCompositor()->GetCompositionTime(),
           img->mFrameID, img->mProducerID);
         static_cast<LayerManagerComposite*>(aLayer->GetLayerManager())->
             AppendImageCompositeNotification(info);
       }
       mLastFrameID = img->mFrameID;
       mLastProducerID = img->mProducerID;
     }
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -1104,17 +1104,17 @@ ImageBridgeChild::RecvParentAsyncMessage
 mozilla::ipc::IPCResult
 ImageBridgeChild::RecvDidComposite(InfallibleTArray<ImageCompositeNotification>&& aNotifications)
 {
   for (auto& n : aNotifications) {
     RefPtr<ImageContainerListener> listener;
     {
       MutexAutoLock lock(mContainerMapLock);
       ImageContainer* imageContainer;
-      imageContainer = mImageContainers.Get(n.asyncCompositableID());
+      imageContainer = mImageContainers.Get(n.compositable().Value());
       if (imageContainer) {
         listener = imageContainer->GetImageContainerListener();
       }
     }
     if (listener) {
       listener->NotifyComposite(n);
     }
   }
--- a/gfx/layers/ipc/ImageBridgeParent.cpp
+++ b/gfx/layers/ipc/ImageBridgeParent.cpp
@@ -242,27 +242,27 @@ ImageBridgeParent::AllocPCompositablePar
   }
   if (!aID) {
     NS_ERROR("Expected non-zero async compositable ID");
     return actor;
   }
 
   CompositableHost* host = CompositableHost::FromIPDLActor(actor);
 
-  host->SetAsyncRef(AsyncCompositableRef(OtherPid(), aID));
+  host->SetAsyncRef(AsyncCompositableRef(OtherPid(), CompositableHandle(aID)));
   mCompositables[aID] = host;
 
   return actor;
 }
 
 bool ImageBridgeParent::DeallocPCompositableParent(PCompositableParent* aActor)
 {
   if (CompositableHost* host = CompositableHost::FromIPDLActor(aActor)) {
     const AsyncCompositableRef& ref = host->GetAsyncRef();
-    mCompositables.erase(ref.mAsyncId);
+    mCompositables.erase(ref.mHandle.Value());
   }
   return CompositableHost::DestroyIPDLActor(aActor);
 }
 
 PTextureParent*
 ImageBridgeParent::AllocPTextureParent(const SurfaceDescriptor& aSharedData,
                                        const LayersBackend& aLayersBackend,
                                        const TextureFlags& aFlags,
@@ -319,17 +319,17 @@ ImageBridgeParent::NotifyImageComposites
   // notifications in one message per group.
   aNotifications.Sort(ProcessIdComparator());
   uint32_t i = 0;
   bool ok = true;
   while (i < aNotifications.Length()) {
     AutoTArray<ImageCompositeNotification,1> notifications;
     notifications.AppendElement(aNotifications[i].mNotification);
     uint32_t end = i + 1;
-    MOZ_ASSERT(aNotifications[i].mNotification.asyncCompositableID());
+    MOZ_ASSERT(aNotifications[i].mNotification.compositable());
     ProcessId pid = aNotifications[i].mImageBridgeProcessId;
     while (end < aNotifications.Length() &&
            aNotifications[end].mImageBridgeProcessId == pid) {
       notifications.AppendElement(aNotifications[end].mNotification);
       ++end;
     }
     GetInstance(pid)->SendPendingAsyncMessages();
     if (!GetInstance(pid)->SendDidComposite(notifications)) {
@@ -434,19 +434,19 @@ ImageBridgeParent::NotifyNotUsed(PTextur
     OpNotifyNotUsed(textureId, aTransactionId));
 
   if (!IsAboutToSendAsyncMessages()) {
     SendPendingAsyncMessages();
   }
 }
 
 CompositableHost*
-ImageBridgeParent::FindCompositable(uint64_t aId)
+ImageBridgeParent::FindCompositable(const CompositableHandle& aHandle)
 {
-  auto iter = mCompositables.find(aId);
+  auto iter = mCompositables.find(aHandle.Value());
   if (iter == mCompositables.end()) {
     return nullptr;
   }
   return iter->second;
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/ipc/ImageBridgeParent.h
+++ b/gfx/layers/ipc/ImageBridgeParent.h
@@ -118,17 +118,17 @@ public:
   static ImageBridgeParent* GetInstance(ProcessId aId);
 
   static bool NotifyImageComposites(nsTArray<ImageCompositeNotificationInfo>& aNotifications);
 
   virtual bool UsesImageBridge() const override { return true; }
 
   virtual bool IPCOpen() const override { return !mClosed; }
 
-  CompositableHost* FindCompositable(uint64_t aId);
+  CompositableHost* FindCompositable(const CompositableHandle& aHandle);
 
 protected:
   void OnChannelConnected(int32_t pid) override;
 
   void Bind(Endpoint<PImageBridgeParent>&& aEndpoint);
 
 private:
   void DeferredDestroy();
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -594,17 +594,17 @@ LayerTransactionParent::RecvUpdate(const
         // Do not attach compositables from old layer trees. Return true since
         // content cannot handle errors.
         return IPC_OK();
       }
       ImageBridgeParent* imageBridge = ImageBridgeParent::GetInstance(OtherPid());
       if (!imageBridge) {
         return IPC_FAIL_NO_REASON(this);
       }
-      CompositableHost* host = imageBridge->FindCompositable(op.containerID());
+      CompositableHost* host = imageBridge->FindCompositable(op.compositable());
       if (!host) {
         NS_ERROR("CompositableHost not found in the map");
         return IPC_FAIL_NO_REASON(this);
       }
       if (!Attach(AsLayer(op.layer()), host, true)) {
         return IPC_FAIL_NO_REASON(this);
       }
       if (mLayerManager->GetCompositor()) {
--- a/gfx/layers/ipc/LayersMessages.ipdlh
+++ b/gfx/layers/ipc/LayersMessages.ipdlh
@@ -45,16 +45,17 @@ using struct mozilla::layers::ScrollMeta
 using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h";
 using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h";
 using mozilla::layers::MaybeLayerClip from "FrameMetrics.h";
 using mozilla::gfx::Glyph from "Layers.h";
 using mozilla::layers::BorderColors from "mozilla/layers/LayersTypes.h";
 using mozilla::layers::BorderCorners from "mozilla/layers/LayersTypes.h";
 using mozilla::layers::BorderWidths from "mozilla/layers/LayersTypes.h";
 using mozilla::layers::LayerHandle from "mozilla/layers/LayersTypes.h";
+using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h";
 
 namespace mozilla {
 namespace layers {
 
 struct TargetConfig {
   IntRect naturalBounds;
   ScreenRotation rotation;
   ScreenOrientationInternal orientation;
@@ -73,17 +74,17 @@ struct OpCreateRefLayer        { LayerHa
 
 struct OpAttachCompositable {
   LayerHandle layer;
   PCompositable compositable;
 };
 
 struct OpAttachAsyncCompositable {
   LayerHandle layer;
-  uint64_t containerID;
+  CompositableHandle compositable;
 };
 
 struct ThebesBufferData {
   IntRect rect;
   IntPoint rotation;
 };
 
 struct CubicBezierFunction {
@@ -517,17 +518,17 @@ struct OpContentBufferSwap {
   nsIntRegion frontUpdatedRegion;
 };
 
 /**
  * An ImageCompositeNotification is sent the first time a particular
  * image is composited by an ImageHost.
  */
 struct ImageCompositeNotification {
-  uint64_t asyncCompositableID;
+  CompositableHandle compositable;
   TimeStamp imageTimeStamp;
   TimeStamp firstCompositeTimeStamp;
   uint32_t frameID;
   uint32_t producerID;
 };
 
 // Unit of a "changeset reply".  This is a weird abstraction, probably
 // only to be used for buffer swapping.
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -857,17 +857,17 @@ void ShadowLayerForwarder::Attach(Compos
   mTxn->AddEdit(OpAttachCompositable(Shadow(aLayer), nullptr, aCompositable->GetIPDLActor()));
 }
 
 void ShadowLayerForwarder::AttachAsyncCompositable(const CompositableHandle& aHandle,
                                                    ShadowableLayer* aLayer)
 {
   MOZ_ASSERT(aLayer);
   MOZ_ASSERT(aHandle);
-  mTxn->AddEdit(OpAttachAsyncCompositable(Shadow(aLayer), aHandle.Value()));
+  mTxn->AddEdit(OpAttachAsyncCompositable(Shadow(aLayer), aHandle));
 }
 
 void ShadowLayerForwarder::SetShadowManager(PLayerTransactionChild* aShadowManager)
 {
   mShadowManager = static_cast<LayerTransactionChild*>(aShadowManager);
   mShadowManager->SetForwarder(this);
 }