added cache for GxsId icons, to speed it up

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7533 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-09-13 16:34:07 +00:00
parent e2a8ed46f2
commit cf1b3e1be8

View File

@ -72,6 +72,13 @@ static bool findTagIcon(int tag_class, int tag_type, QIcon &icon)
QImage GxsIdDetails::makeDefaultIcon(const RsGxsId& id)
{
static std::map<RsGxsId,QImage> image_cache ;
std::map<RsGxsId,QImage>::const_iterator it = image_cache.find(id) ;
if(it != image_cache.end())
return it->second ;
int S = 128 ;
QImage pix(S,S,QImage::Format_RGB32) ;
@ -130,7 +137,10 @@ QImage GxsIdDetails::makeDefaultIcon(const RsGxsId& id)
pix.setPixel( S-1-i, S-1-j, q) ;
pix.setPixel( i, S-1-j, q) ;
}
return pix.scaled(64,64,Qt::KeepAspectRatio,Qt::SmoothTransformation) ;
image_cache[id] = pix.scaled(64,64,Qt::KeepAspectRatio,Qt::SmoothTransformation) ;
return image_cache[id] ;
}