mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 05:45:37 +00:00
Bug 897452 - Part 0.1 - Make it possible for TextureClient to call virtual methods just before its destructor. r=bjacob
This commit is contained in:
parent
1c93aa8df9
commit
85c56fc061
@ -111,7 +111,8 @@ ShmemTextureClient::DropTextureData()
|
||||
}
|
||||
|
||||
TextureClient::TextureClient(TextureFlags aFlags)
|
||||
: mID(0)
|
||||
: mRefCount(0)
|
||||
, mID(0)
|
||||
, mFlags(aFlags)
|
||||
, mShared(false)
|
||||
, mValid(true)
|
||||
|
@ -149,12 +149,28 @@ public:
|
||||
* In order to send several different buffers to the compositor side, use
|
||||
* several TextureClients.
|
||||
*/
|
||||
class TextureClient : public AtomicRefCounted<TextureClient>
|
||||
class TextureClient
|
||||
{
|
||||
public:
|
||||
TextureClient(TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
|
||||
virtual ~TextureClient();
|
||||
|
||||
void AddRef() {
|
||||
MOZ_ASSERT(mRefCount >= 0);
|
||||
++mRefCount;
|
||||
}
|
||||
|
||||
void Release() {
|
||||
MOZ_ASSERT(mRefCount > 0);
|
||||
if (0 == --mRefCount) {
|
||||
#ifdef DEBUG
|
||||
mRefCount = detail::DEAD;
|
||||
#endif
|
||||
Finalize();
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
virtual TextureClientSurface* AsTextureClientSurface() { return nullptr; }
|
||||
virtual TextureClientDrawTarget* AsTextureClientDrawTarget() { return nullptr; }
|
||||
virtual TextureClientYCbCr* AsTextureClientYCbCr() { return nullptr; }
|
||||
@ -253,6 +269,20 @@ public:
|
||||
// method to forget about the shmem _without_ releasing it.
|
||||
virtual void OnActorDestroy() {}
|
||||
|
||||
private:
|
||||
Atomic<int> mRefCount;
|
||||
|
||||
/**
|
||||
* Called once, just before the destructor.
|
||||
*
|
||||
* Here goes the shut-down code that uses virtual methods.
|
||||
* Must only be called by Release().
|
||||
*/
|
||||
void Finalize()
|
||||
{
|
||||
// XXX Bug 897452 - Coming soon
|
||||
}
|
||||
|
||||
protected:
|
||||
void AddFlags(TextureFlags aFlags)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user