Bug 1146315 - Part 2: Release D3D11 YUV textures on the main thread. r=nical

--HG--
extra : rebase_source : 6d8d17dd02bb63a8ea0adcd94de891aad369d6dc
This commit is contained in:
Matt Woodrow 2015-03-26 13:05:25 +13:00
parent a5a35423f7
commit 439798a572
3 changed files with 25 additions and 4 deletions

View File

@ -66,6 +66,17 @@ using namespace mozilla::ipc;
using namespace mozilla::gl;
using namespace mozilla::gfx;
struct ReleaseKeepAlive : public nsRunnable
{
NS_IMETHOD Run()
{
mKeep = nullptr;
return NS_OK;
}
UniquePtr<KeepAlive> mKeep;
};
/**
* TextureChild is the content-side incarnation of the PTexture IPDL actor.
*
@ -79,13 +90,21 @@ using namespace mozilla::gfx;
*/
class TextureChild final : public PTextureChild
{
~TextureChild() {}
~TextureChild()
{
if (mKeep && mMainThreadOnly && !NS_IsMainThread()) {
nsRefPtr<ReleaseKeepAlive> release = new ReleaseKeepAlive();
release->mKeep = Move(mKeep);
NS_DispatchToMainThread(release);
}
}
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TextureChild)
TextureChild()
: mForwarder(nullptr)
, mTextureClient(nullptr)
, mMainThreadOnly(false)
, mIPCOpen(false)
{
}
@ -135,6 +154,7 @@ private:
RefPtr<TextureClient> mWaitForRecycle;
TextureClient* mTextureClient;
UniquePtr<KeepAlive> mKeep;
bool mMainThreadOnly;
bool mIPCOpen;
friend class TextureClient;
@ -495,11 +515,12 @@ TextureClient::~TextureClient()
}
void
TextureClient::KeepUntilFullDeallocation(UniquePtr<KeepAlive> aKeep)
TextureClient::KeepUntilFullDeallocation(UniquePtr<KeepAlive> aKeep, bool aMainThreadOnly)
{
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mActor->mKeep);
mActor->mKeep = Move(aKeep);
mActor->mMainThreadOnly = aMainThreadOnly;
}
void TextureClient::ForceRemove(bool sync)

View File

@ -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(UniquePtr<KeepAlive> aKeep);
void KeepUntilFullDeallocation(UniquePtr<KeepAlive> aKeep, bool aMainThreadOnly = false);
/**
* Create and init the TextureChild/Parent IPDL actor pair.

View File

@ -529,7 +529,7 @@ protected:
DXGIYCbCrTextureClient::~DXGIYCbCrTextureClient()
{
if (mHoldRefs[0] && mActor) {
KeepUntilFullDeallocation(MakeUnique<YCbCrKeepAliveD3D11>(mHoldRefs));
KeepUntilFullDeallocation(MakeUnique<YCbCrKeepAliveD3D11>(mHoldRefs), true);
}
MOZ_COUNT_DTOR(DXGIYCbCrTextureClient);
}