Allow OpenGLBackend to hold a surfaceless context

For a virtual rendering backend a surfaceless context is needed. Such
a context may not call glDrawBuffer as that results in a GL error.

This change allows the OpenGLBackend to announce that it's context is
surfaceless.
This commit is contained in:
Martin Gräßlin 2015-10-08 15:54:24 +02:00
parent 2e888da70e
commit 0fc1142ca2
2 changed files with 18 additions and 1 deletions

View file

@ -405,7 +405,9 @@ SceneOpenGL::SceneOpenGL(OpenGLBackend *backend, QObject *parent)
return;
}
#ifndef KWIN_HAVE_OPENGLES
glDrawBuffer(GL_BACK);
if (!m_backend->isSurfaceLessContext()) {
glDrawBuffer(GL_BACK);
}
#endif
m_debug = qstrcmp(qgetenv("KWIN_GL_DEBUG"), "1") == 0;

View file

@ -482,6 +482,13 @@ public:
return m_haveBufferAge;
}
/**
* @returns whether the context is surfaceless
**/
bool isSurfaceLessContext() const {
return m_surfaceLessContext;
}
/**
* Returns the damage that has accumulated since a buffer of the given age was presented.
*/
@ -561,6 +568,13 @@ protected:
m_renderTimer.start();
}
/**
* @param set whether the context is surface less
**/
void setSurfaceLessContext(bool set) {
m_surfaceLessContext = set;
}
SwapProfiler m_swapProfiler;
private:
@ -596,6 +610,7 @@ private:
* @brief Timer to measure how long a frame renders.
**/
QElapsedTimer m_renderTimer;
bool m_surfaceLessContext = false;
};
class SceneOpenGLDecorationRenderer : public Decoration::Renderer