示例#1
0
void
WebGLFramebuffer::FramebufferTextureLayer(GLenum attachment, WebGLTexture* tex,
                                          GLint level, GLint layer)
{
    MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
               mContext->mBoundReadFramebuffer == this);

    const TexImageTarget texImageTarget = (tex ? tex->Target().get()
                                               : LOCAL_GL_TEXTURE_2D);

    RefPtr<WebGLTexture> tex_ = tex; // Bug 1201275
    const auto fnAttach = [this, &tex_, texImageTarget, level, layer](GLenum attachment) {
        const auto attachPoint = this->GetAttachPoint(attachment);
        MOZ_ASSERT(attachPoint);

        attachPoint->SetTexImageLayer(tex_, texImageTarget, level, layer);
    };

    if (mContext->IsWebGL2() && attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
        fnAttach(LOCAL_GL_DEPTH_ATTACHMENT);
        fnAttach(LOCAL_GL_STENCIL_ATTACHMENT);
    } else {
        fnAttach(attachment);
    }

    InvalidateFramebufferStatus();
}
示例#2
0
void
WebGLFramebuffer::FramebufferTexture2D(FBAttachment attachPointEnum,
                                       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;
        }
    }

    AttachPoint& attachPoint = GetAttachPoint(attachPointEnum);
    attachPoint.SetTexImage(tex, texImageTarget, level);

    InvalidateFramebufferStatus();
}
示例#3
0
void
WebGLFramebuffer::FramebufferRenderbuffer(GLenum attachment, RBTarget rbtarget,
                                          WebGLRenderbuffer* rb)
{
    MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
               mContext->mBoundReadFramebuffer == this);

    if (!mContext->ValidateObjectAllowNull("framebufferRenderbuffer: renderbuffer", rb))
        return;

    // `attachPointEnum` is validated by ValidateFramebufferAttachment().

    RefPtr<WebGLRenderbuffer> rb_ = rb; // Bug 1201275
    const auto fnAttach = [this, &rb_](GLenum attachment) {
        const auto attachPoint = this->GetAttachPoint(attachment);
        MOZ_ASSERT(attachPoint);

        attachPoint->SetRenderbuffer(rb_);
    };

    if (mContext->IsWebGL2() && attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
        fnAttach(LOCAL_GL_DEPTH_ATTACHMENT);
        fnAttach(LOCAL_GL_STENCIL_ATTACHMENT);
    } else {
        fnAttach(attachment);
    }

    InvalidateFramebufferStatus();
}
示例#4
0
void
WebGLFramebuffer::FramebufferRenderbuffer(FBAttachment attachPointEnum,
                                          RBTarget rbtarget,
                                          WebGLRenderbuffer* rb)
{
    MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
               mContext->mBoundReadFramebuffer == this);

    if (!mContext->ValidateObjectAllowNull("framebufferRenderbuffer: renderbuffer", rb))
        return;

    // `attachPoint` is validated by ValidateFramebufferAttachment().
    AttachPoint& attachPoint = GetAttachPoint(attachPointEnum);
    attachPoint.SetRenderbuffer(rb);

    InvalidateFramebufferStatus();
}
示例#5
0
void
WebGLFramebuffer::FramebufferTexture2D(GLenum attachment, 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;
        }
    }

    RefPtr<WebGLTexture> tex_ = tex; // Bug 1201275
    const auto fnAttach = [this, &tex_, texImageTarget, level](GLenum attachment) {
        const auto attachPoint = this->GetAttachPoint(attachment);
        MOZ_ASSERT(attachPoint);

        attachPoint->SetTexImage(tex_, texImageTarget, level);
    };

    if (mContext->IsWebGL2() && attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
        fnAttach(LOCAL_GL_DEPTH_ATTACHMENT);
        fnAttach(LOCAL_GL_STENCIL_ATTACHMENT);
    } else {
        fnAttach(attachment);
    }

    InvalidateFramebufferStatus();
}