From 18b7c7e2dc19c6a5422c017529fee2839e3ab0a1 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Thu, 25 Feb 2016 09:23:23 +0100 Subject: [PATCH] Bug 1250117 - Fix b2g timeouts when gralloc is disabled. r=sotaro --- gfx/layers/client/CompositableClient.cpp | 15 +------- gfx/layers/client/ContentClient.cpp | 22 ++---------- gfx/layers/client/TextureClient.cpp | 24 +++++++++++++ gfx/layers/client/TextureClient.h | 6 ++++ gfx/layers/client/TiledContentClient.cpp | 44 +++++++----------------- gfx/layers/opengl/GrallocTextureClient.h | 2 ++ 6 files changed, 48 insertions(+), 65 deletions(-) diff --git a/gfx/layers/client/CompositableClient.cpp b/gfx/layers/client/CompositableClient.cpp index 790e4f67e038..0d0b0a3c92d2 100644 --- a/gfx/layers/client/CompositableClient.cpp +++ b/gfx/layers/client/CompositableClient.cpp @@ -290,23 +290,10 @@ CompositableClient::DumpTextureClient(std::stringstream& aStream, AutoRemoveTexture::~AutoRemoveTexture() { -#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 if (mCompositable && mTexture && mCompositable->IsConnected()) { - // remove old buffer from CompositableHost - RefPtr waiter = new AsyncTransactionWaiter(); - RefPtr tracker = - new RemoveTextureFromCompositableTracker(waiter); - // Hold TextureClient until transaction complete. - tracker->SetTextureClient(mTexture); - mTexture->SetRemoveFromCompositableWaiter(waiter); - // RemoveTextureFromCompositableAsync() expects CompositorChild's presence. - mCompositable->GetForwarder()->RemoveTextureFromCompositableAsync(tracker, mCompositable, mTexture); - } -#else - if (mCompositable && mTexture) { + mTexture->RemoveFromCompositable(mCompositable); mCompositable->RemoveTexture(mTexture); } -#endif } } // namespace layers diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 950c480793eb..838eb0647146 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -448,31 +448,13 @@ ContentClientDoubleBuffered::Updated(const nsIntRegion& aRegionToDraw, { ContentClientRemoteBuffer::Updated(aRegionToDraw, aVisibleRegion, aDidSelfCopy); -#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 if (mFrontClient) { - // remove old buffer from CompositableHost - RefPtr waiter = new AsyncTransactionWaiter(); - RefPtr tracker = - new RemoveTextureFromCompositableTracker(waiter); - // Hold TextureClient until transaction complete. - tracker->SetTextureClient(mFrontClient); - mFrontClient->SetRemoveFromCompositableWaiter(waiter); - // RemoveTextureFromCompositableAsync() expects CompositorChild's presence. - GetForwarder()->RemoveTextureFromCompositableAsync(tracker, this, mFrontClient); + mFrontClient->RemoveFromCompositable(this); } if (mFrontClientOnWhite) { - // remove old buffer from CompositableHost - RefPtr waiter = new AsyncTransactionWaiter(); - RefPtr tracker = - new RemoveTextureFromCompositableTracker(waiter); - // Hold TextureClient until transaction complete. - tracker->SetTextureClient(mFrontClientOnWhite); - mFrontClientOnWhite->SetRemoveFromCompositableWaiter(waiter); - // RemoveTextureFromCompositableAsync() expects CompositorChild's presence. - GetForwarder()->RemoveTextureFromCompositableAsync(tracker, this, mFrontClientOnWhite); + mFrontClientOnWhite->RemoveFromCompositable(this); } -#endif } void diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index b9df7574f9f6..f3a45ec28df7 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -951,6 +951,30 @@ bool TextureClient::CopyToTextureClient(TextureClient* aTarget, return true; } +void +TextureClient::RemoveFromCompositable(CompositableClient* aCompositable, + AsyncTransactionWaiter* aWaiter) +{ + MOZ_ASSERT(aCompositable); + +#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 + if (GetIPDLActor() && aCompositable->GetIPDLActor() + && mData->AsGrallocTextureData()) { + // remove old buffer from CompositableHost + RefPtr waiter = waiter ? waiter + : new AsyncTransactionWaiter(); + RefPtr tracker = + new RemoveTextureFromCompositableTracker(waiter); + // Hold TextureClient until transaction complete. + tracker->SetTextureClient(this); + mRemoveFromCompositableWaiter = waiter; + // RemoveTextureFromCompositableAsync() expects CompositorChild's presence. + GetForwarder()->RemoveTextureFromCompositableAsync(tracker, aCompositable, this); + } +#endif + +} + void TextureClient::SetRemoveFromCompositableWaiter(AsyncTransactionWaiter* aWaiter) { mRemoveFromCompositableWaiter = aWaiter; diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index 740d2e3b06aa..365d0a55b06e 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -47,6 +47,7 @@ namespace layers { class AsyncTransactionWaiter; class CompositableForwarder; +class GrallocTextureData; class ISurfaceAllocator; class CompositableClient; struct PlanarYCbCrData; @@ -231,6 +232,8 @@ public: return nullptr; } #endif + + virtual GrallocTextureData* AsGrallocTextureData() { return nullptr; } }; /** @@ -577,6 +580,9 @@ public: TextureData* GetInternalData() { return mData; } const TextureData* GetInternalData() const { return mData; } + virtual void RemoveFromCompositable(CompositableClient* aCompositable, + AsyncTransactionWaiter* aWaiter = nullptr); + private: static void TextureClientRecycleCallback(TextureClient* aClient, void* aClosure); diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index ba4b0fc1e509..9b8c096a87cb 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -569,22 +569,15 @@ TileClient::Dump(std::stringstream& aStream) void TileClient::Flip() { -#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 - if (mFrontBuffer && mFrontBuffer->GetIPDLActor() && - mCompositableClient && mCompositableClient->GetIPDLActor()) { - // remove old buffer from CompositableHost - RefPtr waiter = new AsyncTransactionWaiter(); - RefPtr tracker = - new RemoveTextureFromCompositableTracker(waiter); - // Hold TextureClient until transaction complete. - tracker->SetTextureClient(mFrontBuffer); - mFrontBuffer->SetRemoveFromCompositableWaiter(waiter); - // RemoveTextureFromCompositableAsync() expects CompositorChild's presence. - mManager->AsShadowForwarder()->RemoveTextureFromCompositableAsync(tracker, - mCompositableClient, - mFrontBuffer); + if (mCompositableClient) { + if (mFrontBuffer) { + mFrontBuffer->RemoveFromCompositable(mCompositableClient); + } + if (mFrontBufferOnWhite) { + mFrontBufferOnWhite->RemoveFromCompositable(mCompositableClient); + } } -#endif + RefPtr frontBuffer = mFrontBuffer; RefPtr frontBufferOnWhite = mFrontBufferOnWhite; mFrontBuffer = mBackBuffer; @@ -667,25 +660,14 @@ TileClient::DiscardFrontBuffer() { if (mFrontBuffer) { MOZ_ASSERT(mFrontLock); -#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 - MOZ_ASSERT(!mFrontBufferOnWhite); - if (mFrontBuffer->GetIPDLActor() && - mCompositableClient && mCompositableClient->GetIPDLActor()) { - // remove old buffer from CompositableHost - RefPtr waiter = new AsyncTransactionWaiter(); - RefPtr tracker = - new RemoveTextureFromCompositableTracker(waiter); - // Hold TextureClient until transaction complete. - tracker->SetTextureClient(mFrontBuffer); - mFrontBuffer->SetRemoveFromCompositableWaiter(waiter); - // RemoveTextureFromCompositableAsync() expects CompositorChild's presence. - mManager->AsShadowForwarder()->RemoveTextureFromCompositableAsync(tracker, - mCompositableClient, - mFrontBuffer); + + if (mCompositableClient) { + mFrontBuffer->RemoveFromCompositable(mCompositableClient); } -#endif + mAllocator->ReturnTextureClientDeferred(mFrontBuffer); if (mFrontBufferOnWhite) { + mFrontBufferOnWhite->RemoveFromCompositable(mCompositableClient); mAllocator->ReturnTextureClientDeferred(mFrontBufferOnWhite); } mFrontLock->ReadUnlock(); diff --git a/gfx/layers/opengl/GrallocTextureClient.h b/gfx/layers/opengl/GrallocTextureClient.h index 13259159eda8..5d409f404f9c 100644 --- a/gfx/layers/opengl/GrallocTextureClient.h +++ b/gfx/layers/opengl/GrallocTextureClient.h @@ -109,6 +109,8 @@ public: virtual TextureFlags GetTextureFlags() const override; + virtual GrallocTextureData* AsGrallocTextureData() { return this; } + protected: GrallocTextureData(MaybeMagicGrallocBufferHandle aGrallocHandle, gfx::IntSize aSize, gfx::SurfaceFormat aFormat,