* Update the snow flakes only once per frame. This fixes the problem of faster snow flakes if there are more then one screens.
* Disable snow effect if there is an active full screen effect as it causes some problems. E.g. in desktop grid the snow flakes are painted several times and by that look terrible. CCBUG: 176489 svn path=/trunk/KDE/kdebase/workspace/; revision=890836
This commit is contained in:
parent
6d3f171ce5
commit
b9fd1e6d10
2 changed files with 19 additions and 5 deletions
|
@ -50,6 +50,7 @@ SnowEffect::SnowEffect()
|
|||
, mShader( 0 )
|
||||
, mInited( false )
|
||||
, mUseShader( true )
|
||||
, hasSnown( false )
|
||||
{
|
||||
srandom( std::time( NULL ) );
|
||||
nextFlakeMillis = 0;
|
||||
|
@ -81,7 +82,7 @@ void SnowEffect::reconfigure( ReconfigureFlags )
|
|||
|
||||
void SnowEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if ( active )
|
||||
if ( active && effects->activeFullScreenEffect() == NULL )
|
||||
{
|
||||
// if number of active snowflakes is smaller than maximum number
|
||||
// create a random new snowflake
|
||||
|
@ -101,6 +102,7 @@ void SnowEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
|||
nextFlakeMillis = next;
|
||||
}
|
||||
data.mask |= PAINT_SCREEN_TRANSFORMED;
|
||||
hasSnown = false;
|
||||
}
|
||||
effects->prePaintScreen( data, time );
|
||||
}
|
||||
|
@ -116,6 +118,8 @@ void SnowEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
|||
|
||||
void SnowEffect::snowing( QRegion& region )
|
||||
{
|
||||
if( effects->activeFullScreenEffect() != NULL )
|
||||
return;
|
||||
if(! texture ) loadTexture();
|
||||
if( texture )
|
||||
{
|
||||
|
@ -136,10 +140,14 @@ void SnowEffect::snowing( QRegion& region )
|
|||
for (int i=0; i<flakes.count(); i++)
|
||||
{
|
||||
SnowFlake& flake = flakes[i];
|
||||
if( flake.addFrame() == 0 )
|
||||
if( !hasSnown )
|
||||
{
|
||||
flakes.removeAt( i-- );
|
||||
continue;
|
||||
// only update during first paint in one frame
|
||||
if( flake.addFrame() == 0 )
|
||||
{
|
||||
flakes.removeAt( i-- );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( mUseShader )
|
||||
|
@ -156,7 +164,11 @@ void SnowEffect::snowing( QRegion& region )
|
|||
}
|
||||
else
|
||||
{
|
||||
flake.updateSpeedAndRotation();
|
||||
if( !hasSnown )
|
||||
{
|
||||
// only update during first paint in one frame
|
||||
flake.updateSpeedAndRotation();
|
||||
}
|
||||
// no shader
|
||||
// save the matrix
|
||||
glPushMatrix();
|
||||
|
@ -186,6 +198,7 @@ void SnowEffect::snowing( QRegion& region )
|
|||
glDisable( GL_BLEND );
|
||||
texture->unbind();
|
||||
glPopAttrib();
|
||||
hasSnown = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ class SnowEffect
|
|||
bool mInited;
|
||||
bool mUseShader;
|
||||
QRegion repaintRegion;
|
||||
bool hasSnown;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in a new issue