From 0fc1142ca229dcc40d7fd29ee3eccc633fe3955b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 8 Oct 2015 15:54:24 +0200 Subject: [PATCH] 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. --- scene_opengl.cpp | 4 +++- scene_opengl.h | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 8b3be71d50..13714e3634 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -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; diff --git a/scene_opengl.h b/scene_opengl.h index 5a697bdfdc..8f7c3d3ca3 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -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