Reduce cache size and truncate opacity settings for shadow focus transition, based on the
animation durations. For default duration (200msec), this reduces the size of the cache by about a factor 10, and still corresponds to a 120Hz frame rate. BUG: 234187 svn path=/trunk/KDE/kdebase/workspace/; revision=1114935
This commit is contained in:
parent
c9ccedb810
commit
99a0cddd77
7 changed files with 108 additions and 15 deletions
|
@ -48,7 +48,7 @@ namespace Oxygen
|
|||
OxygenFactory::OxygenFactory():
|
||||
initialized_( false ),
|
||||
helper_( "oxygenDeco" ),
|
||||
shadowCache_( helper_, maxAnimationIndex)
|
||||
shadowCache_( helper_ )
|
||||
{
|
||||
readConfig();
|
||||
setInitialized( true );
|
||||
|
@ -109,6 +109,32 @@ namespace Oxygen
|
|||
changed = true;
|
||||
}
|
||||
|
||||
// initialize shadow cache
|
||||
switch( defaultConfiguration().shadowCacheMode() )
|
||||
{
|
||||
case OxygenConfiguration::CacheDisabled:
|
||||
{
|
||||
shadowCache_.setEnabled( false );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
case OxygenConfiguration::CacheVariable:
|
||||
{
|
||||
shadowCache_.setEnabled( true );
|
||||
shadowCache_.setMaxIndex( qMin( 256, int( 120*defaultConfiguration().animationsDuration()/1000 ) ) );
|
||||
break;
|
||||
}
|
||||
|
||||
case OxygenConfiguration::CacheMaximum:
|
||||
{
|
||||
shadowCache_.setEnabled( true );
|
||||
shadowCache_.setMaxIndex( 256 );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// read exceptionsreadConfig
|
||||
OxygenExceptionList exceptions( config );
|
||||
if( !( exceptions == exceptions_ ) )
|
||||
|
|
|
@ -68,8 +68,6 @@ namespace Oxygen
|
|||
|
||||
enum
|
||||
{
|
||||
//! maximum index/frame used for animations
|
||||
maxAnimationIndex = 256,
|
||||
|
||||
//! this is the top title bar edge
|
||||
TFRAMESIZE = 3,
|
||||
|
|
|
@ -1345,8 +1345,7 @@ namespace Oxygen
|
|||
if( configuration().useOxygenShadows() && glowIsAnimated() && !isForcedActive() )
|
||||
{
|
||||
|
||||
int frame = maxAnimationIndex*glowIntensity();
|
||||
tileSet = shadowCache().tileSet( this, frame );
|
||||
tileSet = shadowCache().tileSet( this, glowIntensity() );
|
||||
|
||||
} else tileSet = shadowCache().tileSet( this );
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ namespace Oxygen
|
|||
animateTitleChange_( true ),
|
||||
animationsDuration_( 150 ),
|
||||
tabsEnabled_( true ),
|
||||
useNarrowButtonSpacing_( false )
|
||||
useNarrowButtonSpacing_( false ),
|
||||
shadowCacheMode_( CacheVariable )
|
||||
{}
|
||||
|
||||
//__________________________________________________
|
||||
|
|
|
@ -93,6 +93,20 @@ namespace Oxygen
|
|||
SizeGripWhenNeeded
|
||||
};
|
||||
|
||||
//! cache mode
|
||||
enum ShadowCacheMode
|
||||
{
|
||||
// no shadow cache
|
||||
CacheDisabled,
|
||||
|
||||
// shadow cache depends
|
||||
// on animation duration
|
||||
CacheVariable,
|
||||
|
||||
// shadow cache has maximum size
|
||||
CacheMaximum
|
||||
};
|
||||
|
||||
//! default constructor
|
||||
OxygenConfiguration( void );
|
||||
|
||||
|
@ -156,6 +170,17 @@ namespace Oxygen
|
|||
|
||||
//@}
|
||||
|
||||
//!@name cache mode
|
||||
//@{
|
||||
|
||||
void setShadowCacheMode( ShadowCacheMode mode )
|
||||
{ shadowCacheMode_ = mode; }
|
||||
|
||||
ShadowCacheMode shadowCacheMode( void ) const
|
||||
{ return shadowCacheMode_; }
|
||||
|
||||
//@]
|
||||
|
||||
//!@name frame border
|
||||
//@{
|
||||
|
||||
|
@ -339,6 +364,9 @@ namespace Oxygen
|
|||
//! narrow button spacing
|
||||
bool useNarrowButtonSpacing_;
|
||||
|
||||
//! cache mode
|
||||
ShadowCacheMode shadowCacheMode_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -32,19 +32,21 @@
|
|||
#include <cassert>
|
||||
#include <KColorUtils>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
namespace Oxygen
|
||||
{
|
||||
|
||||
//_______________________________________________________
|
||||
OxygenShadowCache::OxygenShadowCache( OxygenDecoHelper& helper, int maxIndex ):
|
||||
OxygenShadowCache::OxygenShadowCache( OxygenDecoHelper& helper ):
|
||||
helper_( helper ),
|
||||
maxIndex_( maxIndex ),
|
||||
activeShadowConfiguration_( OxygenShadowConfiguration( QPalette::Active ) ),
|
||||
inactiveShadowConfiguration_( OxygenShadowConfiguration( QPalette::Inactive ) )
|
||||
{
|
||||
shadowCache_.setMaxCost( 1<<6 );
|
||||
animatedShadowCache_.setMaxCost( maxIndex_<<6 );
|
||||
|
||||
setEnabled( true );
|
||||
setMaxIndex( 256 );
|
||||
|
||||
}
|
||||
|
||||
//_______________________________________________________
|
||||
|
@ -81,9 +83,10 @@ namespace Oxygen
|
|||
}
|
||||
|
||||
//_______________________________________________________
|
||||
TileSet* OxygenShadowCache::tileSet( const OxygenClient* client, int index )
|
||||
TileSet* OxygenShadowCache::tileSet( const OxygenClient* client, qreal opacity )
|
||||
{
|
||||
|
||||
int index( opacity*maxIndex_ );
|
||||
assert( index <= maxIndex_ );
|
||||
|
||||
// construct key
|
||||
|
@ -96,7 +99,6 @@ namespace Oxygen
|
|||
|
||||
// create shadow and tileset otherwise
|
||||
qreal size( shadowSize() );
|
||||
qreal opacity( qreal(index)/qreal(maxIndex_) );
|
||||
|
||||
QPixmap shadow( size*2, size*2 );
|
||||
shadow.fill( Qt::transparent );
|
||||
|
|
|
@ -44,12 +44,48 @@ namespace Oxygen
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
OxygenShadowCache( OxygenDecoHelper& helper, int maxIndex );
|
||||
OxygenShadowCache( OxygenDecoHelper& helper );
|
||||
|
||||
//! destructor
|
||||
virtual ~OxygenShadowCache( void )
|
||||
{}
|
||||
|
||||
//! cache size
|
||||
void setEnabled( bool enabled )
|
||||
{
|
||||
enabled_ = enabled;
|
||||
if( enabled )
|
||||
{
|
||||
|
||||
shadowCache_.setMaxCost( 1<<6 );
|
||||
animatedShadowCache_.setMaxCost( maxIndex_<<6 );
|
||||
|
||||
} else {
|
||||
|
||||
shadowCache_.setMaxCost( 1 );
|
||||
animatedShadowCache_.setMaxCost( 1 );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//! max animation index
|
||||
int maxIndex( void ) const
|
||||
{ return maxIndex_; }
|
||||
|
||||
//! max animation index
|
||||
void setMaxIndex( int value )
|
||||
{
|
||||
maxIndex_ = value;
|
||||
if( enabled_ )
|
||||
{
|
||||
|
||||
shadowCache_.setMaxCost( 1<<6 );
|
||||
animatedShadowCache_.setMaxCost( maxIndex_<<6 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//! invalidate caches
|
||||
void invalidateCaches( void )
|
||||
{
|
||||
|
@ -86,8 +122,8 @@ namespace Oxygen
|
|||
//! get shadow matching client
|
||||
TileSet* tileSet( const OxygenClient* );
|
||||
|
||||
//! get shadow matching client and animation index
|
||||
TileSet* tileSet( const OxygenClient*, int );
|
||||
//! get shadow matching client and opacity
|
||||
TileSet* tileSet( const OxygenClient*, qreal );
|
||||
|
||||
//! Key class to be used into QCache
|
||||
/*! class is entirely inline for optimization */
|
||||
|
@ -168,6 +204,9 @@ namespace Oxygen
|
|||
//! helper
|
||||
OxygenDecoHelper& helper_;
|
||||
|
||||
//! caching enable state
|
||||
bool enabled_;
|
||||
|
||||
//! max index
|
||||
/*! it is used to set caches max cost, and calculate animation opacity */
|
||||
int maxIndex_;
|
||||
|
|
Loading…
Reference in a new issue