diff --git a/gfx/layers/composite/CompositableHost.cpp b/gfx/layers/composite/CompositableHost.cpp index fcae53e15f06..8fea18267f38 100644 --- a/gfx/layers/composite/CompositableHost.cpp +++ b/gfx/layers/composite/CompositableHost.cpp @@ -59,20 +59,19 @@ CompositableHost::AddTextureHost(TextureHost* aTexture) } void -CompositableHost::RemoveTextureHost(uint64_t aTextureID) +CompositableHost::RemoveTextureHost(TextureHost* aTexture) { - if (mFirstTexture && mFirstTexture->GetID() == aTextureID) { - RefPtr toRemove = mFirstTexture; + uint64_t textureID = aTexture->GetID(); + if (mFirstTexture && mFirstTexture->GetID() == textureID) { mFirstTexture = mFirstTexture->GetNextSibling(); - toRemove->SetNextSibling(nullptr); + aTexture->SetNextSibling(nullptr); } RefPtr it = mFirstTexture; while (it) { if (it->GetNextSibling() && - it->GetNextSibling()->GetID() == aTextureID) { - RefPtr toRemove = it->GetNextSibling(); + it->GetNextSibling()->GetID() == textureID) { it->SetNextSibling(it->GetNextSibling()->GetNextSibling()); - toRemove->SetNextSibling(nullptr); + aTexture->SetNextSibling(nullptr); } it = it->GetNextSibling(); } diff --git a/gfx/layers/composite/CompositableHost.h b/gfx/layers/composite/CompositableHost.h index 391abdf591b0..aabe36f6d96e 100644 --- a/gfx/layers/composite/CompositableHost.h +++ b/gfx/layers/composite/CompositableHost.h @@ -296,18 +296,13 @@ public: void AddTextureHost(TextureHost* aTexture); virtual void UseTextureHost(TextureHost* aTexture) {} - virtual void RemoveTextureHost(uint64_t aTextureID); // If a texture host is flagged for deferred removal, the compositable will // get an option to run any cleanup code early, that is when it would have - // been run if the texture host was not marked deferred. That is, this method - // is called _before_ RemoveTextureHost for deferred removal texture hosts. + // been run if the texture host was not marked deferred. // If the compositable does not cleanup the texture host now, it is the // compositable's responsibility to cleanup the texture host before the // texture host dies. - virtual void RemoveTextureHostDeferred(TextureHost* aTexture) - { - MOZ_CRASH("Compositable was not expecting to handle deferred removal of texture hosts"); - } + virtual void RemoveTextureHost(TextureHost* aTexture); TextureHost* GetTextureHost(uint64_t aTextureID); protected: diff --git a/gfx/layers/composite/ContentHost.cpp b/gfx/layers/composite/ContentHost.cpp index 8cd6904338bb..2b763b58edf2 100644 --- a/gfx/layers/composite/ContentHost.cpp +++ b/gfx/layers/composite/ContentHost.cpp @@ -48,7 +48,7 @@ ContentHostBaseNew::DestroyTextureHost() // The third clause in the if statement checks that we are in fact done with // this texture. We don't want to prematurely deallocate a texture we might // use again or double deallocate. Deallocation will happen in - // RemoveTextureHostDeferred. + // RemoveTextureHost. // Note that GetTextureHost is linear in the number of texture hosts, but as // long as that number is small (I expect a maximum of 6 for now) then it // should be ok. @@ -74,13 +74,16 @@ ContentHostBaseNew::DestroyTextureHostOnWhite() } void -ContentHostBaseNew::RemoveTextureHostDeferred(TextureHost* aTexture) +ContentHostBaseNew::RemoveTextureHost(TextureHost* aTexture) { - if (!(mTextureHost && mTextureHost == aTexture) && + if ((aTexture->GetFlags() & TEXTURE_DEALLOCATE_DEFERRED) && + !(mTextureHost && mTextureHost == aTexture) && !(mTextureHostOnWhite && mTextureHostOnWhite == aTexture)) { - MOZ_ASSERT(aTexture->GetFlags() & TEXTURE_DEALLOCATE_DEFERRED); + MOZ_ASSERT(!(aTexture->GetFlags() & TEXTURE_DEALLOCATE_CLIENT)); aTexture->DeallocateSharedData(); } + + CompositableHost::RemoveTextureHost(aTexture); } class MOZ_STACK_CLASS AutoLockTextureHost diff --git a/gfx/layers/composite/ImageHost.cpp b/gfx/layers/composite/ImageHost.cpp index 4b485b61bac5..f4a70314c7cb 100644 --- a/gfx/layers/composite/ImageHost.cpp +++ b/gfx/layers/composite/ImageHost.cpp @@ -42,10 +42,10 @@ ImageHost::UseTextureHost(TextureHost* aTexture) } void -ImageHost::RemoveTextureHost(uint64_t aTextureID) +ImageHost::RemoveTextureHost(TextureHost* aTexture) { - CompositableHost::RemoveTextureHost(aTextureID); - if (mFrontBuffer && mFrontBuffer->GetID() == aTextureID) { + CompositableHost::RemoveTextureHost(aTexture); + if (mFrontBuffer && mFrontBuffer->GetID() == aTexture->GetID()) { mFrontBuffer = nullptr; } } diff --git a/gfx/layers/composite/ImageHost.h b/gfx/layers/composite/ImageHost.h index 00014c013175..52ddbf5e7665 100644 --- a/gfx/layers/composite/ImageHost.h +++ b/gfx/layers/composite/ImageHost.h @@ -55,7 +55,7 @@ public: virtual void UseTextureHost(TextureHost* aTexture) MOZ_OVERRIDE; - virtual void RemoveTextureHost(uint64_t aTextureID) MOZ_OVERRIDE; + virtual void RemoveTextureHost(TextureHost* aTexture) MOZ_OVERRIDE; virtual TextureHost* GetAsTextureHost() MOZ_OVERRIDE; diff --git a/gfx/layers/ipc/CompositableTransactionParent.cpp b/gfx/layers/ipc/CompositableTransactionParent.cpp index 0f33946d6e3f..599d8c1fbfc9 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.cpp +++ b/gfx/layers/ipc/CompositableTransactionParent.cpp @@ -271,15 +271,12 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation TextureFlags flags = texture->GetFlags(); - if (flags & TEXTURE_DEALLOCATE_DEFERRED) { - MOZ_ASSERT(!(flags & TEXTURE_DEALLOCATE_CLIENT), - "textures should not be marked for deferred removal and client-side removal"); - compositable->RemoveTextureHostDeferred(texture); - } else if (!(flags & TEXTURE_DEALLOCATE_CLIENT)) { + if (!(flags & TEXTURE_DEALLOCATE_CLIENT) && + !(flags & TEXTURE_DEALLOCATE_DEFERRED)) { texture->DeallocateSharedData(); } - compositable->RemoveTextureHost(op.textureID()); + compositable->RemoveTextureHost(texture); // if it is not the host that deallocates the shared data, then we need // to notfy the client side to tell when it is safe to deallocate or