зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1347811 - Share WebRenderCompositableHolder between WebRenderBridgeParent r=nical
This commit is contained in:
Родитель
7fc02188d8
Коммит
cc4d383fff
|
@ -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;
|
||||
};
|
||||
|
||||
struct PipelineTexturesHolder {
|
||||
// Holds forwarding WebRenderTextureHosts.
|
||||
std::queue<ForwardingTextureHosts> mWebRenderTextureHosts;
|
||||
std::queue<ForwardingTextureHost> mTextureHosts;
|
||||
};
|
||||
|
||||
nsClassHashtable<nsUint64HashKey, PipelineTexturesHolder> mPipelineTexturesHolders;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
|
Загрузка…
Ссылка в новой задаче