Make the new taskbar thumbnail shader work with NVIDIA driver. Therefore the alpha channel has to be added to oqaque windows in scene_opengl.

svn path=/trunk/KDE/kdebase/workspace/; revision=1130622
This commit is contained in:
Martin Gräßlin 2010-05-25 20:28:23 +00:00
parent e9f419c819
commit cfce13e615
3 changed files with 14 additions and 13 deletions

View file

@ -47,14 +47,6 @@ TaskbarThumbnailEffect::TaskbarThumbnailEffect()
unsigned char dummy = 0;
XChangeProperty( display(), rootWindow(), atom, atom, 8, PropModeReplace, &dummy, 1 );
// With the NVIDIA driver the alpha values are set to 0 when drawing a window texture
// without an alpha channel on an FBO that has an alpha channel.
// This creates problems when the FBO is drawn on the backbuffer with blending enabled,
// so for now we only do high quality scaling with windows with alpha channels with
// the NVIDIA driver.
const QByteArray vendor = (const char *) glGetString( GL_VENDOR );
alphaWindowsOnly = vendor.startsWith("NVIDIA");
if ( GLShader::fragmentShaderSupported() &&
GLShader::vertexShaderSupported() &&
GLRenderTarget::supported() )
@ -193,13 +185,13 @@ void TaskbarThumbnailEffect::paintWindow( EffectWindow* w, int mask, QRegion reg
if( thumbw == NULL )
continue;
WindowPaintData thumbData( thumbw );
thumbData.opacity = data.opacity;
thumbData.opacity *= data.opacity;
QRect r;
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( effects->compositingType() == KWin::OpenGLCompositing )
{
if ( shader && (!alphaWindowsOnly || thumbw->hasAlpha()) )
if ( shader )
{
int tx = thumb.rect.x() + w->x();
int ty = thumb.rect.y() + w->y();

View file

@ -67,7 +67,6 @@ class TaskbarThumbnailEffect
int uOffsets;
int uKernel;
int uKernelSize;
bool alphaWindowsOnly;
};
} // namespace

View file

@ -1838,6 +1838,16 @@ void SceneOpenGL::Window::prepareRenderStates( TextureType type, double opacity,
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant );
}
}
else if( !alpha && opaque )
{
float constant[] = { 1.0, 1.0, 1.0, 1.0 };
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_CONSTANT );
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant );
}
}
void SceneOpenGL::Window::restoreStates( TextureType type, double opacity, double brightness, double saturation, GLShader* shader )
@ -1893,9 +1903,9 @@ void SceneOpenGL::Window::restoreRenderStates( TextureType type, double opacity,
glDisable( tex->target());
glActiveTexture(GL_TEXTURE0);
}
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glColor4f( 0, 0, 0, 0 );
}
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glColor4f( 0, 0, 0, 0 );
glPopAttrib(); // ENABLE_BIT
}