Bug 1145492 - Update FramebufferTexture2D to allow binding mipmaps. r=jgilbert
authorDan Glastonbury <dan.glastonbury@gmail.com>
Wed, 18 Feb 2015 09:52:51 +1000
changeset 264040 290493befabb4bf0d5f359c2d8ce81c801105506
parent 264039 33e2a9f54849e847d05f19c1d9353df1bab84784
child 264041 3b449f8dd470a2cc866c302f527e20bedaadb786
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1145492
milestone39.0a1
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 1145492 - Update FramebufferTexture2D to allow binding mipmaps. r=jgilbert
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLFramebuffer.cpp
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -885,16 +885,21 @@ WebGLContext::FramebufferTexture2D(GLenu
                                    GLint level)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateFramebufferTarget(target, "framebufferTexture2D"))
         return;
 
+    if (!IsWebGL2() && level != 0) {
+        ErrorInvalidValue("framebufferTexture2D: level must be 0.");
+        return;
+    }
+
     WebGLFramebuffer* fb;
     switch (target) {
     case LOCAL_GL_FRAMEBUFFER:
     case LOCAL_GL_DRAW_FRAMEBUFFER:
         fb = mBoundDrawFramebuffer;
         break;
 
     case LOCAL_GL_READ_FRAMEBUFFER:
--- a/dom/canvas/WebGLFramebuffer.cpp
+++ b/dom/canvas/WebGLFramebuffer.cpp
@@ -494,37 +494,29 @@ WebGLFramebuffer::FramebufferRenderbuffe
 void
 WebGLFramebuffer::FramebufferTexture2D(FBAttachment attachPoint,
                                        TexImageTarget texImageTarget,
                                        WebGLTexture* tex, GLint level)
 {
     MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
                mContext->mBoundReadFramebuffer == this);
 
-    if (!mContext->ValidateObjectAllowNull("framebufferTexture2D: texture",
-                                           tex))
-    {
+    if (!mContext->ValidateObjectAllowNull("framebufferTexture2D: texture", tex))
         return;
-    }
 
     if (tex) {
         bool isTexture2D = tex->Target() == LOCAL_GL_TEXTURE_2D;
         bool isTexTarget2D = texImageTarget == LOCAL_GL_TEXTURE_2D;
         if (isTexture2D != isTexTarget2D) {
             mContext->ErrorInvalidOperation("framebufferTexture2D: Mismatched"
                                             " texture and texture target.");
             return;
         }
     }
 
-    if (level != 0) {
-        mContext->ErrorInvalidValue("framebufferTexture2D: Level must be 0.");
-        return;
-    }
-
     /* Get the requested attachment. If result is NULL, attachment is invalid
      * and an error is generated.
      *
      * Don't use GetAttachment(...) here because it opt builds it returns
      * mColorAttachment[0] for invalid attachment, which we really don't want to
      * mess with.
      */
     Attachment* attachment = GetAttachmentOrNull(attachPoint);