From 6a9b6692e8cf4168528cb11e9de9b5c231073577 Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Mon, 2 Mar 2009 05:18:13 +0000 Subject: [PATCH] Fix rendering of text and unstyled frames in OpenGL mode. Now it looks identical to what it is in XRender mode. svn path=/trunk/KDE/kdebase/workspace/; revision=933999 --- lib/kwineffects.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index 12da3bbdcd..1b3fe15e5f 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -1454,11 +1454,17 @@ void EffectFrame::render( QRegion region, double opacity, double frameOpacity ) glColor4f( 0.0, 0.0, 0.0, opacity * frameOpacity ); + // Our unstyled frame texture is premultiplied + // TODO: Fix GLTexture::convertToGLFormat() + glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); + m_unstyledTexture->bind(); m_unstyledTexture->enableNormalizedTexCoords(); renderGLGeometry( verts.count() / 2, verts.data(), texCoords.data() ); m_unstyledTexture->disableNormalizedTexCoords(); m_unstyledTexture->unbind(); + + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); } else if( m_style == Styled ) { @@ -1491,6 +1497,10 @@ void EffectFrame::render( QRegion region, double opacity, double frameOpacity ) // Render text if( !m_text.isEmpty() ) { + // Our text texture is premultiplied + // TODO: Fix GLTexture::convertToGLFormat() + glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); + if( !m_textTexture ) // Lazy creation updateTextTexture(); m_textTexture->bind(); @@ -1747,7 +1757,8 @@ void EffectFrame::updateTextTexture() text = metrics.elidedText( text, Qt::ElideRight, rect.width() ); } - // TODO: Use QPixmap for this once GLTexture has been converted to it + // TODO: Use QPixmap for this once GLTexture has been converted to it. This will + // allow us to change the contents without creating a completely new texture. QImage pixmap( m_geometry.size(), QImage::Format_ARGB32 ); pixmap.fill( Qt::transparent ); QPainter p( &pixmap ); @@ -1804,8 +1815,18 @@ void EffectFrame::updateUnstyledTexture() { #ifdef KWIN_HAVE_OPENGL_COMPOSITING delete m_unstyledTexture; - QString filename = KGlobal::dirs()->findResource( "data", "kwin/circle.png" ); - m_unstyledTexture = new GLTexture( filename ); + // Based off circle() from kwinxrenderutils.cpp +#define CS 8 + QImage tmp( 2 * CS, 2 * CS, QImage::Format_ARGB32 ); + tmp.fill( Qt::transparent ); + QPainter p( &tmp ); + p.setRenderHint( QPainter::Antialiasing ); + p.setPen( Qt::NoPen ); + p.setBrush( Qt::black ); + p.drawEllipse( tmp.rect() ); + p.end(); +#undef CS + m_unstyledTexture = new GLTexture( tmp ); #endif }