Bug 1453801 - Part 2. Ensure shared surfaces are properly released from render texture cache. r=sotaro

This commit is contained in:
Andrew Osmond
2018-04-23 07:57:15 -04:00
parent 8361ce2f41
commit 0513161507
6 changed files with 69 additions and 15 deletions

View File

@@ -10,6 +10,7 @@
#include "gfxEnv.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/SharedSurfacesParent.h"
#include "mozilla/layers/WebRenderImageHost.h"
#include "mozilla/layers/WebRenderTextureHost.h"
#include "mozilla/webrender/WebRenderAPI.h"
@@ -382,6 +383,24 @@ AsyncImagePipelineManager::HoldExternalImage(const wr::PipelineId& aPipelineId,
holder->mTextureHosts.push(ForwardingTextureHost(aEpoch, aTexture));
}
void
AsyncImagePipelineManager::HoldExternalImage(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, const wr::ExternalImageId& aImageId)
{
if (mDestroyed) {
SharedSurfacesParent::Release(aImageId);
return;
}
PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId));
MOZ_ASSERT(holder);
if (!holder) {
SharedSurfacesParent::Release(aImageId);
return;
}
holder->mExternalImages.push(ForwardingExternalImage(aEpoch, aImageId));
}
void
AsyncImagePipelineManager::PipelineRendered(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch)
{
@@ -397,6 +416,15 @@ AsyncImagePipelineManager::PipelineRendered(const wr::PipelineId& aPipelineId, c
}
holder->mTextureHosts.pop();
}
while (!holder->mExternalImages.empty()) {
if (aEpoch <= holder->mExternalImages.front().mEpoch) {
break;
}
DebugOnly<bool> released =
SharedSurfacesParent::Release(holder->mExternalImages.front().mImageId);
MOZ_ASSERT(released);
holder->mExternalImages.pop();
}
}
}