slight performance for xrender shadows
svn path=/trunk/KDE/kdebase/workspace/; revision=967093icc-effect-5.14.5
parent
6cb5af9119
commit
46148b6c80
|
@ -41,6 +41,7 @@ KWIN_EFFECT( shadow, ShadowEffect )
|
||||||
ShadowEffect::ShadowEffect()
|
ShadowEffect::ShadowEffect()
|
||||||
: shadowSize( 0 )
|
: shadowSize( 0 )
|
||||||
{
|
{
|
||||||
|
cachedBlendPicture = X::None;
|
||||||
reconfigure( ReconfigureAll );
|
reconfigure( ReconfigureAll );
|
||||||
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
this, SLOT(updateShadowColor()));
|
this, SLOT(updateShadowColor()));
|
||||||
|
@ -685,12 +686,20 @@ void ShadowEffect::drawShadowQuadXRender( XRenderPicture *picture, QRect rect, f
|
||||||
QColor color, float opacity, float brightness, float saturation )
|
QColor color, float opacity, float brightness, float saturation )
|
||||||
{
|
{
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||||
XRenderColor xc;
|
XRenderPicture fill;
|
||||||
if( color.isValid() )
|
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
|
else
|
||||||
xc = preMultiply( QColor( 255, 255, 255 ), opacity );
|
fill = xRenderBlendPicture(opacity);
|
||||||
XRenderPicture fill = xRenderFill( &xc );
|
|
||||||
|
|
||||||
// Scale if required
|
// Scale if required
|
||||||
if( xScale != 1.0 || yScale != 1.0 )
|
if( xScale != 1.0 || yScale != 1.0 )
|
||||||
|
@ -714,8 +723,7 @@ void ShadowEffect::drawShadowQuadXRender( XRenderPicture *picture, QRect rect, f
|
||||||
|
|
||||||
// Fake brightness by overlaying black
|
// Fake brightness by overlaying black
|
||||||
// Cannot use XRenderFillRectangle() due to ARGB
|
// Cannot use XRenderFillRectangle() due to ARGB
|
||||||
XRenderColor col = { 0, 0, 0, 0xffff * ( 1 - brightness ) * opacity };
|
fill = xRenderBlendPicture(( 1 - brightness ) * opacity);
|
||||||
fill = xRenderFill( &col );
|
|
||||||
XRenderComposite( display(), PictOpOver, fill, *picture, effects->xrenderBufferPicture(), 0, 0, 0, 0,
|
XRenderComposite( display(), PictOpOver, fill, *picture, effects->xrenderBufferPicture(), 0, 0, 0, 0,
|
||||||
rect.x(), rect.y(), rect.width(), rect.height() );
|
rect.x(), rect.y(), rect.width(), rect.height() );
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class ShadowEffect
|
||||||
int shadowFuzzyness;
|
int shadowFuzzyness;
|
||||||
int shadowSize;
|
int shadowSize;
|
||||||
bool intensifyActiveShadow;
|
bool intensifyActiveShadow;
|
||||||
QColor shadowColor;
|
QColor shadowColor, cachedColor;
|
||||||
bool forceDecorated;
|
bool forceDecorated;
|
||||||
bool forceUndecorated;
|
bool forceUndecorated;
|
||||||
bool forceOther;
|
bool forceOther;
|
||||||
|
@ -81,6 +81,7 @@ class ShadowEffect
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||||
QList< QList<XRenderPicture*> > mShadowPics;
|
QList< QList<XRenderPicture*> > mShadowPics;
|
||||||
QList<XRenderPicture*> mDefaultShadowPics;
|
QList<XRenderPicture*> mDefaultShadowPics;
|
||||||
|
XRenderPicture cachedBlendPicture;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QList<WindowQuadType> mShadowQuadTypes;
|
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() );
|
0, 0, 0, 0, geom.x(), geom.y(), geom.width(), geom.height() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opacity, TODO: Can we further optimize this?
|
XRenderPicture fill = xRenderBlendPicture(opacity);
|
||||||
XRenderPicture fill = xRenderFill( QColor( 255, 255, 255, int( opacity * 255 )));
|
|
||||||
|
|
||||||
// Render icon
|
// Render icon
|
||||||
if( !m_icon.isNull() && !m_iconSize.isEmpty() )
|
if( !m_icon.isNull() && !m_iconSize.isEmpty() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,6 +83,18 @@ XRenderPicture xRenderFill( const QColor &c )
|
||||||
return xRenderFill( &xc );
|
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};
|
static XRenderPicture *_circle[4] = {NULL, NULL, NULL, NULL};
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,11 @@ XRenderPicture::operator Picture()
|
||||||
return d->value();
|
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
|
* Creates a 1x1 Picture filled with c
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue