Bug 1363347 - Allow multiple external image IDs to be bound to the same image host if owned by the same WRBridge. r=sotaro

This commit is contained in:
Andrew Osmond 2017-05-18 06:50:03 -04:00
Родитель 501bd51b08
Коммит 67c80db4e7
3 изменённых файлов: 25 добавлений и 3 удалений

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

@ -661,7 +661,7 @@ WebRenderBridgeParent::RecvRemoveExternalImageId(const ExternalImageId& aImageId
MOZ_ASSERT(mExternalImageIds.Get(wr::AsUint64(aImageId)).get());
WebRenderImageHost* wrHost = mExternalImageIds.Get(wr::AsUint64(aImageId)).get();
if (wrHost) {
wrHost->SetWrBridge(nullptr);
wrHost->ClearWrBridge();
}
mExternalImageIds.Remove(wr::AsUint64(aImageId));
@ -875,7 +875,7 @@ WebRenderBridgeParent::ClearResources()
}
DeleteOldImages();
for (auto iter = mExternalImageIds.Iter(); !iter.Done(); iter.Next()) {
iter.Data()->SetWrBridge(nullptr);
iter.Data()->ClearWrBridge();
}
mExternalImageIds.Clear();
mCompositableHolder->RemovePipeline(mPipelineId, wr::NewEpoch(mWrEpoch));

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

@ -28,6 +28,7 @@ WebRenderImageHost::WebRenderImageHost(const TextureInfo& aTextureInfo)
: CompositableHost(aTextureInfo)
, ImageComposite()
, mWrBridge(nullptr)
, mWrBridgeBindings(0)
{}
WebRenderImageHost::~WebRenderImageHost()
@ -279,8 +280,25 @@ WebRenderImageHost::GetImageSize() const
void
WebRenderImageHost::SetWrBridge(WebRenderBridgeParent* aWrBridge)
{
SetCurrentTextureHost(nullptr);
// For image hosts created through ImageBridgeParent, there may be multiple
// references to it due to the order of creation and freeing of layers by
// the layer tree. However this should be limited to things such as video
// which will not be reused across different WebRenderBridgeParent objects.
MOZ_ASSERT(aWrBridge);
MOZ_ASSERT(!mWrBridge || mWrBridge == aWrBridge);
mWrBridge = aWrBridge;
++mWrBridgeBindings;
}
void
WebRenderImageHost::ClearWrBridge()
{
MOZ_ASSERT(mWrBridgeBindings > 0);
--mWrBridgeBindings;
if (mWrBridgeBindings == 0) {
SetCurrentTextureHost(nullptr);
mWrBridge = nullptr;
}
}
} // namespace layers

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

@ -71,6 +71,8 @@ public:
void SetWrBridge(WebRenderBridgeParent* aWrBridge);
void ClearWrBridge();
protected:
// ImageComposite
virtual TimeStamp GetCompositionTime() const override;
@ -79,6 +81,8 @@ protected:
WebRenderBridgeParent* MOZ_NON_OWNING_REF mWrBridge;
uint32_t mWrBridgeBindings;
CompositableTextureHostRef mCurrentTextureHost;
};