Bug 913821 - Conservatively ensure that TextureClients/Hosts are removed at the end of a video. r=sotaro

This commit is contained in:
Nicolas Silva 2013-09-12 16:50:35 +02:00
parent 86d7c1b1ec
commit be66706698
7 changed files with 45 additions and 1 deletions

View File

@ -32,9 +32,26 @@ CompositableClient::~CompositableClient()
{
MOZ_COUNT_DTOR(CompositableClient);
Destroy();
FlushTexturesToRemoveCallbacks();
MOZ_ASSERT(mTexturesToRemove.Length() == 0, "would leak textures pending for deletion");
}
void
CompositableClient::FlushTexturesToRemoveCallbacks()
{
std::map<uint64_t,TextureClientData*>::iterator it
= mTexturesToRemoveCallbacks.begin();
std::map<uint64_t,TextureClientData*>::iterator stop
= mTexturesToRemoveCallbacks.end();
for (; it != stop; ++it) {
it->second->DeallocateSharedData(GetForwarder());
delete it->second;
}
mTexturesToRemoveCallbacks.clear();
}
LayersBackend
CompositableClient::GetCompositorBackendType() const
{

View File

@ -141,6 +141,7 @@ public:
void OnReplyTextureRemoved(uint64_t aTextureID);
void FlushTexturesToRemoveCallbacks();
protected:
struct TextureIDAndFlags {
TextureIDAndFlags(uint64_t aID, TextureFlags aFlags)

View File

@ -261,7 +261,7 @@ public:
void AddTextureHost(TextureHost* aTexture);
virtual void UseTextureHost(TextureHost* aTexture) {}
void RemoveTextureHost(uint64_t aTextureID);
virtual void RemoveTextureHost(uint64_t aTextureID);
TextureHost* GetTextureHost(uint64_t aTextureID);
protected:

View File

@ -42,6 +42,15 @@ ImageHost::UseTextureHost(TextureHost* aTexture)
mFrontBuffer = aTexture;
}
void
ImageHost::RemoveTextureHost(uint64_t aTextureID)
{
CompositableHost::RemoveTextureHost(aTextureID);
if (mFrontBuffer && mFrontBuffer->GetID() == aTextureID) {
mFrontBuffer = nullptr;
}
}
TextureHost*
ImageHost::GetTextureHost()
{

View File

@ -57,6 +57,8 @@ public:
virtual void UseTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
virtual void RemoveTextureHost(uint64_t aTextureID) MOZ_OVERRIDE;
virtual TextureHost* GetTextureHost() MOZ_OVERRIDE;
virtual void SetPictureRect(const nsIntRect& aPictureRect) MOZ_OVERRIDE

View File

@ -444,6 +444,7 @@ void ImageBridgeChild::FlushImageNow(ImageClient* aClient, ImageContainer* aCont
aClient->FlushImage();
aClient->OnTransaction();
sImageBridgeChildSingleton->EndTransaction();
aClient->FlushTexturesToRemoveCallbacks();
}
void

View File

@ -111,6 +111,20 @@ GrallocTextureClientOGL::GrallocTextureClientOGL(CompositableClient* aCompositab
GrallocTextureClientOGL::~GrallocTextureClientOGL()
{
MOZ_COUNT_DTOR(GrallocTextureClientOGL);
if (ShouldDeallocateInDestructor()) {
// If the buffer has never been shared we must deallocate it or it would
// leak.
if (mBufferLocked) {
mBufferLocked->Unlock();
} else {
MOZ_ASSERT(mCompositable);
// We just need to wrap the actor in a SurfaceDescriptor because that's what
// ISurfaceAllocator uses as input, we don't care about the other parameters.
SurfaceDescriptor sd = SurfaceDescriptorGralloc(nullptr, mGrallocActor,
nsIntSize(0,0), false, false);
mCompositable->GetForwarder()->DestroySharedSurface(&sd);
}
}
}
void