Bug 972164 - Fix readPixels to generate INV_FB_OP on incomplete FB before INV_OP. - r=kamidphish
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 28 Feb 2014 18:51:43 -0800
changeset 171712 eec88498d1e7d882c3cb283dbfb9d87fcca60896
parent 171711 5f165f29aed0277f832accdb409080221d0e98dc
child 171713 8b52006f691b8b6e4dea034bb8cebc27b5b83f13
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerskamidphish
bugs972164
milestone30.0a1
Bug 972164 - Fix readPixels to generate INV_FB_OP on incomplete FB before INV_OP. - r=kamidphish
content/canvas/src/WebGLContextGL.cpp
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -2314,25 +2314,25 @@ WebGLContext::ReadPixels(GLint x, GLint 
         }
         default:
             return ErrorInvalidOperation("readPixels: Invalid format/type pair");
     }
 
     MakeContextCurrent();
 
     if (mBoundFramebuffer) {
+        // prevent readback of arbitrary video memory through uninitialized renderbuffers!
+        if (!mBoundFramebuffer->CheckAndInitializeAttachments())
+            return ErrorInvalidFramebufferOperation("readPixels: incomplete framebuffer");
+
         GLenum readPlaneBits = LOCAL_GL_COLOR_BUFFER_BIT;
         if (!mBoundFramebuffer->HasCompletePlanes(readPlaneBits)) {
             return ErrorInvalidOperation("readPixels: Read source attachment doesn't have the"
                                          " correct color/depth/stencil type.");
         }
-
-        // prevent readback of arbitrary video memory through uninitialized renderbuffers!
-        if (!mBoundFramebuffer->CheckAndInitializeAttachments())
-            return ErrorInvalidFramebufferOperation("readPixels: incomplete framebuffer");
     }
     // Now that the errors are out of the way, on to actually reading
 
     // If we won't be reading any pixels anyways, just skip the actual reading
     if (width == 0 || height == 0)
         return DummyFramebufferOperation("readPixels");
 
     if (CanvasUtils::CheckSaneSubrectSize(x, y, width, height, framebufferWidth, framebufferHeight)) {