From cf1b3e1be8aaa8fd7bcca5b63154f2264187cfec Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 13 Sep 2014 16:34:07 +0000 Subject: [PATCH] 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 --- retroshare-gui/src/gui/gxs/GxsIdDetails.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index 4ca17c0ee..0673779c9 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -72,6 +72,13 @@ static bool findTagIcon(int tag_class, int tag_type, QIcon &icon) QImage GxsIdDetails::makeDefaultIcon(const RsGxsId& id) { + static std::map image_cache ; + + std::map::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] ; }