From 6fc9eaab4accdf77989dd3ba775c7083b5d2b16f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 2 Aug 2017 11:37:31 -0700 Subject: [PATCH] Don't flush async paints on the main thread. (bug 1386517, r=mattwoodrow) --- gfx/layers/client/TextureClient.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 0abee6bdfc20..9990cddfc7ef 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -543,22 +543,23 @@ TextureClient::Unlock() } if (mBorrowedDrawTarget) { - if (mOpenMode & OpenMode::OPEN_WRITE) { - mBorrowedDrawTarget->Flush(); - if (mReadbackSink && !mData->ReadBack(mReadbackSink)) { - // Fallback implementation for reading back, because mData does not - // have a backend-specific implementation and returned false. - RefPtr snapshot = mBorrowedDrawTarget->Snapshot(); - RefPtr dataSurf = snapshot->GetDataSurface(); - mReadbackSink->ProcessReadback(dataSurf); + if (!(mOpenMode & OpenMode::OPEN_ASYNC_WRITE)) { + if (mOpenMode & OpenMode::OPEN_WRITE) { + mBorrowedDrawTarget->Flush(); + if (mReadbackSink && !mData->ReadBack(mReadbackSink)) { + // Fallback implementation for reading back, because mData does not + // have a backend-specific implementation and returned false. + RefPtr snapshot = mBorrowedDrawTarget->Snapshot(); + RefPtr dataSurf = snapshot->GetDataSurface(); + mReadbackSink->ProcessReadback(dataSurf); + } } - } - mBorrowedDrawTarget->DetachAllSnapshots(); - // If this assertion is hit, it means something is holding a strong reference - // to our DrawTarget externally, which is not allowed. - MOZ_ASSERT_IF(!(mOpenMode & OpenMode::OPEN_ASYNC_WRITE), - mBorrowedDrawTarget->refCount() <= mExpectedDtRefs); + mBorrowedDrawTarget->DetachAllSnapshots(); + // If this assertion is hit, it means something is holding a strong reference + // to our DrawTarget externally, which is not allowed. + MOZ_ASSERT(mBorrowedDrawTarget->refCount() <= mExpectedDtRefs); + } mBorrowedDrawTarget = nullptr; }