From b9fd1e6d10d1cea78a49a62289fb779d2a565913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 30 Nov 2008 13:11:11 +0000 Subject: [PATCH] * 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 --- effects/snow.cpp | 23 ++++++++++++++++++----- effects/snow.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/effects/snow.cpp b/effects/snow.cpp index 49fb696b0b..b259b4d809 100644 --- a/effects/snow.cpp +++ b/effects/snow.cpp @@ -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; iunbind(); glPopAttrib(); + hasSnown = true; } } diff --git a/effects/snow.h b/effects/snow.h index 4c4ebdc933..d11bc60e3d 100644 --- a/effects/snow.h +++ b/effects/snow.h @@ -98,6 +98,7 @@ class SnowEffect bool mInited; bool mUseShader; QRegion repaintRegion; + bool hasSnown; }; } // namespace