Commit 9c398de6 authored by Roman Gilg's avatar Roman Gilg Committed by David Edmundson

[libkwineffects] Set original backend framebuffer for render targets

Summary:
KWin only renders into the default framebuffer, which is for example an EGL
surface.

To prepare a post-processing step with a different framebuffer allow the
framebuffer to be changable. For that KWin's current framebuffer must be
communicated to the GLRenderTarget class, which otherwise does not set it back
to KWin's current one when a render target is disabled again.

Test Plan: Compiles, with other patches for Gl based screen rotation

Reviewers: #kwin

Subscribers: fredrik, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25904
parent dfea5798
......@@ -1061,6 +1061,7 @@ QSize GLRenderTarget::s_virtualScreenSize;
QRect GLRenderTarget::s_virtualScreenGeometry;
qreal GLRenderTarget::s_virtualScreenScale = 1.0;
GLint GLRenderTarget::s_virtualScreenViewport[4];
GLuint GLRenderTarget::s_kwinFramebuffer = 0;
void GLRenderTarget::initStatic()
{
......@@ -1185,7 +1186,7 @@ bool GLRenderTarget::disable()
return false;
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, s_kwinFramebuffer);
mTexture.setDirty();
return true;
......@@ -1256,7 +1257,7 @@ void GLRenderTarget::initFBO()
#if DEBUG_GLRENDERTARGET
if ((err = glGetError()) != GL_NO_ERROR) {
qCCritical(LIBKWINGLUTILS) << "glFramebufferTexture2D failed: " << formatGLError(err);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, s_kwinFramebuffer);
glDeleteFramebuffers(1, &mFramebuffer);
return;
}
......@@ -1264,7 +1265,7 @@ void GLRenderTarget::initFBO()
const GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, s_kwinFramebuffer);
if (status != GL_FRAMEBUFFER_COMPLETE) {
// We have an incomplete framebuffer, consider it invalid
......@@ -1291,7 +1292,7 @@ void GLRenderTarget::blitFromFramebuffer(const QRect &source, const QRect &desti
GLRenderTarget::pushRenderTarget(this);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mFramebuffer);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, s_kwinFramebuffer);
const QRect s = source.isNull() ? s_virtualScreenGeometry : source;
const QRect d = destination.isNull() ? QRect(0, 0, mTexture.width(), mTexture.height()) : destination;
......
......@@ -546,6 +546,15 @@ public:
return s_virtualScreenScale;
}
/**
* The framebuffer of KWin's OpenGL window or other object currently being rendered to
*
* @since 5.18
*/
static void setKWinFramebuffer(GLuint fb) {
s_kwinFramebuffer = fb;
}
protected:
void initFBO();
......@@ -561,6 +570,7 @@ private:
static QRect s_virtualScreenGeometry;
static qreal s_virtualScreenScale;
static GLint s_virtualScreenViewport[4];
static GLuint s_kwinFramebuffer;
GLTexture mTexture;
bool mValid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment