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:
parent
9b555fc201
commit
5d19671835
2 changed files with 40 additions and 17 deletions
|
@ -45,7 +45,10 @@ LogoutEffect::LogoutEffect()
|
|||
Atom hack = XInternAtom( display(), "_KWIN_LOGOUT_EFFECT", False );
|
||||
XChangeProperty( display(), sel, hack, hack, 8, PropModeReplace, (unsigned char*)&hack, 1 );
|
||||
// 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 );
|
||||
}
|
||||
|
||||
|
@ -60,29 +63,49 @@ LogoutEffect::~LogoutEffect()
|
|||
void LogoutEffect::reconfigure( ReconfigureFlags )
|
||||
{
|
||||
KConfigGroup conf = effects->effectConfig( "Logout" );
|
||||
bool useBlur = conf.readEntry( "UseBlur", true );
|
||||
|
||||
useBlur = conf.readEntry( "UseBlur", true );
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
blurSupported = false;
|
||||
delete blurTexture;
|
||||
blurTexture = NULL;
|
||||
delete blurTarget;
|
||||
blurTarget = NULL;
|
||||
if( effects->compositingType() == OpenGLCompositing && GLTexture::NPOTTextureSupported() && useBlur )
|
||||
{ // 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.
|
||||
// Create texture and render target
|
||||
blurTexture = new GLTexture( displayWidth(), displayHeight() );
|
||||
blurTexture->setFilter( GL_LINEAR_MIPMAP_LINEAR );
|
||||
blurTexture->setWrapMode( GL_CLAMP_TO_EDGE );
|
||||
|
||||
blurTarget = new GLRenderTarget( blurTexture );
|
||||
if( blurTarget->valid() )
|
||||
blurSupported = true;
|
||||
}
|
||||
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 )
|
||||
{ // 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.
|
||||
// Create texture and render target
|
||||
blurTexture = new GLTexture( displayWidth(), displayHeight() );
|
||||
blurTexture->setFilter( GL_LINEAR_MIPMAP_LINEAR );
|
||||
blurTexture->setWrapMode( GL_CLAMP_TO_EDGE );
|
||||
|
||||
blurTarget = new GLRenderTarget( blurTexture );
|
||||
if( blurTarget->valid() )
|
||||
blurSupported = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( logoutWindow != NULL && !logoutWindowClosed )
|
||||
progress = qMin( 1.0, progress + time / animationTime( 2000.0 ));
|
||||
else if( progress > 0.0 )
|
||||
|
|
|
@ -54,7 +54,7 @@ class LogoutEffect
|
|||
bool logoutWindowPassed;
|
||||
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
bool blurSupported;
|
||||
bool blurSupported, useBlur;
|
||||
GLTexture* blurTexture;
|
||||
GLRenderTarget* blurTarget;
|
||||
double windowOpacity;
|
||||
|
|
Loading…
Reference in a new issue