Bug 1360701 - Remove sync wait during removing pipeline r=nical

This commit is contained in:
sotaro 2017-05-16 17:28:20 -07:00
Родитель f9396fc921
Коммит 12f8ed1f22
5 изменённых файлов: 41 добавлений и 28 удалений

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

@ -1841,12 +1841,14 @@ CompositorBridgeParent::DidComposite(TimeStamp& aCompositeStart,
void void
CompositorBridgeParent::NotifyDidCompositeToPipeline(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd) CompositorBridgeParent::NotifyDidCompositeToPipeline(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd)
{ {
if (!mWrBridge) {
return;
}
mWrBridge->CompositableHolder()->Update(aPipelineId, aEpoch);
if (mPaused) { if (mPaused) {
return; return;
} }
MOZ_ASSERT(mWrBridge);
mWrBridge->CompositableHolder()->Update(aPipelineId, aEpoch);
if (mWrBridge->PipelineId() == aPipelineId) { if (mWrBridge->PipelineId() == aPipelineId) {
uint64_t transactionId = mWrBridge->FlushTransactionIdsForEpoch(aEpoch); uint64_t transactionId = mWrBridge->FlushTransactionIdsForEpoch(aEpoch);

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

@ -863,26 +863,26 @@ WebRenderBridgeParent::Resume()
void void
WebRenderBridgeParent::ClearResources() WebRenderBridgeParent::ClearResources()
{ {
if (mApi) { if (!mApi) {
++mWrEpoch; // Update webrender epoch return;
mApi->ClearRootDisplayList(wr::NewEpoch(mWrEpoch), mPipelineId);
for (auto iter = mActiveKeys.Iter(); !iter.Done(); iter.Next()) {
mKeysToDelete.push_back(iter.Data());
iter.Remove();
}
if (!mKeysToDelete.empty()) {
// XXX Sync wait.
mApi->WaitFlushed();
DeleteOldImages();
}
} }
++mWrEpoch; // Update webrender epoch
mApi->ClearRootDisplayList(wr::NewEpoch(mWrEpoch), mPipelineId);
// Schedule composition to clean up Pipeline
mCompositorScheduler->ScheduleComposition();
for (auto iter = mActiveKeys.Iter(); !iter.Done(); iter.Next()) {
mKeysToDelete.push_back(iter.Data());
iter.Remove();
}
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()->SetWrBridge(nullptr);
} }
mExternalImageIds.Clear(); mExternalImageIds.Clear();
mCompositableHolder->RemovePipeline(mPipelineId); mCompositableHolder->RemovePipeline(mPipelineId, wr::NewEpoch(mWrEpoch));
if (mWidget && mCompositorScheduler) { if (mWidget) {
mCompositorScheduler->Destroy(); mCompositorScheduler->Destroy();
} }
mCompositorScheduler = nullptr; mCompositorScheduler = nullptr;

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

@ -8,6 +8,7 @@
#include "CompositableHost.h" #include "CompositableHost.h"
#include "mozilla/layers/WebRenderImageHost.h" #include "mozilla/layers/WebRenderImageHost.h"
#include "mozilla/layers/WebRenderTextureHost.h" #include "mozilla/layers/WebRenderTextureHost.h"
#include "mozilla/webrender/WebRenderAPI.h"
namespace mozilla { namespace mozilla {
@ -25,7 +26,6 @@ WebRenderCompositableHolder::WebRenderCompositableHolder(uint32_t aIdNamespace)
WebRenderCompositableHolder::~WebRenderCompositableHolder() WebRenderCompositableHolder::~WebRenderCompositableHolder()
{ {
MOZ_COUNT_DTOR(WebRenderCompositableHolder); MOZ_COUNT_DTOR(WebRenderCompositableHolder);
MOZ_ASSERT(mPipelineTexturesHolders.IsEmpty());
} }
void void
@ -39,18 +39,22 @@ WebRenderCompositableHolder::AddPipeline(const wr::PipelineId& aPipelineId)
} }
void void
WebRenderCompositableHolder::RemovePipeline(const wr::PipelineId& aPipelineId) WebRenderCompositableHolder::RemovePipeline(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch)
{ {
uint64_t id = wr::AsUint64(aPipelineId); PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId));
if (mPipelineTexturesHolders.Get(id)) { MOZ_ASSERT(holder);
mPipelineTexturesHolders.Remove(id); if (!holder) {
return;
} }
MOZ_ASSERT(holder->mDestroyedEpoch.isNothing());
holder->mDestroyedEpoch = Some(aEpoch);
} }
void void
WebRenderCompositableHolder::HoldExternalImage(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, WebRenderTextureHost* aTexture) WebRenderCompositableHolder::HoldExternalImage(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, WebRenderTextureHost* aTexture)
{ {
MOZ_ASSERT(aTexture); MOZ_ASSERT(aTexture);
PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId)); PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId));
MOZ_ASSERT(holder); MOZ_ASSERT(holder);
if (!holder) { if (!holder) {
@ -64,10 +68,17 @@ void
WebRenderCompositableHolder::Update(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch) WebRenderCompositableHolder::Update(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch)
{ {
PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId)); PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId));
if (!holder || holder->mTextureHosts.empty()) { if (!holder) {
return; return;
} }
// Remove Pipeline
if (holder->mDestroyedEpoch.isSome() && holder->mDestroyedEpoch.ref() <= aEpoch) {
mPipelineTexturesHolders.Remove(wr::AsUint64(aPipelineId));
return;
}
// Release TextureHosts based on Epoch
while (!holder->mTextureHosts.empty()) { while (!holder->mTextureHosts.empty()) {
if (aEpoch <= holder->mTextureHosts.front().mEpoch) { if (aEpoch <= holder->mTextureHosts.front().mEpoch) {
break; break;

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

@ -9,6 +9,7 @@
#include <queue> #include <queue>
#include "mozilla/layers/TextureHost.h" #include "mozilla/layers/TextureHost.h"
#include "mozilla/Maybe.h"
#include "mozilla/webrender/WebRenderTypes.h" #include "mozilla/webrender/WebRenderTypes.h"
#include "nsClassHashtable.h" #include "nsClassHashtable.h"
@ -35,7 +36,7 @@ protected:
public: public:
void AddPipeline(const wr::PipelineId& aPipelineId); void AddPipeline(const wr::PipelineId& aPipelineId);
void RemovePipeline(const wr::PipelineId& aPipelineId); void RemovePipeline(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch);
void HoldExternalImage(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, WebRenderTextureHost* aTexture); void HoldExternalImage(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, WebRenderTextureHost* aTexture);
void Update(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch); void Update(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch);
@ -61,9 +62,9 @@ public:
uint32_t GetNextResourceId() { return ++mResourceId; } uint32_t GetNextResourceId() { return ++mResourceId; }
uint32_t GetNamespace() { return mIdNamespace; } uint32_t GetNamespace() { return mIdNamespace; }
WrImageKey GetImageKey() wr::ImageKey GetImageKey()
{ {
WrImageKey key; wr::ImageKey key;
key.mNamespace = GetNamespace(); key.mNamespace = GetNamespace();
key.mHandle = GetNextResourceId(); key.mHandle = GetNextResourceId();
return key; return key;
@ -83,6 +84,7 @@ private:
struct PipelineTexturesHolder { struct PipelineTexturesHolder {
// Holds forwarding WebRenderTextureHosts. // Holds forwarding WebRenderTextureHosts.
std::queue<ForwardingTextureHost> mTextureHosts; std::queue<ForwardingTextureHost> mTextureHosts;
Maybe<wr::Epoch> mDestroyedEpoch;
}; };
uint32_t mIdNamespace; uint32_t mIdNamespace;

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

@ -23,7 +23,6 @@ class CompositorWidget;
namespace layers { namespace layers {
class CompositorBridgeParentBase; class CompositorBridgeParentBase;
class WebRenderBridgeParent;
} }
namespace wr { namespace wr {
@ -124,7 +123,6 @@ protected:
bool mUseANGLE; bool mUseANGLE;
friend class DisplayListBuilder; friend class DisplayListBuilder;
friend class layers::WebRenderBridgeParent;
}; };
/// This is a simple C++ wrapper around WrState defined in the rust bindings. /// This is a simple C++ wrapper around WrState defined in the rust bindings.