Bug 1228687: ScopedResolveTexturesForDraw needs the context to be current, so make those calls earlier. r=jgilbert
authorMilan Sreckovic <milan@mozilla.com>
Thu, 17 Mar 2016 23:00:34 -0700
changeset 289313 b4a2342c8f5d781844dc26d9b504801d120910d6
parent 289312 2b7b7ea014d8b429c2f2c1d0aeceb479d60d7cf0
child 289314 52029291217539501fced30b968fe639d8d0c011
push id30099
push usercbook@mozilla.com
push dateFri, 18 Mar 2016 14:52:23 +0000
treeherdermozilla-central@9c5d494d0548 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1228687
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1228687: ScopedResolveTexturesForDraw needs the context to be current, so make those calls earlier. r=jgilbert
dom/canvas/WebGLContextDraw.cpp
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -42,16 +42,18 @@ public:
     ~ScopedResolveTexturesForDraw();
 };
 
 ScopedResolveTexturesForDraw::ScopedResolveTexturesForDraw(WebGLContext* webgl,
                                                            const char* funcName,
                                                            bool* const out_error)
     : mWebGL(webgl)
 {
+    MOZ_ASSERT(webgl->gl->IsCurrent());
+
     typedef decltype(WebGLContext::mBound2DTextures) TexturesT;
 
     const auto fnResolveAll = [this, funcName](const TexturesT& textures)
     {
         const auto len = textures.Length();
         for (uint32_t texUnit = 0; texUnit < len; ++texUnit) {
             WebGLTexture* tex = textures[texUnit];
             if (!tex)
@@ -215,17 +217,17 @@ WebGLContext::DrawArrays_check(GLint fir
         return false;
     }
 
     if (uint32_t(primcount) > mMaxFetchedInstances) {
         ErrorInvalidOperation("%s: bound instance attribute buffers do not have sufficient size for given primcount", info);
         return false;
     }
 
-    MakeContextCurrent();
+    MOZ_ASSERT(gl->IsCurrent());
 
     if (mBoundDrawFramebuffer) {
         if (!mBoundDrawFramebuffer->ValidateAndInitAttachments(info))
             return false;
     } else {
         ClearBackbufferIfNeeded();
     }
 
@@ -241,16 +243,18 @@ WebGLContext::DrawArrays(GLenum mode, GL
 {
     const char funcName[] = "drawArrays";
     if (IsContextLost())
         return;
 
     if (!ValidateDrawModeEnum(mode, funcName))
         return;
 
+    MakeContextCurrent();
+
     bool error;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
     if (error)
         return;
 
     if (!DrawArrays_check(first, count, 1, funcName))
         return;
 
@@ -269,16 +273,18 @@ WebGLContext::DrawArraysInstanced(GLenum
 {
     const char funcName[] = "drawArraysInstanced";
     if (IsContextLost())
         return;
 
     if (!ValidateDrawModeEnum(mode, funcName))
         return;
 
+    MakeContextCurrent();
+
     bool error;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
     if (error)
         return;
 
     if (!DrawArrays_check(first, count, primcount, funcName))
         return;
 
@@ -404,17 +410,17 @@ WebGLContext::DrawElements_check(GLsizei
     // Bug 1008310 - Check if buffer has been used with a different previous type
     if (elemArrayBuffer.IsElementArrayUsedWithMultipleTypes()) {
         GenerateWarning("%s: bound element array buffer previously used with a type other than "
                         "%s, this will affect performance.",
                         info,
                         WebGLContext::EnumName(type));
     }
 
-    MakeContextCurrent();
+    MOZ_ASSERT(gl->IsCurrent());
 
     if (mBoundDrawFramebuffer) {
         if (!mBoundDrawFramebuffer->ValidateAndInitAttachments(info))
             return false;
     } else {
         ClearBackbufferIfNeeded();
     }
 
@@ -431,16 +437,18 @@ WebGLContext::DrawElements(GLenum mode, 
 {
     const char funcName[] = "drawElements";
     if (IsContextLost())
         return;
 
     if (!ValidateDrawModeEnum(mode, funcName))
         return;
 
+    MakeContextCurrent();
+
     bool error;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
     if (error)
         return;
 
     GLuint upperBound = 0;
     if (!DrawElements_check(count, type, byteOffset, 1, funcName, &upperBound))
         return;
@@ -468,16 +476,18 @@ WebGLContext::DrawElementsInstanced(GLen
 {
     const char funcName[] = "drawElementsInstanced";
     if (IsContextLost())
         return;
 
     if (!ValidateDrawModeEnum(mode, funcName))
         return;
 
+    MakeContextCurrent();
+
     bool error;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
     if (error)
         return;
 
     GLuint upperBound = 0;
     if (!DrawElements_check(count, type, byteOffset, primcount, funcName, &upperBound))
         return;