Bug 1128170 - Use UniquePtr for TextureClient KeepAlive objects to make sure we don't leak them. r=jrmuizel

This commit is contained in:
Matt Woodrow 2015-02-18 13:35:30 +13:00
Родитель 5cc04bad46
Коммит 5ea802bd9a
5 изменённых файлов: 11 добавлений и 10 удалений

Просмотреть файл

@ -86,7 +86,6 @@ public:
TextureChild()
: mForwarder(nullptr)
, mTextureClient(nullptr)
, mKeep(nullptr)
, mIPCOpen(false)
{
}
@ -135,7 +134,7 @@ private:
RefPtr<CompositableForwarder> mForwarder;
RefPtr<TextureClient> mWaitForRecycle;
TextureClient* mTextureClient;
KeepAlive* mKeep;
UniquePtr<KeepAlive> mKeep;
bool mIPCOpen;
friend class TextureClient;
@ -154,7 +153,7 @@ TextureChild::ActorDestroy(ActorDestroyReason why)
mTextureClient->mActor = nullptr;
}
mWaitForRecycle = nullptr;
delete mKeep;
mKeep = nullptr;
}
// static
@ -496,11 +495,11 @@ TextureClient::~TextureClient()
}
void
TextureClient::KeepUntilFullDeallocation(KeepAlive* aKeep)
TextureClient::KeepUntilFullDeallocation(UniquePtr<KeepAlive> aKeep)
{
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mActor->mKeep);
mActor->mKeep = aKeep;
mActor->mKeep = Move(aKeep);
}
void TextureClient::ForceRemove(bool sync)

Просмотреть файл

@ -403,7 +403,7 @@ public:
* It's a temporary hack to ensure that DXGI textures don't get destroyed
* between serialization and deserialization.
*/
void KeepUntilFullDeallocation(KeepAlive* aKeep);
void KeepUntilFullDeallocation(UniquePtr<KeepAlive> aKeep);
/**
* Create and init the TextureChild/Parent IPDL actor pair.

Просмотреть файл

@ -179,9 +179,9 @@ TextureClientD3D11::~TextureClientD3D11()
{
if (mActor) {
if (mTexture) {
KeepUntilFullDeallocation(new TKeepAlive<ID3D10Texture2D>(mTexture10));
KeepUntilFullDeallocation(MakeUnique<TKeepAlive<ID3D10Texture2D>>(mTexture10));
} else if (mTexture10) {
KeepUntilFullDeallocation(new TKeepAlive<ID3D11Texture2D>(mTexture));
KeepUntilFullDeallocation(MakeUnique<TKeepAlive<ID3D11Texture2D>>(mTexture));
}
}
#ifdef DEBUG

Просмотреть файл

@ -739,7 +739,7 @@ SharedTextureClientD3D9::SharedTextureClientD3D9(ISurfaceAllocator* aAllocator,
SharedTextureClientD3D9::~SharedTextureClientD3D9()
{
if (mTexture && mActor) {
KeepUntilFullDeallocation(new TKeepAlive<IDirect3DTexture9>(mTexture));
KeepUntilFullDeallocation(MakeUnique<TKeepAlive<IDirect3DTexture9>>(mTexture));
}
if (mTexture) {
gfxWindowsPlatform::sD3D9SharedTextureUsed -= mDesc.Width * mDesc.Height * 4;

Просмотреть файл

@ -266,7 +266,9 @@ public:
mTexture = aTexture;
mHandle = aSharedHandle;
mDesc = aDesc;
gfxWindowsPlatform::sD3D9SharedTextureUsed += mDesc.Width * mDesc.Height * 4;
if (mTexture) {
gfxWindowsPlatform::sD3D9SharedTextureUsed += mDesc.Width * mDesc.Height * 4;
}
}
virtual gfx::IntSize GetSize() const