Move push/popRenderTarget to kwingluitls
(De)Activating a FBO is OpenGL specific and does not belong into EffectsHandler.
This commit is contained in:
parent
16a025d907
commit
e5e5c4a020
11 changed files with 38 additions and 52 deletions
30
effects.cpp
30
effects.cpp
|
@ -784,36 +784,6 @@ EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectsHandlerImpl::pushRenderTarget(GLRenderTarget* target)
|
|
||||||
{
|
|
||||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
|
||||||
target->enable();
|
|
||||||
render_targets.push(target);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
GLRenderTarget* EffectsHandlerImpl::popRenderTarget()
|
|
||||||
{
|
|
||||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
|
||||||
GLRenderTarget* ret = render_targets.pop();
|
|
||||||
ret->disable();
|
|
||||||
if (!render_targets.isEmpty())
|
|
||||||
render_targets.top()->enable();
|
|
||||||
return ret;
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EffectsHandlerImpl::isRenderTargetBound()
|
|
||||||
{
|
|
||||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
|
||||||
return !render_targets.isEmpty();
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void EffectsHandlerImpl::addRepaintFull()
|
void EffectsHandlerImpl::addRepaintFull()
|
||||||
{
|
{
|
||||||
Workspace::self()->addRepaintFull();
|
Workspace::self()->addRepaintFull();
|
||||||
|
|
|
@ -111,10 +111,6 @@ public:
|
||||||
virtual void setActiveFullScreenEffect(Effect* e);
|
virtual void setActiveFullScreenEffect(Effect* e);
|
||||||
virtual Effect* activeFullScreenEffect() const;
|
virtual Effect* activeFullScreenEffect() const;
|
||||||
|
|
||||||
virtual void pushRenderTarget(GLRenderTarget* target);
|
|
||||||
virtual GLRenderTarget* popRenderTarget();
|
|
||||||
virtual bool isRenderTargetBound();
|
|
||||||
|
|
||||||
virtual void addRepaintFull();
|
virtual void addRepaintFull();
|
||||||
virtual void addRepaint(const QRect& r);
|
virtual void addRepaint(const QRect& r);
|
||||||
virtual void addRepaint(const QRegion& r);
|
virtual void addRepaint(const QRegion& r);
|
||||||
|
@ -202,7 +198,6 @@ protected:
|
||||||
void setupUnmanagedConnections(KWin::Unmanaged *u);
|
void setupUnmanagedConnections(KWin::Unmanaged *u);
|
||||||
|
|
||||||
Effect* keyboard_grab_effect;
|
Effect* keyboard_grab_effect;
|
||||||
QStack<GLRenderTarget*> render_targets;
|
|
||||||
Effect* fullscreen_effect;
|
Effect* fullscreen_effect;
|
||||||
QList<EffectWindow*> elevated_windows;
|
QList<EffectWindow*> elevated_windows;
|
||||||
QMultiMap< int, EffectPair > effect_order;
|
QMultiMap< int, EffectPair > effect_order;
|
||||||
|
|
|
@ -273,7 +273,7 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o
|
||||||
r.width(), r.height());
|
r.width(), r.height());
|
||||||
|
|
||||||
// Draw the texture on the offscreen framebuffer object, while blurring it horizontally
|
// Draw the texture on the offscreen framebuffer object, while blurring it horizontally
|
||||||
effects->pushRenderTarget(target);
|
GLRenderTarget::pushRenderTarget(target);
|
||||||
|
|
||||||
shader->bind();
|
shader->bind();
|
||||||
shader->setDirection(Qt::Horizontal);
|
shader->setDirection(Qt::Horizontal);
|
||||||
|
@ -293,7 +293,7 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o
|
||||||
|
|
||||||
drawRegion(expanded);
|
drawRegion(expanded);
|
||||||
|
|
||||||
effects->popRenderTarget();
|
GLRenderTarget::popRenderTarget();
|
||||||
scratch.unbind();
|
scratch.unbind();
|
||||||
scratch.discard();
|
scratch.discard();
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ void LogoutEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
||||||
{
|
{
|
||||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||||
if (blurSupported && progress > 0.0)
|
if (blurSupported && progress > 0.0)
|
||||||
effects->pushRenderTarget(blurTarget);
|
GLRenderTarget::pushRenderTarget(blurTarget);
|
||||||
#endif
|
#endif
|
||||||
effects->paintScreen(mask, region, data);
|
effects->paintScreen(mask, region, data);
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ void LogoutEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
||||||
// is set as it may still be even if it wasn't rendered.
|
// is set as it may still be even if it wasn't rendered.
|
||||||
renderVignetting();
|
renderVignetting();
|
||||||
} else {
|
} else {
|
||||||
GLRenderTarget* target = effects->popRenderTarget();
|
GLRenderTarget* target = GLRenderTarget::popRenderTarget();
|
||||||
assert(target == blurTarget);
|
assert(target == blurTarget);
|
||||||
Q_UNUSED(target);
|
Q_UNUSED(target);
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ void LookingGlassEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||||
if (m_valid && m_enabled) {
|
if (m_valid && m_enabled) {
|
||||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||||
// Start rendering to texture
|
// Start rendering to texture
|
||||||
effects->pushRenderTarget(m_fbo);
|
GLRenderTarget::pushRenderTarget(m_fbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
effects->prePaintScreen(data, time);
|
effects->prePaintScreen(data, time);
|
||||||
|
@ -231,7 +231,7 @@ void LookingGlassEffect::postPaintScreen()
|
||||||
effects->postPaintScreen();
|
effects->postPaintScreen();
|
||||||
if (m_valid && m_enabled) {
|
if (m_valid && m_enabled) {
|
||||||
// Disable render texture
|
// Disable render texture
|
||||||
GLRenderTarget* target = effects->popRenderTarget();
|
GLRenderTarget* target = GLRenderTarget::popRenderTarget();
|
||||||
assert(target == m_fbo);
|
assert(target == m_fbo);
|
||||||
Q_UNUSED(target);
|
Q_UNUSED(target);
|
||||||
m_texture->bind();
|
m_texture->bind();
|
||||||
|
|
|
@ -102,7 +102,7 @@ void ScreenShotEffect::postPaintScreen()
|
||||||
d.yTranslate = -m_scheduledScreenshot->y() - top;
|
d.yTranslate = -m_scheduledScreenshot->y() - top;
|
||||||
// render window into offscreen texture
|
// render window into offscreen texture
|
||||||
int mask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT;
|
int mask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT;
|
||||||
effects->pushRenderTarget(target);
|
GLRenderTarget::pushRenderTarget(target);
|
||||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
|
@ -110,7 +110,7 @@ void ScreenShotEffect::postPaintScreen()
|
||||||
// copy content from framebuffer into image
|
// copy content from framebuffer into image
|
||||||
QImage img(QSize(width, height), QImage::Format_ARGB32);
|
QImage img(QSize(width, height), QImage::Format_ARGB32);
|
||||||
glReadPixels(0, offscreenTexture->height() - height, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits());
|
glReadPixels(0, offscreenTexture->height() - height, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits());
|
||||||
effects->popRenderTarget();
|
GLRenderTarget::popRenderTarget();
|
||||||
ScreenShotEffect::convertFromGLImage(img, width, height);
|
ScreenShotEffect::convertFromGLImage(img, width, height);
|
||||||
if (m_type & INCLUDE_CURSOR) {
|
if (m_type & INCLUDE_CURSOR) {
|
||||||
grabPointerImage(img, m_scheduledScreenshot->x() + left, m_scheduledScreenshot->y() + top);
|
grabPointerImage(img, m_scheduledScreenshot->x() + left, m_scheduledScreenshot->y() + top);
|
||||||
|
|
|
@ -256,7 +256,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
|
||||||
|
|
||||||
// Bind the offscreen FBO and draw the window on it unscaled
|
// Bind the offscreen FBO and draw the window on it unscaled
|
||||||
updateOffscreenSurfaces();
|
updateOffscreenSurfaces();
|
||||||
effects->pushRenderTarget(m_offscreenTarget);
|
GLRenderTarget::pushRenderTarget(m_offscreenTarget);
|
||||||
|
|
||||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
@ -341,7 +341,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
|
||||||
cache->setWrapMode(GL_CLAMP_TO_EDGE);
|
cache->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||||
cache->bind();
|
cache->bind();
|
||||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, m_offscreenTex->height() - th, tw, th);
|
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, m_offscreenTex->height() - th, tw, th);
|
||||||
effects->popRenderTarget();
|
GLRenderTarget::popRenderTarget();
|
||||||
|
|
||||||
if (ShaderManager::instance()->isValid()) {
|
if (ShaderManager::instance()->isValid()) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
|
@ -744,7 +744,7 @@ PaintClipper::Iterator::Iterator()
|
||||||
#ifndef KWIN_HAVE_OPENGLES
|
#ifndef KWIN_HAVE_OPENGLES
|
||||||
glPushAttrib(GL_SCISSOR_BIT);
|
glPushAttrib(GL_SCISSOR_BIT);
|
||||||
#endif
|
#endif
|
||||||
if (!effects->isRenderTargetBound())
|
if (!GLRenderTarget::isRenderTargetBound())
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
data->rects = paintArea().rects();
|
data->rects = paintArea().rects();
|
||||||
data->index = -1;
|
data->index = -1;
|
||||||
|
@ -764,7 +764,7 @@ PaintClipper::Iterator::~Iterator()
|
||||||
{
|
{
|
||||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||||
if (clip() && effects->compositingType() == OpenGLCompositing) {
|
if (clip() && effects->compositingType() == OpenGLCompositing) {
|
||||||
if (!effects->isRenderTargetBound())
|
if (!GLRenderTarget::isRenderTargetBound())
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
#ifndef KWIN_HAVE_OPENGLES
|
#ifndef KWIN_HAVE_OPENGLES
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
@ -797,7 +797,7 @@ void PaintClipper::Iterator::next()
|
||||||
{
|
{
|
||||||
data->index++;
|
data->index++;
|
||||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||||
if (clip() && effects->compositingType() == OpenGLCompositing && !effects->isRenderTargetBound() && data->index < data->rects.count()) {
|
if (clip() && effects->compositingType() == OpenGLCompositing && !GLRenderTarget::isRenderTargetBound() && data->index < data->rects.count()) {
|
||||||
const QRect& r = data->rects[ data->index ];
|
const QRect& r = data->rects[ data->index ];
|
||||||
// Scissor rect has to be given in OpenGL coords
|
// Scissor rect has to be given in OpenGL coords
|
||||||
glScissor(r.x(), displayHeight() - r.y() - r.height(), r.width(), r.height());
|
glScissor(r.x(), displayHeight() - r.y() - r.height(), r.width(), r.height());
|
||||||
|
|
|
@ -700,10 +700,6 @@ public:
|
||||||
virtual void setActiveFullScreenEffect(Effect* e) = 0;
|
virtual void setActiveFullScreenEffect(Effect* e) = 0;
|
||||||
virtual Effect* activeFullScreenEffect() const = 0;
|
virtual Effect* activeFullScreenEffect() const = 0;
|
||||||
|
|
||||||
virtual void pushRenderTarget(GLRenderTarget* target) = 0;
|
|
||||||
virtual GLRenderTarget* popRenderTarget() = 0;
|
|
||||||
virtual bool isRenderTargetBound() = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules the entire workspace to be repainted next time.
|
* Schedules the entire workspace to be repainted next time.
|
||||||
* If you call it during painting (including prepaint) then it does not
|
* If you call it during painting (including prepaint) then it does not
|
||||||
|
|
|
@ -1326,6 +1326,7 @@ void ShaderManager::resetShader(ShaderType type)
|
||||||
|
|
||||||
/*** GLRenderTarget ***/
|
/*** GLRenderTarget ***/
|
||||||
bool GLRenderTarget::sSupported = false;
|
bool GLRenderTarget::sSupported = false;
|
||||||
|
QStack<GLRenderTarget*> GLRenderTarget::s_renderTargets = QStack<GLRenderTarget*>();
|
||||||
|
|
||||||
void GLRenderTarget::initStatic()
|
void GLRenderTarget::initStatic()
|
||||||
{
|
{
|
||||||
|
@ -1336,6 +1337,26 @@ void GLRenderTarget::initStatic()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GLRenderTarget::isRenderTargetBound()
|
||||||
|
{
|
||||||
|
return !s_renderTargets.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLRenderTarget::pushRenderTarget(GLRenderTarget* target)
|
||||||
|
{
|
||||||
|
target->enable();
|
||||||
|
s_renderTargets.push(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLRenderTarget* GLRenderTarget::popRenderTarget()
|
||||||
|
{
|
||||||
|
GLRenderTarget* ret = s_renderTargets.pop();
|
||||||
|
ret->disable();
|
||||||
|
if (!s_renderTargets.isEmpty())
|
||||||
|
s_renderTargets.top()->enable();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
GLRenderTarget::GLRenderTarget(GLTexture* color)
|
GLRenderTarget::GLRenderTarget(GLTexture* color)
|
||||||
{
|
{
|
||||||
// Reset variables
|
// Reset variables
|
||||||
|
|
|
@ -523,6 +523,9 @@ public:
|
||||||
static bool supported() {
|
static bool supported() {
|
||||||
return sSupported;
|
return sSupported;
|
||||||
}
|
}
|
||||||
|
static void pushRenderTarget(GLRenderTarget *target);
|
||||||
|
static GLRenderTarget *popRenderTarget();
|
||||||
|
static bool isRenderTargetBound();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -531,6 +534,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool sSupported;
|
static bool sSupported;
|
||||||
|
static QStack<GLRenderTarget*> s_renderTargets;
|
||||||
|
|
||||||
GLTexture* mTexture;
|
GLTexture* mTexture;
|
||||||
bool mValid;
|
bool mValid;
|
||||||
|
|
Loading…
Reference in a new issue