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

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

@ -28,6 +28,7 @@ WebRenderImageHost::WebRenderImageHost(const TextureInfo& aTextureInfo)
: CompositableHost(aTextureInfo) : CompositableHost(aTextureInfo)
, ImageComposite() , ImageComposite()
, mWrBridge(nullptr) , mWrBridge(nullptr)
, mWrBridgeBindings(0)
{} {}
WebRenderImageHost::~WebRenderImageHost() WebRenderImageHost::~WebRenderImageHost()
@ -279,8 +280,25 @@ WebRenderImageHost::GetImageSize() const
void void
WebRenderImageHost::SetWrBridge(WebRenderBridgeParent* aWrBridge) 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; mWrBridge = aWrBridge;
++mWrBridgeBindings;
}
void
WebRenderImageHost::ClearWrBridge()
{
MOZ_ASSERT(mWrBridgeBindings > 0);
--mWrBridgeBindings;
if (mWrBridgeBindings == 0) {
SetCurrentTextureHost(nullptr);
mWrBridge = nullptr;
}
} }
} // namespace layers } // namespace layers

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

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