From 054c8a62a65943f739773acd2a1d5b2d5ae8aa4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 18 Dec 2010 21:11:45 +0100 Subject: [PATCH] Reflected windows in coverswitch Reflection plane is still missing On special request I added showing the reflected windows during the animation when the shader is used --- effects/coverswitch/coverswitch.cpp | 39 ++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/effects/coverswitch/coverswitch.cpp b/effects/coverswitch/coverswitch.cpp index 75866f9b52..23fd297c7e 100644 --- a/effects/coverswitch/coverswitch.cpp +++ b/effects/coverswitch/coverswitch.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . #include #include +#include #include #include #include @@ -248,14 +249,15 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& if( reflection ) { -#ifndef KWIN_HAVE_OPENGLES // restrict painting the reflections to the current screen QRegion clip = QRegion( area ); PaintClipper::push( clip ); // no reflections during start and stop animation - if( !start && !stop ) + // except when using a shader + if( (!start && !stop) || ShaderManager::instance()->isValid() ) paintScene( frontWindow, leftWindows, rightWindows, true ); PaintClipper::pop( clip ); +#ifndef KWIN_HAVE_OPENGLES glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA ); glPolygonMode( GL_FRONT, GL_FILL ); @@ -770,16 +772,35 @@ void CoverSwitchEffect::paintWindowCover( EffectWindow* w, bool reflectedWindow, if( reflectedWindow ) { + if (ShaderManager::instance()->isValid()) { + GLShader *shader = ShaderManager::instance()->pushShader(ShaderManager::GenericShader); + QMatrix4x4 origMatrix = shader->getUniformMatrix4x4("screenTransformation"); + QMatrix4x4 reflectionMatrix; + reflectionMatrix.scale(1.0, -1.0, 1.0); + shader->setUniform("screenTransformation", origMatrix*reflectionMatrix); + data.yTranslate = - area.height() - windowRect.y() - windowRect.height(); + if (start) { + data.opacity *= timeLine.value(); + } else if (stop) { + data.opacity *= 1.0 - timeLine.value(); + } + effects->paintWindow( w, + PAINT_WINDOW_TRANSFORMED, + infiniteRegion(), data ); + shader->setUniform("screenTransformation", origMatrix); + ShaderManager::instance()->popShader(); + } else { #ifndef KWIN_HAVE_OPENGLES - glPushMatrix(); - glScalef( 1.0, -1.0, 1.0 ); - data.yTranslate = - area.height() - windowRect.y() - windowRect.height(); - effects->paintWindow( w, - PAINT_WINDOW_TRANSFORMED, - infiniteRegion(), data ); - glPopMatrix(); + glPushMatrix(); + glScalef( 1.0, -1.0, 1.0 ); + data.yTranslate = - area.height() - windowRect.y() - windowRect.height(); + effects->paintWindow( w, + PAINT_WINDOW_TRANSFORMED, + infiniteRegion(), data ); + glPopMatrix(); #endif } + } else { effects->paintWindow( w,