From eae6279ca9d5266726dec300454c83ee98910ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 22 Feb 2009 10:58:26 +0000 Subject: [PATCH] Fill empty areas in multi screen setups in cylinder and sphere as well. svn path=/trunk/KDE/kdebase/workspace/; revision=929833 --- effects/cube/cube.cpp | 39 ++++++++++++++++++++++++++------- effects/cube/data/cylinder.frag | 19 +++++++++++----- effects/cube/data/cylinder.vert | 1 + effects/cube/data/sphere.vert | 1 + 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 0142d06e3c..4d4a063cf3 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -1347,6 +1347,7 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP 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 ); float factor = 0.0f; if( start ) factor = 1.0f - timeLine.value(); @@ -1363,6 +1364,7 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP sphereShader->setUniform( "xCoord", (float)w->x() ); sphereShader->setUniform( "yCoord", (float)w->y() ); sphereShader->setUniform( "cubeAngle", (effects->numberOfDesktops() - 2 )/(float)effects->numberOfDesktops() * 180.0f ); + sphereShader->setUniform( "useTexture", 1.0f ); float factor = 0.0f; if( start ) factor = 1.0f - timeLine.value(); @@ -1531,8 +1533,13 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP } data.quads = new_quads; } + } + effects->paintWindow( w, mask, region, data ); + if( activated && cube_painting ) + { if( w->isDesktop() && effects->numScreens() > 1 && paintCaps ) { + QRect rect = effects->clientArea( FullArea, activeScreen, painting_desktop ); QRegion paint = QRegion( rect ); for( int i=0; inumScreens(); i++ ) { @@ -1544,6 +1551,17 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP // in case of free area in multiscreen setup fill it with cap color if( !paint.isEmpty() ) { + if( mode == Cylinder ) + { + cylinderShader->setUniform( "useTexture", -1.0f ); + cylinderShader->setUniform( "xCoord", 0.0f ); + } + if( mode == Sphere ) + { + sphereShader->setUniform( "useTexture", -1.0f ); + sphereShader->setUniform( "xCoord", 0.0f ); + sphereShader->setUniform( "yCoord", 0.0f ); + } glColor4f( capColor.redF(), capColor.greenF(), capColor.blueF(), cubeOpacity ); glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT ); glEnable( GL_BLEND ); @@ -1551,20 +1569,25 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP glBegin( GL_QUADS ); foreach( QRect paintRect, paint.rects() ) { - glVertex2f( paintRect.x(), paintRect.y() ); - glVertex2f( paintRect.x()+paintRect.width(), paintRect.y() ); - glVertex2f( paintRect.x()+paintRect.width(), paintRect.y() + paintRect.height() ); - glVertex2f( paintRect.x(), paintRect.y() + paintRect.height() ); + for( int i=0; i<=(paintRect.height()/40.0); i++ ) + { + for( int j=0; j<=(paintRect.width()/40.0); j++ ) + { + glVertex2f( paintRect.x()+j*40.0f, paintRect.y()+i*40.0f ); + glVertex2f( qMin( paintRect.x()+(j+1)*40.0f, (float)paintRect.x() + paintRect.width() ), + paintRect.y()+i*40.0f ); + glVertex2f( qMin( paintRect.x()+(j+1)*40.0f, (float)paintRect.x() + paintRect.width() ), + qMin( paintRect.y() + (i+1)*40.0f, (float)paintRect.y() + paintRect.height() ) ); + glVertex2f( paintRect.x()+j*40.0f, + qMin( paintRect.y() + (i+1)*40.0f, (float)paintRect.y() + paintRect.height() ) ); + } + } } glEnd(); glDisable( GL_BLEND ); glPopAttrib(); } } - } - effects->paintWindow( w, mask, region, data ); - if( activated && cube_painting ) - { glPopMatrix(); if( mode == Cylinder ) cylinderShader->unbind(); diff --git a/effects/cube/data/cylinder.frag b/effects/cube/data/cylinder.frag index d467c64141..f8bad0eb96 100644 --- a/effects/cube/data/cylinder.frag +++ b/effects/cube/data/cylinder.frag @@ -3,6 +3,7 @@ uniform float windowWidth; uniform float windowHeight; uniform float opacity; uniform float front; +uniform float useTexture; vec2 pix2tex(vec2 pix) { @@ -15,10 +16,18 @@ void main() discard; if( front < 0.0 && !gl_FrontFacing ) discard; - // 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 ) - discard; - gl_FragColor.rgba = texture2D(winTexture, pix2tex(gl_TexCoord[0].xy)).rgba; + + 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 ) + discard; + gl_FragColor.rgba = texture2D(winTexture, pix2tex(gl_TexCoord[0].xy)).rgba; + } + else + { + gl_FragColor = gl_Color; + } gl_FragColor.a = gl_FragColor.a * opacity; } diff --git a/effects/cube/data/cylinder.vert b/effects/cube/data/cylinder.vert index e3a766e422..4a706628e6 100644 --- a/effects/cube/data/cylinder.vert +++ b/effects/cube/data/cylinder.vert @@ -36,4 +36,5 @@ void main() vec3 diff = (gl_Vertex.xyz - vertex.xyz)*timeLine; vertex.xyz += diff; gl_Position = gl_ModelViewProjectionMatrix * vertex; + gl_FrontColor = gl_Color; } diff --git a/effects/cube/data/sphere.vert b/effects/cube/data/sphere.vert index 9921b60412..dca87ee6a5 100644 --- a/effects/cube/data/sphere.vert +++ b/effects/cube/data/sphere.vert @@ -41,4 +41,5 @@ void main() vertex.xyz += diff; gl_Position = gl_ModelViewProjectionMatrix * vec4( vertex, 1.0 ); + gl_FrontColor = gl_Color; }