b=612334; (related) misc fixes in webgl, from original patch; r=bjacob, a=b
authorVladimir Vukicevic <vladimir@pobox.com>
Wed, 22 Dec 2010 15:31:02 -0800
changeset 59619 ad071e6d8bb340b6db40c049ef0689f6159bede3
parent 59618 026750b84bc2e69f916104cf1d391e3b4a311c41
child 59620 8232a1410e4241fd68d63e4a671788deebd1b5b4
push id17698
push uservladimir@mozilla.com
push dateWed, 22 Dec 2010 23:31:58 +0000
treeherdermozilla-central@8232a1410e42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob, b
bugs612334
milestone2.0b9pre
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
b=612334; (related) misc fixes in webgl, from original patch; r=bjacob, a=b
content/canvas/src/WebGLContextGL.cpp
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -2550,16 +2550,20 @@ WebGLContext::ReadPixels_base(WebGLint x
     if (HTMLCanvasElement()->IsWriteOnly() && !nsContentUtils::IsCallerTrustedForRead()) {
         LogMessageIfVerbose("ReadPixels: Not allowed");
         return NS_ERROR_DOM_SECURITY_ERR;
     }
 
     if (width < 0 || height < 0)
         return ErrorInvalidValue("ReadPixels: negative size passed");
 
+    // there's nothing to do in this case, since we won't read any pixels
+    if (width == 0 || height == 0)
+        return NS_OK;
+
     WebGLsizei boundWidth = mBoundFramebuffer ? mBoundFramebuffer->width() : mWidth;
     WebGLsizei boundHeight = mBoundFramebuffer ? mBoundFramebuffer->height() : mHeight;
 
     PRUint32 size = 0;
     bool badFormat = false, badType = false;
     switch (format) {
     case LOCAL_GL_RGBA:
         size = 4;
@@ -2665,17 +2669,18 @@ WebGLContext::ReadPixels_base(WebGLint x
                      + checked_alignedRowSize.value() * (subrect_y_in_dest_buffer + y_inside_subrect)
                      + size * subrect_x_in_dest_buffer, // destination
                    subrect_data + subrect_alignedRowSize * y_inside_subrect, // source
                    subrect_plainRowSize); // size
         }
         delete [] subrect_data;
     }
 
-    // if we're reading alpha, we may need to do fixup
+    // if we're reading alpha, we may need to do fixup.  Note that we don't allow
+    // GL_ALPHA to readpixels currently, but we had the code written for it already.
     if (format == LOCAL_GL_ALPHA ||
         format == LOCAL_GL_RGBA)
     {
         PRBool needAlphaFixup;
         if (mBoundFramebuffer) {
             needAlphaFixup = !mBoundFramebuffer->ColorAttachment().HasAlpha();
         } else {
             needAlphaFixup = gl->ActualFormat().alpha == 0;