[kwinglutils] Improve cleanup handling

* add static cleanup handlers to GLTexturePrivate and GLRenderTarget
* revert the runtime resolved features (e.g. RenderTargets are not
  supported once we run the cleanup code)
* clear the extension lists
* reset the version variables

REVIEW: 117484
This commit is contained in:
Martin Gräßlin 2014-04-10 18:04:54 +02:00
parent c837ffddf4
commit b8cc10ffab
4 changed files with 34 additions and 0 deletions

View file

@ -175,6 +175,14 @@ void GLTexturePrivate::initStatic()
#endif
}
void GLTexturePrivate::cleanup()
{
sNPOTTextureSupported = false;
sFramebufferObjectSupported = false;
sSaturationSupported = false;
sTextureFormat = GL_RGBA; // custom dummy, GL_BGRA is not present on GLES
}
bool GLTexture::isNull() const
{
Q_D(const GLTexture);

View file

@ -77,6 +77,8 @@ public:
static uint s_fbo;
static uint s_textureObjectCounter;
private:
friend void KWin::cleanupGL();
static void cleanup();
Q_DISABLE_COPY(GLTexturePrivate)
};

View file

@ -136,8 +136,19 @@ void initGL(OpenGLPlatformInterface platformInterface)
void cleanupGL()
{
ShaderManager::cleanup();
GLTexturePrivate::cleanup();
GLRenderTarget::cleanup();
GLVertexBuffer::cleanup();
GLPlatform::cleanup();
glExtensions.clear();
glxExtensions.clear();
eglExtension.clear();
glVersion = 0;
glXVersion = 0;
eglVersion = 0;
glTextureUnitsCount = 0;
}
bool hasGLVersion(int major, int minor, int release)
@ -924,6 +935,13 @@ void GLRenderTarget::initStatic()
#endif
}
void GLRenderTarget::cleanup()
{
Q_ASSERT(s_renderTargets.isEmpty());
sSupported = false;
s_blitSupported = false;
}
bool GLRenderTarget::isRenderTargetBound()
{
return !s_renderTargets.isEmpty();
@ -1873,6 +1891,10 @@ void GLVertexBuffer::cleanup()
delete GLVertexBufferPrivate::s_indexBuffer;
GLVertexBufferPrivate::s_indexBuffer = nullptr;
#endif
GLVertexBufferPrivate::hasMapBufferRange = false;
GLVertexBufferPrivate::supportsIndexedQuads = false;
delete GLVertexBufferPrivate::streamingBuffer;
GLVertexBufferPrivate::streamingBuffer = nullptr;
}
GLVertexBuffer *GLVertexBuffer::streamingBuffer()

View file

@ -511,6 +511,8 @@ protected:
private:
friend void KWin::cleanupGL();
static void cleanup();
static bool sSupported;
static bool s_blitSupported;
static QStack<GLRenderTarget*> s_renderTargets;