Bug 1303879 - Validate attachments inside ScopedResolveTextures. - r=mtseng draft
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 01 Sep 2016 13:51:03 -0700
changeset 415740 58ab10cfe0dfb0140a7792034eb88385990c9c88
parent 415227 3541bd40ef969237126e6b641efd24f5111acc8d
child 415741 9d087a768ec052f35b593befe802fadf229d2a88
push id29953
push userbmo:jgilbert@mozilla.com
push dateTue, 20 Sep 2016 23:29:17 +0000
reviewersmtseng
bugs1303879
milestone51.0a1
Bug 1303879 - Validate attachments inside ScopedResolveTextures. - r=mtseng MozReview-Commit-ID: 7HLiUV9QcY4
dom/canvas/WebGLContextDraw.cpp
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -99,17 +99,24 @@ ScopedResolveTexturesForDraw::ScopedReso
         mWebGL->ErrorInvalidOperation("%s: The current program is not linked.", funcName);
         *out_error = true;
         return;
     }
 
     const std::vector<const WebGLFBAttachPoint*>* attachList = nullptr;
     const auto& fb = mWebGL->mBoundDrawFramebuffer;
     if (fb) {
+        if (!fb->ValidateAndInitAttachments(funcName)) {
+            *out_error = true;
+            return;
+        }
+
         attachList = &(fb->ResolvedCompleteData()->texDrawBuffers);
+    } else {
+        webgl->ClearBackbufferIfNeeded();
     }
 
     MOZ_ASSERT(mWebGL->mActiveProgramLinkInfo);
     const auto& uniformSamplers = mWebGL->mActiveProgramLinkInfo->uniformSamplers;
     for (const auto& uniform : uniformSamplers) {
         const auto& texList = *(uniform->mSamplerTexList);
 
         for (const auto& texUnit : uniform->mSamplerValues) {
@@ -291,25 +298,16 @@ 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;
     }
 
-    MOZ_ASSERT(gl->IsCurrent());
-
-    if (mBoundDrawFramebuffer) {
-        if (!mBoundDrawFramebuffer->ValidateAndInitAttachments(info))
-            return false;
-    } else {
-        ClearBackbufferIfNeeded();
-    }
-
     if (!DoFakeVertexAttrib0(checked_firstPlusCount.value())) {
         return false;
     }
 
     return true;
 }
 
 void
@@ -492,28 +490,18 @@ 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));
     }
 
-    MOZ_ASSERT(gl->IsCurrent());
-
-    if (mBoundDrawFramebuffer) {
-        if (!mBoundDrawFramebuffer->ValidateAndInitAttachments(info))
-            return false;
-    } else {
-        ClearBackbufferIfNeeded();
-    }
-
-    if (!DoFakeVertexAttrib0(mMaxFetchedVertices)) {
+    if (!DoFakeVertexAttrib0(mMaxFetchedVertices))
         return false;
-    }
 
     return true;
 }
 
 void
 WebGLContext::DrawElements(GLenum mode, GLsizei count, GLenum type,
                            WebGLintptr byteOffset)
 {