Bug 1647491 - Hold ref to previous webgl frontbuffer while in-flight. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D81921
This commit is contained in:
Jeff Gilbert 2020-07-02 01:45:36 +00:00
Родитель cdcaab85f1
Коммит 335a0af676
2 изменённых файлов: 15 добавлений и 9 удалений

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

@ -48,11 +48,15 @@ UniquePtr<SwapChainPresenter> SwapChain::Acquire(const gfx::IntSize& size) {
}
auto ret = MakeUnique<SwapChainPresenter>(*this);
ret->SwapBackBuffer(std::move(surf));
const auto old = ret->SwapBackBuffer(surf);
MOZ_ALWAYS_TRUE(!old);
return ret;
}
void SwapChain::ClearPool() { mPool = {}; }
void SwapChain::ClearPool() {
mPool = {};
mPrevFrontBuffer = nullptr;
}
// -
@ -69,7 +73,8 @@ SwapChainPresenter::~SwapChainPresenter() {
auto newFront = SwapBackBuffer(nullptr);
if (newFront) {
mSwapChain->mFrontBuffer = std::move(newFront);
mSwapChain->mPrevFrontBuffer = mSwapChain->mFrontBuffer;
mSwapChain->mFrontBuffer = newFront;
}
}
@ -80,8 +85,8 @@ std::shared_ptr<SharedSurface> SwapChainPresenter::SwapBackBuffer(
mBackBuffer->ProducerRelease();
mBackBuffer->Commit();
}
auto old = std::move(mBackBuffer);
mBackBuffer = std::move(back);
auto old = mBackBuffer;
mBackBuffer = back;
if (mBackBuffer) {
mBackBuffer->WaitForBufferOwnership();
mBackBuffer->ProducerAcquire();

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

@ -56,12 +56,13 @@ class SwapChain final {
public:
UniquePtr<SurfaceFactory> mFactory;
private:
std::shared_ptr<SharedSurface> mFrontBuffer;
SwapChainPresenter* mPresenter = nullptr;
private:
std::queue<std::shared_ptr<SharedSurface>> mPool;
std::shared_ptr<SharedSurface> mFrontBuffer;
public:
std::shared_ptr<SharedSurface> mPrevFrontBuffer; // Hold this ref while it's in-flight.
private:
SwapChainPresenter* mPresenter = nullptr;
public:
SwapChain();