Bug 1119019 - Avoid destroying a SharedSurface before its TextureClient/Host pair. r=sotaro

This commit is contained in:
Nicolas Silva 2015-01-23 15:35:16 +01:00
Родитель 5600f01996
Коммит 0b465c61eb
4 изменённых файлов: 29 добавлений и 7 удалений

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

@ -403,5 +403,20 @@ CanvasClientSharedSurface::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
forwarder->UseTexture(this, mFrontTex);
}
void
CanvasClientSharedSurface::ClearSurfaces()
{
if (mFrontTex && (mFront || mPrevFront)) {
// Force a synchronous destruction so that the TextureHost does not
// outlive the SharedSurface. This won't be needed once TextureClient/Host
// and SharedSurface are merged.
mFrontTex->ForceRemove(true /* sync */);
mFrontTex = nullptr;
}
// It is important to destroy the SharedSurface *after* the TextureClient.
mFront = nullptr;
mPrevFront = nullptr;
}
}
}

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

@ -119,25 +119,30 @@ private:
RefPtr<TextureClient> mFrontTex;
void ClearSurfaces();
public:
CanvasClientSharedSurface(CompositableForwarder* aLayerForwarder,
TextureFlags aFlags);
~CanvasClientSharedSurface()
{
ClearSurfaces();
}
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE {
return TextureInfo(CompositableType::IMAGE);
}
virtual void Clear() MOZ_OVERRIDE {
mFront = nullptr;
mPrevFront = nullptr;
mFrontTex = nullptr;
ClearSurfaces();
}
virtual void Update(gfx::IntSize aSize,
ClientCanvasLayer* aLayer) MOZ_OVERRIDE;
virtual void OnDetach() MOZ_OVERRIDE {
CanvasClientSharedSurface::Clear();
ClearSurfaces();
}
};

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

@ -503,10 +503,10 @@ TextureClient::KeepUntilFullDeallocation(KeepAlive* aKeep)
mActor->mKeep = aKeep;
}
void TextureClient::ForceRemove()
void TextureClient::ForceRemove(bool sync)
{
if (mValid && mActor) {
if (GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
if (sync || GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
MOZ_PERFORMANCE_WARNING("gfx", "TextureClient/Host pair requires synchronous deallocation");
if (mActor->IPCOpen()) {
mActor->SendClearTextureHostSync();

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

@ -426,8 +426,10 @@ public:
* If the texture flags contain TextureFlags::DEALLOCATE_CLIENT, the destruction
* will be synchronously coordinated with the compositor side, otherwise it
* will be done asynchronously.
* If sync is true, the destruction will be synchronous regardless of the
* texture's flags (bad for performance, use with care).
*/
void ForceRemove();
void ForceRemove(bool sync = false);
virtual void SetReleaseFenceHandle(FenceHandle aReleaseFenceHandle)
{