Bug 685184 - Finalize attachments slightly earlier. - r=jgilbert
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 01 Oct 2013 17:31:37 -0700
changeset 149589 550a2b69c1f479589eed8f68cf6a9999acf9eeef
parent 149588 447244440bd0b2f4b979160d40654dea1dc1df1c
child 149590 e31e0e25850486a58d26f0f32ffd3f88c2b09cef
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjgilbert
bugs685184
milestone27.0a1
Bug 685184 - Finalize attachments slightly earlier. - r=jgilbert
content/canvas/src/WebGLFramebuffer.cpp
--- a/content/canvas/src/WebGLFramebuffer.cpp
+++ b/content/canvas/src/WebGLFramebuffer.cpp
@@ -374,16 +374,21 @@ WebGLFramebuffer::CheckAndInitializeRend
     // enforce WebGL section 6.5 which is WebGL-specific, hence OpenGL itself would not
     // generate the INVALID_FRAMEBUFFER_OPERATION that we need here
     if (HasDepthStencilConflict())
         return false;
 
     if (HasIncompleteAttachment())
         return false;
 
+    mContext->MakeContextCurrent();
+
+    // Ok, attach our chosen flavor of {DEPTH, STENCIL, DEPTH_STENCIL}.
+    FinalizeAttachments();
+
     size_t colorAttachmentCount = size_t(mColorAttachments.Length());
 
     {
         bool hasUnitializedRenderbuffers = false;
 
         for (size_t i = 0; i < colorAttachmentCount; i++) {
             hasUnitializedRenderbuffers |= mColorAttachments[i].HasUninitializedRenderbuffer();
         }
@@ -399,21 +404,16 @@ WebGLFramebuffer::CheckAndInitializeRend
 
     // ensure INVALID_FRAMEBUFFER_OPERATION in zero-size case
     const WebGLRectangleObject *rect = mColorAttachments[0].RectangleObject();
     if (!rect ||
         !rect->Width() ||
         !rect->Height())
         return false;
 
-    mContext->MakeContextCurrent();
-
-    // Ok, attach our chosen flavor of {DEPTH, STENCIL, DEPTH_STENCIL}.
-    FinalizeAttachments();
-
     GLenum status = mContext->CheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
     if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE)
         return false;
 
     uint32_t mask = 0;
     bool colorAttachmentsMask[WebGLContext::sMaxColorAttachments] = { false };
 
     MOZ_ASSERT( colorAttachmentCount <= WebGLContext::sMaxColorAttachments );