Bug 1347811 - Share WebRenderCompositableHolder between WebRenderBridgeParent r=nical

This commit is contained in:
sotaro 2017-03-22 10:27:38 +09:00
Родитель 7fc02188d8
Коммит cc4d383fff
5 изменённых файлов: 47 добавлений и 26 удалений

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

@ -1839,6 +1839,8 @@ CompositorBridgeParent::NotifyDidCompositeToPipeline(const wr::PipelineId& aPipe
}
MOZ_ASSERT(mWrBridge);
mWrBridge->CompositableHolder()->Update(aPipelineId, aEpoch);
if (mWrBridge->PipelineId() == aPipelineId) {
uint64_t transactionId = mWrBridge->FlushTransactionIdsForEpoch(aEpoch);
Unused << SendDidComposite(0, transactionId, aCompositeStart, aCompositeEnd);

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

@ -223,7 +223,7 @@ CrossProcessCompositorBridgeParent::AllocPWebRenderBridgeParent(const wr::Pipeli
WebRenderBridgeParent* parent = nullptr;
RefPtr<wr::WebRenderAPI> api = root->GetWebRenderAPI();
RefPtr<WebRenderCompositableHolder> holder = new WebRenderCompositableHolder();
RefPtr<WebRenderCompositableHolder> holder = root->CompositableHolder();
parent = new WebRenderBridgeParent(this, aPipelineId, nullptr, root->CompositorScheduler(), Move(api), Move(holder));
parent->AddRef(); // IPDL reference

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

@ -113,6 +113,7 @@ WebRenderBridgeParent::WebRenderBridgeParent(CompositorBridgeParentBase* aCompos
, mDestroyed(false)
{
MOZ_ASSERT(mCompositableHolder);
mCompositableHolder->AddPipeline(mPipelineId);
if (mWidget) {
MOZ_ASSERT(!mCompositorScheduler);
mCompositorScheduler = new CompositorVsyncScheduler(this, mWidget);
@ -327,7 +328,7 @@ WebRenderBridgeParent::ProcessWebRenderCommands(const gfx::IntSize &aSize,
mApi->AddExternalImageBuffer(key,
descriptor,
wrTexture->GetExternalImageKey());
mCompositableHolder->HoldExternalImage(aEpoch, texture->AsWebRenderTextureHost());
mCompositableHolder->HoldExternalImage(mPipelineId, aEpoch, texture->AsWebRenderTextureHost());
keysToDelete.push_back(key);
break;
}
@ -570,9 +571,6 @@ WebRenderBridgeParent::FlushTransactionIdsForEpoch(const wr::Epoch& aEpoch)
}
mPendingTransactionIds.pop();
}
mCompositableHolder->Update(aEpoch);
return id;
}
@ -609,9 +607,7 @@ WebRenderBridgeParent::ClearResources()
DeleteOldImages();
}
}
if (mCompositableHolder) {
mCompositableHolder->Destroy();
}
mCompositableHolder->RemovePipeline(mPipelineId);
mExternalImageIds.Clear();
if (mWidget && mCompositorScheduler) {

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

@ -23,36 +23,54 @@ WebRenderCompositableHolder::WebRenderCompositableHolder()
WebRenderCompositableHolder::~WebRenderCompositableHolder()
{
MOZ_COUNT_DTOR(WebRenderCompositableHolder);
MOZ_ASSERT(mWebRenderTextureHosts.empty());
MOZ_ASSERT(mPipelineTexturesHolders.IsEmpty());
}
void
WebRenderCompositableHolder::Destroy()
WebRenderCompositableHolder::AddPipeline(const wr::PipelineId& aPipelineId)
{
while (!mWebRenderTextureHosts.empty()) {
mWebRenderTextureHosts.pop();
uint64_t id = wr::AsUint64(aPipelineId);
MOZ_ASSERT(!mPipelineTexturesHolders.Get(id));
PipelineTexturesHolder* holder = new PipelineTexturesHolder();
mPipelineTexturesHolders.Put(id, holder);
}
void
WebRenderCompositableHolder::RemovePipeline(const wr::PipelineId& aPipelineId)
{
uint64_t id = wr::AsUint64(aPipelineId);
if (mPipelineTexturesHolders.Get(id)) {
mPipelineTexturesHolders.Remove(id);
}
}
void
WebRenderCompositableHolder::HoldExternalImage(const wr::Epoch& aEpoch, WebRenderTextureHost* aTexture)
WebRenderCompositableHolder::HoldExternalImage(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, WebRenderTextureHost* aTexture)
{
MOZ_ASSERT(aTexture);
PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId));
MOZ_ASSERT(holder);
if (!holder) {
return;
}
// Hold WebRenderTextureHost until end of its usage on RenderThread
mWebRenderTextureHosts.push(ForwardingTextureHosts(aEpoch, aTexture));
holder->mTextureHosts.push(ForwardingTextureHost(aEpoch, aTexture));
}
void
WebRenderCompositableHolder::Update(const wr::Epoch& aEpoch)
WebRenderCompositableHolder::Update(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch)
{
if (mWebRenderTextureHosts.empty()) {
PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId));
if (!holder || holder->mTextureHosts.empty()) {
return;
}
while (!mWebRenderTextureHosts.empty()) {
if (aEpoch <= mWebRenderTextureHosts.front().mEpoch) {
while (!holder->mTextureHosts.empty()) {
if (aEpoch <= holder->mTextureHosts.front().mEpoch) {
break;
}
mWebRenderTextureHosts.pop();
holder->mTextureHosts.pop();
}
}

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

@ -33,14 +33,15 @@ protected:
~WebRenderCompositableHolder();
public:
void Destroy();
void HoldExternalImage(const wr::Epoch& aEpoch, WebRenderTextureHost* aTexture);
void Update(const wr::Epoch& aEpoch);
void AddPipeline(const wr::PipelineId& aPipelineId);
void RemovePipeline(const wr::PipelineId& aPipelineId);
void HoldExternalImage(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, WebRenderTextureHost* aTexture);
void Update(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch);
private:
struct ForwardingTextureHosts {
ForwardingTextureHosts(const wr::Epoch& aEpoch, TextureHost* aTexture)
struct ForwardingTextureHost {
ForwardingTextureHost(const wr::Epoch& aEpoch, TextureHost* aTexture)
: mEpoch(aEpoch)
, mTexture(aTexture)
{}
@ -48,8 +49,12 @@ private:
CompositableTextureHostRef mTexture;
};
// Holds forwarding WebRenderTextureHosts.
std::queue<ForwardingTextureHosts> mWebRenderTextureHosts;
struct PipelineTexturesHolder {
// Holds forwarding WebRenderTextureHosts.
std::queue<ForwardingTextureHost> mTextureHosts;
};
nsClassHashtable<nsUint64HashKey, PipelineTexturesHolder> mPipelineTexturesHolders;
};
} // namespace layers