SkGLContextHelper::~SkGLContextHelper() {

    if (fGL) {
        // TODO: determine why DeleteFramebuffers is generating a GL error in tests
        SK_GL_NOERRCHECK(*this, DeleteFramebuffers(1, &fFBO));
        SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fColorBufferID));
        SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fDepthStencilBufferID));
    }

    SkSafeUnref(fGL);
}
void SkNativeSharedGLContext::destroyGLResources() {
    if (fGL) {
        // We need this thread to grab the GLX context before we can make
        // OpenGL calls.  But glXMakeCurrent() will flush the old context,
        // which might have been uninitialized.  Calling with (None, NULL)
        // first solves this problem (somehow).
        glXMakeCurrent(fDisplay, None, NULL);
        glXMakeCurrent(fDisplay, fGlxPixmap, fContext);

        SK_GL_NOERRCHECK(*this, DeleteFramebuffers(1, &fFBO));
        SK_GL_NOERRCHECK(*this, DeleteTextures(1, &fTextureID));
        SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fDepthStencilBufferID));
    }

    glXMakeCurrent(fDisplay, None, NULL);
    glXDestroyGLXPixmap(fDisplay, fGlxPixmap);
    fGlxPixmap = 0;
}