diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index 0132300770d..9497ba34b21 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -13,7 +13,6 @@ #include "mozilla/gfx/Rect.h" // for Rect, IntRect #include "mozilla/gfx/Types.h" // for Float #include "mozilla/layers/CompositorTypes.h" // for DiagnosticTypes, etc -#include "mozilla/layers/FenceUtils.h" // for FenceHandle #include "mozilla/layers/LayersTypes.h" // for LayersBackend #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsRegion.h" @@ -354,11 +353,6 @@ public: virtual void SetFBAcquireFence(Layer* aLayer) {} - virtual FenceHandle GetReleaseFence() - { - return FenceHandle(); - } - /** * Post-rendering stuff if the rendering is done outside of this Compositor * e.g., by Composer2D. diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index 7d2a36a466e..5c344caea82 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -358,7 +358,7 @@ public: virtual void SetReleaseFenceHandle(FenceHandle aReleaseFenceHandle) { - mReleaseFenceHandle.Merge(aReleaseFenceHandle); + mReleaseFenceHandle = aReleaseFenceHandle; } const FenceHandle& GetReleaseFenceHandle() const diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index 2bcc3a711e2..8463e57bcbf 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -80,6 +80,8 @@ public: void CompositorRecycle(); + void SendFenceHandleIfPresent(); + virtual bool RecvClientRecycle() MOZ_OVERRIDE; virtual bool RecvClearTextureHostSync() MOZ_OVERRIDE; @@ -145,6 +147,14 @@ TextureHost::GetIPDLActor() return mActor; } +// static +void +TextureHost::SendFenceHandleIfPresent(PTextureParent* actor) +{ + TextureParent* parent = static_cast(actor); + parent->SendFenceHandleIfPresent(); +} + FenceHandle TextureHost::GetAndResetReleaseFenceHandle() { @@ -704,6 +714,7 @@ void TextureParent::CompositorRecycle() { mTextureHost->ClearRecycleCallback(); + SendFenceHandleIfPresent(); if (mTextureHost->GetFlags() & TextureFlags::RECYCLE) { mozilla::unused << SendCompositorRecycle(); @@ -713,6 +724,28 @@ TextureParent::CompositorRecycle() } } +void +TextureParent::SendFenceHandleIfPresent() +{ +#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 + if (mTextureHost) { + TextureHostOGL* hostOGL = mTextureHost->AsHostOGL(); + if (!hostOGL) { + return; + } + android::sp fence = hostOGL->GetAndResetReleaseFence(); + if (fence.get() && fence->isValid()) { + // HWC might not provide Fence. + // In this case, HWC implicitly handles buffer's fence. + + FenceHandle handle = FenceHandle(fence); + RefPtr tracker = new FenceDeliveryTracker(handle); + mCompositableManager->SendFenceHandle(tracker, this, handle); + } + } +#endif +} + bool TextureParent::RecvClientRecycle() { diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index b3683c2084f..db0afbc4734 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -421,6 +421,8 @@ public: */ PTextureParent* GetIPDLActor(); + static void SendFenceHandleIfPresent(PTextureParent* actor); + FenceHandle GetAndResetReleaseFenceHandle(); /** diff --git a/gfx/layers/ipc/CompositableTransactionParent.cpp b/gfx/layers/ipc/CompositableTransactionParent.cpp index 210a48a2829..99be5058b66 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.cpp +++ b/gfx/layers/ipc/CompositableTransactionParent.cpp @@ -162,7 +162,7 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation MOZ_ASSERT(tex.get()); compositable->RemoveTextureHost(tex); // send FenceHandle if present. - SendFenceHandleIfPresent(op.textureParent(), compositable); + TextureHost::SendFenceHandleIfPresent(op.textureParent()); break; } case CompositableOperation::TOpRemoveTextureAsync: { @@ -179,8 +179,7 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation GetChildProcessId(), op.holderId(), op.transactionId(), - op.textureParent(), - compositable); + op.textureParent()); // If the message is recievied via PLayerTransaction, // Send message back via PImageBridge. @@ -191,7 +190,7 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation op.transactionId())); } else { // send FenceHandle if present. - SendFenceHandleIfPresent(op.textureParent(), compositable); + TextureHost::SendFenceHandleIfPresent(op.textureParent()); ReplyRemoveTexture(OpReplyRemoveTexture(false, // isMain op.holderId(), @@ -259,42 +258,6 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation return true; } -void -CompositableParentManager::SendPendingAsyncMessges() -{ - if (mPendingAsyncMessage.empty()) { - return; - } - - // Some type of AsyncParentMessageData message could have - // one file descriptor (e.g. OpDeliverFence). - // A number of file descriptors per gecko ipc message have a limitation - // on OS_POSIX (MACOSX or LINUX). -#if defined(OS_POSIX) - static const uint32_t kMaxMessageNumber = FileDescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE; -#else - // default number that works everywhere else - static const uint32_t kMaxMessageNumber = 250; -#endif - - InfallibleTArray messages; - messages.SetCapacity(mPendingAsyncMessage.size()); - for (size_t i = 0; i < mPendingAsyncMessage.size(); i++) { - messages.AppendElement(mPendingAsyncMessage[i]); - // Limit maximum number of messages. - if (messages.Length() >= kMaxMessageNumber) { - SendAsyncMessage(messages); - // Initialize Messages. - messages.Clear(); - } - } - - if (messages.Length() > 0) { - SendAsyncMessage(messages); - } - mPendingAsyncMessage.clear(); -} - } // namespace } // namespace diff --git a/gfx/layers/ipc/CompositableTransactionParent.h b/gfx/layers/ipc/CompositableTransactionParent.h index 4d6283a99bd..0a86edf333e 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.h +++ b/gfx/layers/ipc/CompositableTransactionParent.h @@ -30,17 +30,12 @@ class CompositableParentManager : public ISurfaceAllocator , public AsyncTransactionTrackersHolder { public: - virtual void SendFenceHandleIfPresent(PTextureParent* aTexture, - CompositableHost* aCompositableHost) = 0; - virtual void SendFenceHandle(AsyncTransactionTracker* aTracker, PTextureParent* aTexture, const FenceHandle& aFence) = 0; virtual void SendAsyncMessage(const InfallibleTArray& aMessage) = 0; - void SendPendingAsyncMessges(); - /** * Get child side's process Id. */ @@ -62,7 +57,6 @@ protected: virtual void ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) {} - std::vector mPendingAsyncMessage; }; } // namespace diff --git a/gfx/layers/ipc/FenceUtils.h b/gfx/layers/ipc/FenceUtils.h index d513cc70cf1..82c2498aaf5 100644 --- a/gfx/layers/ipc/FenceUtils.h +++ b/gfx/layers/ipc/FenceUtils.h @@ -26,7 +26,6 @@ struct FenceHandle { explicit FenceHandle(const FenceHandleFromChild& aFenceHandle) {} bool operator==(const FenceHandle&) const { return false; } bool IsValid() const { return false; } - void Merge(const FenceHandle& aFenceHandle) {} }; struct FenceHandleFromChild { diff --git a/gfx/layers/ipc/FenceUtilsGonk.cpp b/gfx/layers/ipc/FenceUtilsGonk.cpp index 728766cdf79..d4d89964024 100644 --- a/gfx/layers/ipc/FenceUtilsGonk.cpp +++ b/gfx/layers/ipc/FenceUtilsGonk.cpp @@ -49,7 +49,6 @@ ParamTraits::Write(Message* aMsg, flattenable->flatten(data, nbytes, fds, nfds); #endif aMsg->WriteSize(nbytes); - aMsg->WriteSize(nfds); aMsg->WriteBytes(data, nbytes); for (size_t n = 0; n < nfds; ++n) { // These buffers can't die in transit because they're created @@ -64,20 +63,14 @@ ParamTraits::Read(const Message* aMsg, void** aIter, paramType* aResult) { size_t nbytes; - size_t nfds; const char* data; if (!aMsg->ReadSize(aIter, &nbytes) || - !aMsg->ReadSize(aIter, &nfds) || !aMsg->ReadBytes(aIter, &data, nbytes)) { return false; } - // Check if nfds is correct. - // aMsg->num_fds() could include fds of another ParamTraits<>s. - if (nfds > aMsg->num_fds()) { - return false; - } + size_t nfds = aMsg->num_fds(); int fds[nfds]; for (size_t n = 0; n < nfds; ++n) { @@ -145,7 +138,6 @@ ParamTraits::Write(Message* aMsg, flattenable->flatten(data, nbytes, fds, nfds); #endif aMsg->WriteSize(nbytes); - aMsg->WriteSize(nfds); aMsg->WriteBytes(data, nbytes); for (size_t n = 0; n < nfds; ++n) { // If the Fence was shared cross-process, SCM_RIGHTS does @@ -169,20 +161,14 @@ ParamTraits::Read(const Message* aMsg, void** aIter, paramType* aResult) { size_t nbytes; - size_t nfds; const char* data; if (!aMsg->ReadSize(aIter, &nbytes) || - !aMsg->ReadSize(aIter, &nfds) || !aMsg->ReadBytes(aIter, &data, nbytes)) { return false; } - // Check if nfds is correct. - // aMsg->num_fds() could include fds of another ParamTraits<>s. - if (nfds > aMsg->num_fds()) { - return false; - } + size_t nfds = aMsg->num_fds(); int fds[nfds]; for (size_t n = 0; n < nfds; ++n) { @@ -225,30 +211,6 @@ FenceHandle::FenceHandle(const FenceHandleFromChild& aFenceHandle) { mFence = aFenceHandle.mFence; } -void -FenceHandle::Merge(const FenceHandle& aFenceHandle) -{ - if (!aFenceHandle.IsValid()) { - return; - } - - if (!IsValid()) { - mFence = aFenceHandle.mFence; - } else { - android::sp mergedFence = android::Fence::merge( - android::String8::format("FenceHandle"), - mFence, aFenceHandle.mFence); - if (!mergedFence.get()) { - // synchronization is broken, the best we can do is hope fences - // signal in order so the new fence will act like a union. - // This error handling is same as android::ConsumerBase does. - mFence = aFenceHandle.mFence; - return; - } - mFence = mergedFence; - } -} - FenceHandleFromChild::FenceHandleFromChild(const sp& aFence) : mFence(aFence) { diff --git a/gfx/layers/ipc/FenceUtilsGonk.h b/gfx/layers/ipc/FenceUtilsGonk.h index 6a82ded6ddc..203904bb538 100644 --- a/gfx/layers/ipc/FenceUtilsGonk.h +++ b/gfx/layers/ipc/FenceUtilsGonk.h @@ -23,9 +23,9 @@ struct FenceHandle { FenceHandle() { } - explicit FenceHandle(const android::sp& aFence); + FenceHandle(const android::sp& aFence); - explicit FenceHandle(const FenceHandleFromChild& aFenceHandle); + FenceHandle(const FenceHandleFromChild& aFenceHandle); bool operator==(const FenceHandle& aOther) const { return mFence.get() == aOther.mFence.get(); @@ -36,8 +36,6 @@ struct FenceHandle { return mFence.get() && mFence->isValid(); } - void Merge(const FenceHandle& aFenceHandle); - android::sp mFence; }; @@ -46,9 +44,9 @@ struct FenceHandleFromChild { FenceHandleFromChild() { } - explicit FenceHandleFromChild(const android::sp& aFence); + FenceHandleFromChild(const android::sp& aFence); - explicit FenceHandleFromChild(const FenceHandle& aFence) { + FenceHandleFromChild(const FenceHandle& aFence) { mFence = aFence.mFence; } diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index 9ce2f3b0804..362988e8841 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -96,25 +96,9 @@ ImageBridgeParent::ActorDestroy(ActorDestroyReason aWhy) NewRunnableMethod(this, &ImageBridgeParent::DeferredDestroy)); } -class MOZ_STACK_CLASS AutoImageBridgeParentAsyncMessageSender -{ -public: - explicit AutoImageBridgeParentAsyncMessageSender(ImageBridgeParent* aImageBridge) - : mImageBridge(aImageBridge) {} - - ~AutoImageBridgeParentAsyncMessageSender() - { - mImageBridge->SendPendingAsyncMessges(); - } -private: - ImageBridgeParent* mImageBridge; -}; - bool ImageBridgeParent::RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply) { - AutoImageBridgeParentAsyncMessageSender autoAsyncMessageSender(this); - // If we don't actually have a compositor, then don't bother // creating any textures. if (Compositor::GetBackend() == LayersBackend::LAYERS_NONE) { @@ -352,7 +336,9 @@ bool ImageBridgeParent::IsSameProcess() const void ImageBridgeParent::ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) { - mPendingAsyncMessage.push_back(aReply); + InfallibleTArray messages; + messages.AppendElement(aReply); + mozilla::unused << SendParentAsyncMessages(messages); } /*static*/ void @@ -366,80 +352,35 @@ ImageBridgeParent::ReplyRemoveTexture(base::ProcessId aChildProcessId, imageBridge->ReplyRemoveTexture(aReply); } -void -ImageBridgeParent::SendFenceHandleIfPresent(PTextureParent* aTexture, - CompositableHost* aCompositableHost) -{ - RefPtr texture = TextureHost::AsTextureHost(aTexture); - if (!texture) { - return; - } - - // Send a ReleaseFence of CompositorOGL. - if (aCompositableHost && aCompositableHost->GetCompositor()) { - FenceHandle fence = aCompositableHost->GetCompositor()->GetReleaseFence(); - if (fence.IsValid()) { - RefPtr tracker = new FenceDeliveryTracker(fence); - HoldUntilComplete(tracker); - mPendingAsyncMessage.push_back(OpDeliverFence(tracker->GetId(), - aTexture, nullptr, - fence)); - } - } - - // Send a ReleaseFence that is set by HwcComposer2D. - FenceHandle fence = texture->GetAndResetReleaseFenceHandle(); - if (fence.IsValid()) { - RefPtr tracker = new FenceDeliveryTracker(fence); - HoldUntilComplete(tracker); - mPendingAsyncMessage.push_back(OpDeliverFence(tracker->GetId(), - aTexture, nullptr, - fence)); - } -} - -void +/*static*/ void ImageBridgeParent::SendFenceHandleToTrackerIfPresent(uint64_t aDestHolderId, uint64_t aTransactionId, - PTextureParent* aTexture, - CompositableHost* aCompositableHost) + PTextureParent* aTexture) { RefPtr texture = TextureHost::AsTextureHost(aTexture); if (!texture) { return; } - - // Send a ReleaseFence of CompositorOGL. - if (aCompositableHost && aCompositableHost->GetCompositor()) { - FenceHandle fence = aCompositableHost->GetCompositor()->GetReleaseFence(); - if (fence.IsValid()) { - RefPtr tracker = new FenceDeliveryTracker(fence); - HoldUntilComplete(tracker); - mPendingAsyncMessage.push_back(OpDeliverFenceToTracker(tracker->GetId(), - aDestHolderId, - aTransactionId, - fence)); - } - } - - // Send a ReleaseFence that is set by HwcComposer2D. FenceHandle fence = texture->GetAndResetReleaseFenceHandle(); - if (fence.IsValid()) { - RefPtr tracker = new FenceDeliveryTracker(fence); - HoldUntilComplete(tracker); - mPendingAsyncMessage.push_back(OpDeliverFenceToTracker(tracker->GetId(), - aDestHolderId, - aTransactionId, - fence)); + if (!fence.IsValid()) { + return; } + + RefPtr tracker = new FenceDeliveryTracker(fence); + HoldUntilComplete(tracker); + InfallibleTArray messages; + messages.AppendElement(OpDeliverFenceToTracker(tracker->GetId(), + aDestHolderId, + aTransactionId, + fence)); + mozilla::unused << SendParentAsyncMessages(messages); } /*static*/ void ImageBridgeParent::SendFenceHandleToTrackerIfPresent(base::ProcessId aChildProcessId, uint64_t aDestHolderId, uint64_t aTransactionId, - PTextureParent* aTexture, - CompositableHost* aCompositableHost) + PTextureParent* aTexture) { ImageBridgeParent* imageBridge = ImageBridgeParent::GetInstance(aChildProcessId); if (!imageBridge) { @@ -447,19 +388,9 @@ ImageBridgeParent::SendFenceHandleToTrackerIfPresent(base::ProcessId aChildProce } imageBridge->SendFenceHandleToTrackerIfPresent(aDestHolderId, aTransactionId, - aTexture, - aCompositableHost); + aTexture); } -/*static*/ void -ImageBridgeParent::SendPendingAsyncMessges(base::ProcessId aChildProcessId) -{ - ImageBridgeParent* imageBridge = ImageBridgeParent::GetInstance(aChildProcessId); - if (!imageBridge) { - return; - } - imageBridge->SendPendingAsyncMessges(); -} } // layers } // mozilla diff --git a/gfx/layers/ipc/ImageBridgeParent.h b/gfx/layers/ipc/ImageBridgeParent.h index e58e304b158..cbf857e575e 100644 --- a/gfx/layers/ipc/ImageBridgeParent.h +++ b/gfx/layers/ipc/ImageBridgeParent.h @@ -56,9 +56,6 @@ public: Create(Transport* aTransport, ProcessId aChildProcessId); // CompositableParentManager - virtual void SendFenceHandleIfPresent(PTextureParent* aTexture, - CompositableHost* aCompositableHost) MOZ_OVERRIDE; - virtual void SendFenceHandle(AsyncTransactionTracker* aTracker, PTextureParent* aTexture, const FenceHandle& aFence) MOZ_OVERRIDE; @@ -125,17 +122,12 @@ public: void SendFenceHandleToTrackerIfPresent(uint64_t aDestHolderId, uint64_t aTransactionId, - PTextureParent* aTexture, - CompositableHost* aCompositableHost); + PTextureParent* aTexture); static void SendFenceHandleToTrackerIfPresent(base::ProcessId aChildProcessId, uint64_t aDestHolderId, uint64_t aTransactionId, - PTextureParent* aTexture, - CompositableHost* aCompositableHost); - - using CompositableParentManager::SendPendingAsyncMessges; - static void SendPendingAsyncMessges(base::ProcessId aChildProcessId); + PTextureParent* aTexture); static ImageBridgeParent* GetInstance(ProcessId aId); diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index 5c9dbcbf532..670928832c8 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -18,7 +18,6 @@ #include "mozilla/layers/ColorLayerComposite.h" #include "mozilla/layers/Compositor.h" // for Compositor #include "mozilla/layers/ContainerLayerComposite.h" -#include "mozilla/layers/ImageBridgeParent.h" // for ImageBridgeParent #include "mozilla/layers/ImageLayerComposite.h" #include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/layers/LayersMessages.h" // for EditReply, etc @@ -193,21 +192,6 @@ LayerTransactionParent::RecvUpdateNoSwap(const InfallibleTArray& cset, aTransactionStart, nullptr); } -class MOZ_STACK_CLASS AutoLayerTransactionParentAsyncMessageSender -{ -public: - explicit AutoLayerTransactionParentAsyncMessageSender(LayerTransactionParent* aLayerTransaction) - : mLayerTransaction(aLayerTransaction) {} - - ~AutoLayerTransactionParentAsyncMessageSender() - { - mLayerTransaction->SendPendingAsyncMessges(); - ImageBridgeParent::SendPendingAsyncMessges(mLayerTransaction->GetChildProcessId()); - } -private: - LayerTransactionParent* mLayerTransaction; -}; - bool LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, const uint64_t& aTransactionId, @@ -239,7 +223,6 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, } EditReplyVector replyv; - AutoLayerTransactionParentAsyncMessageSender autoAsyncMessageSender(this); { AutoResolveRefLayers resolve(mShadowLayersManager->GetCompositionManager(this)); @@ -906,38 +889,6 @@ bool LayerTransactionParent::IsSameProcess() const return OtherProcess() == ipc::kInvalidProcessHandle; } -void -LayerTransactionParent::SendFenceHandleIfPresent(PTextureParent* aTexture, - CompositableHost* aCompositableHost) -{ - RefPtr texture = TextureHost::AsTextureHost(aTexture); - if (!texture) { - return; - } - - // Send a ReleaseFence of CompositorOGL. - if (aCompositableHost && aCompositableHost->GetCompositor()) { - FenceHandle fence = aCompositableHost->GetCompositor()->GetReleaseFence(); - if (fence.IsValid()) { - RefPtr tracker = new FenceDeliveryTracker(fence); - HoldUntilComplete(tracker); - mPendingAsyncMessage.push_back(OpDeliverFence(tracker->GetId(), - aTexture, nullptr, - fence)); - } - } - - // Send a ReleaseFence that is set by HwcComposer2D. - FenceHandle fence = texture->GetAndResetReleaseFenceHandle(); - if (fence.IsValid()) { - RefPtr tracker = new FenceDeliveryTracker(fence); - HoldUntilComplete(tracker); - mPendingAsyncMessage.push_back(OpDeliverFence(tracker->GetId(), - aTexture, nullptr, - fence)); - } -} - void LayerTransactionParent::SendFenceHandle(AsyncTransactionTracker* aTracker, PTextureParent* aTexture, diff --git a/gfx/layers/ipc/LayerTransactionParent.h b/gfx/layers/ipc/LayerTransactionParent.h index 27aa9bb6cba..af4bcf4fce9 100644 --- a/gfx/layers/ipc/LayerTransactionParent.h +++ b/gfx/layers/ipc/LayerTransactionParent.h @@ -86,9 +86,6 @@ public: void SetPendingTransactionId(uint64_t aId) { mPendingTransaction = aId; } // CompositableParentManager - virtual void SendFenceHandleIfPresent(PTextureParent* aTexture, - CompositableHost* aCompositableHost) MOZ_OVERRIDE; - virtual void SendFenceHandle(AsyncTransactionTracker* aTracker, PTextureParent* aTexture, const FenceHandle& aFence) MOZ_OVERRIDE; diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 0cb39b8a5ec..6c4c09b04ee 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -1398,33 +1398,49 @@ CompositorOGL::SetFBAcquireFence(Layer* aLayer) return; } - android::sp fence = new android::Fence(GetGonkDisplay()->GetPrevFBAcquireFd()); - if (fence.get() && fence->isValid()) { - FenceHandle handle = FenceHandle(fence); - mReleaseFenceHandle.Merge(handle); + const nsIntRegion& visibleRegion = aLayer->GetEffectiveVisibleRegion(); + if (visibleRegion.IsEmpty()) { + return; } -} -FenceHandle -CompositorOGL::GetReleaseFence() -{ - if (!mReleaseFenceHandle.IsValid()) { - return FenceHandle(); + // Set FBAcquireFence on ContainerLayer's childs + ContainerLayer* container = aLayer->AsContainerLayer(); + if (container) { + for (Layer* child = container->GetFirstChild(); child; child = child->GetNextSibling()) { + SetFBAcquireFence(child); + } + return; } - return FenceHandle(new android::Fence(mReleaseFenceHandle.mFence->dup())); -} + // Set FBAcquireFence as tiles' ReleaseFence on TiledLayerComposer. + TiledLayerComposer* composer = nullptr; + LayerComposite* shadow = aLayer->AsLayerComposite(); + // Only ask for the composer if we have a compositable host. Timing + // may make it so that we don't - see bug 1000634. + if (shadow && shadow->GetCompositableHost()) { + composer = shadow->GetTiledLayerComposer(); + if (composer) { + composer->SetReleaseFence(new android::Fence(GetGonkDisplay()->GetPrevFBAcquireFd())); + return; + } + } + + // Set FBAcquireFence as layer buffer's ReleaseFence + LayerRenderState state = aLayer->GetRenderState(); + if (!state.mTexture) { + return; + } + TextureHostOGL* texture = state.mTexture->AsHostOGL(); + if (!texture) { + return; + } + texture->SetReleaseFence(new android::Fence(GetGonkDisplay()->GetPrevFBAcquireFd())); +} #else void CompositorOGL::SetFBAcquireFence(Layer* aLayer) { } - -FenceHandle -CompositorOGL::GetReleaseFence() -{ - return FenceHandle(); -} #endif void diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index 96975e0b255..0bf1fc29ae8 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -209,7 +209,6 @@ public: virtual void EndFrame() MOZ_OVERRIDE; virtual void SetFBAcquireFence(Layer* aLayer) MOZ_OVERRIDE; - virtual FenceHandle GetReleaseFence() MOZ_OVERRIDE; virtual void EndFrameForExternalComposition(const gfx::Matrix& aTransform) MOZ_OVERRIDE; virtual void AbortFrame() MOZ_OVERRIDE; @@ -394,8 +393,6 @@ private: * FlipY for the y-flipping calculation. */ GLint mHeight; - - FenceHandle mReleaseFenceHandle; }; }