From ec6ba5a531bd5a6eb040e0ff6e0da3e08de7bd9a Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Tue, 3 Mar 2020 00:43:10 +0000 Subject: [PATCH] Bug 1617751 - Ensure that GLScreenBuffer back buffer is created using the newly attached factory. r=jgilbert Differential Revision: https://phabricator.services.mozilla.com/D64183 --HG-- extra : moz-landing-system : lando --- dom/canvas/WebGLContext.cpp | 10 +++++++++- dom/canvas/WebGLContext.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 93b33eaec129..1cc2116dba18 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -952,6 +952,12 @@ Maybe WebGLContext::InitializeCanvasRenderer( gl->Screen()->Morph(std::move(factory)); +#if defined(MOZ_WIDGET_ANDROID) + // On Android we are using a different GLScreenBuffer for WebVR, so we need + // a resize here because PresentScreenBuffer() may not be called for the + // gl->Screen() after we set the new factory. + mForceResizeOnPresent = true; +#endif mVRReady = true; return Some(ret); } @@ -978,12 +984,14 @@ bool WebGLContext::PresentScreenBuffer(gl::GLScreenBuffer* const targetScreen) { if (!ValidateAndInitFB(nullptr)) return false; const auto& screen = targetScreen ? targetScreen : gl->Screen(); - if ((!screen->IsReadBufferReady() || screen->Size() != mDefaultFB->mSize) && + if ((!screen->IsReadBufferReady() || mForceResizeOnPresent || + screen->Size() != mDefaultFB->mSize) && !screen->Resize(mDefaultFB->mSize)) { GenerateWarning("screen->Resize failed. Losing context."); LoseContext(); return false; } + mForceResizeOnPresent = false; gl->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0); BlitBackbufferToCurDriverFB(); diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index 53ad255d23db..5418722976e5 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -849,6 +849,7 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr { bool mCanLoseContextInForeground = true; bool mShouldPresent = false; bool mDisableFragHighP = false; + bool mForceResizeOnPresent = false; bool mVRReady = false; template