Bug 1313281 - Part 2: Remove DeliverFence. r=sotaro
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 27 Oct 2016 20:59:50 +1300
changeset 362548 9722bbd2b7678fbdc77cf0086aeb85af7272377a
parent 362547 e20bcc969b5df21acd407aad88505b9dc5e5f52a
child 362549 05a787b3ef8eaf9cb19864cd96c111ff0f77c0f2
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1313281
milestone52.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 1313281 - Part 2: Remove DeliverFence. r=sotaro
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/ipc/CompositorBridgeChild.cpp
gfx/layers/ipc/CompositorBridgeChild.h
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/ISurfaceAllocator.cpp
gfx/layers/ipc/ISurfaceAllocator.h
gfx/layers/ipc/ImageBridgeChild.cpp
gfx/layers/ipc/ImageBridgeChild.h
gfx/layers/ipc/ImageBridgeParent.cpp
gfx/layers/ipc/ImageBridgeParent.h
gfx/layers/ipc/LayersMessages.ipdlh
gfx/vr/ipc/VRManagerChild.cpp
gfx/vr/ipc/VRManagerChild.h
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -151,38 +151,16 @@ TextureHost::GetTextureSerial(PTexturePa
 }
 
 PTextureParent*
 TextureHost::GetIPDLActor()
 {
   return mActor;
 }
 
-bool
-TextureHost::SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
-{
-  if (!aReleaseFenceHandle.IsValid()) {
-    // HWC might not provide Fence.
-    // In this case, HWC implicitly handles buffer's fence.
-    return false;
-  }
-
-  mReleaseFenceHandle.Merge(aReleaseFenceHandle);
-
-  return true;
-}
-
-FenceHandle
-TextureHost::GetAndResetReleaseFenceHandle()
-{
-  FenceHandle fence;
-  mReleaseFenceHandle.TransferToAnotherFenceHandle(fence);
-  return fence;
-}
-
 void
 TextureHost::SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle)
 {
   mAcquireFenceHandle = aAcquireFenceHandle;
 }
 
 FenceHandle
 TextureHost::GetAndResetAcquireFenceHandle()
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -581,56 +581,41 @@ public:
       UnbindTextureSource();
       // Send mFwdTransactionId to client side if necessary.
       NotifyNotUsed();
     }
   }
 
   int NumCompositableRefs() const { return mCompositableCount; }
 
-  /**
-   * Store a fence that will signal when the current buffer is no longer being read.
-   * Similar to android's GLConsumer::setReleaseFence()
-   */
-  bool SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle);
-
-  /**
-   * Return a releaseFence's Fence and clear a reference to the Fence.
-   */
-  FenceHandle GetAndResetReleaseFenceHandle();
-
   void SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle);
 
   /**
    * Return a acquireFence's Fence and clear a reference to the Fence.
    */
   FenceHandle GetAndResetAcquireFenceHandle();
 
   virtual void WaitAcquireFenceHandleSyncComplete() {};
 
   void SetLastFwdTransactionId(uint64_t aTransactionId);
 
   virtual bool NeedsFenceHandle() { return false; }
 
-  virtual FenceHandle GetCompositorReleaseFence() { return FenceHandle(); }
-
   void DeserializeReadLock(const ReadLockDescriptor& aDesc,
                            ISurfaceAllocator* aAllocator);
 
   TextureReadLock* GetReadLock() { return mReadLock; }
 
   virtual Compositor* GetCompositor() = 0;
 
   virtual BufferTextureHost* AsBufferTextureHost() { return nullptr; }
 
 protected:
   void ReadUnlock();
 
-  FenceHandle mReleaseFenceHandle;
-
   FenceHandle mAcquireFenceHandle;
 
   void RecycleTexture(TextureFlags aFlags);
 
   virtual void UpdatedInternal(const nsIntRegion *Region) {}
 
   /**
    * Called when mCompositableCount becomes 0.
--- a/gfx/layers/ipc/CompositorBridgeChild.cpp
+++ b/gfx/layers/ipc/CompositorBridgeChild.cpp
@@ -871,22 +871,16 @@ CompositorBridgeChild::DeallocPTextureCh
 
 bool
 CompositorBridgeChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageData>&& aMessages)
 {
   for (AsyncParentMessageArray::index_type i = 0; i < aMessages.Length(); ++i) {
     const AsyncParentMessageData& message = aMessages[i];
 
     switch (message.type()) {
-      case AsyncParentMessageData::TOpDeliverFence: {
-        const OpDeliverFence& op = message.get_OpDeliverFence();
-        FenceHandle fence = op.fence();
-        DeliverFence(op.TextureId(), fence);
-        break;
-      }
       case AsyncParentMessageData::TOpNotifyNotUsed: {
         const OpNotifyNotUsed& op = message.get_OpNotifyNotUsed();
         NotifyNotUsed(op.TextureId(), op.fwdTransactionId());
         break;
       }
       default:
         NS_ERROR("unknown AsyncParentMessageData type");
         return false;
@@ -945,26 +939,16 @@ CompositorBridgeChild::NotifyNotUsed(uin
   if (aFwdTransactionId < client->GetLastFwdTransactionId()) {
     // Released on host side, but client already requested newer use texture.
     return;
   }
   mTexturesWaitingRecycled.Remove(aTextureId);
 }
 
 void
-CompositorBridgeChild::DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
-{
-  RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
-  if (!client) {
-    return;
-  }
-  client->SetReleaseFenceHandle(aReleaseFenceHandle);
-}
-
-void
 CompositorBridgeChild::CancelWaitForRecycle(uint64_t aTextureId)
 {
   RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
   if (!client) {
     return;
   }
   mTexturesWaitingRecycled.Remove(aTextureId);
 }
--- a/gfx/layers/ipc/CompositorBridgeChild.h
+++ b/gfx/layers/ipc/CompositorBridgeChild.h
@@ -184,18 +184,16 @@ public:
   void HoldUntilCompositableRefReleasedIfNecessary(TextureClient* aClient);
 
   /**
    * Notify id of Texture When host side end its use. Transaction id is used to
    * make sure if there is no newer usage.
    */
   void NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId);
 
-  void DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
-
   virtual void CancelWaitForRecycle(uint64_t aTextureId) override;
 
   TextureClientPool* GetTexturePool(KnowsCompositor* aAllocator,
                                     gfx::SurfaceFormat aFormat,
                                     TextureFlags aFlags);
   void ClearTexturePool();
 
   virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() override;
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -113,17 +113,16 @@ CompositorBridgeParentBase::NotifyNotUse
   }
 
   if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
      !texture->NeedsFenceHandle()) {
     return;
   }
 
   if (texture->GetFlags() & TextureFlags::RECYCLE) {
-    SendFenceHandleIfPresent(aTexture);
     uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
     mPendingAsyncMessage.push_back(
       OpNotifyNotUsed(textureId, aTransactionId));
     return;
   }
 
   // Gralloc requests to deliver fence to client side.
   // If client side does not use TextureFlags::RECYCLE flag,
--- a/gfx/layers/ipc/ISurfaceAllocator.cpp
+++ b/gfx/layers/ipc/ISurfaceAllocator.cpp
@@ -20,44 +20,16 @@ NS_IMPL_ISUPPORTS(GfxMemoryImageReporter
 mozilla::Atomic<ptrdiff_t> GfxMemoryImageReporter::sAmount(0);
 
 mozilla::ipc::SharedMemory::SharedMemoryType OptimalShmemType()
 {
   return ipc::SharedMemory::SharedMemoryType::TYPE_BASIC;
 }
 
 void
-HostIPCAllocator::SendFenceHandleIfPresent(PTextureParent* aTexture)
-{
-  RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
-  if (!texture) {
-    return;
-  }
-
-  if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
-     !texture->NeedsFenceHandle()) {
-    return;
-  }
-
-  uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
-
-  // Send a ReleaseFence of CompositorOGL.
-  FenceHandle fence = texture->GetCompositorReleaseFence();
-  if (fence.IsValid()) {
-    mPendingAsyncMessage.push_back(OpDeliverFence(textureId, fence));
-  }
-
-  // Send a ReleaseFence that is set to TextureHost by HwcComposer2D.
-  fence = texture->GetAndResetReleaseFenceHandle();
-  if (fence.IsValid()) {
-    mPendingAsyncMessage.push_back(OpDeliverFence(textureId, fence));
-  }
-}
-
-void
 HostIPCAllocator::SendPendingAsyncMessages()
 {
   if (mPendingAsyncMessage.empty()) {
     return;
   }
 
   // Some type of AsyncParentMessageData message could have
   // one file descriptor (e.g. OpDeliverFence).
--- a/gfx/layers/ipc/ISurfaceAllocator.h
+++ b/gfx/layers/ipc/ISurfaceAllocator.h
@@ -131,18 +131,16 @@ public:
    * Get child side's process Id.
    */
   virtual base::ProcessId GetChildProcessId() = 0;
 
   virtual void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) = 0;
 
   virtual void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) = 0;
 
-  void SendFenceHandleIfPresent(PTextureParent* aTexture);
-
   virtual void SendPendingAsyncMessages();
 
   virtual void SetAboutToSendAsyncMessages()
   {
     mAboutToSendAsyncMessages = true;
   }
 
   bool IsAboutToSendAsyncMessages()
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -241,45 +241,26 @@ ImageBridgeChild::NotifyNotUsed(uint64_t
   if (aFwdTransactionId < client->GetLastFwdTransactionId()) {
     // Released on host side, but client already requested newer use texture.
     return;
   }
   mTexturesWaitingRecycled.Remove(aTextureId);
 }
 
 void
-ImageBridgeChild::DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
-{
-  RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
-  if (!client) {
-    return;
-  }
-  client->SetReleaseFenceHandle(aReleaseFenceHandle);
-}
-
-void
 ImageBridgeChild::HoldUntilFenceHandleDelivery(TextureClient* aClient, uint64_t aTransactionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   // XXX Re-enable fence handling
   return;
 
   NS_RUNTIMEABORT("not reached");
 }
 
 void
-ImageBridgeChild::DeliverFenceToNonRecycle(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
-{
-  // XXX Re-enable fence handling
-  return;
-
-  NS_RUNTIMEABORT("not reached");
-}
-
-void
 ImageBridgeChild::NotifyNotUsedToNonRecycle(uint64_t aTextureId, uint64_t aTransactionId)
 {
   // XXX Re-enable fence handling
   return;
 
   NS_RUNTIMEABORT("not reached");
 }
 
@@ -1196,33 +1177,16 @@ ImageBridgeChild::DeallocPImageContainer
 
 bool
 ImageBridgeChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageData>&& aMessages)
 {
   for (AsyncParentMessageArray::index_type i = 0; i < aMessages.Length(); ++i) {
     const AsyncParentMessageData& message = aMessages[i];
 
     switch (message.type()) {
-      case AsyncParentMessageData::TOpDeliverFence: {
-        const OpDeliverFence& op = message.get_OpDeliverFence();
-        FenceHandle fence = op.fence();
-        DeliverFence(op.TextureId(), fence);
-        break;
-      }
-      case AsyncParentMessageData::TOpDeliverFenceToNonRecycle: {
-        // Notify ReleaseCompositableRef to a TextureClient that belongs to
-        // LayerTransactionChild. It is used only on gonk to deliver fence to
-        // a TextureClient that does not have TextureFlags::RECYCLE.
-        // In this case, LayerTransactionChild's ipc could not be used to deliver fence.
-
-        const OpDeliverFenceToNonRecycle& op = message.get_OpDeliverFenceToNonRecycle();
-        FenceHandle fence = op.fence();
-        DeliverFenceToNonRecycle(op.TextureId(), fence);
-        break;
-      }
       case AsyncParentMessageData::TOpNotifyNotUsed: {
         const OpNotifyNotUsed& op = message.get_OpNotifyNotUsed();
         NotifyNotUsed(op.TextureId(), op.fwdTransactionId());
         break;
       }
       case AsyncParentMessageData::TOpNotifyNotUsedToNonRecycle: {
         // Notify ReleaseCompositableRef to a TextureClient that belongs to
         // LayerTransactionChild. It is used only on gonk to deliver fence to
--- a/gfx/layers/ipc/ImageBridgeChild.h
+++ b/gfx/layers/ipc/ImageBridgeChild.h
@@ -286,22 +286,18 @@ public:
   void HoldUntilCompositableRefReleasedIfNecessary(TextureClient* aClient);
 
   /**
    * Notify id of Texture When host side end its use. Transaction id is used to
    * make sure if there is no newer usage.
    */
   void NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId);
 
-  void DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
-
   void HoldUntilFenceHandleDelivery(TextureClient* aClient, uint64_t aTransactionId);
 
-  void DeliverFenceToNonRecycle(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
-
   void NotifyNotUsedToNonRecycle(uint64_t aTextureId, uint64_t aTransactionId);
 
   void CancelWaitFenceHandle(TextureClient* aClient);
 
   virtual void CancelWaitForRecycle(uint64_t aTextureId) override;
 
   virtual bool DestroyInTransaction(PTextureChild* aTexture, bool synchronously) override;
   virtual bool DestroyInTransaction(PCompositableChild* aCompositable, bool synchronously) override;
--- a/gfx/layers/ipc/ImageBridgeParent.cpp
+++ b/gfx/layers/ipc/ImageBridgeParent.cpp
@@ -403,59 +403,29 @@ ImageBridgeParent::DeallocShmem(ipc::Shm
 }
 
 bool ImageBridgeParent::IsSameProcess() const
 {
   return OtherPid() == base::GetCurrentProcId();
 }
 
 void
-ImageBridgeParent::SendFenceHandleToNonRecycle(PTextureParent* aTexture)
-{
-  RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
-  if (!texture) {
-    return;
-  }
-
-  if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
-     !texture->NeedsFenceHandle()) {
-    return;
-  }
-
-  uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
-
-  // Send a ReleaseFence of CompositorOGL.
-  FenceHandle fence = texture->GetCompositorReleaseFence();
-  if (fence.IsValid()) {
-    mPendingAsyncMessage.push_back(OpDeliverFenceToNonRecycle(textureId, fence));
-  }
-
-  // Send a ReleaseFence that is set to TextureHost by HwcComposer2D.
-  fence = texture->GetAndResetReleaseFenceHandle();
-  if (fence.IsValid()) {
-    mPendingAsyncMessage.push_back(OpDeliverFenceToNonRecycle(textureId, fence));
-  }
-}
-
-void
 ImageBridgeParent::NotifyNotUsedToNonRecycle(PTextureParent* aTexture,
                                              uint64_t aTransactionId)
 {
   RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
   if (!texture) {
     return;
   }
 
   if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
      !texture->NeedsFenceHandle()) {
     return;
   }
 
-  SendFenceHandleToNonRecycle(aTexture);
-
   uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
   mPendingAsyncMessage.push_back(
     OpNotifyNotUsedToNonRecycle(textureId, aTransactionId));
 
 }
 
 /*static*/ void
 ImageBridgeParent::NotifyNotUsedToNonRecycle(base::ProcessId aChildProcessId,
@@ -497,17 +467,16 @@ ImageBridgeParent::NotifyNotUsed(PTextur
     return;
   }
 
   if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
      !texture->NeedsFenceHandle()) {
     return;
   }
 
-  SendFenceHandleIfPresent(aTexture);
   uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
   mPendingAsyncMessage.push_back(
     OpNotifyNotUsed(textureId, aTransactionId));
 
   if (!IsAboutToSendAsyncMessages()) {
     SendPendingAsyncMessages();
   }
 }
--- a/gfx/layers/ipc/ImageBridgeParent.h
+++ b/gfx/layers/ipc/ImageBridgeParent.h
@@ -108,18 +108,16 @@ public:
   virtual bool AllocUnsafeShmem(size_t aSize,
                                 ipc::SharedMemory::SharedMemoryType aType,
                                 ipc::Shmem* aShmem) override;
 
   virtual void DeallocShmem(ipc::Shmem& aShmem) override;
 
   virtual bool IsSameProcess() const override;
 
-  void SendFenceHandleToNonRecycle(PTextureParent* aTexture);
-
   void NotifyNotUsedToNonRecycle(PTextureParent* aTexture,
                                  uint64_t aTransactionId);
 
   static void NotifyNotUsedToNonRecycle(base::ProcessId aChildProcessId,
                                         PTextureParent* aTexture,
                                         uint64_t aTransactionId);
 
   using CompositableParentManager::SetAboutToSendAsyncMessages;
--- a/gfx/layers/ipc/LayersMessages.ipdlh
+++ b/gfx/layers/ipc/LayersMessages.ipdlh
@@ -411,26 +411,16 @@ struct OpUseComponentAlphaTextures {
   ReadLockDescriptor sharedLockWhite;
 };
 
 union MaybeRegion {
   nsIntRegion;
   null_t;
 };
 
-struct OpDeliverFence {
-  uint64_t TextureId;
-  FenceHandle fence;
-};
-
-struct OpDeliverFenceToNonRecycle {
-  uint64_t TextureId;
-  FenceHandle fence;
-};
-
 struct OpNotifyNotUsed {
   uint64_t TextureId;
   uint64_t fwdTransactionId;
 };
 
 struct OpNotifyNotUsedToNonRecycle {
   uint64_t TextureId;
   uint64_t fwdTransactionId;
@@ -509,16 +499,14 @@ struct ImageCompositeNotification {
 
 // Unit of a "changeset reply".  This is a weird abstraction, probably
 // only to be used for buffer swapping.
 union EditReply {
   OpContentBufferSwap;
 };
 
 union AsyncParentMessageData {
-  OpDeliverFence;
-  OpDeliverFenceToNonRecycle;
   OpNotifyNotUsed;
   OpNotifyNotUsedToNonRecycle;
 };
 
 } // namespace
 } // namespace
--- a/gfx/vr/ipc/VRManagerChild.cpp
+++ b/gfx/vr/ipc/VRManagerChild.cpp
@@ -314,22 +314,16 @@ VRManagerChild::GetInputFrameID()
 
 bool
 VRManagerChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageData>&& aMessages)
 {
   for (InfallibleTArray<AsyncParentMessageData>::index_type i = 0; i < aMessages.Length(); ++i) {
     const AsyncParentMessageData& message = aMessages[i];
 
     switch (message.type()) {
-      case AsyncParentMessageData::TOpDeliverFence: {
-        const OpDeliverFence& op = message.get_OpDeliverFence();
-        FenceHandle fence = op.fence();
-        DeliverFence(op.TextureId(), fence);
-        break;
-      }
       case AsyncParentMessageData::TOpNotifyNotUsed: {
         const OpNotifyNotUsed& op = message.get_OpNotifyNotUsed();
         NotifyNotUsed(op.TextureId(), op.fwdTransactionId());
         break;
       }
       default:
         NS_ERROR("unknown AsyncParentMessageData type");
         return false;
@@ -343,26 +337,16 @@ VRManagerChild::CreateTexture(const Surf
                               LayersBackend aLayersBackend,
                               TextureFlags aFlags,
                               uint64_t aSerial)
 {
   return SendPTextureConstructor(aSharedData, aLayersBackend, aFlags, aSerial);
 }
 
 void
-VRManagerChild::DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
-{
-  RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
-  if (!client) {
-    return;
-  }
-  client->SetReleaseFenceHandle(aReleaseFenceHandle);
-}
-
-void
 VRManagerChild::CancelWaitForRecycle(uint64_t aTextureId)
 {
   RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
   if (!client) {
     return;
   }
   mTexturesWaitingRecycled.Remove(aTextureId);
 }
--- a/gfx/vr/ipc/VRManagerChild.h
+++ b/gfx/vr/ipc/VRManagerChild.h
@@ -139,18 +139,16 @@ protected:
 
   friend class layers::CompositorBridgeChild;
 
 private:
 
   void FireDOMVRDisplayConnectEventInternal();
   void FireDOMVRDisplayDisconnectEventInternal();
   void FireDOMVRDisplayPresentChangeEventInternal();
-
-  void DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
   /**
   * Notify id of Texture When host side end its use. Transaction id is used to
   * make sure if there is no newer usage.
   */
   void NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId);
 
   nsTArray<RefPtr<VRDisplayClient> > mDisplays;
   bool mDisplaysInitialized;