Bug 613350 - Pass 2 more WebGL draw-test - r=vladimir a=joe
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 25 Nov 2010 09:00:00 -0500
changeset 58219 215657c24079bbb00b4008d88d761369abdfc5d6
parent 58218 367ff816f171eb3c833e0d680dc273d92d64da83
child 58220 8545045acca27b494f7eb353a8270a31d6e5092c
push id17206
push userbjacob@mozilla.com
push dateThu, 25 Nov 2010 15:19:01 +0000
treeherdermozilla-central@215657c24079 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladimir, joe
bugs613350
milestone2.0b8pre
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 613350 - Pass 2 more WebGL draw-test - r=vladimir a=joe
content/canvas/src/WebGLContextGL.cpp
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -1042,33 +1042,33 @@ NS_IMETHODIMP
 WebGLContext::DrawArrays(GLenum mode, WebGLint first, WebGLsizei count)
 {
     if (!ValidateDrawModeEnum(mode, "drawArrays: mode"))
         return NS_OK;
 
     if (first < 0 || count < 0)
         return ErrorInvalidValue("DrawArrays: negative first or count");
 
+    // If count is 0, there's nothing to do.
+    if (count == 0)
+        return NS_OK;
+
     // If there is no current program, this is silently ignored.
     // Any checks below this depend on a program being available.
     if (!mCurrentProgram)
         return NS_OK;
 
     CheckedInt32 checked_firstPlusCount = CheckedInt32(first) + count;
 
     if (!checked_firstPlusCount.valid())
         return ErrorInvalidOperation("drawArrays: overflow in first+count");
 
     if (!ValidateBuffers(checked_firstPlusCount.value()))
         return ErrorInvalidOperation("DrawArrays: bound vertex attribute buffers do not have sufficient size for given first and count");
 
-    // If count is 0, there's nothing to do.
-    if (count == 0)
-        return NS_OK;
-
     MakeContextCurrent();
 
     if (mBoundFramebuffer && !mBoundFramebuffer->CheckAndInitializeRenderbuffers())
         return NS_OK;
 
     BindFakeBlackTextures();
     DoFakeVertexAttrib0(checked_firstPlusCount.value());
 
@@ -1086,16 +1086,20 @@ NS_IMETHODIMP
 WebGLContext::DrawElements(WebGLenum mode, WebGLsizei count, WebGLenum type, WebGLint byteOffset)
 {
     if (!ValidateDrawModeEnum(mode, "drawElements: mode"))
         return NS_OK;
 
     if (count < 0 || byteOffset < 0)
         return ErrorInvalidValue("DrawElements: negative count or offset");
 
+    // If count is 0, there's nothing to do.
+    if (count == 0)
+        return NS_OK;
+
     CheckedUint32 checked_byteCount;
 
     if (type == LOCAL_GL_UNSIGNED_SHORT) {
         checked_byteCount = 2 * CheckedUint32(count);
         if (byteOffset % 2 != 0)
             return ErrorInvalidValue("DrawElements: invalid byteOffset for UNSIGNED_SHORT (must be a multiple of 2)");
     } else if (type == LOCAL_GL_UNSIGNED_BYTE) {
         checked_byteCount = count;
@@ -1138,20 +1142,16 @@ WebGLContext::DrawElements(WebGLenum mod
     CheckedUint32 checked_neededCount = CheckedUint32(maxIndex) + 1;
     if (!checked_neededCount.valid())
         return ErrorInvalidOperation("drawElements: overflow in maxIndex+1");
     if (!ValidateBuffers(checked_neededCount.value())) {
         return ErrorInvalidOperation("DrawElements: bound vertex attribute buffers do not have sufficient "
                                      "size for given indices from the bound element array");
     }
 
-    // If count is 0, there's nothing to do.
-    if (count == 0)
-        return NS_OK;
-
     MakeContextCurrent();
 
     if (mBoundFramebuffer && !mBoundFramebuffer->CheckAndInitializeRenderbuffers())
         return NS_OK;
 
     BindFakeBlackTextures();
     DoFakeVertexAttrib0(checked_neededCount.value());