Bug 1383786 - Delete image keys as soon as they are not used anymore. r=sotaro

This commit is contained in:
Nicolas Silva 2017-09-26 15:31:08 +02:00
Родитель f1d8bb2519
Коммит 96de7b8d80
2 изменённых файлов: 6 добавлений и 33 удалений

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

@ -43,29 +43,10 @@ void
AsyncImagePipelineManager::Destroy()
{
MOZ_ASSERT(!mDestroyed);
DeleteOldAsyncImages();
mApi = nullptr;
mDestroyed = true;
}
bool
AsyncImagePipelineManager::HasKeysToDelete()
{
return !mKeysToDelete.IsEmpty();
}
void
AsyncImagePipelineManager::DeleteOldAsyncImages()
{
MOZ_ASSERT(!mDestroyed);
wr::ResourceUpdateQueue resources;
for (wr::ImageKey key : mKeysToDelete) {
resources.DeleteImage(key);
}
mApi->UpdateResources(resources);
mKeysToDelete.Clear();
}
void
AsyncImagePipelineManager::AddPipeline(const wr::PipelineId& aPipelineId)
{
@ -166,8 +147,7 @@ AsyncImagePipelineManager::UpdateAsyncImagePipeline(const wr::PipelineId& aPipel
Maybe<TextureHost::ResourceUpdateOp>
AsyncImagePipelineManager::UpdateImageKeys(wr::ResourceUpdateQueue& aResources,
AsyncImagePipeline* aPipeline,
nsTArray<wr::ImageKey>& aKeys,
nsTArray<wr::ImageKey>& aKeysToDelete)
nsTArray<wr::ImageKey>& aKeys)
{
MOZ_ASSERT(aKeys.IsEmpty());
MOZ_ASSERT(aPipeline);
@ -208,9 +188,9 @@ AsyncImagePipelineManager::UpdateImageKeys(wr::ResourceUpdateQueue& aResources,
&& aPipeline->mKeys.Length() == numKeys;
if (!canUpdate) {
// TODO(nical) we should be able to push these key deletions directly in the
// ResourceUpdateQueue now.
aKeysToDelete.AppendElements(aPipeline->mKeys);
for (auto key : aPipeline->mKeys) {
aResources.DeleteImage(key);
}
aPipeline->mKeys.Clear();
for (uint32_t i = 0; i < numKeys; ++i) {
aPipeline->mKeys.AppendElement(GenerateImageKey());
@ -277,7 +257,6 @@ AsyncImagePipelineManager::ApplyAsyncImages()
++mAsyncImageEpoch; // Update webrender epoch
wr::Epoch epoch = wr::NewEpoch(mAsyncImageEpoch);
nsTArray<wr::ImageKey> keysToDelete;
// We use a pipeline with a very small display list for each video element.
// Update each of them if needed.
@ -287,7 +266,7 @@ AsyncImagePipelineManager::ApplyAsyncImages()
AsyncImagePipeline* pipeline = iter.Data();
nsTArray<wr::ImageKey> keys;
auto op = UpdateImageKeys(resourceUpdates, pipeline, keys, keysToDelete);
auto op = UpdateImageKeys(resourceUpdates, pipeline, keys);
if (op != Some(TextureHost::ADD_IMAGE)) {
// We don't need to update the display list, either because we can't or because
@ -346,8 +325,6 @@ AsyncImagePipelineManager::ApplyAsyncImages()
dl.dl_desc, dl.dl.inner.data, dl.dl.inner.length,
resourceUpdates);
}
DeleteOldAsyncImages();
mKeysToDelete.SwapElements(keysToDelete);
}
void

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

@ -42,7 +42,6 @@ protected:
public:
void Destroy();
bool HasKeysToDelete();
void AddPipeline(const wr::PipelineId& aPipelineId);
void RemovePipeline(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch);
@ -92,7 +91,6 @@ public:
}
private:
void DeleteOldAsyncImages();
uint32_t GetNextResourceId() { return ++mResourceId; }
wr::IdNamespace GetNamespace() { return mIdNamespace; }
@ -138,8 +136,7 @@ private:
Maybe<TextureHost::ResourceUpdateOp>
UpdateImageKeys(wr::ResourceUpdateQueue& aResourceUpdates,
AsyncImagePipeline* aPipeline,
nsTArray<wr::ImageKey>& aKeys,
nsTArray<wr::ImageKey>& aKeysToDelete);
nsTArray<wr::ImageKey>& aKeys);
Maybe<TextureHost::ResourceUpdateOp>
UpdateWithoutExternalImage(wr::ResourceUpdateQueue& aResources,
TextureHost* aTexture,
@ -153,7 +150,6 @@ private:
nsClassHashtable<nsUint64HashKey, PipelineTexturesHolder> mPipelineTexturesHolders;
nsClassHashtable<nsUint64HashKey, AsyncImagePipeline> mAsyncImagePipelines;
uint32_t mAsyncImageEpoch;
nsTArray<wr::ImageKey> mKeysToDelete;
bool mDestroyed;
// Render time for the current composition.