bool
GLContextWGL::BindTex2DOffscreen(GLContext *aOffscreen)
{
    if (aOffscreen->GetContextType() != ContextTypeWGL) {
        NS_WARNING("non-WGL context");
        return false;
    }

    if (!aOffscreen->IsOffscreen()) {
        NS_WARNING("non-offscreen context");
        return false;
    }

    GLContextWGL *offs = static_cast<GLContextWGL*>(aOffscreen);

    if (offs->mPBuffer) {
        BOOL ok = sWGLLib[mLibType].fBindTexImage(offs->mPBuffer,
                                            LOCAL_WGL_FRONT_LEFT_ARB);
        if (!ok) {
            NS_WARNING("CanvasLayerOGL::Updated wglBindTexImageARB failed");
            return false;
        }
    } else if (offs->mOffscreenTexture) {
          GLContext::ContextFlags flag = 
                       sWGLLib[mLibType].GetLibraryType() == WGLLibrary::MESA_LLVMPIPE_LIB
                       ? GLContext::ContextFlagsMesaLLVMPipe
                       : GLContext::ContextFlagsNone;

        if (offs->GetSharedContext() != GLContextProviderWGL::GetGlobalContext(flag))
        {
            NS_WARNING("offscreen FBO context can only be bound with context sharing!");
            return false;
        }

        fBindTexture(LOCAL_GL_TEXTURE_2D, offs->mOffscreenTexture);
    } else {
        NS_WARNING("don't know how to bind this!");
        return false;
    }

    return true;
}
PRBool
GLContextWGL::BindTex2DOffscreen(GLContext *aOffscreen)
{
    if (aOffscreen->GetContextType() != ContextTypeWGL) {
        NS_WARNING("non-WGL context");
        return PR_FALSE;
    }

    if (!aOffscreen->IsOffscreen()) {
        NS_WARNING("non-offscreen context");
        return PR_FALSE;
    }

    GLContextWGL *offs = static_cast<GLContextWGL*>(aOffscreen);

    if (offs->mPBuffer) {
        BOOL ok = sWGLLibrary.fBindTexImage(offs->mPBuffer,
                                            LOCAL_WGL_FRONT_LEFT_ARB);
        if (!ok) {
            NS_WARNING("CanvasLayerOGL::Updated wglBindTexImageARB failed");
            return PR_FALSE;
        }
    } else if (offs->mOffscreenTexture) {
        if (offs->GetSharedContext() != GLContextProviderWGL::GetGlobalContext())
        {
            NS_WARNING("offscreen FBO context can only be bound with context sharing!");
            return PR_FALSE;
        }

        fBindTexture(LOCAL_GL_TEXTURE_2D, offs->mOffscreenTexture);
    } else {
        NS_WARNING("don't know how to bind this!");
        return PR_FALSE;
    }

    return PR_TRUE;
}