Paint effect text onto a QImage instead of a QPixmap. Makes OpenGL mode
faster, XRender slower and works around a subpixel font rendering problem. BUG: 173089 svn path=/trunk/KDE/kdebase/workspace/; revision=888946icc-effect-5.14.5
parent
e77541ab7f
commit
2b22689c45
|
@ -363,12 +363,12 @@ bool EffectsHandler::paintText( const QString& text, const QRect& rect, const QC
|
||||||
QString painttext = fm.elidedText( text, Qt::ElideRight, rect.width() );
|
QString painttext = fm.elidedText( text, Qt::ElideRight, rect.width() );
|
||||||
QRect textrect = fm.boundingRect( painttext );
|
QRect textrect = fm.boundingRect( painttext );
|
||||||
|
|
||||||
// Create temporary QPixmap where the text will be drawn onto
|
// Create temporary QImage where the text will be drawn onto
|
||||||
QPixmap textPixmap( textrect.width(), textrect.height());
|
QImage textImage( textrect.width(), textrect.height(), QImage::Format_ARGB32 );
|
||||||
textPixmap.fill( Qt::transparent );
|
textImage.fill( Qt::transparent );
|
||||||
|
|
||||||
// Draw the text
|
// Draw the text
|
||||||
p.begin( &textPixmap );
|
p.begin( &textImage );
|
||||||
p.setFont( font );
|
p.setFont( font );
|
||||||
p.setRenderHint( QPainter::TextAntialiasing );
|
p.setRenderHint( QPainter::TextAntialiasing );
|
||||||
p.setPen( color );
|
p.setPen( color );
|
||||||
|
@ -394,7 +394,7 @@ bool EffectsHandler::paintText( const QString& text, const QRect& rect, const QC
|
||||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||||
if( effects->compositingType() == OpenGLCompositing )
|
if( effects->compositingType() == OpenGLCompositing )
|
||||||
{
|
{
|
||||||
GLTexture textTexture( textPixmap, GL_TEXTURE_RECTANGLE_ARB );
|
GLTexture textTexture( textImage, GL_TEXTURE_RECTANGLE_ARB );
|
||||||
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT );
|
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT );
|
||||||
glEnable( GL_BLEND );
|
glEnable( GL_BLEND );
|
||||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||||
|
@ -408,8 +408,8 @@ bool EffectsHandler::paintText( const QString& text, const QRect& rect, const QC
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||||
if( effects->compositingType() == XRenderCompositing )
|
if( effects->compositingType() == XRenderCompositing )
|
||||||
{
|
{
|
||||||
XRenderPicture textPicture( textPixmap );
|
XRenderPicture textPicture( QPixmap::fromImage( textImage ));
|
||||||
XRenderComposite( display(), textPixmap.depth() == 32 ? PictOpOver : PictOpSrc,
|
XRenderComposite( display(), textImage.depth() == 32 ? PictOpOver : PictOpSrc,
|
||||||
textPicture, None, effects->xrenderBufferPicture(),
|
textPicture, None, effects->xrenderBufferPicture(),
|
||||||
0, 0, 0, 0, area.x(), area.y(), area.width(), area.height());
|
0, 0, 0, 0, area.x(), area.y(), area.width(), area.height());
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue