示例#1
0
GLint
WebGLRenderbuffer::GetRenderbufferParameter(RBTarget target,
                                            RBParam pname) const
{
    gl::GLContext* gl = mContext->gl;

    switch (pname.get()) {
    case LOCAL_GL_RENDERBUFFER_STENCIL_SIZE:
        if (!mFormat)
            return 0;

        if (!mFormat->format->s)
            return 0;

        return 8;

    case LOCAL_GL_RENDERBUFFER_SAMPLES:
    case LOCAL_GL_RENDERBUFFER_WIDTH:
    case LOCAL_GL_RENDERBUFFER_HEIGHT:
    case LOCAL_GL_RENDERBUFFER_RED_SIZE:
    case LOCAL_GL_RENDERBUFFER_GREEN_SIZE:
    case LOCAL_GL_RENDERBUFFER_BLUE_SIZE:
    case LOCAL_GL_RENDERBUFFER_ALPHA_SIZE:
    case LOCAL_GL_RENDERBUFFER_DEPTH_SIZE:
        {
            gl->fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mPrimaryRB);
            GLint i = 0;
            gl->fGetRenderbufferParameteriv(target.get(), pname.get(), &i);
            return i;
        }

    case LOCAL_GL_RENDERBUFFER_INTERNAL_FORMAT:
        {
            GLenum ret = 0;
            if (mFormat) {
                ret = mFormat->format->sizedFormat;

                if (!mContext->IsWebGL2() && ret == LOCAL_GL_DEPTH24_STENCIL8) {
                    ret = LOCAL_GL_DEPTH_STENCIL;
                }
            }
            return ret;
        }
    }

    MOZ_ASSERT(false, "This function should only be called with valid `pname`.");
    return 0;
}
示例#2
0
GLint
WebGLRenderbuffer::GetRenderbufferParameter(RBTarget target,
                                            RBParam pname) const
{
    gl::GLContext* gl = mContext->gl;

    switch (pname.get()) {
    case LOCAL_GL_RENDERBUFFER_STENCIL_SIZE:
        if (NeedsDepthStencilEmu(mContext->gl, InternalFormatForGL())) {
            if (gl->WorkAroundDriverBugs() &&
                gl->Renderer() == gl::GLRenderer::Tegra)
            {
                return 8;
            }

            gl::ScopedBindRenderbuffer autoRB(gl, mSecondaryRB);

            GLint i = 0;
            gl->fGetRenderbufferParameteriv(target.get(), pname.get(), &i);
            return i;
        }
        // Fall through otherwise.

    case LOCAL_GL_RENDERBUFFER_WIDTH:
    case LOCAL_GL_RENDERBUFFER_HEIGHT:
    case LOCAL_GL_RENDERBUFFER_RED_SIZE:
    case LOCAL_GL_RENDERBUFFER_GREEN_SIZE:
    case LOCAL_GL_RENDERBUFFER_BLUE_SIZE:
    case LOCAL_GL_RENDERBUFFER_ALPHA_SIZE:
    case LOCAL_GL_RENDERBUFFER_DEPTH_SIZE:
        {
            GLint i = 0;
            gl->fGetRenderbufferParameteriv(target.get(), pname.get(), &i);
            return i;
        }
    }

    MOZ_ASSERT(false,
               "This function should only be called with valid `pname`.");
    return 0;
}