Bug 1208071 - Ensure that only valid texture actors are added to ImageBridge tarnsactions. r=sotaro

This commit is contained in:
Nicolas Silva 2015-09-30 18:17:30 +02:00
parent 61055aaa87
commit 7ee195c608
3 changed files with 23 additions and 2 deletions

View File

@ -198,6 +198,11 @@ TextureClient::AsTextureClient(PTextureChild* actor)
return actor ? static_cast<TextureChild*>(actor)->mTextureClient : nullptr;
}
bool
TextureClient::IsSharedWithCompositor() const {
return mShared && mActor && mActor->IPCOpen();
}
void
TextureClient::AddFlags(TextureFlags aFlags)
{
@ -639,7 +644,7 @@ TextureClient::ShouldDeallocateInDestructor() const
// but we haven't been shared yet or
// TextureFlags::DEALLOCATE_CLIENT is set, then we should
// deallocate on the client instead.
return !IsSharedWithCompositor() || (GetFlags() & TextureFlags::DEALLOCATE_CLIENT);
return !mShared || (GetFlags() & TextureFlags::DEALLOCATE_CLIENT);
}
void

View File

@ -382,7 +382,7 @@ public:
void MarkImmutable() { AddFlags(TextureFlags::IMMUTABLE); }
bool IsSharedWithCompositor() const { return mShared; }
bool IsSharedWithCompositor() const;
bool ShouldDeallocateInDestructor() const;

View File

@ -119,6 +119,11 @@ ImageBridgeChild::UseTextures(CompositableClient* aCompositable,
for (auto& t : aTextures) {
MOZ_ASSERT(t.mTextureClient);
MOZ_ASSERT(t.mTextureClient->GetIPDLActor());
if (!t.mTextureClient->IsSharedWithCompositor()) {
return;
}
FenceHandle fence = t.mTextureClient->GetAcquireFenceHandle();
textures.AppendElement(TimedTexture(nullptr, t.mTextureClient->GetIPDLActor(),
fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t()),
@ -936,6 +941,11 @@ ImageBridgeChild::RemoveTextureFromCompositable(CompositableClient* aCompositabl
TextureClient* aTexture)
{
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(aTexture);
MOZ_ASSERT(aTexture->IsSharedWithCompositor());
if (!aTexture || !aTexture->IsSharedWithCompositor()) {
return;
}
if (aTexture->GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
nullptr, aTexture->GetIPDLActor()));
@ -952,6 +962,12 @@ ImageBridgeChild::RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aA
CompositableClient* aCompositable,
TextureClient* aTexture)
{
MOZ_ASSERT(!mShuttingDown);
MOZ_ASSERT(aTexture);
MOZ_ASSERT(aTexture->IsSharedWithCompositor());
if (!aTexture || !aTexture->IsSharedWithCompositor()) {
return;
}
mTxn->AddNoSwapEdit(OpRemoveTextureAsync(CompositableClient::GetTrackersHolderId(aCompositable->GetIPDLActor()),
aAsyncTransactionTracker->GetId(),
nullptr, aCompositable->GetIPDLActor(),