From 2ec500123f25ef70d13f03a6e4efe0f4c68335f5 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Wed, 21 Apr 2021 01:03:32 +0000 Subject: [PATCH] Bug 1706510 - If no frontbuffer, reuse BindDefaultFBForRead. r=lsalzman Don't bind mDefaultFB->mFB directly, since it might be multisampled. Differential Revision: https://phabricator.services.mozilla.com/D112881 --- dom/canvas/WebGLContext.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 51f96c7b454e..16160c9e6b17 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -991,13 +991,6 @@ bool WebGLContext::FrontBufferSnapshotInto(Range dest) { if (!IsWebGL2()) { fbTarget = LOCAL_GL_FRAMEBUFFER; } - - gl->fBindFramebuffer(fbTarget, - front->mFb ? front->mFb->mFB : mDefaultFB->mFB); - if (pboWas) { - BindBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, nullptr); - } - auto reset2 = MakeScopeExit([&] { DoBindFB(readFbWas, fbTarget); if (pboWas) { @@ -1005,6 +998,20 @@ bool WebGLContext::FrontBufferSnapshotInto(Range dest) { } }); + if (front->mFb) { + gl->fBindFramebuffer(fbTarget, front->mFb->mFB); + } else { + if (!BindDefaultFBForRead()) { + gfxCriticalError() << "BindDefaultFBForRead failed"; + return false; + } + } + if (pboWas) { + BindBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, nullptr); + } + + // - + const auto& size = front->mDesc.size; const size_t stride = size.width * 4; MOZ_ASSERT(dest.length() == stride * size.height);