Backport r1002976 by luebking:

Fix memory leak and avoid wasteful memory allocation while the effect is
not in use.
CCBUG: 201445

svn path=/branches/KDE/4.3/kdebase/workspace/; revision=1003554
This commit is contained in:
Lucas Murray 2009-07-28 10:34:02 +00:00
parent 9b555fc201
commit 5d19671835
2 changed files with 40 additions and 17 deletions

View file

@ -45,7 +45,10 @@ LogoutEffect::LogoutEffect()
Atom hack = XInternAtom( display(), "_KWIN_LOGOUT_EFFECT", False ); Atom hack = XInternAtom( display(), "_KWIN_LOGOUT_EFFECT", False );
XChangeProperty( display(), sel, hack, hack, 8, PropModeReplace, (unsigned char*)&hack, 1 ); XChangeProperty( display(), sel, hack, hack, 8, PropModeReplace, (unsigned char*)&hack, 1 );
// the atom is not removed when effect is destroyed, this is temporary anyway // the atom is not removed when effect is destroyed, this is temporary anyway
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
blurTexture = NULL;
blurTarget = NULL;
#endif
reconfigure( ReconfigureAll ); reconfigure( ReconfigureAll );
} }
@ -60,12 +63,34 @@ LogoutEffect::~LogoutEffect()
void LogoutEffect::reconfigure( ReconfigureFlags ) void LogoutEffect::reconfigure( ReconfigureFlags )
{ {
KConfigGroup conf = effects->effectConfig( "Logout" ); KConfigGroup conf = effects->effectConfig( "Logout" );
bool useBlur = conf.readEntry( "UseBlur", true ); useBlur = conf.readEntry( "UseBlur", true );
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
blurSupported = false; delete blurTexture;
blurTexture = NULL; blurTexture = NULL;
delete blurTarget;
blurTarget = NULL; blurTarget = NULL;
blurSupported = false;
#endif
}
void LogoutEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if ( !logoutWindow )
{
if (blurTexture)
{
delete blurTexture;
blurTexture = NULL;
delete blurTarget;
blurTarget = NULL;
blurSupported = false;
}
}
else if ( !blurTexture )
{
blurSupported = false;
delete blurTarget; // catch as we just tested the texture ;-P
if( effects->compositingType() == OpenGLCompositing && GLTexture::NPOTTextureSupported() && useBlur ) if( effects->compositingType() == OpenGLCompositing && GLTexture::NPOTTextureSupported() && useBlur )
{ // TODO: It seems that it is not possible to create a GLRenderTarget that has { // TODO: It seems that it is not possible to create a GLRenderTarget that has
// a different size than the display right now. Most likely a KWin core bug. // a different size than the display right now. Most likely a KWin core bug.
@ -78,11 +103,9 @@ void LogoutEffect::reconfigure( ReconfigureFlags )
if( blurTarget->valid() ) if( blurTarget->valid() )
blurSupported = true; blurSupported = true;
} }
#endif
} }
#endif
void LogoutEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
if( logoutWindow != NULL && !logoutWindowClosed ) if( logoutWindow != NULL && !logoutWindowClosed )
progress = qMin( 1.0, progress + time / animationTime( 2000.0 )); progress = qMin( 1.0, progress + time / animationTime( 2000.0 ));
else if( progress > 0.0 ) else if( progress > 0.0 )

View file

@ -54,7 +54,7 @@ class LogoutEffect
bool logoutWindowPassed; bool logoutWindowPassed;
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
bool blurSupported; bool blurSupported, useBlur;
GLTexture* blurTexture; GLTexture* blurTexture;
GLRenderTarget* blurTarget; GLRenderTarget* blurTarget;
double windowOpacity; double windowOpacity;