diff --git a/gfx/gl/ScopedGLHelpers.cpp b/gfx/gl/ScopedGLHelpers.cpp index f6a51e5abd2a..5ba94cfab02e 100644 --- a/gfx/gl/ScopedGLHelpers.cpp +++ b/gfx/gl/ScopedGLHelpers.cpp @@ -52,7 +52,12 @@ ScopedGLState::UnwrapImpl() void ScopedBindFramebuffer::Init() { - mOldFB = mGL->GetFB(); + if (mGL->IsSupported(GLFeature::framebuffer_blit)) { + mOldReadFB = mGL->GetReadFB(); + mOldDrawFB = mGL->GetDrawFB(); + } else { + mOldReadFB = mOldDrawFB = mGL->GetFB(); + } } ScopedBindFramebuffer::ScopedBindFramebuffer(GLContext* aGL) @@ -74,7 +79,12 @@ ScopedBindFramebuffer::UnwrapImpl() // Check that we're not falling out of scope after the current context changed. MOZ_ASSERT(mGL->IsCurrent()); - mGL->BindFB(mOldFB); + if (mOldReadFB == mOldDrawFB) { + mGL->BindFB(mOldDrawFB); + } else { + mGL->BindDrawFB(mOldDrawFB); + mGL->BindReadFB(mOldReadFB); + } } diff --git a/gfx/gl/ScopedGLHelpers.h b/gfx/gl/ScopedGLHelpers.h index bf35acce4aa2..e7f4aa4f5e15 100644 --- a/gfx/gl/ScopedGLHelpers.h +++ b/gfx/gl/ScopedGLHelpers.h @@ -74,7 +74,8 @@ struct ScopedBindFramebuffer friend struct ScopedGLWrapper; protected: - GLuint mOldFB; + GLuint mOldReadFB; + GLuint mOldDrawFB; private: void Init();