From 3f4b77e0eac934b62904091edc98836062878a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 20 Apr 2009 11:33:06 +0000 Subject: [PATCH] Pass opacity, brightness and saturation from shadow to a bound shader. So the shadow won't be a solid brick when a shader (e.g. invert) is active. CCBUG: 188352 svn path=/trunk/KDE/kdebase/workspace/; revision=956600 --- effects/shadow/shadow.cpp | 26 +++++++++++++++++++------- effects/shadow/shadow.h | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/effects/shadow/shadow.cpp b/effects/shadow/shadow.cpp index 6c289d3bfb..3577ddc6b2 100644 --- a/effects/shadow/shadow.cpp +++ b/effects/shadow/shadow.cpp @@ -656,12 +656,18 @@ void ShadowEffect::restoreRenderStates( GLTexture *texture, double opacity, doub } void ShadowEffect::drawShadowQuadOpenGL( GLTexture *texture, QVector verts, QVector texCoords, - QRegion region, float opacity, float brightness, float saturation ) + QRegion region, float opacity, float brightness, float saturation, GLShader* shader ) { #ifdef KWIN_HAVE_OPENGL_COMPOSITING glColor4f( 1.0, 1.0, 1.0, 1.0 ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); prepareRenderStates( texture, opacity, brightness, saturation ); // Usually overrides the above + if( shader ) + { + shader->setUniform("opacity", opacity); + shader->setUniform("saturation", saturation); + shader->setUniform("brightness", brightness); + } texture->bind(); texture->enableNormalizedTexCoords(); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); @@ -811,7 +817,8 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c verts, texcoords, region, data.opacity * window->shadowOpacity( ShadowBorderedActive ), data.brightness * window->shadowBrightness( ShadowBorderedActive ), - data.saturation * window->shadowSaturation( ShadowBorderedActive )); + data.saturation * window->shadowSaturation( ShadowBorderedActive ), + data.shader); // Inactive shadow texture = effects->shadowTextureList( ShadowBorderedInactive ); @@ -819,7 +826,8 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c verts, texcoords, region, data.opacity * window->shadowOpacity( ShadowBorderedInactive ), data.brightness * window->shadowBrightness( ShadowBorderedInactive ), - data.saturation * window->shadowSaturation( ShadowBorderedInactive )); + data.saturation * window->shadowSaturation( ShadowBorderedInactive ), + data.shader); } else if( effects->shadowTextureList( ShadowBorderlessActive ) == texture ) { // Decoration-less normal windows @@ -829,7 +837,8 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c verts, texcoords, region, data.opacity * window->shadowOpacity( ShadowBorderlessActive ), data.brightness * window->shadowBrightness( ShadowBorderlessActive ), - data.saturation * window->shadowSaturation( ShadowBorderlessActive )); + data.saturation * window->shadowSaturation( ShadowBorderlessActive ), + data.shader); } else { @@ -838,7 +847,8 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c verts, texcoords, region, data.opacity * window->shadowOpacity( ShadowBorderlessInactive ), data.brightness * window->shadowBrightness( ShadowBorderlessInactive ), - data.saturation * window->shadowSaturation( ShadowBorderlessInactive )); + data.saturation * window->shadowSaturation( ShadowBorderlessInactive ), + data.shader); } } else @@ -847,7 +857,8 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c verts, texcoords, region, data.opacity * window->shadowOpacity( ShadowOther ), data.brightness * window->shadowBrightness( ShadowOther ), - data.saturation * window->shadowSaturation( ShadowOther )); + data.saturation * window->shadowSaturation( ShadowOther ), + data.shader); } } } @@ -861,7 +872,8 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c verts, texcoords, region, data.opacity * opacity, data.brightness, - data.saturation ); + data.saturation, + data.shader); } glPopMatrix(); diff --git a/effects/shadow/shadow.h b/effects/shadow/shadow.h index 452e589496..fb1a48195d 100644 --- a/effects/shadow/shadow.h +++ b/effects/shadow/shadow.h @@ -54,7 +54,7 @@ class ShadowEffect void restoreRenderStates( GLTexture *texture, double opacity, double brightness, double saturation ); void drawShadowQuadOpenGL( GLTexture *texture, QVector verts, QVector texCoords, - QRegion region, float opacity, float brightness, float saturation ); + QRegion region, float opacity, float brightness, float saturation, GLShader* shader ); void drawShadowQuadXRender( XRenderPicture *picture, QRect rect, float xScale, float yScale, QColor color, float opacity, float brightness, float saturation );