void WebGLFramebuffer::EnsureColorAttachPoints(size_t colorAttachmentId)
{
    MOZ_ASSERT(colorAttachmentId < WebGLContext::kMaxColorAttachments);

    if (colorAttachmentId < ColorAttachmentCount())
        return;

    while (ColorAttachmentCount() < WebGLContext::kMaxColorAttachments) {
        GLenum nextAttachPoint = LOCAL_GL_COLOR_ATTACHMENT0 + ColorAttachmentCount();
        mMoreColorAttachments.AppendElement(AttachPoint(this, nextAttachPoint));
    }

    MOZ_ASSERT(ColorAttachmentCount() == WebGLContext::kMaxColorAttachments);
}
Example #2
0
bool
WebGLFramebuffer::HasCompletePlanes(GLbitfield mask)
{
    if (CheckFramebufferStatus() != LOCAL_GL_FRAMEBUFFER_COMPLETE)
        return false;

    MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
               mContext->mBoundReadFramebuffer == this);

    bool hasPlanes = true;
    if (mask & LOCAL_GL_COLOR_BUFFER_BIT) {
        hasPlanes &= ColorAttachmentCount() &&
                     ColorAttachment(0).IsDefined();
    }

    if (mask & LOCAL_GL_DEPTH_BUFFER_BIT) {
        hasPlanes &= DepthAttachment().IsDefined() ||
                     DepthStencilAttachment().IsDefined();
    }

    if (mask & LOCAL_GL_STENCIL_BUFFER_BIT) {
        hasPlanes &= StencilAttachment().IsDefined() ||
                     DepthStencilAttachment().IsDefined();
    }

    return hasPlanes;
}
Example #3
0
void
WebGLFramebuffer::FinalizeAttachments() const
{
    gl::GLContext* gl = mContext->gl;

    for (size_t i = 0; i < ColorAttachmentCount(); i++) {
        ColorAttachment(i).FinalizeAttachment(gl, LOCAL_GL_COLOR_ATTACHMENT0+i);
    }

    DepthAttachment().FinalizeAttachment(gl, LOCAL_GL_DEPTH_ATTACHMENT);
    StencilAttachment().FinalizeAttachment(gl, LOCAL_GL_STENCIL_ATTACHMENT);
    DepthStencilAttachment().FinalizeAttachment(gl,
                                                LOCAL_GL_DEPTH_STENCIL_ATTACHMENT);

    FinalizeDrawAndReadBuffers(gl, ColorAttachment(0).IsDefined());
}