Bug 1426280 - Remove explicit MakeCurrents from WebGL now that we use implicit MakeCurrent. - r=lenzak draft
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 19 Dec 2017 17:21:18 -0800
changeset 713275 1227bb13390d90c439cb135dc8a35232ca239f5d
parent 713235 1624b88874765bf57e9feba176d30149c748d9d2
child 744303 4216cef5c6b74774ca0782d35880a5f45194bf44
push id93606
push userbmo:jgilbert@mozilla.com
push dateWed, 20 Dec 2017 01:21:46 +0000
reviewerslenzak
bugs1426280
milestone59.0a1
Bug 1426280 - Remove explicit MakeCurrents from WebGL now that we use implicit MakeCurrent. - r=lenzak MozReview-Commit-ID: HxWWPmD1Yzu
dom/canvas/TexUnpackBlob.cpp
dom/canvas/WebGL2ContextBuffers.cpp
dom/canvas/WebGL2ContextFramebuffers.cpp
dom/canvas/WebGL2ContextMRTs.cpp
dom/canvas/WebGL2ContextSamplers.cpp
dom/canvas/WebGL2ContextState.cpp
dom/canvas/WebGL2ContextSync.cpp
dom/canvas/WebGL2ContextTransformFeedback.cpp
dom/canvas/WebGL2ContextUniforms.cpp
dom/canvas/WebGLBuffer.cpp
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextBuffers.cpp
dom/canvas/WebGLContextDraw.cpp
dom/canvas/WebGLContextFramebufferOperations.cpp
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLContextState.cpp
dom/canvas/WebGLContextTextures.cpp
dom/canvas/WebGLContextUtils.cpp
dom/canvas/WebGLContextValidate.cpp
dom/canvas/WebGLContextVertexArray.cpp
dom/canvas/WebGLContextVertices.cpp
dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
dom/canvas/WebGLExtensionMOZDebug.cpp
dom/canvas/WebGLExtensionSRGB.cpp
dom/canvas/WebGLFramebuffer.cpp
dom/canvas/WebGLProgram.cpp
dom/canvas/WebGLQuery.cpp
dom/canvas/WebGLRenderbuffer.cpp
dom/canvas/WebGLSampler.cpp
dom/canvas/WebGLShader.cpp
dom/canvas/WebGLSync.cpp
dom/canvas/WebGLTexture.cpp
dom/canvas/WebGLTextureUpload.cpp
dom/canvas/WebGLTransformFeedback.cpp
dom/canvas/WebGLUniformLocation.cpp
dom/canvas/WebGLVertexArrayGL.cpp
--- a/dom/canvas/TexUnpackBlob.cpp
+++ b/dom/canvas/TexUnpackBlob.cpp
@@ -618,17 +618,16 @@ TexUnpackImage::TexOrSubImage(bool isSub
                               GLint yOffset, GLint zOffset, const webgl::PackingInfo& pi,
                               GLenum* const out_error) const
 {
     MOZ_ASSERT_IF(needsRespec, !isSubImage);
 
     WebGLContext* webgl = tex->mContext;
 
     gl::GLContext* gl = webgl->GL();
-    gl->MakeCurrent();
 
     if (needsRespec) {
         *out_error = DoTexOrSubImage(isSubImage, gl, target.get(), level, dui, xOffset,
                                      yOffset, zOffset, mWidth, mHeight, mDepth,
                                      nullptr);
         if (*out_error)
             return true;
     }
--- a/dom/canvas/WebGL2ContextBuffers.cpp
+++ b/dom/canvas/WebGL2ContextBuffers.cpp
@@ -78,17 +78,16 @@ WebGL2Context::CopyBufferSubData(GLenum 
                               funcName,
                               (readType == WebGLBuffer::Kind::OtherData) ? "other"
                                                                          : "element",
                               (writeType == WebGLBuffer::Kind::OtherData) ? "other"
                                                                           : "element");
         return;
     }
 
-    gl->MakeCurrent();
     const ScopedLazyBind readBind(gl, readTarget, readBuffer);
     const ScopedLazyBind writeBind(gl, writeTarget, writeBuffer);
     gl->fCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
 }
 
 void
 WebGL2Context::GetBufferSubData(GLenum target, GLintptr srcByteOffset,
                                 const dom::ArrayBufferView& dstData, GLuint dstElemOffset,
@@ -123,17 +122,16 @@ WebGL2Context::GetBufferSubData(GLenum t
     if (!CheckedInt<GLsizeiptr>(byteLen).isValid()) {
         ErrorOutOfMemory("%s: Size too large.", funcName);
         return;
     }
     const GLsizeiptr glByteLen(byteLen);
 
     ////
 
-    gl->MakeCurrent();
     const ScopedLazyBind readBind(gl, target, buffer);
 
     if (byteLen) {
         const bool isTF = (target == LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER);
         GLenum mapTarget = target;
         if (isTF) {
             gl->fBindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK, mEmptyTFO);
             gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, buffer->mGLName);
--- a/dom/canvas/WebGL2ContextFramebuffers.cpp
+++ b/dom/canvas/WebGL2ContextFramebuffers.cpp
@@ -161,18 +161,16 @@ WebGLContext::ValidateInvalidateFramebuf
                                             ErrorResult* const out_rv,
                                             std::vector<GLenum>* const scopedVector,
                                             GLsizei* const out_glNumAttachments,
                                             const GLenum** const out_glAttachments)
 {
     if (IsContextLost())
         return false;
 
-    gl->MakeCurrent();
-
     if (!ValidateFramebufferTarget(target, funcName))
         return false;
 
     const WebGLFramebuffer* fb;
     bool isDefaultFB;
     switch (target) {
     case LOCAL_GL_FRAMEBUFFER:
     case LOCAL_GL_DRAW_FRAMEBUFFER:
@@ -311,18 +309,16 @@ WebGL2Context::InvalidateSubFramebuffer(
 
 void
 WebGL2Context::ReadBuffer(GLenum mode)
 {
     const char funcName[] = "readBuffer";
     if (IsContextLost())
         return;
 
-    gl->MakeCurrent();
-
     if (mBoundReadFramebuffer) {
         mBoundReadFramebuffer->ReadBuffer(funcName, mode);
         return;
     }
 
     // Operating on the default framebuffer.
     if (mode != LOCAL_GL_NONE &&
         mode != LOCAL_GL_BACK)
--- a/dom/canvas/WebGL2ContextMRTs.cpp
+++ b/dom/canvas/WebGL2ContextMRTs.cpp
@@ -57,18 +57,16 @@ WebGL2Context::ValidateClearBuffer(const
     if (availElemCount < requiredElements) {
         ErrorInvalidValue("%s: Not enough elements. Require %zu. Given %zu.",
                           funcName, requiredElements, availElemCount);
         return false;
     }
 
     ////
 
-    MakeContextCurrent();
-
     const auto& fb = mBoundDrawFramebuffer;
     if (fb) {
         if (!fb->ValidateAndInitAttachments(funcName))
             return false;
 
         if (!fb->ValidateClearBufferType(funcName, buffer, drawBuffer, funcType))
             return false;
     } else if (buffer == LOCAL_GL_COLOR) {
--- a/dom/canvas/WebGL2ContextSamplers.cpp
+++ b/dom/canvas/WebGL2ContextSamplers.cpp
@@ -11,17 +11,16 @@ namespace mozilla {
 
 already_AddRefed<WebGLSampler>
 WebGL2Context::CreateSampler()
 {
     if (IsContextLost())
         return nullptr;
 
     GLuint sampler;
-    MakeContextCurrent();
     gl->fGenSamplers(1, &sampler);
 
     RefPtr<WebGLSampler> globj = new WebGLSampler(this, sampler);
     return globj.forget();
 }
 
 void
 WebGL2Context::DeleteSampler(WebGLSampler* sampler)
@@ -41,17 +40,16 @@ WebGL2Context::DeleteSampler(WebGLSample
 }
 
 bool
 WebGL2Context::IsSampler(const WebGLSampler* sampler)
 {
     if (!ValidateIsObject("isSampler", sampler))
         return false;
 
-    MakeContextCurrent();
     return gl->fIsSampler(sampler->mGLName);
 }
 
 void
 WebGL2Context::BindSampler(GLuint unit, WebGLSampler* sampler)
 {
     if (IsContextLost())
         return;
@@ -59,17 +57,16 @@ WebGL2Context::BindSampler(GLuint unit, 
     if (sampler && !ValidateObject("bindSampler", *sampler))
         return;
 
     if (unit >= mGLMaxTextureUnits)
         return ErrorInvalidValue("bindSampler: unit must be < %u", mGLMaxTextureUnits);
 
     ////
 
-    gl->MakeCurrent();
     gl->fBindSampler(unit, sampler ? sampler->mGLName : 0);
 
     InvalidateResolveCacheForTextureWithTexUnit(unit);
     mBoundSamplers[unit] = sampler;
 }
 
 void
 WebGL2Context::SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param)
@@ -107,18 +104,16 @@ WebGL2Context::GetSamplerParameter(JSCon
     if (IsContextLost())
         return;
 
     if (!ValidateObject(funcName, sampler))
         return;
 
     ////
 
-    gl->MakeCurrent();
-
     switch (pname) {
     case LOCAL_GL_TEXTURE_MIN_FILTER:
     case LOCAL_GL_TEXTURE_MAG_FILTER:
     case LOCAL_GL_TEXTURE_WRAP_S:
     case LOCAL_GL_TEXTURE_WRAP_T:
     case LOCAL_GL_TEXTURE_WRAP_R:
     case LOCAL_GL_TEXTURE_COMPARE_MODE:
     case LOCAL_GL_TEXTURE_COMPARE_FUNC:
--- a/dom/canvas/WebGL2ContextState.cpp
+++ b/dom/canvas/WebGL2ContextState.cpp
@@ -22,18 +22,16 @@ WebGL2Context::GetParameter(JSContext* c
   // The following cases are handled in WebGLContext::GetParameter():
   //     case LOCAL_GL_MAX_COLOR_ATTACHMENTS:
   //     case LOCAL_GL_MAX_DRAW_BUFFERS:
   //     case LOCAL_GL_DRAW_BUFFERi:
 
   if (IsContextLost())
     return JS::NullValue();
 
-  MakeContextCurrent();
-
   switch (pname) {
     /* GLboolean */
     case LOCAL_GL_RASTERIZER_DISCARD:
     case LOCAL_GL_SAMPLE_ALPHA_TO_COVERAGE:
     case LOCAL_GL_SAMPLE_COVERAGE: {
       realGLboolean b = 0;
       gl->fGetBooleanv(pname, &b);
       return JS::BooleanValue(bool(b));
--- a/dom/canvas/WebGL2ContextSync.cpp
+++ b/dom/canvas/WebGL2ContextSync.cpp
@@ -24,17 +24,16 @@ WebGL2Context::FenceSync(GLenum conditio
         return nullptr;
     }
 
     if (flags != 0) {
         ErrorInvalidValue("fenceSync: flags must be 0");
         return nullptr;
     }
 
-    MakeContextCurrent();
     RefPtr<WebGLSync> globj = new WebGLSync(this, condition, flags);
     return globj.forget();
 }
 
 bool
 WebGL2Context::IsSync(const WebGLSync* sync)
 {
     if (!ValidateIsObject("isSync", sync))
@@ -68,17 +67,16 @@ WebGL2Context::ClientWaitSync(const WebG
     }
 
     if (timeout > kMaxClientWaitSyncTimeoutNS) {
         ErrorInvalidOperation("%s: `timeout` must not exceed %s nanoseconds.", funcName,
                               "MAX_CLIENT_WAIT_TIMEOUT_WEBGL");
         return LOCAL_GL_WAIT_FAILED;
     }
 
-    MakeContextCurrent();
     return gl->fClientWaitSync(sync.mGLName, flags, timeout);
 }
 
 void
 WebGL2Context::WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout)
 {
     const char funcName[] = "waitSync";
     if (IsContextLost())
@@ -92,17 +90,16 @@ WebGL2Context::WaitSync(const WebGLSync&
         return;
     }
 
     if (timeout != -1) {
         ErrorInvalidValue("%s: `timeout` must be TIMEOUT_IGNORED.", funcName);
         return;
     }
 
-    MakeContextCurrent();
     gl->fWaitSync(sync.mGLName, flags, LOCAL_GL_TIMEOUT_IGNORED);
 }
 
 void
 WebGL2Context::GetSyncParameter(JSContext*, const WebGLSync& sync, GLenum pname,
                                 JS::MutableHandleValue retval)
 {
     const char funcName[] = "getSyncParameter";
@@ -110,18 +107,16 @@ WebGL2Context::GetSyncParameter(JSContex
     if (IsContextLost())
         return;
 
     if (!ValidateObject(funcName, sync))
         return;
 
     ////
 
-    gl->MakeCurrent();
-
     GLint result = 0;
     switch (pname) {
     case LOCAL_GL_OBJECT_TYPE:
     case LOCAL_GL_SYNC_STATUS:
     case LOCAL_GL_SYNC_CONDITION:
     case LOCAL_GL_SYNC_FLAGS:
         gl->fGetSynciv(sync.mGLName, pname, 1, nullptr, &result);
         retval.set(JS::Int32Value(result));
--- a/dom/canvas/WebGL2ContextTransformFeedback.cpp
+++ b/dom/canvas/WebGL2ContextTransformFeedback.cpp
@@ -15,17 +15,16 @@ namespace mozilla {
 // Transform Feedback
 
 already_AddRefed<WebGLTransformFeedback>
 WebGL2Context::CreateTransformFeedback()
 {
     if (IsContextLost())
         return nullptr;
 
-    MakeContextCurrent();
     GLuint tf = 0;
     gl->fGenTransformFeedbacks(1, &tf);
 
     RefPtr<WebGLTransformFeedback> ret = new WebGLTransformFeedback(this, tf);
     return ret.forget();
 }
 
 void
@@ -48,17 +47,16 @@ WebGL2Context::DeleteTransformFeedback(W
 }
 
 bool
 WebGL2Context::IsTransformFeedback(const WebGLTransformFeedback* tf)
 {
     if (!ValidateIsObject("isTransformFeedback", tf))
         return false;
 
-    MakeContextCurrent();
     return gl->fIsTransformFeedback(tf->mGLName);
 }
 
 void
 WebGL2Context::BindTransformFeedback(GLenum target, WebGLTransformFeedback* tf)
 {
     const char funcName[] = "bindTransformFeedback";
     if (IsContextLost())
@@ -82,17 +80,16 @@ WebGL2Context::BindTransformFeedback(GLe
     ////
 
     if (mBoundTransformFeedback) {
         mBoundTransformFeedback->AddBufferBindCounts(-1);
     }
 
     mBoundTransformFeedback = (tf ? tf : mDefaultTransformFeedback);
 
-    MakeContextCurrent();
     gl->fBindTransformFeedback(target, mBoundTransformFeedback->mGLName);
 
     if (mBoundTransformFeedback) {
         mBoundTransformFeedback->AddBufferBindCounts(+1);
     }
 }
 
 void
--- a/dom/canvas/WebGL2ContextUniforms.cpp
+++ b/dom/canvas/WebGL2ContextUniforms.cpp
@@ -21,48 +21,44 @@ namespace mozilla {
 // Uniforms
 
 void
 WebGLContext::Uniform1ui(WebGLUniformLocation* loc, GLuint v0)
 {
     if (!ValidateUniformSetter(loc, 1, LOCAL_GL_UNSIGNED_INT, "uniform1ui"))
         return;
 
-    MakeContextCurrent();
     gl->fUniform1ui(loc->mLoc, v0);
 }
 
 void
 WebGLContext::Uniform2ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1)
 {
     if (!ValidateUniformSetter(loc, 2, LOCAL_GL_UNSIGNED_INT, "uniform2ui"))
         return;
 
-    MakeContextCurrent();
     gl->fUniform2ui(loc->mLoc, v0, v1);
 }
 
 void
 WebGLContext::Uniform3ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1, GLuint v2)
 {
     if (!ValidateUniformSetter(loc, 3, LOCAL_GL_UNSIGNED_INT, "uniform3ui"))
         return;
 
-    MakeContextCurrent();
     gl->fUniform3ui(loc->mLoc, v0, v1, v2);
 }
 
 void
 WebGLContext::Uniform4ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1, GLuint v2,
                          GLuint v3)
 {
     if (!ValidateUniformSetter(loc, 4, LOCAL_GL_UNSIGNED_INT, "uniform4ui"))
         return;
 
-    MakeContextCurrent();
     gl->fUniform4ui(loc->mLoc, v0, v1, v2, v3);
 }
 
 // -------------------------------------------------------------------------
 // Uniform Buffer Objects and Transform Feedback Buffers
 
 void
 WebGL2Context::GetIndexedParameter(JSContext* cx, GLenum target, GLuint index,
@@ -189,17 +185,16 @@ WebGL2Context::GetActiveUniforms(JSConte
     JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, count));
     UniquePtr<GLint[]> samples(new GLint[count]);
     if (!array || !samples) {
         ErrorOutOfMemory("%s: Failed to allocate buffers.", funcName);
         return;
     }
     retval.setObject(*array);
 
-    MakeContextCurrent();
     gl->fGetActiveUniformsiv(program.mGLName, count, uniformIndices.Elements(), pname,
                              samples.get());
 
     switch (pname) {
     case LOCAL_GL_UNIFORM_TYPE:
     case LOCAL_GL_UNIFORM_SIZE:
     case LOCAL_GL_UNIFORM_BLOCK_INDEX:
     case LOCAL_GL_UNIFORM_OFFSET:
@@ -247,18 +242,16 @@ WebGL2Context::GetActiveUniformBlockPara
 {
     out_retval.setNull();
     if (IsContextLost())
         return;
 
     if (!ValidateObject("getActiveUniformBlockParameter: program", program))
         return;
 
-    MakeContextCurrent();
-
     switch(pname) {
     case LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
     case LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
     case LOCAL_GL_UNIFORM_BLOCK_BINDING:
     case LOCAL_GL_UNIFORM_BLOCK_DATA_SIZE:
     case LOCAL_GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
         out_retval.set(program.GetActiveUniformBlockParam(uniformBlockIndex, pname));
         return;
--- a/dom/canvas/WebGLBuffer.cpp
+++ b/dom/canvas/WebGLBuffer.cpp
@@ -52,17 +52,16 @@ WebGLBuffer::SetContentAfterBind(GLenum 
     default:
         MOZ_CRASH("GFX: invalid target");
     }
 }
 
 void
 WebGLBuffer::Delete()
 {
-    mContext->MakeContextCurrent();
     mContext->gl->fDeleteBuffers(1, &mGLName);
 
     mByteLength = 0;
     mFetchInvalidator.InvalidateCaches();
 
     mIndexCache = nullptr;
     mIndexRanges.clear();
     LinkedListElement<WebGLBuffer>::remove(); // remove from mContext->mBuffers
@@ -131,17 +130,16 @@ WebGLBuffer::BufferData(GLenum target, s
             mContext->ErrorOutOfMemory("%s: Failed to alloc index cache.", funcName);
             return;
         }
         memcpy(newIndexCache.get(), data, size);
         uploadData = newIndexCache.get();
     }
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
     const ScopedLazyBind lazyBind(gl, target, this);
 
     const bool sizeChanges = (size != ByteLength());
     if (sizeChanges) {
         gl::GLContext::LocalErrorScope errorScope(*gl);
         gl->fBufferData(target, size, uploadData, usage);
         const auto error = errorScope.GetError();
 
@@ -191,17 +189,16 @@ WebGLBuffer::BufferSubData(GLenum target
         uploadData = cachedDataBegin;
 
         InvalidateCacheRange(dstByteOffset, dataLen);
     }
 
     ////
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
     const ScopedLazyBind lazyBind(gl, target, this);
 
     gl->fBufferSubData(target, dstByteOffset, dataLen, uploadData);
 }
 
 bool
 WebGLBuffer::ValidateRange(const char* funcName, size_t byteOffset, size_t byteLen) const
 {
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -207,18 +207,16 @@ ClearLinkedList(LinkedList<T>& list)
 }
 
 void
 WebGLContext::DestroyResourcesAndContext()
 {
     if (!gl)
         return;
 
-    gl->MakeCurrent();
-
     mBound2DTextures.Clear();
     mBoundCubeMapTextures.Clear();
     mBound3DTextures.Clear();
     mBound2DArrayTextures.Clear();
     mBoundSamplers.Clear();
     mBoundArrayBuffer = nullptr;
     mBoundCopyReadBuffer = nullptr;
     mBoundCopyWriteBuffer = nullptr;
@@ -893,18 +891,16 @@ WebGLContext::SetDimensions(int32_t sign
             (uint32_t)mHeight == height)
         {
             return NS_OK;
         }
 
         if (IsContextLost())
             return NS_OK;
 
-        MakeContextCurrent();
-
         // If we've already drawn, we should commit the current buffer.
         PresentScreenBuffer();
 
         if (IsContextLost()) {
             GenerateWarning("WebGL context was lost due to swap failure.");
             return NS_OK;
         }
 
@@ -1485,18 +1481,16 @@ WebGLContext::GetContextAttributes(dom::
 NS_IMETHODIMP
 WebGLContext::MozGetUnderlyingParamString(uint32_t pname, nsAString& retval)
 {
     if (IsContextLost())
         return NS_OK;
 
     retval.SetIsVoid(true);
 
-    MakeContextCurrent();
-
     switch (pname) {
     case LOCAL_GL_VENDOR:
     case LOCAL_GL_RENDERER:
     case LOCAL_GL_VERSION:
     case LOCAL_GL_SHADING_LANGUAGE_VERSION:
     case LOCAL_GL_EXTENSIONS:
         {
             const char* s = (const char*)gl->fGetString(pname);
@@ -1509,17 +1503,16 @@ WebGLContext::MozGetUnderlyingParamStrin
     }
 
     return NS_OK;
 }
 
 void
 WebGLContext::ClearScreen()
 {
-    MakeContextCurrent();
     ScopedBindFramebuffer autoFB(gl, 0);
 
     const bool changeDrawBuffers = (mDefaultFB_DrawBuffer0 != LOCAL_GL_BACK);
     if (changeDrawBuffers) {
         gl->Screen()->SetDrawBuffer(LOCAL_GL_BACK);
     }
 
     GLbitfield bufferBits = LOCAL_GL_COLOR_BUFFER_BIT;
@@ -1534,18 +1527,16 @@ WebGLContext::ClearScreen()
         gl->Screen()->SetDrawBuffer(mDefaultFB_DrawBuffer0);
     }
 }
 
 void
 WebGLContext::ForceClearFramebufferWithDefaultValues(GLbitfield clearBits,
                                                      bool fakeNoAlpha)
 {
-    MakeContextCurrent();
-
     const bool initializeColorBuffer = bool(clearBits & LOCAL_GL_COLOR_BUFFER_BIT);
     const bool initializeDepthBuffer = bool(clearBits & LOCAL_GL_DEPTH_BUFFER_BIT);
     const bool initializeStencilBuffer = bool(clearBits & LOCAL_GL_STENCIL_BUFFER_BIT);
 
     // Fun GL fact: No need to worry about the viewport here, glViewport is just
     // setting up a coordinates transformation, it doesn't affect glClear at all.
     AssertCachedGlobalState();
 
@@ -1634,18 +1625,16 @@ WebGLContext::PresentScreenBuffer()
         return false;
     }
 
     if (!mShouldPresent) {
         return false;
     }
     MOZ_ASSERT(!mBackbufferNeedsClear);
 
-    gl->MakeCurrent();
-
     GLScreenBuffer* screen = gl->Screen();
     MOZ_ASSERT(screen);
 
     if (!screen->PublishFrame(screen->Size())) {
         ForceLoseContext();
         return false;
     }
 
@@ -1974,17 +1963,16 @@ WebGLContext::GetSurfaceSnapshot(gfxAlph
                                            : SurfaceFormat::B8G8R8X8;
     RefPtr<DataSourceSurface> surf;
     surf = Factory::CreateDataSourceSurfaceWithStride(IntSize(mWidth, mHeight),
                                                       surfFormat,
                                                       mWidth * 4);
     if (NS_WARN_IF(!surf))
         return nullptr;
 
-    gl->MakeCurrent();
     {
         ScopedBindFramebuffer autoFB(gl, 0);
         ClearBackbufferIfNeeded();
 
         // Save, override, then restore glReadBuffer.
         const GLenum readBufferMode = gl->Screen()->GetReadBufferMode();
 
         if (readBufferMode != LOCAL_GL_BACK) {
@@ -2437,17 +2425,16 @@ WebGLContext::ValidateArrayBufferView(co
     return true;
 }
 
 ////
 
 void
 WebGLContext::UpdateMaxDrawBuffers()
 {
-    gl->MakeCurrent();
     mGLMaxColorAttachments = gl->GetIntAs<uint32_t>(LOCAL_GL_MAX_COLOR_ATTACHMENTS);
     mGLMaxDrawBuffers = gl->GetIntAs<uint32_t>(LOCAL_GL_MAX_DRAW_BUFFERS);
 
     // WEBGL_draw_buffers:
     // "The value of the MAX_COLOR_ATTACHMENTS_WEBGL parameter must be greater than or
     //  equal to that of the MAX_DRAW_BUFFERS_WEBGL parameter."
     mGLMaxDrawBuffers = std::min(mGLMaxDrawBuffers, mGLMaxColorAttachments);
 }
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1702,18 +1702,16 @@ public:
                                  uint8_t** const out_bytes, size_t* const out_byteLen);
 
 protected:
     ////
 
     void Invalidate();
     void DestroyResourcesAndContext();
 
-    void MakeContextCurrent() const { } // MakeCurrent is implicit now.
-
     // helpers
 
     bool ConvertImage(size_t width, size_t height, size_t srcStride,
                       size_t dstStride, const uint8_t* src, uint8_t* dst,
                       WebGLTexelFormat srcFormat, bool srcPremultiplied,
                       WebGLTexelFormat dstFormat, bool dstPremultiplied,
                       size_t dstTexelSize);
 
--- a/dom/canvas/WebGLContextBuffers.cpp
+++ b/dom/canvas/WebGLContextBuffers.cpp
@@ -144,17 +144,16 @@ WebGLContext::BindBuffer(GLenum target, 
 
     const auto& slot = ValidateBufferSlot(funcName, target);
     if (!slot)
         return;
 
     if (buffer && !buffer->ValidateCanBindToTarget(funcName, target))
         return;
 
-    gl->MakeCurrent();
     gl->fBindBuffer(target, buffer ? buffer->mGLName : 0);
 
     WebGLBuffer::SetSlot(target, buffer, slot);
     if (buffer) {
         buffer->SetContentAfterBind(target);
     }
 
     switch (target) {
@@ -211,17 +210,16 @@ WebGLContext::BindBufferBase(GLenum targ
         return;
     }
 
     if (buffer && !buffer->ValidateCanBindToTarget(funcName, target))
         return;
 
     ////
 
-    gl->MakeCurrent();
     gl->fBindBufferBase(target, index, buffer ? buffer->mGLName : 0);
 
     ////
 
     WebGLBuffer::SetSlot(target, buffer, genericBinding);
     WebGLBuffer::SetSlot(target, buffer, &indexedBinding->mBufferBinding);
     indexedBinding->mRangeStart = 0;
     indexedBinding->mRangeSize = 0;
@@ -261,18 +259,16 @@ WebGLContext::BindBufferRange(GLenum tar
 
     if (buffer && !size) {
         ErrorInvalidValue("%s: size must be non-zero for non-null buffer.", funcName);
         return;
     }
 
     ////
 
-    gl->MakeCurrent();
-
     switch (target) {
     case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER:
         if (offset % 4 != 0 || size % 4 != 0) {
             ErrorInvalidValue("%s: For %s, `offset` and `size` must be multiples of 4.",
                               funcName, "TRANSFORM_FEEDBACK_BUFFER");
             return;
         }
         break;
@@ -443,17 +439,16 @@ WebGLContext::BufferSubData(GLenum targe
 
 already_AddRefed<WebGLBuffer>
 WebGLContext::CreateBuffer()
 {
     if (IsContextLost())
         return nullptr;
 
     GLuint buf = 0;
-    MakeContextCurrent();
     gl->fGenBuffers(1, &buf);
 
     RefPtr<WebGLBuffer> globj = new WebGLBuffer(this, buf);
     return globj.forget();
 }
 
 void
 WebGLContext::DeleteBuffer(WebGLBuffer* buffer)
@@ -504,13 +499,12 @@ WebGLContext::DeleteBuffer(WebGLBuffer* 
 }
 
 bool
 WebGLContext::IsBuffer(WebGLBuffer* buffer)
 {
     if (!ValidateIsObject("isBuffer", buffer))
         return false;
 
-    MakeContextCurrent();
     return gl->fIsBuffer(buffer->mGLName);
 }
 
 } // namespace mozilla
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -516,18 +516,16 @@ WebGLContext::DrawArrays_check(const cha
 void
 WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount,
                                   GLsizei instanceCount, const char* const funcName)
 {
     AUTO_PROFILER_LABEL("WebGLContext::DrawArraysInstanced", GRAPHICS);
     if (IsContextLost())
         return;
 
-    MakeContextCurrent();
-
     bool error = false;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
     if (error)
         return;
 
     Maybe<uint32_t> lastVert;
     if (!DrawArrays_check(funcName, first, vertCount, instanceCount, &lastVert))
         return;
@@ -674,18 +672,16 @@ void
 WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei indexCount, GLenum type,
                                     WebGLintptr byteOffset, GLsizei instanceCount,
                                     const char* const funcName)
 {
     AUTO_PROFILER_LABEL("WebGLContext::DrawElementsInstanced", GRAPHICS);
     if (IsContextLost())
         return;
 
-    MakeContextCurrent();
-
     bool error = false;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
     if (error)
         return;
 
     Maybe<uint32_t> lastVert;
     if (!DrawElements_check(funcName, indexCount, type, byteOffset, instanceCount,
                             &lastVert))
@@ -994,13 +990,12 @@ WebGLContext::FakeBlackTexture::Create(g
 WebGLContext::FakeBlackTexture::FakeBlackTexture(gl::GLContext* gl)
     : mGL(gl)
     , mGLName(CreateGLTexture(gl))
 {
 }
 
 WebGLContext::FakeBlackTexture::~FakeBlackTexture()
 {
-    mGL->MakeCurrent();
     mGL->fDeleteTextures(1, &mGLName);
 }
 
 } // namespace mozilla
--- a/dom/canvas/WebGLContextFramebufferOperations.cpp
+++ b/dom/canvas/WebGLContextFramebufferOperations.cpp
@@ -15,18 +15,16 @@ namespace mozilla {
 void
 WebGLContext::Clear(GLbitfield mask)
 {
     const char funcName[] = "clear";
 
     if (IsContextLost())
         return;
 
-    MakeContextCurrent();
-
     uint32_t m = mask & (LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT | LOCAL_GL_STENCIL_BUFFER_BIT);
     if (mask != m)
         return ErrorInvalidValue("%s: invalid mask bits", funcName);
 
     if (mask == 0) {
         GenerateWarning("Calling gl.clear(0) has no effect.");
     } else if (mRasterizerDiscardEnabled) {
         GenerateWarning("Calling gl.clear() with RASTERIZER_DISCARD enabled has no effects.");
@@ -74,18 +72,16 @@ GLClampFloat(GLfloat val)
 }
 
 void
 WebGLContext::ClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
 {
     if (IsContextLost())
         return;
 
-    MakeContextCurrent();
-
     const bool supportsFloatColorBuffers = (IsExtensionEnabled(WebGLExtensionID::EXT_color_buffer_float) ||
                                             IsExtensionEnabled(WebGLExtensionID::EXT_color_buffer_half_float) ||
                                             IsExtensionEnabled(WebGLExtensionID::WEBGL_color_buffer_float));
     if (!supportsFloatColorBuffers) {
         r = GLClampFloat(r);
         g = GLClampFloat(g);
         b = GLClampFloat(b);
         a = GLClampFloat(a);
@@ -100,53 +96,49 @@ WebGLContext::ClearColor(GLfloat r, GLfl
 }
 
 void
 WebGLContext::ClearDepth(GLclampf v)
 {
     if (IsContextLost())
         return;
 
-    MakeContextCurrent();
     mDepthClearValue = GLClampFloat(v);
     gl->fClearDepth(mDepthClearValue);
 }
 
 void
 WebGLContext::ClearStencil(GLint v)
 {
     if (IsContextLost())
         return;
 
-    MakeContextCurrent();
     mStencilClearValue = v;
     gl->fClearStencil(v);
 }
 
 void
 WebGLContext::ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboolean a)
 {
     if (IsContextLost())
         return;
 
-    MakeContextCurrent();
     mColorWriteMask[0] = r;
     mColorWriteMask[1] = g;
     mColorWriteMask[2] = b;
     mColorWriteMask[3] = a;
     gl->fColorMask(r, g, b, a);
 }
 
 void
 WebGLContext::DepthMask(WebGLboolean b)
 {
     if (IsContextLost())
         return;
 
-    MakeContextCurrent();
     mDepthWriteMask = b;
     gl->fDepthMask(b);
 }
 
 void
 WebGLContext::DrawBuffers(const dom::Sequence<GLenum>& buffers)
 {
     const char funcName[] = "drawBuffers";
@@ -190,17 +182,16 @@ void
 WebGLContext::StencilMask(GLuint mask)
 {
     if (IsContextLost())
         return;
 
     mStencilWriteMaskFront = mask;
     mStencilWriteMaskBack = mask;
 
-    MakeContextCurrent();
     gl->fStencilMask(mask);
 }
 
 void
 WebGLContext::StencilMaskSeparate(GLenum face, GLuint mask)
 {
     if (IsContextLost())
         return;
@@ -216,13 +207,12 @@ WebGLContext::StencilMaskSeparate(GLenum
         case LOCAL_GL_FRONT:
             mStencilWriteMaskFront = mask;
             break;
         case LOCAL_GL_BACK:
             mStencilWriteMaskBack = mask;
             break;
     }
 
-    MakeContextCurrent();
     gl->fStencilMaskSeparate(face, mask);
 }
 
 } // namespace mozilla
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -88,17 +88,16 @@ WebGLContext::ActiveTexture(GLenum textu
     {
         return ErrorInvalidEnum(
             "ActiveTexture: texture unit %d out of range. "
             "Accepted values range from TEXTURE0 to TEXTURE0 + %d. "
             "Notice that TEXTURE0 != 0.",
             texture, mGLMaxTextureUnits);
     }
 
-    MakeContextCurrent();
     mActiveTexture = texture - LOCAL_GL_TEXTURE0;
     gl->fActiveTexture(texture);
 }
 
 void
 WebGLContext::AttachShader(WebGLProgram& program, WebGLShader& shader)
 {
     if (IsContextLost())
@@ -133,18 +132,16 @@ WebGLContext::BindFramebuffer(GLenum tar
         return;
 
     if (!ValidateFramebufferTarget(target, "bindFramebuffer"))
         return;
 
     if (wfb && !ValidateObject("bindFramebuffer", *wfb))
         return;
 
-    MakeContextCurrent();
-
     if (!wfb) {
         gl->fBindFramebuffer(target, 0);
     } else {
         GLuint framebuffername = wfb->mGLName;
         gl->fBindFramebuffer(target, framebuffername);
 #ifdef ANDROID
         wfb->mIsFB = true;
 #endif
@@ -193,30 +190,28 @@ WebGLContext::BindRenderbuffer(GLenum ta
 void WebGLContext::BlendEquation(GLenum mode)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateBlendEquationEnum(mode, "blendEquation: mode"))
         return;
 
-    MakeContextCurrent();
     gl->fBlendEquation(mode);
 }
 
 void WebGLContext::BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateBlendEquationEnum(modeRGB, "blendEquationSeparate: modeRGB") ||
         !ValidateBlendEquationEnum(modeAlpha, "blendEquationSeparate: modeAlpha"))
         return;
 
-    MakeContextCurrent();
     gl->fBlendEquationSeparate(modeRGB, modeAlpha);
 }
 
 static bool
 ValidateBlendFuncEnum(WebGLContext* webgl, GLenum factor, const char* funcName, const char* varName)
 {
     switch (factor) {
     case LOCAL_GL_ZERO:
@@ -275,17 +270,16 @@ void WebGLContext::BlendFunc(GLenum sfac
         return;
 
     if (!ValidateBlendFuncEnums(this, sfactor, sfactor, dfactor, dfactor, "blendFunc"))
        return;
 
     if (!ValidateBlendFuncEnumsCompatibility(sfactor, dfactor, "blendFuncSeparate: srcRGB and dstRGB"))
         return;
 
-    MakeContextCurrent();
     gl->fBlendFunc(sfactor, dfactor);
 }
 
 void
 WebGLContext::BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
                                 GLenum srcAlpha, GLenum dstAlpha)
 {
     if (IsContextLost())
@@ -294,17 +288,16 @@ WebGLContext::BlendFuncSeparate(GLenum s
     if (!ValidateBlendFuncEnums(this, srcRGB, srcAlpha, dstRGB, dstAlpha, "blendFuncSeparate"))
        return;
 
     // note that we only check compatibity for the RGB enums, no need to for the Alpha enums, see
     // "Section 6.8 forgetting to mention alpha factors?" thread on the public_webgl mailing list
     if (!ValidateBlendFuncEnumsCompatibility(srcRGB, dstRGB, "blendFuncSeparate: srcRGB and dstRGB"))
         return;
 
-    MakeContextCurrent();
     gl->fBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
 }
 
 GLenum
 WebGLContext::CheckFramebufferStatus(GLenum target)
 {
     const char funcName[] = "checkFramebufferStatus";
     if (IsContextLost())
@@ -364,17 +357,16 @@ void
 WebGLContext::CullFace(GLenum face)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateFaceEnum(face, "cullFace"))
         return;
 
-    MakeContextCurrent();
     gl->fCullFace(face);
 }
 
 void
 WebGLContext::DeleteFramebuffer(WebGLFramebuffer* fbuf)
 {
     if (!ValidateDeleteObject("deleteFramebuffer", fbuf))
         return;
@@ -484,30 +476,28 @@ void
 WebGLContext::DepthFunc(GLenum func)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateComparisonEnum(func, "depthFunc"))
         return;
 
-    MakeContextCurrent();
     gl->fDepthFunc(func);
 }
 
 void
 WebGLContext::DepthRange(GLfloat zNear, GLfloat zFar)
 {
     if (IsContextLost())
         return;
 
     if (zNear > zFar)
         return ErrorInvalidOperation("depthRange: the near value is greater than the far value!");
 
-    MakeContextCurrent();
     gl->fDepthRange(zNear, zFar);
 }
 
 void
 WebGLContext::FramebufferRenderbuffer(GLenum target, GLenum attachment,
                                       GLenum rbtarget, WebGLRenderbuffer* wrb)
 {
     const char funcName[] = "framebufferRenderbuffer";
@@ -582,17 +572,16 @@ WebGLContext::FrontFace(GLenum mode)
     switch (mode) {
         case LOCAL_GL_CW:
         case LOCAL_GL_CCW:
             break;
         default:
             return ErrorInvalidEnumInfo("frontFace: mode", mode);
     }
 
-    MakeContextCurrent();
     gl->fFrontFace(mode);
 }
 
 already_AddRefed<WebGLActiveInfo>
 WebGLContext::GetActiveAttrib(const WebGLProgram& prog, GLuint index)
 {
     if (IsContextLost())
         return nullptr;
@@ -696,18 +685,16 @@ WebGLContext::GetFramebufferAttachmentPa
     case LOCAL_GL_READ_FRAMEBUFFER:
         fb = mBoundReadFramebuffer;
         break;
 
     default:
         MOZ_CRASH("GFX: Bad target.");
     }
 
-    MakeContextCurrent();
-
     if (fb)
         return fb->GetAttachmentParameter(funcName, cx, target, attachment, pname, &rv);
 
     ////////////////////////////////////
 
     if (!IsWebGL2()) {
         ErrorInvalidOperation("%s: Querying against the default framebuffer is not"
                               " allowed in WebGL 1.",
@@ -836,18 +823,16 @@ WebGLContext::GetRenderbufferParameter(G
         return JS::NullValue();
     }
 
     if (!mBoundRenderbuffer) {
         ErrorInvalidOperation("getRenderbufferParameter: no render buffer is bound");
         return JS::NullValue();
     }
 
-    MakeContextCurrent();
-
     switch (pname) {
     case LOCAL_GL_RENDERBUFFER_SAMPLES:
         if (!IsWebGL2())
             break;
         MOZ_FALLTHROUGH;
 
     case LOCAL_GL_RENDERBUFFER_WIDTH:
     case LOCAL_GL_RENDERBUFFER_HEIGHT:
@@ -874,17 +859,16 @@ WebGLContext::GetRenderbufferParameter(G
 
 already_AddRefed<WebGLTexture>
 WebGLContext::CreateTexture()
 {
     if (IsContextLost())
         return nullptr;
 
     GLuint tex = 0;
-    MakeContextCurrent();
     gl->fGenTextures(1, &tex);
 
     RefPtr<WebGLTexture> globj = new WebGLTexture(this, tex);
     return globj.forget();
 }
 
 static GLenum
 GetAndClearError(GLenum* errorVar)
@@ -924,17 +908,16 @@ WebGLContext::GetError()
         return err;
 
     if (IsContextLost())
         return LOCAL_GL_NO_ERROR;
 
     // Either no WebGL-side error, or it's already been cleared.
     // UnderlyingGL-side errors, now.
 
-    MakeContextCurrent();
     GetAndFlushUnderlyingGLErrors();
 
     err = GetAndClearError(&mUnderlyingGLError);
     return err;
 }
 
 JS::Value
 WebGLContext::GetProgramParameter(const WebGLProgram& prog, GLenum pname)
@@ -1019,17 +1002,16 @@ WebGLContext::Hint(GLenum target, GLenum
             isValid = true;
         }
         break;
     }
 
     if (!isValid)
         return ErrorInvalidEnum("hint: invalid hint");
 
-    MakeContextCurrent();
     gl->fHint(target, mode);
 }
 
 bool
 WebGLContext::IsFramebuffer(const WebGLFramebuffer* fb)
 {
     if (!ValidateIsObject("isFramebuffer", fb))
         return false;
@@ -1037,17 +1019,16 @@ WebGLContext::IsFramebuffer(const WebGLF
 #ifdef ANDROID
     if (gl->WorkAroundDriverBugs() &&
         gl->Renderer() == GLRenderer::AndroidEmulator)
     {
         return fb->mIsFB;
     }
 #endif
 
-    MakeContextCurrent();
     return gl->fIsFramebuffer(fb->mGLName);
 }
 
 bool
 WebGLContext::IsProgram(const WebGLProgram* prog)
 {
     if (!ValidateIsObject("isProgram", prog))
         return false;
@@ -1144,17 +1125,16 @@ WebGLContext::PixelStorei(GLenum pname, 
         }
 
         if (pValueSlot) {
             if (param < 0) {
                 ErrorInvalidValue("pixelStorei: param must be >= 0.");
                 return;
             }
 
-            MakeContextCurrent();
             gl->fPixelStorei(pname, param);
             *pValueSlot = param;
             return;
         }
     }
 
     switch (pname) {
     case UNPACK_FLIP_Y_WEBGL:
@@ -1192,17 +1172,16 @@ WebGLContext::PixelStorei(GLenum pname, 
         case 2:
         case 4:
         case 8:
             if (pname == LOCAL_GL_PACK_ALIGNMENT)
                 mPixelStore_PackAlignment = param;
             else if (pname == LOCAL_GL_UNPACK_ALIGNMENT)
                 mPixelStore_UnpackAlignment = param;
 
-            MakeContextCurrent();
             gl->fPixelStorei(pname, param);
             return;
 
         default:
             ErrorInvalidValue("pixelStorei: invalid pack/unpack alignment value");
             return;
         }
 
@@ -1436,17 +1415,16 @@ WebGLContext::ReadPixels(GLint x, GLint 
     const auto bytesAvailable = buffer->ByteLength();
     const auto checkedBytesAfterOffset = CheckedUint32(bytesAvailable) - offset;
 
     uint32_t bytesAfterOffset = 0;
     if (checkedBytesAfterOffset.isValid()) {
         bytesAfterOffset = checkedBytesAfterOffset.value();
     }
 
-    gl->MakeCurrent();
     const ScopedLazyBind lazyBind(gl, LOCAL_GL_PIXEL_PACK_BUFFER, buffer);
 
     ReadPixelsImpl(x, y, width, height, format, type, (void*)offset, bytesAfterOffset);
 }
 
 static webgl::PackingInfo
 DefaultReadPixelPI(const webgl::FormatUsageInfo* usage)
 {
@@ -1573,18 +1551,16 @@ WebGLContext::ReadPixelsImpl(GLint x, GL
         return;
     }
 
     const uint32_t width(rawWidth);
     const uint32_t height(rawHeight);
 
     //////
 
-    MakeContextCurrent();
-
     const webgl::FormatUsageInfo* srcFormat;
     uint32_t srcWidth;
     uint32_t srcHeight;
     if (!ValidateCurFBForRead("readPixels", &srcFormat, &srcWidth, &srcHeight))
         return;
 
     //////
 
@@ -1727,17 +1703,16 @@ void
 WebGLContext::Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
 {
     if (IsContextLost())
         return;
 
     if (width < 0 || height < 0)
         return ErrorInvalidValue("scissor: negative size");
 
-    MakeContextCurrent();
     gl->fScissor(x, y, width, height);
 }
 
 void
 WebGLContext::StencilFunc(GLenum func, GLint ref, GLuint mask)
 {
     if (IsContextLost())
         return;
@@ -1745,17 +1720,16 @@ WebGLContext::StencilFunc(GLenum func, G
     if (!ValidateComparisonEnum(func, "stencilFunc: func"))
         return;
 
     mStencilRefFront = ref;
     mStencilRefBack = ref;
     mStencilValueMaskFront = mask;
     mStencilValueMaskBack = mask;
 
-    MakeContextCurrent();
     gl->fStencilFunc(func, ref, mask);
 }
 
 void
 WebGLContext::StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
 {
     if (IsContextLost())
         return;
@@ -1776,48 +1750,45 @@ WebGLContext::StencilFuncSeparate(GLenum
             mStencilValueMaskFront = mask;
             break;
         case LOCAL_GL_BACK:
             mStencilRefBack = ref;
             mStencilValueMaskBack = mask;
             break;
     }
 
-    MakeContextCurrent();
     gl->fStencilFuncSeparate(face, func, ref, mask);
 }
 
 void
 WebGLContext::StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateStencilOpEnum(sfail, "stencilOp: sfail") ||
         !ValidateStencilOpEnum(dpfail, "stencilOp: dpfail") ||
         !ValidateStencilOpEnum(dppass, "stencilOp: dppass"))
         return;
 
-    MakeContextCurrent();
     gl->fStencilOp(sfail, dpfail, dppass);
 }
 
 void
 WebGLContext::StencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateFaceEnum(face, "stencilOpSeparate: face") ||
         !ValidateStencilOpEnum(sfail, "stencilOpSeparate: sfail") ||
         !ValidateStencilOpEnum(dpfail, "stencilOpSeparate: dpfail") ||
         !ValidateStencilOpEnum(dppass, "stencilOpSeparate: dppass"))
         return;
 
-    MakeContextCurrent();
     gl->fStencilOpSeparate(face, sfail, dpfail, dppass);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Uniform setters.
 
 class ValidateIfSampler
 {
@@ -1880,99 +1851,91 @@ WebGLContext::Uniform1i(WebGLUniformLoca
     if (!ValidateUniformSetter(loc, 1, LOCAL_GL_INT, funcName))
         return;
 
     bool error;
     const ValidateIfSampler validate(this, funcName, loc, 1, &a1, &error);
     if (error)
         return;
 
-    MakeContextCurrent();
     gl->fUniform1i(loc->mLoc, a1);
 }
 
 void
 WebGLContext::Uniform2i(WebGLUniformLocation* loc, GLint a1, GLint a2)
 {
     const char funcName[] = "uniform2i";
     if (!ValidateUniformSetter(loc, 2, LOCAL_GL_INT, funcName))
         return;
 
-    MakeContextCurrent();
     gl->fUniform2i(loc->mLoc, a1, a2);
 }
 
 void
 WebGLContext::Uniform3i(WebGLUniformLocation* loc, GLint a1, GLint a2, GLint a3)
 {
     const char funcName[] = "uniform3i";
     if (!ValidateUniformSetter(loc, 3, LOCAL_GL_INT, funcName))
         return;
 
-    MakeContextCurrent();
     gl->fUniform3i(loc->mLoc, a1, a2, a3);
 }
 
 void
 WebGLContext::Uniform4i(WebGLUniformLocation* loc, GLint a1, GLint a2, GLint a3,
                         GLint a4)
 {
     const char funcName[] = "uniform4i";
     if (!ValidateUniformSetter(loc, 4, LOCAL_GL_INT, funcName))
         return;
 
-    MakeContextCurrent();
     gl->fUniform4i(loc->mLoc, a1, a2, a3, a4);
 }
 
 //////////
 
 void
 WebGLContext::Uniform1f(WebGLUniformLocation* loc, GLfloat a1)
 {
     const char funcName[] = "uniform1f";
     if (!ValidateUniformSetter(loc, 1, LOCAL_GL_FLOAT, funcName))
         return;
 
-    MakeContextCurrent();
     gl->fUniform1f(loc->mLoc, a1);
 }
 
 void
 WebGLContext::Uniform2f(WebGLUniformLocation* loc, GLfloat a1, GLfloat a2)
 {
     const char funcName[] = "uniform2f";
     if (!ValidateUniformSetter(loc, 2, LOCAL_GL_FLOAT, funcName))
         return;
 
-    MakeContextCurrent();
     gl->fUniform2f(loc->mLoc, a1, a2);
 }
 
 void
 WebGLContext::Uniform3f(WebGLUniformLocation* loc, GLfloat a1, GLfloat a2,
                         GLfloat a3)
 {
     const char funcName[] = "uniform3f";
     if (!ValidateUniformSetter(loc, 3, LOCAL_GL_FLOAT, funcName))
         return;
 
-    MakeContextCurrent();
     gl->fUniform3f(loc->mLoc, a1, a2, a3);
 }
 
 void
 WebGLContext::Uniform4f(WebGLUniformLocation* loc, GLfloat a1, GLfloat a2,
                         GLfloat a3, GLfloat a4)
 {
     const char funcName[] = "uniform4f";
     if (!ValidateUniformSetter(loc, 4, LOCAL_GL_FLOAT, funcName))
         return;
 
-    MakeContextCurrent();
     gl->fUniform4f(loc->mLoc, a1, a2, a3, a4);
 }
 
 ////////////////////////////////////////
 // Array
 
 static bool
 ValidateArrOffsetAndCount(WebGLContext* webgl, const char* funcName, size_t elemsAvail,
@@ -2025,17 +1988,16 @@ WebGLContext::UniformNiv(const char* fun
     static const decltype(&gl::GLContext::fUniform1iv) kFuncList[] = {
         &gl::GLContext::fUniform1iv,
         &gl::GLContext::fUniform2iv,
         &gl::GLContext::fUniform3iv,
         &gl::GLContext::fUniform4iv
     };
     const auto func = kFuncList[N-1];
 
-    MakeContextCurrent();
     (gl->*func)(loc->mLoc, numElementsToUpload, elemBytes);
 }
 
 void
 WebGLContext::UniformNuiv(const char* funcName, uint8_t N, WebGLUniformLocation* loc,
                           const Uint32Arr& arr, GLuint elemOffset,
                           GLuint elemCountOverride)
 {
@@ -2058,17 +2020,16 @@ WebGLContext::UniformNuiv(const char* fu
     static const decltype(&gl::GLContext::fUniform1uiv) kFuncList[] = {
         &gl::GLContext::fUniform1uiv,
         &gl::GLContext::fUniform2uiv,
         &gl::GLContext::fUniform3uiv,
         &gl::GLContext::fUniform4uiv
     };
     const auto func = kFuncList[N-1];
 
-    MakeContextCurrent();
     (gl->*func)(loc->mLoc, numElementsToUpload, elemBytes);
 }
 
 void
 WebGLContext::UniformNfv(const char* funcName, uint8_t N, WebGLUniformLocation* loc,
                          const Float32Arr& arr, GLuint elemOffset,
                          GLuint elemCountOverride)
 {
@@ -2091,17 +2052,16 @@ WebGLContext::UniformNfv(const char* fun
     static const decltype(&gl::GLContext::fUniform1fv) kFuncList[] = {
         &gl::GLContext::fUniform1fv,
         &gl::GLContext::fUniform2fv,
         &gl::GLContext::fUniform3fv,
         &gl::GLContext::fUniform4fv
     };
     const auto func = kFuncList[N-1];
 
-    MakeContextCurrent();
     (gl->*func)(loc->mLoc, numElementsToUpload, elemBytes);
 }
 
 static inline void
 MatrixAxBToRowMajor(const uint8_t width, const uint8_t height,
                     const float* __restrict srcColMajor,
                     float* __restrict dstRowMajor)
 {
@@ -2179,17 +2139,16 @@ WebGLContext::UniformMatrixAxBfv(const c
         &gl::GLContext::fUniformMatrix3x4fv,
 
         &gl::GLContext::fUniformMatrix4x2fv,
         &gl::GLContext::fUniformMatrix4x3fv,
         &gl::GLContext::fUniformMatrix4fv
     };
     const auto func = kFuncList[3*(A-2) + (B-2)];
 
-    MakeContextCurrent();
     (gl->*func)(loc->mLoc, numMatsToUpload, uploadTranspose, uploadBytes);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 void
 WebGLContext::UseProgram(WebGLProgram* prog)
 {
@@ -2225,47 +2184,44 @@ WebGLContext::ValidateProgram(const WebG
 
 already_AddRefed<WebGLFramebuffer>
 WebGLContext::CreateFramebuffer()
 {
     if (IsContextLost())
         return nullptr;
 
     GLuint fbo = 0;
-    MakeContextCurrent();
     gl->fGenFramebuffers(1, &fbo);
 
     RefPtr<WebGLFramebuffer> globj = new WebGLFramebuffer(this, fbo);
     return globj.forget();
 }
 
 already_AddRefed<WebGLRenderbuffer>
 WebGLContext::CreateRenderbuffer()
 {
     if (IsContextLost())
         return nullptr;
 
-    MakeContextCurrent();
     RefPtr<WebGLRenderbuffer> globj = new WebGLRenderbuffer(this);
     return globj.forget();
 }
 
 void
 WebGLContext::Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
 {
     if (IsContextLost())
         return;
 
     if (width < 0 || height < 0)
         return ErrorInvalidValue("viewport: negative size");
 
     width = std::min(width, (GLsizei)mGLMaxViewportDims[0]);
     height = std::min(height, (GLsizei)mGLMaxViewportDims[1]);
 
-    MakeContextCurrent();
     gl->fViewport(x, y, width, height);
 
     mViewportX = x;
     mViewportY = y;
     mViewportWidth = width;
     mViewportHeight = height;
 }
 
@@ -2330,17 +2286,16 @@ WebGLContext::GetShaderPrecisionFormat(G
         case LOCAL_GL_MEDIUM_INT:
         case LOCAL_GL_HIGH_INT:
             break;
         default:
             ErrorInvalidEnumInfo("getShaderPrecisionFormat: precisiontype", precisiontype);
             return nullptr;
     }
 
-    MakeContextCurrent();
     GLint range[2], precision;
 
     if (mDisableFragHighP &&
         shadertype == LOCAL_GL_FRAGMENT_SHADER &&
         (precisiontype == LOCAL_GL_HIGH_FLOAT ||
          precisiontype == LOCAL_GL_HIGH_INT))
     {
       precision = 0;
@@ -2406,36 +2361,39 @@ WebGLContext::RestoreContext()
 
     if (!mAllowContextRestore)
         return ErrorInvalidOperation("restoreContext: Context cannot be restored.");
 
     ForceRestoreContext();
 }
 
 void
-WebGLContext::BlendColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
+WebGLContext::BlendColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
+{
     if (IsContextLost())
         return;
-    MakeContextCurrent();
+
     gl->fBlendColor(r, g, b, a);
 }
 
 void
-WebGLContext::Flush() {
+WebGLContext::Flush()
+{
     if (IsContextLost())
         return;
-    MakeContextCurrent();
+
     gl->fFlush();
 }
 
 void
-WebGLContext::Finish() {
+WebGLContext::Finish()
+{
     if (IsContextLost())
         return;
-    MakeContextCurrent();
+
     gl->fFinish();
 }
 
 void
 WebGLContext::LineWidth(GLfloat width)
 {
     if (IsContextLost())
         return;
@@ -2448,29 +2406,30 @@ WebGLContext::LineWidth(GLfloat width)
     }
 
     mLineWidth = width;
 
     if (gl->IsCoreProfile() && width > 1.0) {
         width = 1.0;
     }
 
-    MakeContextCurrent();
     gl->fLineWidth(width);
 }
 
 void
-WebGLContext::PolygonOffset(GLfloat factor, GLfloat units) {
+WebGLContext::PolygonOffset(GLfloat factor, GLfloat units)
+{
     if (IsContextLost())
         return;
-    MakeContextCurrent();
+
     gl->fPolygonOffset(factor, units);
 }
 
 void
-WebGLContext::SampleCoverage(GLclampf value, WebGLboolean invert) {
+WebGLContext::SampleCoverage(GLclampf value, WebGLboolean invert)
+{
     if (IsContextLost())
         return;
-    MakeContextCurrent();
+
     gl->fSampleCoverage(value, invert);
 }
 
 } // namespace mozilla
--- a/dom/canvas/WebGLContextState.cpp
+++ b/dom/canvas/WebGLContextState.cpp
@@ -32,17 +32,16 @@ WebGLContext::Disable(GLenum cap)
 
     realGLboolean* trackingSlot = GetStateTrackingSlot(cap);
 
     if (trackingSlot)
     {
         *trackingSlot = 0;
     }
 
-    MakeContextCurrent();
     gl->fDisable(cap);
 }
 
 void
 WebGLContext::Enable(GLenum cap)
 {
     if (IsContextLost())
         return;
@@ -52,17 +51,16 @@ WebGLContext::Enable(GLenum cap)
 
     realGLboolean* trackingSlot = GetStateTrackingSlot(cap);
 
     if (trackingSlot)
     {
         *trackingSlot = 1;
     }
 
-    MakeContextCurrent();
     gl->fEnable(cap);
 }
 
 bool
 WebGLContext::GetStencilBits(GLint* const out_stencilBits)
 {
     *out_stencilBits = 0;
     if (mBoundDrawFramebuffer) {
@@ -174,18 +172,16 @@ WebGLContext::GetChannelBits(const char*
 JS::Value
 WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
 {
     const char funcName[] = "getParameter";
 
     if (IsContextLost())
         return JS::NullValue();
 
-    MakeContextCurrent();
-
     if (IsWebGL2() || IsExtensionEnabled(WebGLExtensionID::WEBGL_draw_buffers)) {
         if (pname == LOCAL_GL_MAX_COLOR_ATTACHMENTS) {
             return JS::Int32Value(mGLMaxColorAttachments);
 
         } else if (pname == LOCAL_GL_MAX_DRAW_BUFFERS) {
             return JS::Int32Value(mGLMaxDrawBuffers);
 
         } else if (pname >= LOCAL_GL_DRAW_BUFFER0 &&
@@ -612,18 +608,16 @@ void
 WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index,
                                   JS::MutableHandle<JS::Value> retval)
 {
     if (IsContextLost()) {
         retval.setNull();
         return;
     }
 
-    MakeContextCurrent();
-
     switch (pname) {
         case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
         {
             if (index >= mGLMaxTransformFeedbackSeparateAttribs) {
                 ErrorInvalidValue("getParameterIndexed: index should be less than MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS");
                 retval.setNull();
                 return;
             }
@@ -643,17 +637,16 @@ bool
 WebGLContext::IsEnabled(GLenum cap)
 {
     if (IsContextLost())
         return false;
 
     if (!ValidateCapabilityEnum(cap, "isEnabled"))
         return false;
 
-    MakeContextCurrent();
     return gl->fIsEnabled(cap);
 }
 
 bool
 WebGLContext::ValidateCapabilityEnum(GLenum cap, const char* info)
 {
     switch (cap) {
         case LOCAL_GL_BLEND:
--- a/dom/canvas/WebGLContextTextures.cpp
+++ b/dom/canvas/WebGLContextTextures.cpp
@@ -236,19 +236,16 @@ WebGLContext::BindTexture(GLenum rawTarg
     }
 
     if (!currentTexPtr) {
         ErrorInvalidEnumInfo("bindTexture: target", rawTarget);
         return;
     }
 
     const TexTarget texTarget(rawTarget);
-
-    MakeContextCurrent();
-
     if (newTex) {
         if (!newTex->BindTexture(texTarget))
             return;
     } else {
         gl->fBindTexture(texTarget.get(), 0);
     }
 
     *currentTexPtr = newTex;
--- a/dom/canvas/WebGLContextUtils.cpp
+++ b/dom/canvas/WebGLContextUtils.cpp
@@ -737,18 +737,16 @@ AssertUintParamCorrect(gl::GLContext*, G
 {
 }
 #endif
 
 void
 WebGLContext::AssertCachedBindings()
 {
 #ifdef DEBUG
-    MakeContextCurrent();
-
     GetAndFlushUnderlyingGLErrors();
 
     if (IsWebGL2() || IsExtensionEnabled(WebGLExtensionID::OES_vertex_array_object)) {
         GLuint bound = mBoundVertexArray ? mBoundVertexArray->GLName() : 0;
         AssertUintParamCorrect(gl, LOCAL_GL_VERTEX_ARRAY_BINDING, bound);
     }
 
     // Framebuffers
@@ -804,18 +802,16 @@ WebGLContext::AssertCachedBindings()
 
     // We do not check the renderbuffer binding, because we never rely on it matching.
 }
 
 void
 WebGLContext::AssertCachedGlobalState()
 {
 #ifdef DEBUG
-    MakeContextCurrent();
-
     GetAndFlushUnderlyingGLErrors();
 
     ////////////////
 
     // Draw state
     MOZ_ASSERT(gl->fIsEnabled(LOCAL_GL_DEPTH_TEST) == mDepthTestEnabled);
     MOZ_ASSERT(gl->fIsEnabled(LOCAL_GL_DITHER) == mDitherEnabled);
     MOZ_ASSERT_IF(IsWebGL2(),
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -481,18 +481,16 @@ WebGLContext::InitAndValidateGL(FailureR
 
     mBoundArrayBuffer = nullptr;
     mCurrentProgram = nullptr;
 
     mBoundDrawFramebuffer = nullptr;
     mBoundReadFramebuffer = nullptr;
     mBoundRenderbuffer = nullptr;
 
-    MakeContextCurrent();
-
     gl->GetUIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIBS, &mGLMaxVertexAttribs);
 
     if (mGLMaxVertexAttribs < 8) {
         const nsPrintfCString reason("GL_MAX_VERTEX_ATTRIBS: %d is < 8!",
                                      mGLMaxVertexAttribs);
         *out_failReason = { "FEATURE_FAILURE_WEBGL_V_ATRB", reason };
         return false;
     }
--- a/dom/canvas/WebGLContextVertexArray.cpp
+++ b/dom/canvas/WebGLContextVertexArray.cpp
@@ -16,18 +16,16 @@ void
 WebGLContext::BindVertexArray(WebGLVertexArray* array)
 {
     if (IsContextLost())
         return;
 
     if (array && !ValidateObject("bindVertexArrayObject", *array))
         return;
 
-    MakeContextCurrent();
-
     if (mBoundVertexArray) {
         mBoundVertexArray->AddBufferBindCounts(-1);
     }
 
     if (array == nullptr) {
         array = mDefaultVertexArray;
     }
 
@@ -42,17 +40,16 @@ WebGLContext::BindVertexArray(WebGLVerte
 already_AddRefed<WebGLVertexArray>
 WebGLContext::CreateVertexArray()
 {
     if (IsContextLost())
         return nullptr;
 
     RefPtr<WebGLVertexArray> globj = CreateVertexArrayImpl();
 
-    MakeContextCurrent();
     globj->GenVertexArray();
 
     return globj.forget();
 }
 
 WebGLVertexArray*
 WebGLContext::CreateVertexArrayImpl()
 {
@@ -72,13 +69,12 @@ WebGLContext::DeleteVertexArray(WebGLVer
 }
 
 bool
 WebGLContext::IsVertexArray(const WebGLVertexArray* array)
 {
     if (!ValidateIsObject("isVertexArray", array))
         return false;
 
-    MakeContextCurrent();
     return array->IsVertexArray();
 }
 
 } // namespace mozilla
--- a/dom/canvas/WebGLContextVertices.cpp
+++ b/dom/canvas/WebGLContextVertices.cpp
@@ -69,17 +69,16 @@ WebGLContext::VertexAttrib4f(GLuint inde
     if (IsContextLost())
         return;
 
     if (!ValidateAttribIndex(index, funcName))
         return;
 
     ////
 
-    gl->MakeCurrent();
     if (index || !gl->IsCompatibilityProfile()) {
         gl->fVertexAttrib4f(index, x, y, z, w);
     }
 
     ////
 
     mGenericVertexAttribTypes[index] = LOCAL_GL_FLOAT;
     mGenericVertexAttribTypeInvalidator.InvalidateCaches();
@@ -101,17 +100,16 @@ WebGL2Context::VertexAttribI4i(GLuint in
     if (IsContextLost())
         return;
 
     if (!ValidateAttribIndex(index, funcName))
         return;
 
     ////
 
-    gl->MakeCurrent();
     if (index || !gl->IsCompatibilityProfile()) {
         gl->fVertexAttribI4i(index, x, y, z, w);
     }
 
     ////
 
     mGenericVertexAttribTypes[index] = LOCAL_GL_INT;
     mGenericVertexAttribTypeInvalidator.InvalidateCaches();
@@ -133,17 +131,16 @@ WebGL2Context::VertexAttribI4ui(GLuint i
     if (IsContextLost())
         return;
 
     if (!ValidateAttribIndex(index, funcName))
         return;
 
     ////
 
-    gl->MakeCurrent();
     if (index || !gl->IsCompatibilityProfile()) {
         gl->fVertexAttribI4ui(index, x, y, z, w);
     }
 
     ////
 
     mGenericVertexAttribTypes[index] = LOCAL_GL_UNSIGNED_INT;
     mGenericVertexAttribTypeInvalidator.InvalidateCaches();
@@ -160,36 +157,32 @@ void
 WebGLContext::EnableVertexAttribArray(GLuint index)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateAttribIndex(index, "enableVertexAttribArray"))
         return;
 
-    MakeContextCurrent();
-
     gl->fEnableVertexAttribArray(index);
 
     MOZ_ASSERT(mBoundVertexArray);
     mBoundVertexArray->mAttribs[index].mEnabled = true;
     mBoundVertexArray->InvalidateCaches();
 }
 
 void
 WebGLContext::DisableVertexAttribArray(GLuint index)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateAttribIndex(index, "disableVertexAttribArray"))
         return;
 
-    MakeContextCurrent();
-
     if (index || !gl->IsCompatibilityProfile()) {
         gl->fDisableVertexAttribArray(index);
     }
 
     MOZ_ASSERT(mBoundVertexArray);
     mBoundVertexArray->mAttribs[index].mEnabled = false;
     mBoundVertexArray->InvalidateCaches();
 }
@@ -202,18 +195,16 @@ WebGLContext::GetVertexAttrib(JSContext*
     if (IsContextLost())
         return JS::NullValue();
 
     if (!ValidateAttribIndex(index, funcName))
         return JS::NullValue();
 
     MOZ_ASSERT(mBoundVertexArray);
 
-    MakeContextCurrent();
-
     switch (pname) {
     case LOCAL_GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
         return WebGLObjectAsJSValue(cx, mBoundVertexArray->mAttribs[index].mBuf.get(), rv);
 
     case LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE:
         return JS::Int32Value(mBoundVertexArray->mAttribs[index].Stride());
 
     case LOCAL_GL_VERTEX_ATTRIB_ARRAY_SIZE:
@@ -412,17 +403,16 @@ WebGLContext::VertexAttribAnyPointer(con
     if (!buffer && byteOffset) {
         ErrorInvalidOperation("%s: If ARRAY_BUFFER is null, byteOffset must be zero.",
                               funcName);
         return;
     }
 
     ////
 
-    gl->MakeCurrent();
     if (isFuncInt) {
         gl->fVertexAttribIPointer(index, size, type, stride,
                                   reinterpret_cast<void*>(byteOffset));
     } else {
         gl->fVertexAttribPointer(index, size, type, normalized, stride,
                                  reinterpret_cast<void*>(byteOffset));
     }
 
@@ -441,14 +431,12 @@ WebGLContext::VertexAttribDivisor(GLuint
 
     if (!ValidateAttribIndex(index, "vertexAttribDivisor"))
         return;
 
     MOZ_ASSERT(mBoundVertexArray);
     mBoundVertexArray->mAttribs[index].mDivisor = divisor;
     mBoundVertexArray->InvalidateCaches();
 
-    MakeContextCurrent();
-
     gl->fVertexAttribDivisor(index, divisor);
 }
 
 } // namespace mozilla
--- a/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
+++ b/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
@@ -112,17 +112,16 @@ WebGLExtensionDisjointTimerQuery::GetQue
         return;
 
     mContext->GetQueryParameter(cx, query, pname, retval, funcName);
 }
 
 bool
 WebGLExtensionDisjointTimerQuery::IsSupported(const WebGLContext* webgl)
 {
-    webgl->MakeContextCurrent();
     gl::GLContext* gl = webgl->GL();
     return gl->IsSupported(gl::GLFeature::query_objects) &&
            gl->IsSupported(gl::GLFeature::get_query_object_i64v) &&
            gl->IsSupported(gl::GLFeature::query_counter); // provides GL_TIMESTAMP
 }
 
 IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionDisjointTimerQuery, EXT_disjoint_timer_query)
 
--- a/dom/canvas/WebGLExtensionMOZDebug.cpp
+++ b/dom/canvas/WebGLExtensionMOZDebug.cpp
@@ -22,17 +22,16 @@ WebGLExtensionMOZDebug::~WebGLExtensionM
 }
 
 void
 WebGLExtensionMOZDebug::GetParameter(JSContext* cx, GLenum pname,
                                      JS::MutableHandle<JS::Value> retval,
                                      ErrorResult& er) const
 {
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
 
     switch (pname) {
     case LOCAL_GL_EXTENSIONS:
         {
             nsString ret;
             if (!gl->IsCoreProfile()) {
                 const auto rawExts = (const char*)gl->fGetString(LOCAL_GL_EXTENSIONS);
                 ret = NS_ConvertUTF8toUTF16(rawExts);
--- a/dom/canvas/WebGLExtensionSRGB.cpp
+++ b/dom/canvas/WebGLExtensionSRGB.cpp
@@ -16,17 +16,16 @@ WebGLExtensionSRGB::WebGLExtensionSRGB(W
     : WebGLExtensionBase(webgl)
 {
     MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
 
     gl::GLContext* gl = webgl->GL();
     if (!gl->IsGLES()) {
         // Desktop OpenGL requires the following to be enabled in order to
         // support sRGB operations on framebuffers.
-        gl->MakeCurrent();
         gl->fEnable(LOCAL_GL_FRAMEBUFFER_SRGB_EXT);
     }
 
     auto& fua = webgl->mFormatUsage;
 
     RefPtr<gl::GLContext> gl_ = gl; // Bug 1201275
     const auto fnAdd = [&fua, &gl_](webgl::EffectiveFormat effFormat, GLenum format,
                                     GLenum desktopUnpackFormat)
--- a/dom/canvas/WebGLFramebuffer.cpp
+++ b/dom/canvas/WebGLFramebuffer.cpp
@@ -650,17 +650,16 @@ WebGLFramebuffer::Delete()
     mDepthAttachment.Clear(funcName);
     mStencilAttachment.Clear(funcName);
     mDepthStencilAttachment.Clear(funcName);
 
     for (auto& cur : mColorAttachments) {
         cur.Clear(funcName);
     }
 
-    mContext->MakeContextCurrent();
     mContext->gl->fDeleteFramebuffers(1, &mGLName);
 
     LinkedListElement<WebGLFramebuffer>::removeFrom(mContext->mFramebuffers);
 
 #ifdef ANDROID
     mIsFB = false;
 #endif
 }
@@ -1082,18 +1081,16 @@ WebGLFramebuffer::ResolveAttachmentData(
             }
 
             mContext->gl->fDrawBuffers(enumList.size(), enumList.data());
         };
 
         ////
         // Clear
 
-        mContext->MakeContextCurrent();
-
         const bool hasDrawBuffers = mContext->HasDrawBuffers();
         if (hasDrawBuffers) {
             fnDrawBuffers(colorAttachmentsToClear);
         }
 
         {
             gl::ScopedBindFramebuffer autoBind(mContext->gl, mGLName);
 
@@ -1198,17 +1195,16 @@ WebGLFramebuffer::CheckFramebufferStatus
     nsCString statusInfo;
     FBStatus ret = PrecheckFramebufferStatus(&statusInfo);
     do {
         if (ret != LOCAL_GL_FRAMEBUFFER_COMPLETE)
             break;
 
         // Looks good on our end. Let's ask the driver.
         gl::GLContext* const gl = mContext->gl;
-        gl->MakeCurrent();
 
         const ScopedFBRebinder autoFB(mContext);
         gl->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mGLName);
 
         ////
 
         ResolveAttachments(); // OK, attach everything properly!
         RefreshDrawBuffers();
@@ -1328,18 +1324,16 @@ WebGLFramebuffer::DrawBuffers(const char
                                             " COLOR_ATTACHMENTi.",
                                             funcName);
             return;
         }
     }
 
     ////
 
-    mContext->MakeContextCurrent();
-
     mColorDrawBuffers.swap(newColorDrawBuffers);
     RefreshDrawBuffers(); // Calls glDrawBuffers.
     RefreshResolvedData();
 }
 
 void
 WebGLFramebuffer::ReadBuffer(const char* funcName, GLenum attachPoint)
 {
@@ -1353,18 +1347,16 @@ WebGLFramebuffer::ReadBuffer(const char*
             mContext->ErrorInvalidEnum(text, funcName);
         }
         return;
     }
     const auto& attach = maybeAttach.value(); // Might be nullptr.
 
     ////
 
-    mContext->MakeContextCurrent();
-
     mColorReadBuffer = attach;
     RefreshReadBuffer(); // Calls glReadBuffer.
     RefreshResolvedData();
 }
 
 ////
 
 void
@@ -1931,17 +1923,16 @@ WebGLFramebuffer::BlitFramebuffer(WebGLC
         }
     } else if (!srcFB && !dstFB) {
         webgl->ErrorInvalidOperation("%s: Feedback with default framebuffer.", funcName);
         return;
     }
 
     ////
 
-    gl->MakeCurrent();
     webgl->OnBeforeReadCall();
     WebGLContext::ScopedDrawCallWrapper wrapper(*webgl);
     gl->fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1,
                          dstX0, dstY0, dstX1, dstY1,
                          mask, filter);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/dom/canvas/WebGLProgram.cpp
+++ b/dom/canvas/WebGLProgram.cpp
@@ -555,43 +555,34 @@ webgl::LinkedProgramInfo::GetDrawFetchLi
     // --
 
     return mDrawFetchCache.Insert(vao.get(), Move(fetchLimits), Move(cacheDeps));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // WebGLProgram
 
-static GLuint
-CreateProgram(gl::GLContext* gl)
-{
-    gl->MakeCurrent();
-    return gl->fCreateProgram();
-}
-
 WebGLProgram::WebGLProgram(WebGLContext* webgl)
     : WebGLRefCountedObject(webgl)
-    , mGLName(CreateProgram(webgl->GL()))
+    , mGLName(webgl->gl->fCreateProgram())
     , mNumActiveTFOs(0)
     , mNextLink_TransformFeedbackBufferMode(LOCAL_GL_INTERLEAVED_ATTRIBS)
 {
     mContext->mPrograms.insertBack(this);
 }
 
 WebGLProgram::~WebGLProgram()
 {
     DeleteOnce();
 }
 
 void
 WebGLProgram::Delete()
 {
     gl::GLContext* gl = mContext->GL();
-
-    gl->MakeCurrent();
     gl->fDeleteProgram(mGLName);
 
     mVertShader = nullptr;
     mFragShader = nullptr;
 
     mMostRecentLinkInfo = nullptr;
 
     LinkedListElement<WebGLProgram>::removeFrom(mContext->mPrograms);
@@ -623,17 +614,16 @@ WebGLProgram::AttachShader(WebGLShader* 
             mContext->ErrorInvalidOperation("attachShader: Only one of each type of"
                                             " shader may be attached to a program.");
         }
         return;
     }
 
     *shaderSlot = shader;
 
-    mContext->MakeContextCurrent();
     mContext->gl->fAttachShader(mGLName, shader->mGLName);
 }
 
 void
 WebGLProgram::BindAttribLocation(GLuint loc, const nsAString& name)
 {
     if (!ValidateGLSLVariableName(name, mContext, "bindAttribLocation"))
         return;
@@ -681,17 +671,16 @@ WebGLProgram::DetachShader(const WebGLSh
 
     if (*shaderSlot != shader) {
         mContext->ErrorInvalidOperation("detachShader: `shader` is not attached.");
         return;
     }
 
     *shaderSlot = nullptr;
 
-    mContext->MakeContextCurrent();
     mContext->gl->fDetachShader(mGLName, shader->mGLName);
 }
 
 already_AddRefed<WebGLActiveInfo>
 WebGLProgram::GetActiveAttrib(GLuint index) const
 {
     if (!mMostRecentLinkInfo) {
         RefPtr<WebGLActiveInfo> ret = WebGLActiveInfo::CreateInvalid(mContext);
@@ -782,17 +771,16 @@ WebGLProgram::GetFragDataLocation(const 
 
     if (!IsLinked()) {
         mContext->ErrorInvalidOperation("getFragDataLocation: `program` must be linked.");
         return -1;
     }
 
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
 
     const NS_LossyConvertUTF16toASCII userName(userName_wide);
 #ifdef XP_MACOSX
     if (gl->WorkAroundDriverBugs()) {
         // OSX doesn't return locs for indexed names, just the base names.
         // Indicated by failure in: conformance2/programs/gl-get-frag-data-location.html
         bool isArray;
         size_t arrayIndex;
@@ -824,17 +812,16 @@ GetProgramiv(gl::GLContext* gl, GLuint p
     gl->fGetProgramiv(program, pname, &ret);
     return ret;
 }
 
 JS::Value
 WebGLProgram::GetProgramParameter(GLenum pname) const
 {
     gl::GLContext* gl = mContext->gl;
-    gl->MakeCurrent();
 
     if (mContext->IsWebGL2()) {
         switch (pname) {
         case LOCAL_GL_ACTIVE_UNIFORM_BLOCKS:
             if (!IsLinked())
                 return JS::NumberValue(0);
             return JS::NumberValue(LinkInfo()->uniformBlocks.size());
 
@@ -907,17 +894,16 @@ WebGLProgram::GetUniformBlockIndex(const
         }
     }
     if (!info)
         return LOCAL_GL_INVALID_INDEX;
 
     const auto& mappedName = info->mMappedName;
 
     gl::GLContext* gl = mContext->GL();
-    gl->MakeCurrent();
     return gl->fGetUniformBlockIndex(mGLName, mappedName.BeginReading());
 }
 
 void
 WebGLProgram::GetActiveUniformBlockName(GLuint uniformBlockIndex, nsAString& retval) const
 {
     if (!IsLinked()) {
         mContext->ErrorInvalidOperation("getActiveUniformBlockName: `program` must be linked.");
@@ -1029,17 +1015,16 @@ WebGLProgram::GetUniformLocation(const n
     // uniform array, or the name of the uniform array appended with "[0]".
     nsCString mappedName;
     size_t arrayIndex;
     webgl::UniformInfo* info;
     if (!LinkInfo()->FindUniform(userName, &mappedName, &arrayIndex, &info))
         return nullptr;
 
     gl::GLContext* gl = mContext->GL();
-    gl->MakeCurrent();
 
     GLint loc = gl->fGetUniformLocation(mGLName, mappedName.BeginReading());
     if (loc == -1)
         return nullptr;
 
     RefPtr<WebGLUniformLocation> locObj = new WebGLUniformLocation(mContext, LinkInfo(),
                                                                    info, loc, arrayIndex);
     return locObj.forget();
@@ -1054,17 +1039,16 @@ WebGLProgram::GetUniformIndices(const do
         mContext->ErrorInvalidOperation("%s: `program` must be linked.", funcName);
         return;
     }
 
     size_t count = uniformNames.Length();
     nsTArray<GLuint>& arr = retval.SetValue();
 
     gl::GLContext* gl = mContext->GL();
-    gl->MakeCurrent();
 
     for (size_t i = 0; i < count; i++) {
         const NS_LossyConvertUTF16toASCII userName(uniformNames[i]);
 
         nsCString mappedName;
         size_t arrayIndex;
         webgl::UniformInfo* info;
         if (!LinkInfo()->FindUniform(userName, &mappedName, &arrayIndex, &info)) {
@@ -1103,17 +1087,16 @@ WebGLProgram::UniformBlockBinding(GLuint
                                     uniformBlockBinding);
         return;
     }
     const auto& indexedBinding = indexedBindings[uniformBlockBinding];
 
     ////
 
     gl::GLContext* gl = mContext->GL();
-    gl->MakeCurrent();
     gl->fUniformBlockBinding(mGLName, uniformBlockIndex, uniformBlockBinding);
 
     ////
 
     uniformBlock->mBinding = &indexedBinding;
 }
 
 bool
@@ -1165,17 +1148,16 @@ WebGLProgram::LinkProgram()
 
     if (mNumActiveTFOs) {
         mContext->ErrorInvalidOperation("%s: Program is in-use by one or more active"
                                         " transform feedback objects.",
                                         funcName);
         return;
     }
 
-    mContext->MakeContextCurrent();
     // as some of the validation changes program state
 
     mLinkLog.Truncate();
     mMostRecentLinkInfo = nullptr;
 
     if (!ValidateForLink()) {
         mContext->GenerateWarning("%s: %s", funcName, mLinkLog.BeginReading());
         return;
@@ -1459,26 +1441,23 @@ WebGLProgram::UseProgram() const
         mContext->mBoundTransformFeedback->mIsActive &&
         !mContext->mBoundTransformFeedback->mIsPaused)
     {
         mContext->ErrorInvalidOperation("%s: Transform feedback active and not paused.",
                                         funcName);
         return false;
     }
 
-    mContext->MakeContextCurrent();
-
     mContext->gl->fUseProgram(mGLName);
     return true;
 }
 
 void
 WebGLProgram::ValidateProgram() const
 {
-    mContext->MakeContextCurrent();
     gl::GLContext* gl = mContext->gl;
 
 #ifdef XP_MACOSX
     // See bug 593867 for NVIDIA and bug 657201 for ATI. The latter is confirmed
     // with Mac OS 10.6.7.
     if (gl->WorkAroundDriverBugs()) {
         mContext->GenerateWarning("validateProgram: Implemented as a no-op on"
                                   " Mac to work around crashes.");
@@ -1557,17 +1536,16 @@ WebGLProgram::FindUniformByMappedName(co
 
 void
 WebGLProgram::TransformFeedbackVaryings(const dom::Sequence<nsString>& varyings,
                                         GLenum bufferMode)
 {
     const char funcName[] = "transformFeedbackVaryings";
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
 
     switch (bufferMode) {
     case LOCAL_GL_INTERLEAVED_ATTRIBS:
         break;
 
     case LOCAL_GL_SEPARATE_ATTRIBS:
         {
             GLuint maxAttribs = 0;
--- a/dom/canvas/WebGLQuery.cpp
+++ b/dom/canvas/WebGLQuery.cpp
@@ -31,18 +31,16 @@ public:
     }
 };
 
 ////
 
 static GLuint
 GenQuery(gl::GLContext* gl)
 {
-    gl->MakeCurrent();
-
     GLuint ret = 0;
     gl->fGenQueries(1, &ret);
     return ret;
 }
 
 WebGLQuery::WebGLQuery(WebGLContext* webgl)
     : WebGLRefCountedObject(webgl)
     , mGLName(GenQuery(mContext->gl))
@@ -51,17 +49,16 @@ WebGLQuery::WebGLQuery(WebGLContext* web
     , mCanBeAvailable(false)
 {
     mContext->mQueries.insertBack(this);
 }
 
 void
 WebGLQuery::Delete()
 {
-    mContext->MakeContextCurrent();
     mContext->gl->fDeleteQueries(1, &mGLName);
     LinkedListElement<WebGLQuery>::removeFrom(mContext->mQueries);
 }
 
 static void
 DispatchAvailableRunnable(WebGLQuery* query)
 {
     RefPtr<AvailableRunnable> runnable = new AvailableRunnable(query);
@@ -111,33 +108,31 @@ WebGLQuery::BeginQuery(GLenum target, We
 
     mTarget = target;
     mActiveSlot = &slot;
     *mActiveSlot = this;
 
     ////
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
 
     const auto driverTarget = TargetForDriver(gl, mTarget);
     gl->fBeginQuery(driverTarget, mGLName);
 }
 
 void
 WebGLQuery::EndQuery()
 {
     *mActiveSlot = nullptr;
     mActiveSlot = nullptr;
     mCanBeAvailable = false;
 
     ////
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
 
     const auto driverTarget = TargetForDriver(gl, mTarget);
     gl->fEndQuery(driverTarget);
 
     ////
 
     DispatchAvailableRunnable(this);
 }
@@ -173,17 +168,16 @@ WebGLQuery::GetQueryParameter(GLenum pna
     if (!canBeAvailable) {
         if (pname == LOCAL_GL_QUERY_RESULT_AVAILABLE) {
             retval.set(JS::BooleanValue(false));
         }
         return;
     }
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
 
     uint64_t val = 0;
     switch (pname) {
     case LOCAL_GL_QUERY_RESULT_AVAILABLE:
         gl->fGetQueryObjectuiv(mGLName, pname, (GLuint*)&val);
         retval.set(JS::BooleanValue(bool(val)));
         return;
 
@@ -256,17 +250,16 @@ WebGLQuery::QueryCounter(const char* fun
         mContext->ErrorInvalidOperation("%s: Queries cannot change targets.", funcName);
         return;
     }
 
     mTarget = target;
     mCanBeAvailable = false;
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
     gl->fQueryCounter(mGLName, mTarget);
 
     DispatchAvailableRunnable(this);
 }
 
 ////
 
 JSObject*
--- a/dom/canvas/WebGLRenderbuffer.cpp
+++ b/dom/canvas/WebGLRenderbuffer.cpp
@@ -57,18 +57,16 @@ WebGLRenderbuffer::WebGLRenderbuffer(Web
     , mHasBeenBound(false)
 {
     mContext->mRenderbuffers.insertBack(this);
 }
 
 void
 WebGLRenderbuffer::Delete()
 {
-    mContext->MakeContextCurrent();
-
     mContext->gl->fDeleteRenderbuffers(1, &mPrimaryRB);
     if (mSecondaryRB)
         mContext->gl->fDeleteRenderbuffers(1, &mSecondaryRB);
 
     LinkedListElement<WebGLRenderbuffer>::removeFrom(mContext->mRenderbuffers);
 }
 
 int64_t
@@ -192,18 +190,16 @@ WebGLRenderbuffer::RenderbufferStorage(c
         height > mContext->mGLMaxRenderbufferSize)
     {
         mContext->ErrorInvalidValue("%s: Width or height exceeds maximum renderbuffer"
                                     " size.",
                                     funcName);
         return;
     }
 
-    mContext->MakeContextCurrent();
-
     if (!usage->maxSamplesKnown) {
         const_cast<webgl::FormatUsageInfo*>(usage)->ResolveMaxSamples(mContext->gl);
     }
     MOZ_ASSERT(usage->maxSamplesKnown);
 
     if (samples > usage->maxSamples) {
         mContext->ErrorInvalidOperation("%s: `samples` is out of the valid range.", funcName);
         return;
--- a/dom/canvas/WebGLSampler.cpp
+++ b/dom/canvas/WebGLSampler.cpp
@@ -30,17 +30,16 @@ WebGLSampler::WebGLSampler(WebGLContext*
 WebGLSampler::~WebGLSampler()
 {
     DeleteOnce();
 }
 
 void
 WebGLSampler::Delete()
 {
-    mContext->MakeContextCurrent();
     mContext->gl->fDeleteSamplers(1, &mGLName);
 
     removeFrom(mContext->mSamplers);
 }
 
 WebGLContext*
 WebGLSampler::GetParentObject() const
 {
@@ -192,17 +191,16 @@ WebGLSampler::SamplerParameter(const cha
 
     for (uint32_t i = 0; i < mContext->mBoundSamplers.Length(); ++i) {
         if (this == mContext->mBoundSamplers[i])
             mContext->InvalidateResolveCacheForTextureWithTexUnit(i);
     }
 
     ////
 
-    mContext->gl->MakeCurrent();
     if (param.isFloat) {
         mContext->gl->fSamplerParameterf(mGLName, pname, param.f);
     } else {
         mContext->gl->fSamplerParameteri(mGLName, pname, param.i);
     }
 }
 
 ////
--- a/dom/canvas/WebGLShader.cpp
+++ b/dom/canvas/WebGLShader.cpp
@@ -128,26 +128,19 @@ GetCompilationStatusAndLog(gl::GLContext
         out_log->SetLength(0);
     }
 
     *out_success = (compileStatus == LOCAL_GL_TRUE);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-static GLuint
-CreateShader(gl::GLContext* gl, GLenum type)
-{
-    gl->MakeCurrent();
-    return gl->fCreateShader(type);
-}
-
 WebGLShader::WebGLShader(WebGLContext* webgl, GLenum type)
     : WebGLRefCountedObject(webgl)
-    , mGLName(CreateShader(webgl->GL(), type))
+    , mGLName(webgl->gl->fCreateShader(type))
     , mType(type)
     , mTranslationSuccessful(false)
     , mCompilationSuccessful(false)
 {
     mContext->mShaders.insertBack(this);
 }
 
 WebGLShader::~WebGLShader()
@@ -224,18 +217,16 @@ WebGLShader::CompileShader()
                                              &mValidationLog, &mTranslatedSource);
     }
 
     if (!success)
         return;
 
     mTranslationSuccessful = true;
 
-    gl->MakeCurrent();
-
     const char* const parts[] = {
         mTranslatedSource.BeginReading()
     };
     gl->fShaderSource(mGLName, ArrayLength(parts), parts, nullptr);
 
     gl->fCompileShader(mGLName);
 
     GetCompilationStatusAndLog(gl, mGLName, &mCompilationSuccessful, &mCompilationLog);
@@ -443,17 +434,16 @@ WebGLShader::SizeOfIncludingThis(MallocS
            mCompilationLog.SizeOfExcludingThisIfUnshared(mallocSizeOf);
 }
 
 void
 WebGLShader::Delete()
 {
     gl::GLContext* gl = mContext->GL();
 
-    gl->MakeCurrent();
     gl->fDeleteShader(mGLName);
 
     LinkedListElement<WebGLShader>::removeFrom(mContext->mShaders);
 }
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLShader)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLShader, AddRef)
--- a/dom/canvas/WebGLSync.cpp
+++ b/dom/canvas/WebGLSync.cpp
@@ -21,17 +21,16 @@ WebGLSync::WebGLSync(WebGLContext* webgl
 WebGLSync::~WebGLSync()
 {
     DeleteOnce();
 }
 
 void
 WebGLSync::Delete()
 {
-    mContext->MakeContextCurrent();
     mContext->gl->fDeleteSync(mGLName);
     mGLName = 0;
     LinkedListElement<WebGLSync>::removeFrom(mContext->mSyncs);
 }
 
 WebGLContext*
 WebGLSync::GetParentObject() const
 {
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -147,17 +147,16 @@ WebGLTexture::WebGLTexture(WebGLContext*
 void
 WebGLTexture::Delete()
 {
     const char funcName[] = "WebGLTexture::Delete";
     for (auto& cur : mImageInfoArr) {
         cur.Clear(funcName);
     }
 
-    mContext->MakeContextCurrent();
     mContext->gl->fDeleteTextures(1, &mGLName);
 
     LinkedListElement<WebGLTexture>::removeFrom(mContext->mTextures);
 }
 
 size_t
 WebGLTexture::MemoryUsage() const
 {
@@ -642,17 +641,16 @@ ZeroTextureData(WebGLContext* webgl, con
     // We have no sympathy for any of these cases.
 
     // "Doctor, it hurts when I do this!" "Well don't do that!"
     webgl->GenerateWarning("%s: This operation requires zeroing texture data. This is"
                            " slow.",
                            funcName);
 
     gl::GLContext* gl = webgl->GL();
-    gl->MakeCurrent();
 
     GLenum scopeBindTarget;
     switch (target.get()) {
     case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
     case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
     case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
     case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
     case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
@@ -933,17 +931,16 @@ WebGLTexture::GenerateMipmap(TexTarget t
                                         " internal format or is not"
                                         " color-renderable or texture-filterable.",
                                         funcName);
         return;
     }
 
     // Done with validation. Do the operation.
 
-    mContext->MakeContextCurrent();
     gl::GLContext* gl = mContext->gl;
 
     if (gl->WorkAroundDriverBugs()) {
         // bug 696495 - to work around failures in the texture-mips.html test on various drivers, we
         // set the minification filter before calling glGenerateMipmap. This should not carry a significant performance
         // overhead so we do it unconditionally.
         //
         // note that the choice of GL_NEAREST_MIPMAP_NEAREST really matters. See Chromium bug 101105.
@@ -961,18 +958,16 @@ WebGLTexture::GenerateMipmap(TexTarget t
     // mBaseMipmapLevel if the min filter doesn't require mipmaps.
     const uint32_t maxLevel = mBaseMipmapLevel + baseImageInfo.PossibleMipmapLevels() - 1;
     PopulateMipChain(funcName, mBaseMipmapLevel, maxLevel);
 }
 
 JS::Value
 WebGLTexture::GetTexParameter(TexTarget texTarget, GLenum pname)
 {
-    mContext->MakeContextCurrent();
-
     GLint i = 0;
     GLfloat f = 0.0f;
 
     switch (pname) {
     case LOCAL_GL_TEXTURE_MIN_FILTER:
         return JS::NumberValue(uint32_t(mMinFilter.get()));
 
     case LOCAL_GL_TEXTURE_MAG_FILTER:
@@ -1218,17 +1213,16 @@ WebGLTexture::TexParameter(TexTarget tex
 
     default:
         InvalidateResolveCache();
         break;
     }
 
     ////////////////
 
-    mContext->MakeContextCurrent();
     if (!clamped.isFloat)
         mContext->gl->fTexParameteri(texTarget.get(), pname, clamped.i);
     else
         mContext->gl->fTexParameterf(texTarget.get(), pname, clamped.f);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -1150,18 +1150,16 @@ WebGLTexture::TexStorage(const char* fun
                                         " depth: %u)",
                                         funcName, levels, width, height, depth);
         return;
     }
 
     ////////////////////////////////////
     // Do the thing!
 
-    mContext->gl->MakeCurrent();
-
     GLenum error = DoTexStorage(mContext->gl, target.get(), levels, sizedFormat, width,
                                 height, depth);
 
     mContext->OnDataAllocCall();
 
     if (error == LOCAL_GL_OUT_OF_MEMORY) {
         mContext->ErrorOutOfMemory("%s: Ran out of memory during texture allocation.",
                                    funcName);
@@ -1264,19 +1262,16 @@ WebGLTexture::TexImage(const char* funcN
                                             funcName, dstFormat->name);
             return;
         }
     }
 
     ////////////////////////////////////
     // Do the thing!
 
-    MOZ_ALWAYS_TRUE( mContext->gl->MakeCurrent() );
-    MOZ_ASSERT(mContext->gl->IsCurrent());
-
     // It's tempting to do allocation first, and TexSubImage second, but this is generally
     // slower.
 
     const ImageInfo newImageInfo(dstUsage, blob->mWidth, blob->mHeight, blob->mDepth,
                                  blob->HasData());
 
     const bool isSubImage = false;
     const bool needsRespec = (imageInfo->mWidth  != newImageInfo.mWidth ||
@@ -1358,18 +1353,16 @@ WebGLTexture::TexSubImage(const char* fu
                                         " %s and 0x%04x/0x%04x",
                                         funcName, dstFormat->name, pi.format, pi.type);
         return;
     }
 
     ////////////////////////////////////
     // Do the thing!
 
-    mContext->gl->MakeCurrent();
-
     bool uploadWillInitialize;
     if (!EnsureImageDataInitializedForUpload(this, funcName, target, level, xOffset,
                                              yOffset, zOffset, blob->mWidth,
                                              blob->mHeight, blob->mDepth, imageInfo,
                                              &uploadWillInitialize))
     {
         return;
     }
@@ -1491,17 +1484,16 @@ WebGLTexture::CompressedTexImage(const c
                                                 blob->mDepth))
     {
         return;
     }
 
     ////////////////////////////////////
     // Do the thing!
 
-    mContext->gl->MakeCurrent();
     const ScopedLazyBind bindPBO(mContext->gl, LOCAL_GL_PIXEL_UNPACK_BUFFER,
                                  mContext->mBoundPixelUnpackBuffer);
 
     // Warning: Possibly shared memory.  See bug 1225033.
     GLenum error = DoCompressedTexImage(mContext->gl, target, level, internalFormat,
                                         blob->mWidth, blob->mHeight, blob->mDepth,
                                         blob->mAvailBytes, blob->mPtr);
     mContext->OnDataAllocCall();
@@ -1634,18 +1626,16 @@ WebGLTexture::CompressedTexSubImage(cons
             return;
         }
         break;
     }
 
     ////////////////////////////////////
     // Do the thing!
 
-    mContext->gl->MakeCurrent();
-
     bool uploadWillInitialize;
     if (!EnsureImageDataInitializedForUpload(this, funcName, target, level, xOffset,
                                              yOffset, zOffset, blob->mWidth,
                                              blob->mHeight, blob->mDepth, imageInfo,
                                              &uploadWillInitialize))
     {
         return;
     }
@@ -2160,17 +2150,16 @@ WebGLTexture::CopyTexImage2D(TexImageTar
     }
 
     if (!ValidateCopyTexImageFormats(mContext, funcName, srcFormat, dstFormat))
         return;
 
     ////////////////////////////////////
     // Do the thing!
 
-    mContext->gl->MakeCurrent();
     mContext->OnBeforeReadCall();
 
     const bool isSubImage = false;
     if (!DoCopyTexOrSubImage(mContext, funcName, isSubImage, this, target, level, x, y,
                              srcTotalWidth, srcTotalHeight, srcUsage, 0, 0, 0, width,
                              height, dstUsage))
     {
         return;
@@ -2240,17 +2229,16 @@ WebGLTexture::CopyTexSubImage(const char
 
     auto srcFormat = srcUsage->format;
     if (!ValidateCopyTexImageFormats(mContext, funcName, srcFormat, dstFormat))
         return;
 
     ////////////////////////////////////
     // Do the thing!
 
-    mContext->gl->MakeCurrent();
     mContext->OnBeforeReadCall();
 
     bool uploadWillInitialize;
     if (!EnsureImageDataInitializedForUpload(this, funcName, target, level, xOffset,
                                              yOffset, zOffset, width, height, depth,
                                              imageInfo, &uploadWillInitialize))
     {
         return;
--- a/dom/canvas/WebGLTransformFeedback.cpp
+++ b/dom/canvas/WebGLTransformFeedback.cpp
@@ -26,17 +26,16 @@ WebGLTransformFeedback::~WebGLTransformF
 {
     DeleteOnce();
 }
 
 void
 WebGLTransformFeedback::Delete()
 {
     if (mGLName) {
-        mContext->MakeContextCurrent();
         mContext->gl->fDeleteTransformFeedbacks(1, &mGLName);
     }
     removeFrom(mContext->mTransformFeedbacks);
 }
 
 ////////////////////////////////////////
 
 void
@@ -88,17 +87,16 @@ WebGLTransformFeedback::BeginTransformFe
 
         const size_t vertCapacity = buffer->ByteLength() / 4 / componentsPerVert;
         minVertCapacity = std::min(minVertCapacity, vertCapacity);
     }
 
     ////
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
     gl->fBeginTransformFeedback(primMode);
 
     ////
 
     mIsActive = true;
     MOZ_ASSERT(!mIsPaused);
 
     mActive_Program = prog;
@@ -118,17 +116,16 @@ WebGLTransformFeedback::EndTransformFeed
     const char funcName[] = "endTransformFeedback";
 
     if (!mIsActive)
         return mContext->ErrorInvalidOperation("%s: Not active.", funcName);
 
     ////
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
     gl->fEndTransformFeedback();
 
     ////
 
     mIsActive = false;
     mIsPaused = false;
 
     ////
@@ -146,17 +143,16 @@ WebGLTransformFeedback::PauseTransformFe
     {
         mContext->ErrorInvalidOperation("%s: Not active or is paused.", funcName);
         return;
     }
 
     ////
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
     gl->fPauseTransformFeedback();
 
     ////
 
     mIsPaused = true;
 }
 
 void
@@ -171,17 +167,16 @@ WebGLTransformFeedback::ResumeTransformF
         mContext->ErrorInvalidOperation("%s: Active program differs from original.",
                                         funcName);
         return;
     }
 
     ////
 
     const auto& gl = mContext->gl;
-    gl->MakeCurrent();
     gl->fResumeTransformFeedback();
 
     ////
 
     MOZ_ASSERT(mIsActive);
     mIsPaused = false;
 }
 
--- a/dom/canvas/WebGLUniformLocation.cpp
+++ b/dom/canvas/WebGLUniformLocation.cpp
@@ -184,17 +184,16 @@ WebGLUniformLocation::GetUniform(JSConte
 
     const uint8_t elemSize = mInfo->mActiveInfo->mElemSize;
     static const uint8_t kMaxElemSize = 16;
     MOZ_ASSERT(elemSize <= kMaxElemSize);
 
     GLuint prog = mLinkInfo->prog->mGLName;
 
     gl::GLContext* gl = mContext->GL();
-    gl->MakeCurrent();
 
     switch (mInfo->mActiveInfo->mElemType) {
     case LOCAL_GL_INT:
     case LOCAL_GL_INT_VEC2:
     case LOCAL_GL_INT_VEC3:
     case LOCAL_GL_INT_VEC4:
     case LOCAL_GL_SAMPLER_2D:
     case LOCAL_GL_SAMPLER_3D:
--- a/dom/canvas/WebGLVertexArrayGL.cpp
+++ b/dom/canvas/WebGLVertexArrayGL.cpp
@@ -20,17 +20,16 @@ WebGLVertexArrayGL::~WebGLVertexArrayGL(
     DeleteOnce();
 }
 
 void
 WebGLVertexArrayGL::DeleteImpl()
 {
     mElementArrayBuffer = nullptr;
 
-    mContext->MakeContextCurrent();
     mContext->gl->fDeleteVertexArrays(1, &mGLName);
 
     mIsVAO = false;
 }
 
 void
 WebGLVertexArrayGL::BindVertexArrayImpl()
 {
@@ -50,13 +49,12 @@ bool
 WebGLVertexArrayGL::IsVertexArrayImpl() const
 {
     gl::GLContext* gl = mContext->gl;
     if (gl->WorkAroundDriverBugs())
     {
         return mIsVAO;
     }
 
-    mContext->MakeContextCurrent();
     return mContext->gl->fIsVertexArray(mGLName) != 0;
 }
 
 } // namespace mozilla