mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-30 19:00:12 +02:00
* Include tint color in ImageRegistry cache-key.
This commit is contained in:
@@ -47,6 +47,13 @@ ImageRegistry::icon( const QString& image, TomahawkUtils::ImageMode mode )
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
ImageRegistry::cacheKey( const QSize& size, float opacity, QColor tint )
|
||||
{
|
||||
return size.width() * 100 + size.height() * 10 + ( opacity * 100.0 ) + tint.value();
|
||||
}
|
||||
|
||||
|
||||
QPixmap
|
||||
ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, QColor tint )
|
||||
{
|
||||
@@ -61,9 +68,10 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I
|
||||
{
|
||||
subsubcache = subcache.value( mode );
|
||||
|
||||
if ( subsubcache.contains( size.width() * 100 + size.height() * 10 + ( opacity * 100.0 ) ) )
|
||||
const qint64 ck = cacheKey( size, opacity, tint );
|
||||
if ( subsubcache.contains( ck ) )
|
||||
{
|
||||
return subsubcache.value( size.width() * 100 + size.height() * 10 + ( opacity * 100.0 ) );
|
||||
return subsubcache.value( ck );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,7 +122,7 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I
|
||||
if ( !size.isNull() && pixmap.size() != size )
|
||||
pixmap = pixmap.scaled( size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
|
||||
|
||||
putInCache( image, size, mode, opacity, pixmap );
|
||||
putInCache( image, size, mode, opacity, pixmap, tint );
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
@@ -122,7 +130,7 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I
|
||||
|
||||
|
||||
void
|
||||
ImageRegistry::putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap )
|
||||
ImageRegistry::putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Adding to image cache:" << image << size << mode;
|
||||
|
||||
@@ -144,7 +152,7 @@ ImageRegistry::putInCache( const QString& image, const QSize& size, TomahawkUtil
|
||||
}
|
||||
}
|
||||
|
||||
subsubcache.insert( size.width() * 100 + size.height() * 10 + ( opacity * 100.0 ), pixmap );
|
||||
subsubcache.insert( cacheKey( size, opacity, tint ), pixmap );
|
||||
subcache.insert( mode, subsubcache );
|
||||
s_cache.insert( image, subcache );
|
||||
}
|
||||
|
@@ -34,7 +34,8 @@ public:
|
||||
QPixmap pixmap( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode = TomahawkUtils::Original, float opacity = 1.0, QColor tint = QColor( 0, 0, 0, 0 ) );
|
||||
|
||||
private:
|
||||
void putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap );
|
||||
qint64 cacheKey( const QSize& size, float opacity, QColor tint );
|
||||
void putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint );
|
||||
|
||||
static ImageRegistry* s_instance;
|
||||
};
|
||||
|
Reference in New Issue
Block a user