Bug 1570869 - Replace mRenderingCount with a boolean, to make it clear that we are only ever rendering at most one frame. r=nical

The only place that increments mRenderingCount, HandleFrameOneDoc, also synchronously calls FrameRenderingComplete
at the end of the function, which decrements mRenderingCount again. So it can never grow beyond 1.

Depends on D40372

Differential Revision: https://phabricator.services.mozilla.com/D40373

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Markus Stange 2019-08-05 12:02:38 +00:00
parent d00dade81c
commit 6ebb22a9d3
2 changed files with 8 additions and 7 deletions

View File

@ -299,7 +299,7 @@ void RenderThread::HandleFrameOneDoc(wr::WindowId aWindowId, bool aRender) {
it->second->mDocFrameCounts.front());
render = it->second->mRender || aRender;
it->second->mRender = false;
it->second->mRenderingCount++;
it->second->mIsRendering = true;
it->second->mDocFrameCounts.pop();
it->second->mDocFramesSeen = 0;
}
@ -400,7 +400,7 @@ static void NotifyDidRender(layers::CompositorBridgeParent* aBridge,
}
static void NotifyDidStartRender(layers::CompositorBridgeParent* aBridge) {
// Starting a render will change increment mRenderingCount, and potentially
// Starting a render will change mIsRendering, and potentially
// change whether we can allow the bridge to intiate another frame.
if (aBridge->GetWrBridge()) {
aBridge->GetWrBridge()->CompositeIfNeeded();
@ -518,8 +518,8 @@ bool RenderThread::TooManyPendingFrames(wr::WindowId aWindowId) {
if (info->PendingCount() > maxFrameCount) {
return true;
}
MOZ_ASSERT(info->PendingCount() >= info->mRenderingCount);
return info->PendingCount() > info->mRenderingCount;
MOZ_ASSERT(info->PendingCount() >= info->RenderingCount());
return info->PendingCount() > info->RenderingCount();
}
bool RenderThread::IsDestroyed(wr::WindowId aWindowId) {
@ -565,14 +565,14 @@ void RenderThread::FrameRenderingComplete(wr::WindowId aWindowId) {
}
WindowInfo* info = it->second;
MOZ_ASSERT(info->PendingCount() > 0);
MOZ_ASSERT(info->mRenderingCount > 0);
MOZ_ASSERT(info->mIsRendering);
if (info->PendingCount() <= 0) {
return;
}
PendingFrameInfo frame = std::move(info->mPendingFrames.front());
info->mPendingFrames.pop();
info->mRenderingCount--;
info->mIsRendering = false;
// The start time is from WebRenderBridgeParent::CompositeToTarget. From that
// point until now (when the frame is finally pushed to the screen) is

View File

@ -306,10 +306,11 @@ class RenderThread final {
struct WindowInfo {
int64_t PendingCount() { return mPendingFrames.size(); }
int64_t RenderingCount() { return mIsRendering ? 1 : 0; }
bool mIsDestroyed = false;
bool mRender = false;
int64_t mRenderingCount = 0;
bool mIsRendering = false;
uint8_t mDocFramesSeen = 0;
std::queue<PendingFrameInfo> mPendingFrames;
std::queue<uint8_t> mDocFrameCounts;