From 144f578a5d9792a2e8c40861666212c5a5473eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 27 Apr 2009 11:35:35 +0000 Subject: [PATCH] Cylinder and Sphere use new setting of texture width and height. For that renaming windowWidth and windowHeight to textureWidth/Height. So finally the new argb decos work with cylinder and sphere. svn path=/trunk/KDE/kdebase/workspace/; revision=959842 --- effects/cube/cube.cpp | 17 +++++++++++++---- effects/cube/data/cylinder.frag | 10 +++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 462c58af27..e02fe81c97 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -1294,8 +1294,6 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP if( mode == Cylinder ) { cylinderShader->bind(); - cylinderShader->setUniform( "windowWidth", (float)w->width() ); - cylinderShader->setUniform( "windowHeight", (float)w->height() ); cylinderShader->setUniform( "xCoord", (float)w->x() ); cylinderShader->setUniform( "cubeAngle", (effects->numberOfDesktops() - 2 )/(float)effects->numberOfDesktops() * 180.0f ); cylinderShader->setUniform( "useTexture", 1.0f ); @@ -1310,8 +1308,6 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP if( mode == Sphere ) { sphereShader->bind(); - sphereShader->setUniform( "windowWidth", (float)w->width() ); - sphereShader->setUniform( "windowHeight", (float)w->height() ); sphereShader->setUniform( "xCoord", (float)w->x() ); sphereShader->setUniform( "yCoord", (float)w->y() ); sphereShader->setUniform( "cubeAngle", (effects->numberOfDesktops() - 2 )/(float)effects->numberOfDesktops() * 180.0f ); @@ -1324,6 +1320,19 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP sphereShader->setUniform( "timeLine", factor ); data.shader = sphereShader; } + if( data.shader ) + { + int texw = w->width(); + int texh = w->height(); + if( !GLTexture::NPOTTextureSupported() ) + { + kWarning( 1212 ) << "NPOT textures not supported, wasting some memory" ; + texw = nearestPowerOfTwo(texw); + texh = nearestPowerOfTwo(texh); + } + data.shader->setTextureWidth( texw ); + data.shader->setTextureHeight( texh ); + } //kDebug(1212) << w->caption(); float opacity = cubeOpacity; if( start ) diff --git a/effects/cube/data/cylinder.frag b/effects/cube/data/cylinder.frag index bd544901e7..81d49d7ce1 100644 --- a/effects/cube/data/cylinder.frag +++ b/effects/cube/data/cylinder.frag @@ -1,6 +1,6 @@ uniform sampler2D winTexture; -uniform float windowWidth; -uniform float windowHeight; +uniform float textureWidth; +uniform float textureHeight; uniform float opacity; uniform float brightness; uniform float saturation; @@ -9,7 +9,7 @@ uniform float useTexture; vec2 pix2tex(vec2 pix) { - return vec2(pix.x / windowWidth, pix.y / windowHeight); + return vec2(pix.x / textureWidth, pix.y / textureHeight); } void main() @@ -22,8 +22,8 @@ void main() if( useTexture > 0.0 ) { // remove the shadow decoration quads - if( gl_TexCoord[0].x < 0.0 || gl_TexCoord[0].x > windowWidth || - gl_TexCoord[0].y < 0.0 || gl_TexCoord[0].y > windowHeight ) + if( gl_TexCoord[0].x < 0.0 || gl_TexCoord[0].x > textureWidth || + gl_TexCoord[0].y < 0.0 || gl_TexCoord[0].y > textureHeight ) discard; vec4 tex = texture2D(winTexture, pix2tex(gl_TexCoord[0].xy)); tex = vec4( tex.rgb, tex.a * opacity );