From c590710a235ffbe2871b5c46605add3d07ca7ce7 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 11 Dec 2013 20:44:55 -0500 Subject: [PATCH] Bug 897452 - Part 7 - Implement TextureChild::ActorDestroy to notify its TextureClient - r=nical --- gfx/layers/client/TextureClient.cpp | 19 +++++++++++++++++++ gfx/layers/client/TextureClient.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index d531c245778a..b4d93406f667 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -56,6 +56,7 @@ public: TextureChild() : mForwarder(nullptr) , mTextureData(nullptr) + , mTextureClient(nullptr) { MOZ_COUNT_CTOR(TextureChild); } @@ -83,9 +84,15 @@ public: ISurfaceAllocator* GetAllocator() { return mForwarder; } + void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; + +private: + CompositableForwarder* mForwarder; TextureClientData* mTextureData; + TextureClient* mTextureClient; + friend class TextureClient; }; void @@ -105,6 +112,14 @@ TextureChild::Recv__delete__() return true; } +void +TextureChild::ActorDestroy(ActorDestroyReason why) +{ + if (mTextureClient) { + mTextureClient->mActor = nullptr; + } +} + // static PTextureChild* TextureClient::CreateIPDLActor() @@ -133,6 +148,7 @@ TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) mActor = static_cast(aForwarder->CreateEmptyTextureChild()); mActor->mForwarder = aForwarder; + mActor->mTextureClient = this; mShared = true; return mActor->SendInit(desc, GetFlags()); } @@ -250,6 +266,9 @@ TextureClient::Finalize() if (mActor) { // this will call ForceRemove in the right thread, using a sync proxy if needed mActor->GetForwarder()->RemoveTexture(this); + + // mActor has a raw pointer to us, mActor->mTextureClient. Null it before we die. + mActor->mTextureClient = nullptr; } } diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index eb8be948d6ff..0390e5697aa8 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -299,6 +299,8 @@ protected: TextureFlags mFlags; bool mShared; bool mValid; + + friend class TextureChild; }; /**