src/hbcore/image/hbiconloader.cpp
changeset 5 627c4a0fd0e7
parent 2 06ff229162e9
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include <hbiconloader_p.h>
    26 #include "hbiconloader_p.h"
    27 #include "hbthemecommon_p.h"
       
    28 
       
    29 #include <QDir>
       
    30 #include <QCoreApplication>
       
    31 #include <QDebug>
       
    32 #include <QPicture>
       
    33 #include <QPainter>
       
    34 #include <QStyleOption>
       
    35 #include <QApplication> //krazy:exclude=qclasses
       
    36 #include <QtAlgorithms>
       
    37 #include <QTime>
       
    38 #include <QSvgRenderer>
       
    39 #include <QImageReader>
       
    40 #include <QHash>
       
    41 
       
    42 #include "hbframedrawer_p.h"
    27 #include "hbframedrawer_p.h"
    43 #include "hbicontheme_p.h"
    28 #include "hbicontheme_p.h"
    44 #include "hbstandarddirs_p.h"
       
    45 #include "hblayoutdirectionnotifier_p.h"
    29 #include "hblayoutdirectionnotifier_p.h"
    46 #include "hbinstance.h"
    30 #include "hbinstance.h"
    47 #include "hbiconanimation_p.h"
    31 #include "hbiconanimation_p.h"
    48 #include "hbiconanimator.h"
    32 #include "hbiconanimator.h"
    49 #include "hbiconanimator_p.h"
    33 #include "hbiconanimator_p.h"
    58 #include "hbpixmapiconimpl_p.h"
    42 #include "hbpixmapiconimpl_p.h"
    59 #include "hbiconsource_p.h"
    43 #include "hbiconsource_p.h"
    60 #include "hbthemeindex_p.h"
    44 #include "hbthemeindex_p.h"
    61 #include "hbthemecommon_p.h"
    45 #include "hbthemecommon_p.h"
    62 #include "hbiconimplcreator_p.h"
    46 #include "hbiconimplcreator_p.h"
       
    47 #include "hbstandarddirs_p.h"
       
    48 #include <QDir>
       
    49 #include <QCoreApplication>
       
    50 #include <QDebug>
       
    51 #include <QPicture>
       
    52 #include <QPainter>
       
    53 #include <QStyleOption>
       
    54 #include <QApplication> //krazy:exclude=qclasses
       
    55 #include <QtAlgorithms>
       
    56 #include <QTime>
       
    57 #include <QSvgRenderer>
       
    58 #include <QImageReader>
       
    59 #include <QHash>
    63 
    60 
    64 #ifdef HB_NVG_CS_ICON
    61 #ifdef HB_NVG_CS_ICON
    65 #include "hbeglstate_p.h"
    62 #include "hbeglstate_p.h"
    66 #endif
    63 #endif
    67 
    64 
   131                                    const QSizeF &size,
   128                                    const QSizeF &size,
   132                                    Qt::AspectRatioMode aspectRatioMode, 
   129                                    Qt::AspectRatioMode aspectRatioMode, 
   133                                    QIcon::Mode mode, 
   130                                    QIcon::Mode mode, 
   134                                    bool mirrored, 
   131                                    bool mirrored, 
   135                                    const QColor &color,
   132                                    const QColor &color,
   136                                    HbRenderingMode renderMode);
   133                                    HbRenderingMode renderMode );
   137 #endif
   134 #endif
   138 
   135 
   139 public: // data
   136 public: 
   140     QString storedTheme;
   137     QString storedTheme;
   141 
   138 
   142     int sourceResolution;
   139     int sourceResolution;
   143     int resolution;
   140     int resolution;
   144     qreal zoom;
   141     qreal zoom;
   149     bool animationLoading;
   146     bool animationLoading;
   150     // <-- Frame-by-frame animation support ------------------------------------
   147     // <-- Frame-by-frame animation support ------------------------------------
   151 
   148 
   152     HbIconSource *lastIconSource;
   149     HbIconSource *lastIconSource;
   153 
   150 
   154 private: // data
   151 private: 
   155     enum {
   152     enum {
   156         Unknown = 0,
   153         Unknown = 0,
   157         NotMirrored = 1,
   154         NotMirrored = 1,
   158         Mirrored = 2
   155         Mirrored = 2
   159     };
   156     };
   188 }
   185 }
   189 
   186 
   190 QString HbIconLoaderPrivate::removeIconNameSuffix(const QString &iconName)
   187 QString HbIconLoaderPrivate::removeIconNameSuffix(const QString &iconName)
   191 {
   188 {
   192     QString loweredIconName = iconName.toLower();
   189     QString loweredIconName = iconName.toLower();
   193     if (loweredIconName.endsWith(".svg")
   190     if (loweredIconName.endsWith(QLatin1String(".svg"))
   194         || loweredIconName.endsWith(".png")
   191         || loweredIconName.endsWith(QLatin1String(".png"))
   195         || loweredIconName.endsWith(".mng")
   192         || loweredIconName.endsWith(QLatin1String(".mng"))
   196         || loweredIconName.endsWith(".gif")
   193         || loweredIconName.endsWith(QLatin1String(".gif"))
   197         || loweredIconName.endsWith(".xpm")
   194         || loweredIconName.endsWith(QLatin1String(".xpm"))
   198         || loweredIconName.endsWith(".jpg")
   195         || loweredIconName.endsWith(QLatin1String(".jpg"))
   199         || loweredIconName.endsWith(".nvg")) {
   196         || loweredIconName.endsWith(QLatin1String(".nvg"))) {
   200         return iconName.left(iconName.length() - 4);
   197         return iconName.left(iconName.length() - 4);
   201     }
   198     }
   202 
   199 
   203     if (loweredIconName.endsWith(".svgz")
   200     if (loweredIconName.endsWith(QLatin1String(".svgz"))
   204         || loweredIconName.endsWith(".qpic")) {
   201         || loweredIconName.endsWith(QLatin1String(".qpic"))) {
   205         return iconName.left(iconName.length() - 5);
   202         return iconName.left(iconName.length() - 5);
   206     }
   203     }
   207 
   204 
   208     return iconName;
   205     return iconName;
   209 }
   206 }
   231     Q_UNUSED(itemType)
   228     Q_UNUSED(itemType)
   232 
   229 
   233     mirroredIconFound = false;
   230     mirroredIconFound = false;
   234     QString iconPath;
   231     QString iconPath;
   235 
   232 
   236     if (QDir::isRelativePath(resourceName)) {
   233     if (HbThemeUtils::isLogicalName(resourceName)) {
   237 
       
   238 #ifdef Q_OS_SYMBIAN
       
   239         // Try to get themed icon information from theme index
   234         // Try to get themed icon information from theme index
   240         HbThemeIndexResource resource(resourceName);
   235         HbThemeIndexResource resource(resourceName);
   241         if (resource.isValid()) {
   236         if (resource.isValid()) {
   242             if (mirrored) {
   237             if (mirrored) {
   243                 return resource.fullMirroredFileName();
   238                 return resource.fullMirroredFileName();
   244             } else {
   239             } else {
   245                 return resource.fullFileName();
   240                 return resource.fullFileName();
   246             }
   241             }
   247         }
   242         } else {
   248 #endif // Q_OS_SYMBIAN
   243             // Logical name not found in theme index - return empty string
   249 
   244             return QString();
   250         // If there was no theme index, search the icon in theme icon dirs (slow)
       
   251         foreach (const QString &dir, HbThemePrivate::instance()->iconDirectories()) {
       
   252             if (mirrored) {
       
   253                 // If icon is mirrored, try to find the icon in a separate "mirrored" folder used for mirrored icons
       
   254                 iconPath =  HbStandardDirs::findResource( dir + "mirrored" + '/' + resourceName, Hb::IconResource );
       
   255                 if( !iconPath.isEmpty() ) {
       
   256                     mirroredIconFound = true;
       
   257                     break;
       
   258                 }
       
   259             }
       
   260 
       
   261         iconPath =  HbStandardDirs::findResource( dir + resourceName, Hb::IconResource );
       
   262 
       
   263             // If the file was found in this dir, return the filename.
       
   264         if ( !iconPath.isEmpty() ) {
       
   265                 break;
       
   266             }
       
   267         }
   245         }
   268     } else {
   246     } else {
   269         // Absolute path. Do not scan through different theme directories.
   247         // Not a logical name. Check from file system.
   270         QString iconNameCopy(resourceName);
       
   271         if (mirrored) {
   248         if (mirrored) {
   272             // If icon is mirrored, try to find the icon in a separate "mirrored" folder used for mirrored icons
   249             // If icon is mirrored, try to find the icon in a separate "mirrored" folder used for mirrored icons
   273 
   250 
   274             // Find the directory part from the full filename
   251             // Find the directory part from the full filename
   275             int index1 = resourceName.lastIndexOf('/');
   252             int index1 = resourceName.lastIndexOf('/');
   292 
   269 
   293         iconPath = HbStandardDirs::findResource(resourceName, Hb::IconResource);
   270         iconPath = HbStandardDirs::findResource(resourceName, Hb::IconResource);
   294     }
   271     }
   295 
   272 
   296     return iconPath;
   273     return iconPath;
       
   274 }
       
   275 
   297 /*
   276 /*
   298 From Freedesktop.org:
   277 From Freedesktop.org:
   299 
   278 
   300  The exact algorithm (in pseudocode) for looking up an icon in a theme (if the implementation supports SVG) is:
   279  The exact algorithm (in pseudocode) for looking up an icon in a theme (if the implementation supports SVG) is:
   301 
   280 
   425   }
   404   }
   426   return none
   405   return none
   427 
   406 
   428     }
   407     }
   429 */
   408 */
   430 }
       
   431 
   409 
   432 bool HbIconLoaderPrivate::isAutomaticallyMirrored(const QString &iconName)
   410 bool HbIconLoaderPrivate::isAutomaticallyMirrored(const QString &iconName)
   433 {
   411 {
   434     Q_UNUSED(iconName);
       
   435     // only place to get mirroring information is from themeindex
   412     // only place to get mirroring information is from themeindex
   436 #ifdef Q_OS_SYMBIAN
   413     // Try to get themed icon information from theme index
   437         // Try to get themed icon information from theme index
   414     HbThemeIndexResource resource(iconName);
   438         HbThemeIndexResource resource(iconName);
   415     if (resource.isValid()) {
   439         if (resource.isValid()) {
   416         return resource.isAutomaticallyMirrored();
   440             return resource.isAutomaticallyMirrored();
   417     }
   441         }
       
   442 #endif
       
   443 
   418 
   444     return false;
   419     return false;
   445 }
   420 }
   446 
   421 
   447 bool HbIconLoaderPrivate::isLayoutMirrored()
   422 bool HbIconLoaderPrivate::isLayoutMirrored()
   464 {
   439 {
   465     layoutMirrored = mirrored ? Mirrored : NotMirrored;
   440     layoutMirrored = mirrored ? Mirrored : NotMirrored;
   466 }
   441 }
   467 
   442 
   468 #ifdef HB_ICONIMPL_CACHE
   443 #ifdef HB_ICONIMPL_CACHE
   469 QByteArray HbIconLoaderPrivate::createCacheKeyFrom(const QString &iconName, const QSizeF &size,
   444 QByteArray HbIconLoaderPrivate::createCacheKeyFrom( const QString &iconName,
   470     Qt::AspectRatioMode aspectRatioMode, QIcon::Mode mode, bool mirrored, const QColor &color,
   445                                                     const QSizeF &size,
   471     HbRenderingMode renderMode)
   446                                                     Qt::AspectRatioMode aspectRatioMode, 
       
   447                                                     QIcon::Mode mode, 
       
   448                                                     bool mirrored, 
       
   449                                                     const QColor &color,
       
   450                                                     HbRenderingMode renderMode )
   472 {
   451 {
   473     static const int paramArraySize = 8;
   452     static const int paramArraySize = 8;
   474 
   453 
   475     // This uses QByteArray to improve performance compared to QString.
   454     // This uses QByteArray to improve performance compared to QString.
   476     // It allows appending stuff with less heap allocations and conversions compared to using QString.
   455     // It allows appending stuff with less heap allocations and conversions compared to using QString.
   574             d->animationLoading = false;
   553             d->animationLoading = false;
   575             return size;
   554             return size;
   576         }
   555         }
   577     }
   556     }
   578 
   557 
   579     // Step 2: There was no animation definition, try to get default size from theme index if it is a themed icon
   558     // Step 2: There was no animation definition,
       
   559     // try to get default size from theme index if it is a themed icon (logical name).
   580     
   560     
   581     // TODO: change this to simpler function call in Symbian OS env
   561     if (HbThemeUtils::isLogicalName(iconName)) {
   582     if (QDir::isRelativePath(iconName)) {
       
   583 #ifdef Q_OS_SYMBIAN
       
   584         // Try to get themed icon information from theme index
   562         // Try to get themed icon information from theme index
   585         HbThemeIndexResource resource(iconName);
   563         HbThemeIndexResource resource(iconName);
   586         if (resource.isValid()) {
   564         if (resource.isValid()) {
   587             // Try to get themed icon default size from theme index
   565             // Try to get themed icon default size from theme index
   588             if (params.mirrored && resource.mirroredItemSize().isValid()) {
   566             if (params.mirrored && resource.mirroredItemSize().isValid()) {
   589                 size = resource.mirroredItemSize();
   567                 size = resource.mirroredItemSize();
   590             } else {
   568             } else {
   591                 size = resource.defaultItemSize();
   569                 size = resource.defaultItemSize();
   592             }
   570             }
   593             // Returns invalid size if there is a valid theme index, but the item was not found there.
   571         }
   594             return size;
   572         // Returns invalid size if the index did not provide the size
   595         } else {
   573         return size;
   596             // Step 3: Theme index was not used, try to get icon's default size from theme server's default size cache.
       
   597             params.iconFileName = resolveIconFileName(params);
       
   598         }
       
   599 #else
       
   600         params.iconFileName = resolveIconFileName(params);
       
   601 #endif
       
   602     } else { // Absolute path, use it directly without resolving anything.
   574     } else { // Absolute path, use it directly without resolving anything.
   603         params.iconFileName = iconName;
   575         params.iconFileName = iconName;
   604     }
   576     }
   605 
   577 
   606     // If icon filename could not be resolved, return
   578     // If icon filename could not be resolved, return
   608         return size;
   580         return size;
   609     }
   581     }
   610 
   582 
   611     QString format = formatFromPath(params.iconFileName);
   583     QString format = formatFromPath(params.iconFileName);
   612 
   584 
   613 // Theme server on desktop was found very slow (probably due to IPC with QLocalServer/QLocalSocket).
   585     // Step 3: Get the default size from the icon file in the client side
   614 // disabling icon sharing via theme server until theme server performance on desktop is improved
       
   615 #ifdef Q_OS_SYMBIAN
       
   616     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
       
   617     // Try to take data from server if parameters don't prevent it
       
   618     if (manager && format != "MNG" && format != "GIF" &&
       
   619         !iconName.startsWith(':')) { // not using server for app's own resources (iconName is a logical name for theme elements)
       
   620 #ifdef HB_ICON_TRACES
       
   621         qDebug() << "HbIconLoader::DefaultSize req to server " << params.iconFileName;
       
   622 #endif
       
   623         QSizeF sizeFromServer = HbThemeClient::global()->getSharedIconDefaultSize(params.iconFileName);
       
   624 #ifdef HB_ICON_TRACES
       
   625         qDebug() << "HbIconLoader::DefaultSize result from server" << sizeFromServer;
       
   626 #endif
       
   627         if (sizeFromServer.isValid()) {
       
   628             return sizeFromServer;
       
   629         }
       
   630     }
       
   631 #endif // Q_OS_SYMBIAN
       
   632 
       
   633     // Step 4: Get the default size from the icon file in the client side
       
   634     HbIconSource *source = getIconSource(params.iconFileName, format);
   586     HbIconSource *source = getIconSource(params.iconFileName, format);
   635     size = source->defaultSize();
   587     size = source->defaultSize();
   636 
   588 
   637 #ifdef HB_ICON_TRACES
   589 #ifdef HB_ICON_TRACES
   638     qDebug() << "HbIconLoader::DefaultSize from file" << params.iconFileName << size;
   590     qDebug() << "HbIconLoader::DefaultSize from file" << params.iconFileName << size;
   768  *  It also resets the engine's iconImpl and MaskableIcon's iconImpl
   720  *  It also resets the engine's iconImpl and MaskableIcon's iconImpl
   769  */
   721  */
   770 void HbIconLoader::freeGpuIconData()
   722 void HbIconLoader::freeGpuIconData()
   771 {
   723 {
   772 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   724 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   773 	for( int i = 0; i < iconEngineList.count(); i++ ) {	    
   725     for( int i = 0; i < iconEngineList.count(); i++ ) {     
   774         HbIconEngine *engine = iconEngineList.at(i);
   726         HbIconEngine *engine = iconEngineList.at(i);
   775 	    engine->resetIconImpl();
   727         engine->resetIconImpl();
   776 	}	
   728     }   
   777 	for(int i = 0; i< frameDrawerInstanceList.count(); i++) {
   729     for(int i = 0; i< frameDrawerInstanceList.count(); i++) {
   778 	    HbFrameDrawerPrivate * fd = frameDrawerInstanceList.at(i);
   730         HbFrameDrawerPrivate * fd = frameDrawerInstanceList.at(i);
   779 	    if ( (fd->iconFormatType() == SGIMAGE) || (fd->iconFormatType() == NVG) ) {
   731         if ( (fd->iconFormatType() == SGIMAGE) || (fd->iconFormatType() == NVG) ) {
   780 	        fd->resetMaskableIcon();            
   732             fd->resetMaskableIcon();            
   781 	    }    
   733         }    
   782 	}    
   734     }    
   783 #endif
   735 #endif
   784 }
   736 }
   785 
   737 
   786 /*!
   738 /*!
   787   \internal
   739   \internal
   846 {
   798 {
   847     QList<HbIconAnimationDefinition::AnimationFrame> frameDefs = def.frameList();
   799     QList<HbIconAnimationDefinition::AnimationFrame> frameDefs = def.frameList();
   848     QList<HbIconAnimationFrameSet::FrameData> frameList;
   800     QList<HbIconAnimationFrameSet::FrameData> frameList;
   849 
   801 
   850     // Get the default size from the first animation frame
   802     // Get the default size from the first animation frame
   851     params.cleanIconName = frameDefs.at(0).iconName;
   803     return HbIconLoader::defaultSize(frameDefs.at(0).iconName, QString(), params.options);
   852     params.iconFileName = resolveIconFileName(params);
       
   853     QString format = formatFromPath(params.iconFileName);
       
   854 
       
   855     // Try to get the default size from server if the icon is not such that is loaded in client side.
       
   856     if (format != "MNG"
       
   857         && format != "GIF"
       
   858         && !params.iconFileName.startsWith(':'))
       
   859     {
       
   860         QSizeF defSize = HbThemeClient::global()->getSharedIconDefaultSize(params.iconFileName);
       
   861         if (defSize.isValid()) {
       
   862             return defSize;
       
   863         }
       
   864     }
       
   865 
       
   866     // Otherwise get if by calling HbIconLoader::defaultSize for the first animation frame
       
   867     return HbIconLoader::defaultSize(params.iconFileName, QString(), params.options);
       
   868 }
   804 }
   869 
   805 
   870 void HbIconLoader::loadAnimation(HbIconAnimationDefinition &def, HbIconLoadingParams &params)
   806 void HbIconLoader::loadAnimation(HbIconAnimationDefinition &def, HbIconLoadingParams &params)
   871 {
   807 {
   872     Q_ASSERT(!def.isNull());
   808     Q_ASSERT(!def.isNull());
   973 #ifdef HB_ICON_TRACES
   909 #ifdef HB_ICON_TRACES
   974     qDebug() << params.cleanIconName << " => " << iconPath;
   910     qDebug() << params.cleanIconName << " => " << iconPath;
   975 #endif
   911 #endif
   976     // If not found then it can still be a normal file specified with a relative path.
   912     // If not found then it can still be a normal file specified with a relative path.
   977     if (!iconFound) {
   913     if (!iconFound) {
   978         iconFound = QFile(params.iconName).exists();
   914         iconFound = QFile::exists(params.iconName);
   979         if (iconFound) {
   915         if (iconFound) {
   980             iconPath = params.iconName;
   916             iconPath = params.iconName;
   981         }
   917         }
   982     }
   918     }
   983     // Use the 'unknown' icon, if needed, when the queried icon was not found.
   919     // Use the 'unknown' icon, if needed, when the queried icon was not found.
  1269 #ifndef Q_OS_SYMBIAN
  1205 #ifndef Q_OS_SYMBIAN
  1270     Q_UNUSED(newRenderMode)
  1206     Q_UNUSED(newRenderMode)
  1271 #endif
  1207 #endif
  1272 
  1208 
  1273 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
  1209 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
  1274     if (newRenderMode != renderMode) {     
  1210     if (newRenderMode != renderMode) {
  1275         if (newRenderMode == ESWRendering) {
  1211         if (newRenderMode == ESWRendering) {
  1276             // switching from HW to SW mode  
  1212             // switching from HW to SW mode
  1277             freeGpuIconData();            
  1213             freeGpuIconData();
  1278         }        
  1214         }        
  1279         if (HbThemeClient::global()->switchRenderingMode(newRenderMode)) {         
  1215         if (HbThemeClient::global()->switchRenderingMode(newRenderMode)) {
  1280             renderMode = newRenderMode;
  1216             renderMode = newRenderMode;
  1281         }
  1217         }
  1282     }
  1218     }
  1283 #endif
  1219 #endif
  1284 }
  1220 }
  1381 
  1317 
  1382     // Step 2: There was no animation definition, try get icon from server
  1318     // Step 2: There was no animation definition, try get icon from server
  1383     if (!params.animationCreated) {
  1319     if (!params.animationCreated) {
  1384     
  1320     
  1385 #ifdef HB_ICONIMPL_CACHE
  1321 #ifdef HB_ICONIMPL_CACHE
  1386         QByteArray cacheKey = d->createCacheKeyFrom( params.iconName, params.size, params.aspectRatioMode,
  1322         QByteArray cacheKey = d->createCacheKeyFrom( params.iconName, 
  1387                         params.mode, params.mirrored, params.color, params.renderMode );
  1323                                                      params.size,
       
  1324                                                      params.aspectRatioMode,
       
  1325                                                      params.mode, 
       
  1326                                                      params.mirrored, 
       
  1327                                                      params.color, 
       
  1328                                                      params.renderMode );
  1388         //look up in the local iconImplCache. 
  1329         //look up in the local iconImplCache. 
  1389         //If found return the ptr directly
  1330         //If found return the ptr directly
  1390         if (iconImplCache.contains(cacheKey)) {
  1331         if (iconImplCache.contains(cacheKey)) {
  1391             HbIconImpl * ptr = iconImplCache.value(cacheKey);
  1332             HbIconImpl * ptr = iconImplCache.value(cacheKey);
  1392             ptr->incrementRefCount();
  1333             ptr->incrementRefCount();
  1395             qDebug() << "HbIconLoader::loadIcon(): Client RefCount now = " <<ptr->refCount();
  1336             qDebug() << "HbIconLoader::loadIcon(): Client RefCount now = " <<ptr->refCount();
  1396 #endif        
  1337 #endif        
  1397             return ptr;
  1338             return ptr;
  1398         }
  1339         }
  1399 #endif
  1340 #endif
  1400         if (QDir::isRelativePath(iconName)) {
  1341         if (HbThemeUtils::isLogicalName(iconName)) {
  1401             params.iconFileName = resolveIconFileName(params);
  1342             params.iconFileName = resolveIconFileName(params);
  1402         } else {
  1343         } else {
  1403             params.iconFileName = iconName;
  1344             params.iconFileName = iconName;
  1404         }
  1345         }
  1405 
  1346 
  1526     // We don't want to get the consolidated icon for only NVG build, ie. without SGImage lite support.
  1467     // We don't want to get the consolidated icon for only NVG build, ie. without SGImage lite support.
  1527     // Consolidated icon will be created for NVG with SGImage lite support.
  1468     // Consolidated icon will be created for NVG with SGImage lite support.
  1528     // and when NVG is not available.
  1469     // and when NVG is not available.
  1529 #if defined(HB_ICONIMPL_CACHE)
  1470 #if defined(HB_ICONIMPL_CACHE)
  1530 
  1471 
  1531     QByteArray cacheKey = d->createCacheKeyFrom(multiPartIconData.multiPartIconId, size,
  1472     QByteArray cacheKey = d->createCacheKeyFrom(multiPartIconData.multiPartIconId,
  1532                           aspectRatioMode, mode, mirrored, color, renderMode);
  1473                                                 size,
       
  1474                                                 aspectRatioMode,
       
  1475                                                 mode,
       
  1476                                                 mirrored, 
       
  1477                                                 color, 
       
  1478                                                 renderMode);
  1533     //If consolidated icon found in the client's cache, increment ref-count and return
  1479     //If consolidated icon found in the client's cache, increment ref-count and return
  1534     if (iconImplCache.contains(cacheKey)) {
  1480     if (iconImplCache.contains(cacheKey)) {
  1535         HbIconImpl * ptr = iconImplCache.value(cacheKey);
  1481         HbIconImpl * ptr = iconImplCache.value(cacheKey);
  1536         ptr->incrementRefCount();
  1482         ptr->incrementRefCount();
  1537 #ifdef HB_ICON_CACHE_DEBUG
  1483 #ifdef HB_ICON_CACHE_DEBUG
  1698  * This function initiates a single IPC to themeserver in which it sends out icon-parameters
  1644  * This function initiates a single IPC to themeserver in which it sends out icon-parameters
  1699  * for each of the frame-items and gets back a list of HbSharedIconInfo corresponding to 
  1645  * for each of the frame-items and gets back a list of HbSharedIconInfo corresponding to 
  1700  * individual pieces.
  1646  * individual pieces.
  1701  * 
  1647  * 
  1702  */
  1648  */
  1703 void HbIconLoader::getMultiIconImplFromServer(QStringList &multiPartIconList,                                                             
  1649 void HbIconLoader::getMultiIconImplFromServer(QStringList &multiPartIconList,
  1704                                 QVector<QSizeF> &sizeList,
  1650                                 QVector<QSizeF> &sizeList,
  1705                                 Qt::AspectRatioMode aspectRatioMode,
  1651                                 Qt::AspectRatioMode aspectRatioMode,
  1706                                 QIcon::Mode mode,
  1652                                 QIcon::Mode mode,
  1707                                 bool mirrored,
  1653                                 bool mirrored,
  1708                                 bool mirroredIconFound,
  1654                                 bool mirroredIconFound,
  1716     Q_UNUSED(type);
  1662     Q_UNUSED(type);
  1717     QVector<int> posList;
  1663     QVector<int> posList;
  1718 #ifdef HB_ICONIMPL_CACHE
  1664 #ifdef HB_ICONIMPL_CACHE
  1719     // search the client cache first before asking the server
  1665     // search the client cache first before asking the server
  1720     for(int i = 0; i < multiPartIconList.count(); i++) {
  1666     for(int i = 0; i < multiPartIconList.count(); i++) {
  1721         QByteArray cacheKey = d->createCacheKeyFrom( multiPartIconList[i], sizeList[i], aspectRatioMode,
  1667         QByteArray cacheKey = d->createCacheKeyFrom( multiPartIconList[i], 
  1722                         mode, mirrored, color, currRenderMode );
  1668                                                      sizeList[i], 
       
  1669                                                      aspectRatioMode,
       
  1670                                                      mode, 
       
  1671                                                      mirrored, 
       
  1672                                                      color, 
       
  1673                                                      currRenderMode );
  1723         //look up in the local iconImplCache. 
  1674         //look up in the local iconImplCache. 
  1724         //If found return the ptr directly
  1675         //If found return the ptr directly
  1725         HbIconImpl * ptr = 0;
  1676         HbIconImpl * ptr = 0;
  1726         if (iconImplCache.contains(cacheKey)) {
  1677         if (iconImplCache.contains(cacheKey)) {
  1727             ptr = iconImplCache.value(cacheKey);
  1678             ptr = iconImplCache.value(cacheKey);
  1769                 params.size = sizeList.at(i);
  1720                 params.size = sizeList.at(i);
  1770 
  1721 
  1771                 impl = HbIconImplCreator::createIconImpl(iconInfoList.icon[i], params);
  1722                 impl = HbIconImplCreator::createIconImpl(iconInfoList.icon[i], params);
  1772 
  1723 
  1773 #ifdef HB_ICONIMPL_CACHE
  1724 #ifdef HB_ICONIMPL_CACHE
  1774                 QByteArray cacheKey = d->createCacheKeyFrom(multiPartIconList[i], sizeList.at(i) , aspectRatioMode,
  1725                 QByteArray cacheKey = d->createCacheKeyFrom( multiPartIconList[i], 
  1775                                       mode, mirrored, color, currRenderMode);
  1726                                                              sizeList.at(i) , 
       
  1727                                                              aspectRatioMode,
       
  1728                                                              mode, 
       
  1729                                                              mirrored, 
       
  1730                                                              color, 
       
  1731                                                              currRenderMode );
  1776                 iconImplCache.insert(cacheKey, impl);
  1732                 iconImplCache.insert(cacheKey, impl);
  1777 #ifdef HB_ICON_CACHE_DEBUG
  1733 #ifdef HB_ICON_CACHE_DEBUG
  1778                 qDebug() << "HbIconLoader::getMultiIconImplFromServer(): " << params.iconName << " inserted into impl-cache, ref-count now = " << impl->refCount();
  1734                 qDebug() << "HbIconLoader::getMultiIconImplFromServer(): " << params.iconName << " inserted into impl-cache, ref-count now = " << impl->refCount();
  1779 #endif
  1735 #endif
  1780 
  1736