mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 19:30:21 +02:00
* Use QPixmapCache for scaled covers to reduce memory footprint.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QReadWriteLock>
|
||||
#include <QPixmapCache>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -282,15 +283,16 @@ Album::cover( const QSize& size, bool forceLoad ) const
|
||||
|
||||
if ( m_cover && !m_cover->isNull() && !size.isEmpty() )
|
||||
{
|
||||
if ( m_coverCache.contains( size.width() ) )
|
||||
{
|
||||
return m_coverCache.value( size.width() );
|
||||
}
|
||||
const QString cacheKey = infoid() + "_" + size.width();
|
||||
QPixmap cover;
|
||||
|
||||
QPixmap scaledCover;
|
||||
scaledCover = m_cover->scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||
m_coverCache.insert( size.width(), scaledCover );
|
||||
return scaledCover;
|
||||
if ( !QPixmapCache::find( cacheKey, cover ) )
|
||||
{
|
||||
cover = m_cover->scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||
QPixmapCache::insert( cacheKey, cover );
|
||||
return cover;
|
||||
}
|
||||
return cover;
|
||||
}
|
||||
|
||||
if ( m_cover )
|
||||
|
@@ -102,7 +102,6 @@ private:
|
||||
mutable QByteArray m_coverBuffer;
|
||||
#ifndef ENABLE_HEADLESS
|
||||
mutable QPixmap* m_cover;
|
||||
mutable QHash< int, QPixmap > m_coverCache;
|
||||
#endif
|
||||
|
||||
QHash< Tomahawk::ModelMode, QHash< Tomahawk::collection_ptr, Tomahawk::playlistinterface_ptr > > m_playlistInterface;
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QReadWriteLock>
|
||||
#include <QPixmapCache>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -585,15 +586,16 @@ Artist::cover( const QSize& size, bool forceLoad ) const
|
||||
|
||||
if ( m_cover && !m_cover->isNull() && !size.isEmpty() )
|
||||
{
|
||||
if ( m_coverCache.contains( size.width() ) )
|
||||
{
|
||||
return m_coverCache.value( size.width() );
|
||||
}
|
||||
const QString cacheKey = infoid() + "_" + size.width();
|
||||
QPixmap cover;
|
||||
|
||||
QPixmap scaledCover;
|
||||
scaledCover = m_cover->scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||
m_coverCache.insert( size.width(), scaledCover );
|
||||
return scaledCover;
|
||||
if ( !QPixmapCache::find( cacheKey, cover ) )
|
||||
{
|
||||
cover = m_cover->scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||
QPixmapCache::insert( cacheKey, cover );
|
||||
return cover;
|
||||
}
|
||||
return cover;
|
||||
}
|
||||
|
||||
if ( m_cover )
|
||||
|
@@ -131,7 +131,6 @@ private:
|
||||
mutable QByteArray m_coverBuffer;
|
||||
#ifndef ENABLE_HEADLESS
|
||||
mutable QPixmap* m_cover;
|
||||
mutable QHash< int, QPixmap > m_coverCache;
|
||||
#endif
|
||||
|
||||
QHash< Tomahawk::ModelMode, QHash< Tomahawk::collection_ptr, Tomahawk::playlistinterface_ptr > > m_playlistInterface;
|
||||
|
Reference in New Issue
Block a user