void WebGLFramebuffer::FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, WebGLTexture* wtex, GLint level) { MOZ_ASSERT(mContext->mBoundFramebuffer == this); if (!mContext->ValidateObjectAllowNull("framebufferTexture2D: texture", wtex)) return; if (target != LOCAL_GL_FRAMEBUFFER) return mContext->ErrorInvalidEnumInfo("framebufferTexture2D: target", target); if (textarget != LOCAL_GL_TEXTURE_2D && (textarget < LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X || textarget > LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)) { return mContext->ErrorInvalidEnumInfo("framebufferTexture2D: invalid texture target", textarget); } if (wtex) { bool isTexture2D = wtex->Target() == LOCAL_GL_TEXTURE_2D; bool isTexTarget2D = textarget == LOCAL_GL_TEXTURE_2D; if (isTexture2D != isTexTarget2D) { return mContext->ErrorInvalidOperation("framebufferTexture2D: mismatched texture and texture target"); } } if (level != 0) return mContext->ErrorInvalidValue("framebufferTexture2D: level must be 0"); /* 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* a = GetAttachmentOrNull(attachment); if (!a) return; // Error generated internally to GetAttachmentOrNull. /* Invalidate cached framebuffer status and inform texture of it's * new attachment */ mStatus = 0; // Detach current if (a->Texture()) a->Texture()->DetachFrom(this, attachment); else if (a->Renderbuffer()) a->Renderbuffer()->DetachFrom(this, attachment); // Attach new if (wtex) wtex->AttachTo(this, attachment); a->SetTexImage(wtex, textarget, level); }
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)) { 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); if (!attachment) return; // Error generated internally to GetAttachmentOrNull. // Invalidate cached framebuffer status and inform texture of its new // attachment. mStatus = 0; // Detach current: if (attachment->Texture()) attachment->Texture()->DetachFrom(this, attachPoint); else if (attachment->Renderbuffer()) attachment->Renderbuffer()->DetachFrom(this, attachPoint); // Attach new: if (tex) tex->AttachTo(this, attachPoint); attachment->SetTexImage(tex, texImageTarget, level); }
void WebGLFramebuffer::FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum rbtarget, WebGLRenderbuffer* wrb) { MOZ_ASSERT(mContext->mBoundFramebuffer == this); if (!mContext->ValidateObjectAllowNull("framebufferRenderbuffer: renderbuffer", wrb)) return; if (target != LOCAL_GL_FRAMEBUFFER) return mContext->ErrorInvalidEnumInfo("framebufferRenderbuffer: target", target); if (rbtarget != LOCAL_GL_RENDERBUFFER) return mContext->ErrorInvalidEnumInfo("framebufferRenderbuffer: renderbuffer target:", rbtarget); /* 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* a = GetAttachmentOrNull(attachment); if (!a) return; // Error generated internally to GetAttachmentOrNull. /* Invalidate cached framebuffer status and inform texture of it's * new attachment */ mStatus = 0; // Detach current if (a->Texture()) a->Texture()->DetachFrom(this, attachment); else if (a->Renderbuffer()) a->Renderbuffer()->DetachFrom(this, attachment); // Attach new if (wrb) wrb->AttachTo(this, attachment); a->SetRenderbuffer(wrb); }
void WebGLFramebuffer::FramebufferRenderbuffer(FBAttachment attachPoint, RBTarget rbtarget, WebGLRenderbuffer* rb) { MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this || mContext->mBoundReadFramebuffer == this); if (!mContext->ValidateObjectAllowNull("framebufferRenderbuffer: renderbuffer", rb)) { 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); if (!attachment) return; // Error generated internally to GetAttachmentOrNull. // Invalidate cached framebuffer status and inform texture of its new // attachment. mStatus = 0; // Detach current: if (attachment->Texture()) attachment->Texture()->DetachFrom(this, attachPoint); else if (attachment->Renderbuffer()) attachment->Renderbuffer()->DetachFrom(this, attachPoint); // Attach new: if (rb) rb->AttachTo(this, attachPoint); attachment->SetRenderbuffer(rb); }