slight performance for xrender shadows
svn path=/trunk/KDE/kdebase/workspace/; revision=967093
This commit is contained in:
parent
6cb5af9119
commit
46148b6c80
5 changed files with 35 additions and 10 deletions
|
@ -41,6 +41,7 @@ KWIN_EFFECT( shadow, ShadowEffect )
|
|||
ShadowEffect::ShadowEffect()
|
||||
: shadowSize( 0 )
|
||||
{
|
||||
cachedBlendPicture = X::None;
|
||||
reconfigure( ReconfigureAll );
|
||||
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||
this, SLOT(updateShadowColor()));
|
||||
|
@ -685,12 +686,20 @@ void ShadowEffect::drawShadowQuadXRender( XRenderPicture *picture, QRect rect, f
|
|||
QColor color, float opacity, float brightness, float saturation )
|
||||
{
|
||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||
XRenderColor xc;
|
||||
XRenderPicture fill;
|
||||
if( color.isValid() )
|
||||
xc = preMultiply( color, opacity );
|
||||
{
|
||||
if ( color == cachedColor && cachedBlendPicture != X::None )
|
||||
fill = cachedBlendPicture;
|
||||
else
|
||||
{
|
||||
XRenderColor xc = preMultiply( color, opacity );
|
||||
cachedBlendPicture = fill = xRenderFill( &xc );
|
||||
cachedColor = color;
|
||||
}
|
||||
}
|
||||
else
|
||||
xc = preMultiply( QColor( 255, 255, 255 ), opacity );
|
||||
XRenderPicture fill = xRenderFill( &xc );
|
||||
fill = xRenderBlendPicture(opacity);
|
||||
|
||||
// Scale if required
|
||||
if( xScale != 1.0 || yScale != 1.0 )
|
||||
|
@ -714,8 +723,7 @@ void ShadowEffect::drawShadowQuadXRender( XRenderPicture *picture, QRect rect, f
|
|||
|
||||
// Fake brightness by overlaying black
|
||||
// Cannot use XRenderFillRectangle() due to ARGB
|
||||
XRenderColor col = { 0, 0, 0, 0xffff * ( 1 - brightness ) * opacity };
|
||||
fill = xRenderFill( &col );
|
||||
fill = xRenderBlendPicture(( 1 - brightness ) * opacity);
|
||||
XRenderComposite( display(), PictOpOver, fill, *picture, effects->xrenderBufferPicture(), 0, 0, 0, 0,
|
||||
rect.x(), rect.y(), rect.width(), rect.height() );
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ class ShadowEffect
|
|||
int shadowFuzzyness;
|
||||
int shadowSize;
|
||||
bool intensifyActiveShadow;
|
||||
QColor shadowColor;
|
||||
QColor shadowColor, cachedColor;
|
||||
bool forceDecorated;
|
||||
bool forceUndecorated;
|
||||
bool forceOther;
|
||||
|
@ -81,6 +81,7 @@ class ShadowEffect
|
|||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||
QList< QList<XRenderPicture*> > mShadowPics;
|
||||
QList<XRenderPicture*> mDefaultShadowPics;
|
||||
XRenderPicture cachedBlendPicture;
|
||||
#endif
|
||||
|
||||
QList<WindowQuadType> mShadowQuadTypes;
|
||||
|
|
|
@ -1520,9 +1520,8 @@ void EffectFrame::render( QRegion region, double opacity, double frameOpacity )
|
|||
0, 0, 0, 0, geom.x(), geom.y(), geom.width(), geom.height() );
|
||||
}
|
||||
|
||||
// Opacity, TODO: Can we further optimize this?
|
||||
XRenderPicture fill = xRenderFill( QColor( 255, 255, 255, int( opacity * 255 )));
|
||||
|
||||
XRenderPicture fill = xRenderBlendPicture(opacity);
|
||||
|
||||
// Render icon
|
||||
if( !m_icon.isNull() && !m_iconSize.isEmpty() )
|
||||
{
|
||||
|
|
|
@ -83,6 +83,18 @@ XRenderPicture xRenderFill( const QColor &c )
|
|||
return xRenderFill( &xc );
|
||||
}
|
||||
|
||||
static XRenderPicture _blendPicture = X::None;
|
||||
static XRenderColor _blendColor;
|
||||
XRenderPicture xRenderBlendPicture(double opacity)
|
||||
{
|
||||
_blendColor.alpha = ushort(opacity * 0xffff);
|
||||
if (_blendPicture == X::None)
|
||||
_blendPicture = xRenderFill(&_blendColor);
|
||||
else
|
||||
XRenderFillRectangle(display(), PictOpSrc, _blendPicture, &_blendColor, 0, 0, 1, 1);
|
||||
return _blendPicture;
|
||||
}
|
||||
|
||||
|
||||
static XRenderPicture *_circle[4] = {NULL, NULL, NULL, NULL};
|
||||
|
||||
|
|
|
@ -115,6 +115,11 @@ XRenderPicture::operator Picture()
|
|||
return d->value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Static 1x1 picture used to deliver a black pixel with given opacity (for blending performance)
|
||||
* Call and Use, the PixelPicture will stay, but may change it's opacity meanwhile. It's NOT threadsafe either
|
||||
*/
|
||||
KWIN_EXPORT XRenderPicture xRenderBlendPicture( double opacity );
|
||||
/**
|
||||
* Creates a 1x1 Picture filled with c
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue