src/hbcore/image/hbiconloader.cpp
changeset 6 c3690ec91ef8
parent 5 627c4a0fd0e7
child 7 923ff622b8b9
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    42 #include "hbpixmapiconimpl_p.h"
    42 #include "hbpixmapiconimpl_p.h"
    43 #include "hbiconsource_p.h"
    43 #include "hbiconsource_p.h"
    44 #include "hbthemeindex_p.h"
    44 #include "hbthemeindex_p.h"
    45 #include "hbthemecommon_p.h"
    45 #include "hbthemecommon_p.h"
    46 #include "hbiconimplcreator_p.h"
    46 #include "hbiconimplcreator_p.h"
    47 #include "hbstandarddirs_p.h"
       
    48 #include <QDir>
    47 #include <QDir>
    49 #include <QCoreApplication>
    48 #include <QCoreApplication>
    50 #include <QDebug>
    49 #include <QDebug>
    51 #include <QPicture>
    50 #include <QPicture>
    52 #include <QPainter>
    51 #include <QPainter>
    78 
    77 
    79 // SVG animation is currently disabled because of bugs in QT's svg engine
    78 // SVG animation is currently disabled because of bugs in QT's svg engine
    80 #undef HB_SVG_ANIMATION
    79 #undef HB_SVG_ANIMATION
    81 
    80 
    82 static const char *s_unknown = "unknown";
    81 static const char *s_unknown = "unknown";
    83     // Icon name without extension
    82 // Icon name without extension
    84 
    83 
    85 /*!
    84 /*!
    86     \class HbIconLoader
    85     \class HbIconLoader
    87 
    86 
    88     \brief HbIconLoader loads icons according to the Freedesktop Icon Theme Specification
    87     \brief HbIconLoader loads icons according to the Freedesktop Icon Theme Specification
    93 // Allocated dynamically so it can be deleted before the application object is destroyed.
    92 // Allocated dynamically so it can be deleted before the application object is destroyed.
    94 // Deleting it later causes segmentation fault.
    93 // Deleting it later causes segmentation fault.
    95 static HbIconLoader *theLoader = 0;
    94 static HbIconLoader *theLoader = 0;
    96 
    95 
    97 #ifdef HB_ICONIMPL_CACHE
    96 #ifdef HB_ICONIMPL_CACHE
    98 static QHash<QByteArray, HbIconImpl*> iconImplCache;
    97 static QHash<QByteArray, HbIconImpl *> iconImplCache;
    99 #endif
    98 #endif
   100 
    99 
   101 class HbIconLoaderPrivate
   100 class HbIconLoaderPrivate
   102 {
   101 {
   103 public:
   102 public:
   106 
   105 
   107     static HbIconLoaderPrivate *global();
   106     static HbIconLoaderPrivate *global();
   108 
   107 
   109     static QString removeIconNameSuffix(const QString &iconName);
   108     static QString removeIconNameSuffix(const QString &iconName);
   110 
   109 
   111     /* This method is supposed to work the same way 
   110     /* This method is supposed to work the same way
   112        as the FindIconHelper in the Icon Theme Spec: */
   111        as the FindIconHelper in the Icon Theme Spec: */
   113     static QString findSharedResourceHelper(const QString &resourceName,
   112     static QString findSharedResourceHelper(const QString &resourceName,
   114                                   bool mirrored,
   113                                             bool mirrored,
   115                                   bool& mirroredIconFound,
   114                                             bool &mirroredIconFound,
   116                                   Hb::ResourceType itemType = Hb::IconResource,
   115                                             Hb::ResourceType itemType = Hb::IconResource,
   117                                   bool useThemeIndex = true);
   116                                             bool useThemeIndex = true);
   118 
   117 
   119     static QString findEffectHelper(const QString &effectName);
   118     static QString findEffectHelper(const QString &effectName);
   120 
   119 
   121     bool isAutomaticallyMirrored(const QString &iconName);
   120     bool isAutomaticallyMirrored(const QString &iconName);
   122 
   121 
   123     bool isLayoutMirrored();
   122     bool isLayoutMirrored();
   124     void setLayoutMirrored(bool mirrored);
   123     void setLayoutMirrored(bool mirrored);
   125 
   124 
   126 #ifdef HB_ICONIMPL_CACHE
   125 #ifdef HB_ICONIMPL_CACHE
   127     QByteArray createCacheKeyFrom( const QString &iconName, 
   126     QByteArray createCacheKeyFrom(const QString &iconName,
   128                                    const QSizeF &size,
   127                                   const QSizeF &size,
   129                                    Qt::AspectRatioMode aspectRatioMode, 
   128                                   Qt::AspectRatioMode aspectRatioMode,
   130                                    QIcon::Mode mode, 
   129                                   QIcon::Mode mode,
   131                                    bool mirrored, 
   130                                   bool mirrored,
   132                                    const QColor &color,
   131                                   const QColor &color,
   133                                    HbRenderingMode renderMode );
   132                                   HbRenderingMode renderMode);
   134 #endif
   133 #endif
   135 
   134 
   136 public: 
   135 public:
   137     QString storedTheme;
   136     QString storedTheme;
   138 
   137 
   139     int sourceResolution;
   138     int sourceResolution;
   140     int resolution;
   139     int resolution;
   141     qreal zoom;
   140     qreal zoom;
   146     bool animationLoading;
   145     bool animationLoading;
   147     // <-- Frame-by-frame animation support ------------------------------------
   146     // <-- Frame-by-frame animation support ------------------------------------
   148 
   147 
   149     HbIconSource *lastIconSource;
   148     HbIconSource *lastIconSource;
   150 
   149 
   151 private: 
   150 private:
   152     enum {
   151     enum {
   153         Unknown = 0,
   152         Unknown = 0,
   154         NotMirrored = 1,
   153         NotMirrored = 1,
   155         Mirrored = 2
   154         Mirrored = 2
   156     };
   155     };
   160     */
   159     */
   161     int layoutMirrored;
   160     int layoutMirrored;
   162 };
   161 };
   163 
   162 
   164 HbIconLoaderPrivate::HbIconLoaderPrivate() :
   163 HbIconLoaderPrivate::HbIconLoaderPrivate() :
   165         storedTheme(HbTheme::instance()->name()),
   164     storedTheme(HbTheme::instance()->name()),
   166         sourceResolution(144), // This is about the resolution of a Nokia N95 8GB
   165     sourceResolution(144), // This is about the resolution of a Nokia N95 8GB
   167         resolution(144),
   166     resolution(144),
   168         zoom(1.0),
   167     zoom(1.0),
   169         animationManager(HbIconAnimationManager::global()),
   168     animationManager(HbIconAnimationManager::global()),
   170         animationLoading(false),
   169     animationLoading(false),
   171         lastIconSource(0),
   170     lastIconSource(0),
   172         layoutMirrored(Unknown)
   171     layoutMirrored(Unknown)
   173 {
   172 {
   174 }
   173 }
   175 
   174 
   176 HbIconLoaderPrivate::~HbIconLoaderPrivate()
   175 HbIconLoaderPrivate::~HbIconLoaderPrivate()
   177 {
   176 {
   186 
   185 
   187 QString HbIconLoaderPrivate::removeIconNameSuffix(const QString &iconName)
   186 QString HbIconLoaderPrivate::removeIconNameSuffix(const QString &iconName)
   188 {
   187 {
   189     QString loweredIconName = iconName.toLower();
   188     QString loweredIconName = iconName.toLower();
   190     if (loweredIconName.endsWith(QLatin1String(".svg"))
   189     if (loweredIconName.endsWith(QLatin1String(".svg"))
   191         || loweredIconName.endsWith(QLatin1String(".png"))
   190             || loweredIconName.endsWith(QLatin1String(".png"))
   192         || loweredIconName.endsWith(QLatin1String(".mng"))
   191             || loweredIconName.endsWith(QLatin1String(".mng"))
   193         || loweredIconName.endsWith(QLatin1String(".gif"))
   192             || loweredIconName.endsWith(QLatin1String(".gif"))
   194         || loweredIconName.endsWith(QLatin1String(".xpm"))
   193             || loweredIconName.endsWith(QLatin1String(".xpm"))
   195         || loweredIconName.endsWith(QLatin1String(".jpg"))
   194             || loweredIconName.endsWith(QLatin1String(".jpg"))
   196         || loweredIconName.endsWith(QLatin1String(".nvg"))) {
   195             || loweredIconName.endsWith(QLatin1String(".nvg"))) {
   197         return iconName.left(iconName.length() - 4);
   196         return iconName.left(iconName.length() - 4);
   198     }
   197     }
   199 
   198 
   200     if (loweredIconName.endsWith(QLatin1String(".svgz"))
   199     if (loweredIconName.endsWith(QLatin1String(".svgz"))
   201         || loweredIconName.endsWith(QLatin1String(".qpic"))) {
   200             || loweredIconName.endsWith(QLatin1String(".qpic"))) {
   202         return iconName.left(iconName.length() - 5);
   201         return iconName.left(iconName.length() - 5);
   203     }
   202     }
   204 
   203 
   205     return iconName;
   204     return iconName;
   206 }
   205 }
   220         return "BLOB";
   219         return "BLOB";
   221     }
   220     }
   222     return suffix;
   221     return suffix;
   223 }
   222 }
   224 
   223 
   225 QString HbIconLoaderPrivate::findSharedResourceHelper(const QString &resourceName, bool mirrored, bool& mirroredIconFound, Hb::ResourceType itemType, bool useThemeIndex)
   224 QString HbIconLoaderPrivate::findSharedResourceHelper(const QString &resourceName, bool mirrored, bool &mirroredIconFound, Hb::ResourceType itemType, bool useThemeIndex)
   226 {
   225 {
   227     Q_UNUSED(useThemeIndex)
   226     Q_UNUSED(useThemeIndex)
   228     Q_UNUSED(itemType)
   227     Q_UNUSED(itemType)
   229 
   228 
   230     mirroredIconFound = false;
   229     mirroredIconFound = false;
   255             int index = index1 > index2 ? index1 : index2;
   254             int index = index1 > index2 ? index1 : index2;
   256 
   255 
   257             QString iconNameCopy(resourceName);
   256             QString iconNameCopy(resourceName);
   258 
   257 
   259             if (index > 0) {
   258             if (index > 0) {
   260                 iconNameCopy.insert(index+1, QString("mirrored/"));
   259                 iconNameCopy.insert(index + 1, QString("mirrored/"));
   261             }
   260             }
   262             iconPath = HbStandardDirs::findResource(iconNameCopy, Hb::IconResource);
   261             if (QFile::exists(iconNameCopy)) {
   263 
   262                 iconPath = iconNameCopy;
   264             if( !iconPath.isEmpty() ) {
   263             }
       
   264 
       
   265             if (!iconPath.isEmpty()) {
   265                 mirroredIconFound = true;
   266                 mirroredIconFound = true;
   266                 return iconPath;
   267                 return iconPath;
   267             }
   268             }
   268         }
   269         }
   269 
   270 
   270         iconPath = HbStandardDirs::findResource(resourceName, Hb::IconResource);
   271         if (QFile::exists(resourceName)) {
       
   272             iconPath = resourceName;
       
   273         }
   271     }
   274     }
   272 
   275 
   273     return iconPath;
   276     return iconPath;
   274 }
   277 }
   275 
   278 
   299     if filename != none
   302     if filename != none
   300       return filename
   303       return filename
   301   }
   304   }
   302   return none
   305   return none
   303 }
   306 }
   304      
   307 
   305 
   308 
   306 With the following helper functions:
   309 With the following helper functions:
   307 
   310 
   308 LookupIcon(iconname, size, theme) {
   311 LookupIcon(iconname, size, theme) {
   309   for each subdir in $(theme subdir list) {
   312   for each subdir in $(theme subdir list) {
   421 
   424 
   422 bool HbIconLoaderPrivate::isLayoutMirrored()
   425 bool HbIconLoaderPrivate::isLayoutMirrored()
   423 {
   426 {
   424     if (layoutMirrored == Unknown) {
   427     if (layoutMirrored == Unknown) {
   425         // The layout directionality is defined by asking it from the main window.
   428         // The layout directionality is defined by asking it from the main window.
   426         QList<HbMainWindow*> allWindows = hbInstance->allMainWindows();
   429         QList<HbMainWindow *> allWindows = hbInstance->allMainWindows();
   427         HbMainWindow* primaryWindow = allWindows.value(0);
   430         HbMainWindow *primaryWindow = allWindows.value(0);
   428         if (primaryWindow) {
   431         if (primaryWindow) {
   429             layoutMirrored = primaryWindow->layoutDirection() == Qt::LeftToRight ? NotMirrored : Mirrored;
   432             layoutMirrored = primaryWindow->layoutDirection() == Qt::LeftToRight ? NotMirrored : Mirrored;
   430         } else {
   433         } else {
   431             // Do not know mirroring state yet, return not mirrored.
   434             // Do not know mirroring state yet, return not mirrored.
   432             return NotMirrored;
   435             return NotMirrored;
   439 {
   442 {
   440     layoutMirrored = mirrored ? Mirrored : NotMirrored;
   443     layoutMirrored = mirrored ? Mirrored : NotMirrored;
   441 }
   444 }
   442 
   445 
   443 #ifdef HB_ICONIMPL_CACHE
   446 #ifdef HB_ICONIMPL_CACHE
   444 QByteArray HbIconLoaderPrivate::createCacheKeyFrom( const QString &iconName,
   447 QByteArray HbIconLoaderPrivate::createCacheKeyFrom(const QString &iconName,
   445                                                     const QSizeF &size,
   448         const QSizeF &size,
   446                                                     Qt::AspectRatioMode aspectRatioMode, 
   449         Qt::AspectRatioMode aspectRatioMode,
   447                                                     QIcon::Mode mode, 
   450         QIcon::Mode mode,
   448                                                     bool mirrored, 
   451         bool mirrored,
   449                                                     const QColor &color,
   452         const QColor &color,
   450                                                     HbRenderingMode renderMode )
   453         HbRenderingMode renderMode)
   451 {
   454 {
   452     static const int paramArraySize = 8;
   455     static const int paramArraySize = 8;
   453 
   456 
   454     // This uses QByteArray to improve performance compared to QString.
   457     // This uses QByteArray to improve performance compared to QString.
   455     // It allows appending stuff with less heap allocations and conversions compared to using QString.
   458     // It allows appending stuff with less heap allocations and conversions compared to using QString.
   475         temp[6] = 0;
   478         temp[6] = 0;
   476     }
   479     }
   477 
   480 
   478     // Append render mode when creating cache key
   481     // Append render mode when creating cache key
   479     temp[7] = renderMode;
   482     temp[7] = renderMode;
   480     cacheKey.append((char*)&(temp[0]), sizeof(int)*paramArraySize);
   483     cacheKey.append((char *)&(temp[0]), sizeof(int)*paramArraySize);
   481 
   484 
   482     const QChar *iconNamePtr = iconName.constData();
   485     const QChar *iconNamePtr = iconName.constData();
   483     cacheKey.append((char*)iconNamePtr, nameSize * sizeof(QChar));
   486     cacheKey.append((char *)iconNamePtr, nameSize * sizeof(QChar));
   484 
   487 
   485     if (mirrored) {
   488     if (mirrored) {
   486         cacheKey.append('M');
   489         cacheKey.append('M');
   487     }
   490     }
   488 
   491 
   489     return cacheKey;
   492     return cacheKey;
   490 }
   493 }
   491 #endif
   494 #endif
   492 
   495 
   493 HbIconLoader::HbIconLoader(const QString &appName, QObject *parent)
   496 HbIconLoader::HbIconLoader(const QString &appName, QObject *parent)
   494     : QObject( parent )
   497     : QObject(parent)
   495 {
   498 {
   496     setObjectName( appName );
   499     setObjectName(appName);
   497     d = new HbIconLoaderPrivate();
   500     d = new HbIconLoaderPrivate();
   498 
   501 
   499     // Set default rendering mode to EHWRendering    
   502     // Set default rendering mode to EHWRendering
   500     renderMode = EHWRendering;
   503     renderMode = EHWRendering;
   501 
   504 
   502     // Delete the icon loader when the application is destroyed.
   505     // Delete the icon loader when the application is destroyed.
   503     connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(destroy()));
   506     connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(destroy()));
   504 
   507 
   505     connect(HbLayoutDirectionNotifier::instance(), SIGNAL(layoutDirectionChangeStarted()),
   508     connect(HbLayoutDirectionNotifier::instance(), SIGNAL(layoutDirectionChangeStarted()),
   506         this, SLOT(updateLayoutDirection()));
   509             this, SLOT(updateLayoutDirection()));
   507 
   510 
   508 #ifdef HB_TOOL_INTERFACE
   511 #ifdef HB_TOOL_INTERFACE
   509     // This enables partial theme updates.
   512     // This enables partial theme updates.
   510     connect(&hbInstance->theme()->d_ptr->iconTheme, SIGNAL(iconsUpdated(QStringList)), this, SLOT(themeChange(QStringList)));
   513     connect(&hbInstance->theme()->d_ptr->iconTheme, SIGNAL(iconsUpdated(QStringList)), this, SLOT(themeChange(QStringList)));
   511 #endif
   514 #endif
   555         }
   558         }
   556     }
   559     }
   557 
   560 
   558     // Step 2: There was no animation definition,
   561     // Step 2: There was no animation definition,
   559     // try to get default size from theme index if it is a themed icon (logical name).
   562     // try to get default size from theme index if it is a themed icon (logical name).
   560     
   563 
   561     if (HbThemeUtils::isLogicalName(iconName)) {
   564     if (HbThemeUtils::isLogicalName(iconName)) {
   562         // Try to get themed icon information from theme index
   565         // Try to get themed icon information from theme index
   563         HbThemeIndexResource resource(iconName);
   566         HbThemeIndexResource resource(iconName);
   564         if (resource.isValid()) {
   567         if (resource.isValid()) {
   565             // Try to get themed icon default size from theme index
   568             // Try to get themed icon default size from theme index
   607     }
   610     }
   608 }
   611 }
   609 
   612 
   610 bool HbIconLoader::iconsExist(const QString &iconName, const QStringList &suffixList)
   613 bool HbIconLoader::iconsExist(const QString &iconName, const QStringList &suffixList)
   611 {
   614 {
   612     QString name = HbIconLoaderPrivate::removeIconNameSuffix(iconName);
       
   613     bool found = true;
   615     bool found = true;
       
   616     bool logicalName = HbThemeUtils::isLogicalName(iconName);
       
   617 
       
   618     int suffixIndex = iconName.length();
       
   619     if (!logicalName) {
       
   620         // If it is an absolute icon path, the suffix is inserted before the file extension
       
   621         int index = iconName.lastIndexOf(QChar('.'));
       
   622         if (index > 0) {
       
   623             suffixIndex = index;
       
   624         }
       
   625     }
   614 
   626 
   615     foreach (const QString &suffix, suffixList) {
   627     foreach (const QString &suffix, suffixList) {
   616         bool dummy = false;
   628         bool dummy = false;
   617 
   629 
   618         QString path = HbIconLoaderPrivate::findSharedResourceHelper(name + suffix, false, dummy);
   630         QString nameWithSuffix = iconName;
       
   631         nameWithSuffix.insert(suffixIndex, suffix);
       
   632 
       
   633         QString path = HbIconLoaderPrivate::findSharedResourceHelper(nameWithSuffix, false, dummy);
   619         if (path.isEmpty()) {
   634         if (path.isEmpty()) {
   620             found = false;
   635             found = false;
   621             break;
   636             break;
   622         }
   637         }
   623     }
   638     }
   656     return d->resolution;
   671     return d->resolution;
   657 }
   672 }
   658 
   673 
   659 void HbIconLoader::applyResolutionCorrection(QSizeF &size)
   674 void HbIconLoader::applyResolutionCorrection(QSizeF &size)
   660 {
   675 {
   661     size = size * (qreal)(d->resolution) / (qreal)(d->sourceResolution) * d->zoom; 
   676     size = size * (qreal)(d->resolution) / (qreal)(d->sourceResolution) * d->zoom;
   662 }
   677 }
   663 
   678 
   664 void HbIconLoader::themeChange(const QStringList &updatedFiles)
   679 void HbIconLoader::themeChange(const QStringList &updatedFiles)
   665 {
   680 {
   666     foreach (HbFrameDrawerPrivate *frameDrawer, this->frameDrawerInstanceList) frameDrawer->themeChange(updatedFiles);
   681     foreach(HbFrameDrawerPrivate * frameDrawer, this->frameDrawerInstanceList) frameDrawer->themeChange(updatedFiles);
   667 }
   682 }
   668 
   683 
   669 void HbIconLoader::destroy()
   684 void HbIconLoader::destroy()
   670 {
   685 {
   671     if (theLoader) {
   686     if (theLoader) {
   680     // This method is called upon the signal 'layoutDirectionChangeStarted',
   695     // This method is called upon the signal 'layoutDirectionChangeStarted',
   681     // which is emitted before the signal 'layoutDirectionChanged'. Icon
   696     // which is emitted before the signal 'layoutDirectionChanged'. Icon
   682     // classes use that signal to update their pixmaps, so the new layout
   697     // classes use that signal to update their pixmaps, so the new layout
   683     // directionality must be updated in the icon loader before that.
   698     // directionality must be updated in the icon loader before that.
   684     // Thus, there are these separate signals.
   699     // Thus, there are these separate signals.
   685     QList<HbMainWindow*> allWindows = hbInstance->allMainWindows();
   700     QList<HbMainWindow *> allWindows = hbInstance->allMainWindows();
   686     HbMainWindow* primaryWindow = allWindows.value(0);
   701     HbMainWindow *primaryWindow = allWindows.value(0);
   687 
   702 
   688     d->setLayoutMirrored(primaryWindow->layoutDirection() == Qt::RightToLeft);
   703     d->setLayoutMirrored(primaryWindow->layoutDirection() == Qt::RightToLeft);
   689 }
   704 }
   690 
   705 
   691 void HbIconLoader::handleForegroundLost()
   706 void HbIconLoader::handleForegroundLost()
   692 {
   707 {
   693 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   708 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   694     // Remove SGImage /NVG type of icons 
   709     // Remove SGImage /NVG type of icons
   695     freeGpuIconData();
   710     freeGpuIconData();
   696     // delete the VGImage
   711     // delete the VGImage
   697     HbEglStates *eglStateInstance = HbEglStates::global();
   712     HbEglStates *eglStateInstance = HbEglStates::global();
   698     eglStateInstance->handleForegroundLost();
   713     eglStateInstance->handleForegroundLost();
   699     // notify the server to clear the SGImage and NVG type of icons from the client's session
   714     // notify the server to clear the SGImage and NVG type of icons from the client's session
   704 /*!
   719 /*!
   705  * Removes the  IconImpl entry from the client side cache
   720  * Removes the  IconImpl entry from the client side cache
   706  */
   721  */
   707 void HbIconLoader::removeItemInCache(HbIconImpl *iconImpl)
   722 void HbIconLoader::removeItemInCache(HbIconImpl *iconImpl)
   708 {
   723 {
   709 #ifdef HB_ICONIMPL_CACHE  
   724 #ifdef HB_ICONIMPL_CACHE
   710     if ( iconImpl ) {
   725     if (iconImpl) {
   711         iconImplCache.remove(iconImplCache.key(iconImpl));
   726         iconImplCache.remove(iconImplCache.key(iconImpl));
   712     }
   727     }
   713 #else
   728 #else
   714     Q_UNUSED(iconImpl);
   729     Q_UNUSED(iconImpl);
   715 #endif
   730 #endif
   720  *  It also resets the engine's iconImpl and MaskableIcon's iconImpl
   735  *  It also resets the engine's iconImpl and MaskableIcon's iconImpl
   721  */
   736  */
   722 void HbIconLoader::freeGpuIconData()
   737 void HbIconLoader::freeGpuIconData()
   723 {
   738 {
   724 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   739 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   725     for( int i = 0; i < iconEngineList.count(); i++ ) {     
   740     for (int i = 0; i < iconEngineList.count(); i++) {
   726         HbIconEngine *engine = iconEngineList.at(i);
   741         HbIconEngine *engine = iconEngineList.at(i);
   727         engine->resetIconImpl();
   742         engine->resetIconImpl();
   728     }   
   743     }
   729     for(int i = 0; i< frameDrawerInstanceList.count(); i++) {
   744     for (int i = 0; i < frameDrawerInstanceList.count(); i++) {
   730         HbFrameDrawerPrivate * fd = frameDrawerInstanceList.at(i);
   745         HbFrameDrawerPrivate *fd = frameDrawerInstanceList.at(i);
   731         if ( (fd->iconFormatType() == SGIMAGE) || (fd->iconFormatType() == NVG) ) {
   746         if ((fd->iconFormatType() == SGIMAGE) || (fd->iconFormatType() == NVG)) {
   732             fd->resetMaskableIcon();            
   747             fd->resetMaskableIcon();
   733         }    
   748         }
   734     }    
   749     }
   735 #endif
   750 #endif
   736 }
   751 }
   737 
   752 
   738 /*!
   753 /*!
   739   \internal
   754   \internal
   740 
   755 
   741   This is a wrapper for findSharedResourceHelper(). It is used for getting 
   756   This is a wrapper for findSharedResourceHelper(). It is used for getting
   742   resources from the themeserver.
   757   resources from the themeserver.
   743 
   758 
   744   The return value is either same as \a name, when the file is not found in the
   759   The return value is either same as \a name, when the file is not found in the
   745   theme, or the full path and name to the file found in the theme. In certain
   760   theme, or the full path and name to the file found in the theme. In certain
   746   situations the return value can also be an empty string, therefore it should
   761   situations the return value can also be an empty string, therefore it should
   754 
   769 
   755 /*!
   770 /*!
   756   This function is used to register the IconEngine instance to IconLoader
   771   This function is used to register the IconEngine instance to IconLoader
   757  */
   772  */
   758 void HbIconLoader::storeIconEngineInfo(HbIconEngine *iconEngine)
   773 void HbIconLoader::storeIconEngineInfo(HbIconEngine *iconEngine)
   759 {    
   774 {
   760     iconEngineList.append( iconEngine );
   775     iconEngineList.append(iconEngine);
   761 }
   776 }
   762 
   777 
   763 /*!
   778 /*!
   764   This function is used to unregister the Iconengine instance from Iconloader
   779   This function is used to unregister the Iconengine instance from Iconloader
   765  */
   780  */
   766 void HbIconLoader::removeIconEngineInfo(HbIconEngine *iconEngine)
   781 void HbIconLoader::removeIconEngineInfo(HbIconEngine *iconEngine)
   767 {
   782 {
   768    iconEngineList.removeOne(iconEngine); 
   783     iconEngineList.removeOne(iconEngine);
   769 }
   784 }
   770 
   785 
   771 /*!
   786 /*!
   772   This function is used to register the FrameDrawerPrivate instance to IconLoader
   787   This function is used to register the FrameDrawerPrivate instance to IconLoader
   773  */
   788  */
   774 void HbIconLoader::storeFrameDrawerInfo( HbFrameDrawerPrivate *frameDrawer )
   789 void HbIconLoader::storeFrameDrawerInfo(HbFrameDrawerPrivate *frameDrawer)
   775 {
   790 {
   776     frameDrawerInstanceList.append(frameDrawer);
   791     frameDrawerInstanceList.append(frameDrawer);
   777 }
   792 }
   778 
   793 
   779 /*!
   794 /*!
   780   This function is used to unregister the FrameDrawerPrivate instance from IconLoader
   795   This function is used to unregister the FrameDrawerPrivate instance from IconLoader
   781  */
   796  */
   782 void HbIconLoader::removeFrameDrawerInfo( HbFrameDrawerPrivate *frameDrawer )
   797 void HbIconLoader::removeFrameDrawerInfo(HbFrameDrawerPrivate *frameDrawer)
   783 {
   798 {
   784     frameDrawerInstanceList.removeOne(frameDrawer);    
   799     frameDrawerInstanceList.removeOne(frameDrawer);
   785 }
   800 }
   786 
   801 
   787 void HbIconLoader::resolveCleanIconName(HbIconLoadingParams &params) const
   802 void HbIconLoader::resolveCleanIconName(HbIconLoadingParams &params) const
   788 {
   803 {
   789     // Replace empty icon name with the "unknown" icon if needed.
   804     // Replace empty icon name with the "unknown" icon if needed.
   790     if (params.iconName.isEmpty() && params.options.testFlag(ReturnUnknownIcon)) {
   805     if (params.iconName.isEmpty() && params.options.testFlag(ReturnUnknownIcon)) {
   791         params.cleanIconName = QString(s_unknown);
   806         params.cleanIconName = QString(s_unknown);
   792     } else {
   807     } else {
   793         params.cleanIconName = params.iconName; 
   808         params.cleanIconName = params.iconName;
   794     }
   809     }
   795 }
   810 }
   796 
   811 
   797 QSizeF HbIconLoader::getAnimationDefaultSize(HbIconAnimationDefinition &def, HbIconLoadingParams &params)
   812 QSizeF HbIconLoader::getAnimationDefaultSize(HbIconAnimationDefinition &def, HbIconLoadingParams &params)
   798 {
   813 {
   807 {
   822 {
   808     Q_ASSERT(!def.isNull());
   823     Q_ASSERT(!def.isNull());
   809 
   824 
   810     QList<HbIconAnimationDefinition::AnimationFrame> frameDefs = def.frameList();
   825     QList<HbIconAnimationDefinition::AnimationFrame> frameDefs = def.frameList();
   811     QList<HbIconAnimationFrameSet::FrameData> frameList;
   826     QList<HbIconAnimationFrameSet::FrameData> frameList;
   812     
   827 
   813 #ifdef HB_ICON_TRACES
   828 #ifdef HB_ICON_TRACES
   814     if (!params.animator) {
   829     if (!params.animator) {
   815         qDebug() << "HbIconLoader: no animator ptr provided, loading only frame 1 out of" << frameDefs.count();
   830         qDebug() << "HbIconLoader: no animator ptr provided, loading only frame 1 out of" << frameDefs.count();
   816     } else {
   831     } else {
   817         qDebug() << "HbIconLoader: loading" << frameDefs.count() << "frames";
   832         qDebug() << "HbIconLoader: loading" << frameDefs.count() << "frames";
   842         // ...otherwise load the frame with the loader
   857         // ...otherwise load the frame with the loader
   843         if (!frameReady) {
   858         if (!frameReady) {
   844             // Frame-by-frame animations are always loaded in normal mode.
   859             // Frame-by-frame animations are always loaded in normal mode.
   845             // The mode is applied when the icon is painted.
   860             // The mode is applied when the icon is painted.
   846             newFrame.pixmap = HbIconLoader::loadIcon(
   861             newFrame.pixmap = HbIconLoader::loadIcon(
   847                 frame.iconName,
   862                                   frame.iconName,
   848                 params.purpose,
   863                                   params.purpose,
   849                 params.size,
   864                                   params.size,
   850                 params.aspectRatioMode,
   865                                   params.aspectRatioMode,
   851                 QIcon::Normal,
   866                                   QIcon::Normal,
   852                 params.options,
   867                                   params.options,
   853                 0,
   868                                   0,
   854                 params.color);
   869                                   params.color);
   855             
   870 
   856             newFrame.duration = frame.duration;
   871             newFrame.duration = frame.duration;
   857             newFrame.assignJumps(frame.jumps);
   872             newFrame.assignJumps(frame.jumps);
   858         }
   873         }
   859         // Append the frame to the animation frame list
   874         // Append the frame to the animation frame list
   860         frameList.append(newFrame);
   875         frameList.append(newFrame);
   880         }
   895         }
   881 
   896 
   882         // Take default size from the first frame
   897         // Take default size from the first frame
   883         QSizeF renderSize = QSizeF(params.canvasPixmap.size());
   898         QSizeF renderSize = QSizeF(params.canvasPixmap.size());
   884 
   899 
   885         if(!params.isDefaultSize) {
   900         if (!params.isDefaultSize) {
   886             renderSize.scale(params.size, params.aspectRatioMode);
   901             renderSize.scale(params.size, params.aspectRatioMode);
   887         } else if (params.options.testFlag(ResolutionCorrected)) {
   902         } else if (params.options.testFlag(ResolutionCorrected)) {
   888             applyResolutionCorrection(renderSize);
   903             applyResolutionCorrection(renderSize);
   889         }
   904         }
   890 
   905 
   926     return iconPath;
   941     return iconPath;
   927 }
   942 }
   928 
   943 
   929 /*!
   944 /*!
   930  * \fn HbIconImpl *HbIconLoader::getIconFromServer()
   945  * \fn HbIconImpl *HbIconLoader::getIconFromServer()
   931  * 
   946  *
   932  * Initiate an IPC to themeserver to get the icon-data from the server.
   947  * Initiate an IPC to themeserver to get the icon-data from the server.
   933  * 
   948  *
   934  */
   949  */
   935 HbIconImpl *HbIconLoader::getIconFromServer(HbIconLoadingParams &params)
   950 HbIconImpl *HbIconLoader::getIconFromServer(HbIconLoadingParams &params)
   936 {
   951 {
   937 
   952 
   938     HbIconImpl *icon = 0;
   953     HbIconImpl *icon = 0;
   953                    params.color,
   968                    params.color,
   954                    params.renderMode);
   969                    params.renderMode);
   955 
   970 
   956     //Creates HbIconImpl instance based on the type of data returned by themeserver.
   971     //Creates HbIconImpl instance based on the type of data returned by themeserver.
   957     //HbIconImpl thus created could be any one of the following impl-types:
   972     //HbIconImpl thus created could be any one of the following impl-types:
   958     //1. HbSgImageIconImpl 
   973     //1. HbSgImageIconImpl
   959     //2. HbNvgIconImpl
   974     //2. HbNvgIconImpl
   960     //3. HbPixmapIconImpl
   975     //3. HbPixmapIconImpl
   961     icon = HbIconImplCreator::createIconImpl(iconInfo, params);
   976     icon = HbIconImplCreator::createIconImpl(iconInfo, params);
   962 
   977 
   963 #ifdef HB_ICON_TRACES
   978 #ifdef HB_ICON_TRACES
   977     QSizeF renderSize;
   992     QSizeF renderSize;
   978 
   993 
   979     if (svgRenderer && svgRenderer->isValid()) {
   994     if (svgRenderer && svgRenderer->isValid()) {
   980         renderSize = QSizeF(svgRenderer->defaultSize());
   995         renderSize = QSizeF(svgRenderer->defaultSize());
   981 
   996 
   982         if(!params.isDefaultSize) {
   997         if (!params.isDefaultSize) {
   983             renderSize.scale(params.size, params.aspectRatioMode);
   998             renderSize.scale(params.size, params.aspectRatioMode);
   984         } else if (params.options.testFlag(ResolutionCorrected)) {
   999         } else if (params.options.testFlag(ResolutionCorrected)) {
   985             applyResolutionCorrection(renderSize);
  1000             applyResolutionCorrection(renderSize);
   986         }
  1001         }
   987 
  1002 
  1028         QPainter painter;
  1043         QPainter painter;
  1029         painter.begin(&pm);
  1044         painter.begin(&pm);
  1030         svgRenderer->render(&painter, QRectF(QPointF(), renderSize.toSize()));
  1045         svgRenderer->render(&painter, QRectF(QPointF(), renderSize.toSize()));
  1031         painter.end();
  1046         painter.end();
  1032     }
  1047     }
  1033     
  1048 
  1034     source->releaseSvgRenderer();
  1049     source->releaseSvgRenderer();
  1035 }
  1050 }
  1036 
  1051 
  1037 void HbIconLoader::loadPictureIcon(HbIconLoadingParams &params)
  1052 void HbIconLoader::loadPictureIcon(HbIconLoadingParams &params)
  1038 {
  1053 {
  1045 
  1060 
  1046         qreal sx = 1.0;
  1061         qreal sx = 1.0;
  1047         qreal sy = 1.0;
  1062         qreal sy = 1.0;
  1048         bool scale = false;
  1063         bool scale = false;
  1049 
  1064 
  1050         if(!params.isDefaultSize) {
  1065         if (!params.isDefaultSize) {
  1051             scale = true;
  1066             scale = true;
  1052             renderSize.scale(params.size, params.aspectRatioMode);
  1067             renderSize.scale(params.size, params.aspectRatioMode);
  1053         } else if (params.options.testFlag(ResolutionCorrected)) {
  1068         } else if (params.options.testFlag(ResolutionCorrected)) {
  1054             qreal scaleFactor = (qreal)(d->resolution) / (qreal)(d->sourceResolution) * d->zoom;
  1069             qreal scaleFactor = (qreal)(d->resolution) / (qreal)(d->sourceResolution) * d->zoom;
  1055             if (!qFuzzyCompare(scaleFactor, qreal(1.0))) {
  1070             if (!qFuzzyCompare(scaleFactor, qreal(1.0))) {
  1057                 renderSize *= scaleFactor;
  1072                 renderSize *= scaleFactor;
  1058             }
  1073             }
  1059         }
  1074         }
  1060 
  1075 
  1061         if (scale) {
  1076         if (scale) {
  1062             // Determine scale factor as QPicture doesn't allow for scaling 
  1077             // Determine scale factor as QPicture doesn't allow for scaling
  1063             sx = renderSize.width() / picSize.width();
  1078             sx = renderSize.width() / picSize.width();
  1064             sy = renderSize.height() / picSize.height();
  1079             sy = renderSize.height() / picSize.height();
  1065         }
  1080         }
  1066 
  1081 
  1067         QPixmap &pm = params.canvasPixmap;
  1082         QPixmap &pm = params.canvasPixmap;
  1087     bool animationCreated = false;
  1102     bool animationCreated = false;
  1088 
  1103 
  1089     if (imgRenderer && imgRenderer->canRead()) {
  1104     if (imgRenderer && imgRenderer->canRead()) {
  1090         renderSize = QSizeF(imgRenderer->size());
  1105         renderSize = QSizeF(imgRenderer->size());
  1091 
  1106 
  1092         if(!params.isDefaultSize) {
  1107         if (!params.isDefaultSize) {
  1093             renderSize.scale(params.size, params.aspectRatioMode);
  1108             renderSize.scale(params.size, params.aspectRatioMode);
  1094         } else if (params.options.testFlag(ResolutionCorrected)) {
  1109         } else if (params.options.testFlag(ResolutionCorrected)) {
  1095             applyResolutionCorrection(renderSize);
  1110             applyResolutionCorrection(renderSize);
  1096         }
  1111         }
  1097 
  1112 
  1144         }
  1159         }
  1145 
  1160 
  1146         QImage img = imgRenderer->read();
  1161         QImage img = imgRenderer->read();
  1147         params.canvasPixmap = QPixmap::fromImage(img);
  1162         params.canvasPixmap = QPixmap::fromImage(img);
  1148     }
  1163     }
  1149     
  1164 
  1150     source->releaseImageReader();
  1165     source->releaseImageReader();
  1151 }
  1166 }
  1152 
  1167 
  1153 void HbIconLoader::loadPixmapIcon(HbIconLoadingParams &params, const QString &format)
  1168 void HbIconLoader::loadPixmapIcon(HbIconLoadingParams &params, const QString &format)
  1154 {
  1169 {
  1163         // This test implementation improves resize speed up to 5 times..
  1178         // This test implementation improves resize speed up to 5 times..
  1164         if (!params.isDefaultSize && !params.size.isEmpty()) {
  1179         if (!params.isDefaultSize && !params.size.isEmpty()) {
  1165             // Smooth scaling is very expensive (size^2). Therefore we reduce the size
  1180             // Smooth scaling is very expensive (size^2). Therefore we reduce the size
  1166             // to 1.5 of the destination size and using fast transformation.
  1181             // to 1.5 of the destination size and using fast transformation.
  1167             // Therefore we speed up but don't loose quality..
  1182             // Therefore we speed up but don't loose quality..
  1168             if ( pm.size().width() > ( 4 * params.size.toSize().width() ) ) {
  1183             if (pm.size().width() > (4 * params.size.toSize().width())) {
  1169                 // Improve scaling speed by add an intermediate fast transformation..
  1184                 // Improve scaling speed by add an intermediate fast transformation..
  1170                 QSize intermediate_size = QSize( params.size.toSize().width() * 2, params.size.toSize().height() * 2 );
  1185                 QSize intermediate_size = QSize(params.size.toSize().width() * 2, params.size.toSize().height() * 2);
  1171                 pm = pm.scaled(
  1186                 pm = pm.scaled(
  1172                     intermediate_size,
  1187                          intermediate_size,
  1173                     params.aspectRatioMode,
  1188                          params.aspectRatioMode,
  1174                     Qt::FastTransformation ); // Cheap operation!
  1189                          Qt::FastTransformation);  // Cheap operation!
  1175             }
  1190             }
  1176 #endif // ENABLE_EXPERIMENTAL_RESIZE_BOOST__
  1191 #endif // ENABLE_EXPERIMENTAL_RESIZE_BOOST__
  1177 
  1192 
  1178             pm = pm.scaled(
  1193             pm = pm.scaled(
  1179                 params.size.toSize(),
  1194                      params.size.toSize(),
  1180                 params.aspectRatioMode,
  1195                      params.aspectRatioMode,
  1181                 Qt::SmoothTransformation); // Expensive operation!
  1196                      Qt::SmoothTransformation); // Expensive operation!
  1182 
  1197 
  1183 #ifdef ENABLE_EXPERIMENTAL_RESIZE_BOOST__
  1198 #ifdef ENABLE_EXPERIMENTAL_RESIZE_BOOST__
  1184         }
  1199         }
  1185 #endif
  1200 #endif
  1186     }
  1201     }
  1189     source->deletePixmapIfLargerThan(PIXMAP_SIZE_LIMIT);
  1204     source->deletePixmapIfLargerThan(PIXMAP_SIZE_LIMIT);
  1190 }
  1205 }
  1191 
  1206 
  1192 /*!
  1207 /*!
  1193  * \fn void HbIconLoader::switchRenderingMode()
  1208  * \fn void HbIconLoader::switchRenderingMode()
  1194  * 
  1209  *
  1195  * This function gets notified when the rendering mode of the application changes e.g
  1210  * This function gets notified when the rendering mode of the application changes e.g
  1196  * ( Hardware - Software rendering or vice versa ). If the mode is changed from 
  1211  * ( Hardware - Software rendering or vice versa ). If the mode is changed from
  1197  *  Hardware to Software, all Hardware rendered icons will release the GPU resources.
  1212  *  Hardware to Software, all Hardware rendered icons will release the GPU resources.
  1198  *  This function also initiates an IPC call to ThemeServer, so that the server 
  1213  *  This function also initiates an IPC call to ThemeServer, so that the server
  1199  *  can do its part of cleanup. 
  1214  *  can do its part of cleanup.
  1200  *  \a newRenderMode new rendering mode of application 
  1215  *  \a newRenderMode new rendering mode of application
  1201  */ 
  1216  */
  1202 
  1217 
  1203 void HbIconLoader::switchRenderingMode(HbRenderingMode newRenderMode)
  1218 void HbIconLoader::switchRenderingMode(HbRenderingMode newRenderMode)
  1204 {
  1219 {
  1205 #ifndef Q_OS_SYMBIAN
  1220 #ifndef Q_OS_SYMBIAN
  1206     Q_UNUSED(newRenderMode)
  1221     Q_UNUSED(newRenderMode)
  1209 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
  1224 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
  1210     if (newRenderMode != renderMode) {
  1225     if (newRenderMode != renderMode) {
  1211         if (newRenderMode == ESWRendering) {
  1226         if (newRenderMode == ESWRendering) {
  1212             // switching from HW to SW mode
  1227             // switching from HW to SW mode
  1213             freeGpuIconData();
  1228             freeGpuIconData();
  1214         }        
  1229         }
  1215         if (HbThemeClient::global()->switchRenderingMode(newRenderMode)) {
  1230         if (HbThemeClient::global()->switchRenderingMode(newRenderMode)) {
  1216             renderMode = newRenderMode;
  1231             renderMode = newRenderMode;
  1217         }
  1232         }
  1218     }
  1233     }
  1219 #endif
  1234 #endif
  1228     }
  1243     }
  1229 }
  1244 }
  1230 
  1245 
  1231 /*!
  1246 /*!
  1232  * \fn HbIconImpl* HbIconLoader::loadIcon()
  1247  * \fn HbIconImpl* HbIconLoader::loadIcon()
  1233  * 
  1248  *
  1234  * This function is responsible for loading a single-piece icon .
  1249  * This function is responsible for loading a single-piece icon .
  1235  * First it checks whether the icon is present on the application (client)cache,
  1250  * First it checks whether the icon is present on the application (client)cache,
  1236  * if found it increments the ref-count of the HbIconImpl and returns. If the icon
  1251  * if found it increments the ref-count of the HbIconImpl and returns. If the icon
  1237  * is not found in the client's impl-cache, it initiates an IPC to themeserver
  1252  * is not found in the client's impl-cache, it initiates an IPC to themeserver
  1238  * to load the icon. It receives HbSharedIconInfo from themeserver, creates a HbIconImpl
  1253  * to load the icon. It receives HbSharedIconInfo from themeserver, creates a HbIconImpl
  1239  * from this data, inserts this into client's icon-impl-cache and returns.
  1254  * from this data, inserts this into client's icon-impl-cache and returns.
  1240  * 
  1255  *
  1241  */ 
  1256  */
  1242 HbIconImpl *HbIconLoader::loadIcon(
  1257 HbIconImpl *HbIconLoader::loadIcon(
  1243     const QString &iconName,
  1258     const QString &iconName,
  1244     IconDataType type, 
  1259     IconDataType type,
  1245     HbIconLoader::Purpose purpose, 
  1260     HbIconLoader::Purpose purpose,
  1246     const QSizeF &size, 
  1261     const QSizeF &size,
  1247     Qt::AspectRatioMode aspectRatioMode, 
  1262     Qt::AspectRatioMode aspectRatioMode,
  1248     QIcon::Mode mode, 
  1263     QIcon::Mode mode,
  1249     IconLoaderOptions options, 
  1264     IconLoaderOptions options,
  1250     HbIconAnimator *animator,
  1265     HbIconAnimator *animator,
  1251     const QColor &color)
  1266     const QColor &color)
  1252 {
  1267 {
  1253 #ifdef HB_ICON_TRACES
  1268 #ifdef HB_ICON_TRACES
  1254     QString debugString = "HbIconLoader::loadIcon START - ";
  1269     QString debugString = "HbIconLoader::loadIcon START - ";
  1261         debugString.append('x');
  1276         debugString.append('x');
  1262         debugString.append(QString::number(size.height()));
  1277         debugString.append(QString::number(size.height()));
  1263     }
  1278     }
  1264     qDebug() << debugString;
  1279     qDebug() << debugString;
  1265 #endif
  1280 #endif
  1266     Q_UNUSED( type )
  1281     Q_UNUSED(type)
  1267 
  1282 
  1268     HbIconImpl* icon = 0;
  1283     HbIconImpl *icon = 0;
  1269 
  1284 
  1270     if (!size.isValid()) {
  1285     if (!size.isValid()) {
  1271         return 0;
  1286         return 0;
  1272     }
  1287     }
  1273 
  1288 
  1279     params.aspectRatioMode = aspectRatioMode;
  1294     params.aspectRatioMode = aspectRatioMode;
  1280     params.mode = mode;
  1295     params.mode = mode;
  1281     params.options = options;
  1296     params.options = options;
  1282     params.animator = animator;
  1297     params.animator = animator;
  1283     params.color = color;
  1298     params.color = color;
  1284     params.isDefaultSize = ( purpose == AnyPurpose ) && size.isNull();
  1299     params.isDefaultSize = (purpose == AnyPurpose) && size.isNull();
  1285     params.mirrored = options.testFlag(HorizontallyMirrored);
  1300     params.mirrored = options.testFlag(HorizontallyMirrored);
  1286     params.mirroredIconFound = false;
  1301     params.mirroredIconFound = false;
  1287     params.canCache = true;
  1302     params.canCache = true;
  1288     params.animationCreated = false;
  1303     params.animationCreated = false;
  1289     params.mirroringHandled = false;
  1304     params.mirroringHandled = false;
  1315         }
  1330         }
  1316     }
  1331     }
  1317 
  1332 
  1318     // Step 2: There was no animation definition, try get icon from server
  1333     // Step 2: There was no animation definition, try get icon from server
  1319     if (!params.animationCreated) {
  1334     if (!params.animationCreated) {
  1320     
  1335 
  1321 #ifdef HB_ICONIMPL_CACHE
  1336 #ifdef HB_ICONIMPL_CACHE
  1322         QByteArray cacheKey = d->createCacheKeyFrom( params.iconName, 
  1337         QByteArray cacheKey = d->createCacheKeyFrom(params.iconName,
  1323                                                      params.size,
  1338                               params.size,
  1324                                                      params.aspectRatioMode,
  1339                               params.aspectRatioMode,
  1325                                                      params.mode, 
  1340                               params.mode,
  1326                                                      params.mirrored, 
  1341                               params.mirrored,
  1327                                                      params.color, 
  1342                               params.color,
  1328                                                      params.renderMode );
  1343                               params.renderMode);
  1329         //look up in the local iconImplCache. 
  1344         //look up in the local iconImplCache.
  1330         //If found return the ptr directly
  1345         //If found return the ptr directly
  1331         if (iconImplCache.contains(cacheKey)) {
  1346         if (iconImplCache.contains(cacheKey)) {
  1332             HbIconImpl * ptr = iconImplCache.value(cacheKey);
  1347             HbIconImpl *ptr = iconImplCache.value(cacheKey);
  1333             ptr->incrementRefCount();
  1348             ptr->incrementRefCount();
  1334 #ifdef HB_ICON_CACHE_DEBUG
  1349 #ifdef HB_ICON_CACHE_DEBUG
  1335             qDebug() << "HbIconLoader::loadIcon(): " << "Cache hit in iconImplCache for" << params.iconName<<params.size.height() <<"X"<< params.size.width() ;
  1350             qDebug() << "HbIconLoader::loadIcon(): " << "Cache hit in iconImplCache for" << params.iconName << params.size.height() << "X" << params.size.width() ;
  1336             qDebug() << "HbIconLoader::loadIcon(): Client RefCount now = " <<ptr->refCount();
  1351             qDebug() << "HbIconLoader::loadIcon(): Client RefCount now = " << ptr->refCount();
  1337 #endif        
  1352 #endif
  1338             return ptr;
  1353             return ptr;
  1339         }
  1354         }
  1340 #endif
  1355 #endif
  1341         if (HbThemeUtils::isLogicalName(iconName)) {
  1356         if (HbThemeUtils::isLogicalName(iconName)) {
  1342             params.iconFileName = resolveIconFileName(params);
  1357             params.iconFileName = resolveIconFileName(params);
  1358 // Theme server on desktop was found very slow (probably due to IPC with QLocalServer/QLocalSocket).
  1373 // Theme server on desktop was found very slow (probably due to IPC with QLocalServer/QLocalSocket).
  1359 // disabling icon sharing via theme server until theme server performance on desktop is improved
  1374 // disabling icon sharing via theme server until theme server performance on desktop is improved
  1360 #ifdef Q_OS_SYMBIAN
  1375 #ifdef Q_OS_SYMBIAN
  1361         GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
  1376         GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
  1362         // Try to take data from server if parameters don't prevent it
  1377         // Try to take data from server if parameters don't prevent it
  1363         if (!options.testFlag(DoNotCache) 
  1378         if (!options.testFlag(DoNotCache)
  1364             && format != "MNG" 
  1379                 && format != "MNG"
  1365             && format != "GIF" 
  1380                 && format != "GIF"
  1366             && !iconName.startsWith(':') // not using server for app's own resources (iconName is a logical name for theme elements)
  1381                 && !iconName.startsWith(':') // not using server for app's own resources (iconName is a logical name for theme elements)
  1367             && manager ) {
  1382                 && manager) {
  1368 
  1383 
  1369             //Initiate an IPC to themeserver to get the icon-data from the server.
  1384             //Initiate an IPC to themeserver to get the icon-data from the server.
  1370             icon = getIconFromServer(params);
  1385             icon = getIconFromServer(params);
  1371 
  1386 
  1372             if (icon) {
  1387             if (icon) {
  1373 #ifdef HB_ICONIMPL_CACHE
  1388 #ifdef HB_ICONIMPL_CACHE
  1374                 iconImplCache.insert(cacheKey, icon);
  1389                 iconImplCache.insert(cacheKey, icon);
  1375 #ifdef HB_ICON_CACHE_DEBUG
  1390 #ifdef HB_ICON_CACHE_DEBUG
  1376                 qDebug() <<"HbIconLoader::loadIcon(): " << params.iconName << " inserted into impl-cache, ref-count now = " << icon->refCount();
  1391                 qDebug() << "HbIconLoader::loadIcon(): " << params.iconName << " inserted into impl-cache, ref-count now = " << icon->refCount();
  1377 #endif
  1392 #endif
  1378 
  1393 
  1379 #endif
  1394 #endif
  1380                 return icon;
  1395                 return icon;
  1381             }
  1396             }
  1399 
  1414 
  1400     if (!params.mirroringHandled) {
  1415     if (!params.mirroringHandled) {
  1401         // Apply mirroring if required
  1416         // Apply mirroring if required
  1402         if (params.mirrored && !params.mirroredIconFound) {
  1417         if (params.mirrored && !params.mirroredIconFound) {
  1403             QTransform t;
  1418             QTransform t;
  1404             t.scale(-1,1);
  1419             t.scale(-1, 1);
  1405             params.canvasPixmap = params.canvasPixmap.transformed(t);
  1420             params.canvasPixmap = params.canvasPixmap.transformed(t);
  1406         }
  1421         }
  1407     }
  1422     }
  1408 
  1423 
  1409     if (!params.modeHandled) {
  1424     if (!params.modeHandled) {
  1412             QStyleOption opt(0);
  1427             QStyleOption opt(0);
  1413             opt.palette = QApplication::palette();
  1428             opt.palette = QApplication::palette();
  1414             params.canvasPixmap = QApplication::style()->generatedIconPixmap(mode, params.canvasPixmap, &opt);
  1429             params.canvasPixmap = QApplication::style()->generatedIconPixmap(mode, params.canvasPixmap, &opt);
  1415         }
  1430         }
  1416     }
  1431     }
  1417     
  1432 
  1418     if ((params.color.isValid()) && (params.mode != QIcon::Disabled)) {
  1433     if ((params.color.isValid()) && (params.mode != QIcon::Disabled)) {
  1419         QPixmap &pm = params.canvasPixmap;
  1434         QPixmap &pm = params.canvasPixmap;
  1420         if(!pm.isNull()) {
  1435         if (!pm.isNull()) {
  1421             QPixmap mask = pm.alphaChannel(); 
  1436             QPixmap mask = pm.alphaChannel();
  1422             pm.fill(color);
  1437             pm.fill(color);
  1423             pm.setAlphaChannel(mask);
  1438             pm.setAlphaChannel(mask);
  1424         }
  1439         }
  1425     }
  1440     }
  1426 
  1441 
  1432     return icon;
  1447     return icon;
  1433 }
  1448 }
  1434 
  1449 
  1435 /*!
  1450 /*!
  1436  * \fn HbIconImpl* HbIconLoader::loadMultiPieceIcon()
  1451  * \fn HbIconImpl* HbIconLoader::loadMultiPieceIcon()
  1437  * 
  1452  *
  1438  * This function is responsible for loading a multi-piece icon (e.g. 3-piece or 9-piece).
  1453  * This function is responsible for loading a multi-piece icon (e.g. 3-piece or 9-piece).
  1439  * First it checks whether the consolidated (stitched) icon is present in the application (client)
  1454  * First it checks whether the consolidated (stitched) icon is present in the application (client)
  1440  * cache, if found it increments the ref-count of the HbIconImpl and returns. If the icon
  1455  * cache, if found it increments the ref-count of the HbIconImpl and returns. If the icon
  1441  * is not found in the client's impl-cache, it initiates an IPC to themeserver
  1456  * is not found in the client's impl-cache, it initiates an IPC to themeserver
  1442  * to try to load the consolidated icon. If the consolidated (stitched) icon fails in themeserver, the server
  1457  * to try to load the consolidated icon. If the consolidated (stitched) icon fails in themeserver, the server
  1443  * returns a list of icon-data for individual pieces. Each of these pieces will be painted separately
  1458  * returns a list of icon-data for individual pieces. Each of these pieces will be painted separately
  1444  * 
  1459  *
  1445  */
  1460  */
  1446 HbIconImpl* HbIconLoader::loadMultiPieceIcon(const QStringList &listOfIcons,
  1461 HbIconImpl *HbIconLoader::loadMultiPieceIcon(const QStringList &listOfIcons,
  1447                                     HbMultiPartSizeData &multiPartIconData,
  1462         HbMultiPartSizeData &multiPartIconData,
  1448                                     const QSizeF &size,
  1463         const QSizeF &size,
  1449                                     Qt::AspectRatioMode aspectRatioMode,
  1464         Qt::AspectRatioMode aspectRatioMode,
  1450                                     QIcon::Mode mode,
  1465         QIcon::Mode mode,
  1451                                     IconLoaderOptions options,
  1466         IconLoaderOptions options,
  1452                                     QVector<HbIconImpl *> &multiPieceImpls,
  1467         QVector<HbIconImpl *> &multiPieceImpls,
  1453                                     const QColor &color)
  1468         const QColor &color)
  1454 {   
  1469 {
  1455     Q_UNUSED(color);
  1470     Q_UNUSED(color);
  1456     HbIconImpl* icon = 0;
  1471     HbIconImpl *icon = 0;
  1457     if (listOfIcons.count() == 0) {
  1472     if (listOfIcons.count() == 0) {
  1458         return icon;
  1473         return icon;
  1459     }
  1474     }
  1460     
  1475 
  1461     // Whether the icon should be horizontally mirrored
  1476     // Whether the icon should be horizontally mirrored
  1462     bool mirrored = options.testFlag(HorizontallyMirrored);
  1477     bool mirrored = options.testFlag(HorizontallyMirrored);
  1463 
  1478 
  1464     // Whether mirrored version of the icon was found in the file system (otherwise it's mirrored by code).
  1479     // Whether mirrored version of the icon was found in the file system (otherwise it's mirrored by code).
  1465     bool mirroredIconFound = false;
  1480     bool mirroredIconFound = false;
  1468     // Consolidated icon will be created for NVG with SGImage lite support.
  1483     // Consolidated icon will be created for NVG with SGImage lite support.
  1469     // and when NVG is not available.
  1484     // and when NVG is not available.
  1470 #if defined(HB_ICONIMPL_CACHE)
  1485 #if defined(HB_ICONIMPL_CACHE)
  1471 
  1486 
  1472     QByteArray cacheKey = d->createCacheKeyFrom(multiPartIconData.multiPartIconId,
  1487     QByteArray cacheKey = d->createCacheKeyFrom(multiPartIconData.multiPartIconId,
  1473                                                 size,
  1488                           size,
  1474                                                 aspectRatioMode,
  1489                           aspectRatioMode,
  1475                                                 mode,
  1490                           mode,
  1476                                                 mirrored, 
  1491                           mirrored,
  1477                                                 color, 
  1492                           color,
  1478                                                 renderMode);
  1493                           renderMode);
  1479     //If consolidated icon found in the client's cache, increment ref-count and return
  1494     //If consolidated icon found in the client's cache, increment ref-count and return
  1480     if (iconImplCache.contains(cacheKey)) {
  1495     if (iconImplCache.contains(cacheKey)) {
  1481         HbIconImpl * ptr = iconImplCache.value(cacheKey);
  1496         HbIconImpl *ptr = iconImplCache.value(cacheKey);
  1482         ptr->incrementRefCount();
  1497         ptr->incrementRefCount();
  1483 #ifdef HB_ICON_CACHE_DEBUG
  1498 #ifdef HB_ICON_CACHE_DEBUG
  1484         qDebug() << "HbIconLoader::loadMultiPieceIcon()" << "Cache hit in iconImplCache " << multiPartIconData.multiPartIconId << size.height() << "X" << size.width() ;
  1499         qDebug() << "HbIconLoader::loadMultiPieceIcon()" << "Cache hit in iconImplCache " << multiPartIconData.multiPartIconId << size.height() << "X" << size.width() ;
  1485         qDebug() << "HbIconLoader::loadMultiPieceIcon : Client RefCount now = " << ptr->refCount();
  1500         qDebug() << "HbIconLoader::loadMultiPieceIcon : Client RefCount now = " << ptr->refCount();
  1486 #endif
  1501 #endif
  1504 #ifdef  Q_OS_SYMBIAN
  1519 #ifdef  Q_OS_SYMBIAN
  1505 
  1520 
  1506     //If consolidated icon was not found in the client's cache, initiate an IPC to load
  1521     //If consolidated icon was not found in the client's cache, initiate an IPC to load
  1507     //the consolidated icon on themeserver
  1522     //the consolidated icon on themeserver
  1508     iconInfo = HbThemeClient::global()->getMultiPartIconInfo(iconPathList,
  1523     iconInfo = HbThemeClient::global()->getMultiPartIconInfo(iconPathList,
  1509                                                              multiPartIconData, size, aspectRatioMode, mode,
  1524                multiPartIconData, size, aspectRatioMode, mode,
  1510                                                              (mirrored && !mirroredIconFound), options, color, renderMode);
  1525                (mirrored && !mirroredIconFound), options, color, renderMode);
  1511 
  1526 
  1512 #ifdef HB_ICON_TRACES
  1527 #ifdef HB_ICON_TRACES
  1513     qDebug() << "HbIconLoader::getMultiPartIconInfo, offset from server: " << iconInfo.pixmapData.offset << iconPathList;
  1528     qDebug() << "HbIconLoader::getMultiPartIconInfo, offset from server: " << iconInfo.pixmapData.offset << iconPathList;
  1514 #endif
  1529 #endif
  1515 
  1530 
  1555         //Since the consolidated icon-creation failed on themeserver, request loading of individual
  1570         //Since the consolidated icon-creation failed on themeserver, request loading of individual
  1556         //frame-items in a single IPC request to themeserver
  1571         //frame-items in a single IPC request to themeserver
  1557         getMultiIconImplFromServer(iconPathList, sizeList,
  1572         getMultiIconImplFromServer(iconPathList, sizeList,
  1558                                    aspectRatioMode,
  1573                                    aspectRatioMode,
  1559                                    mode,
  1574                                    mode,
  1560                                    mirrored, 
  1575                                    mirrored,
  1561                                    mirroredIconFound,
  1576                                    mirroredIconFound,
  1562                                    options,
  1577                                    options,
  1563                                    color,
  1578                                    color,
  1564                                    HbIconLoader::AnyType,
  1579                                    HbIconLoader::AnyType,
  1565                                    HbIconLoader::AnyPurpose,
  1580                                    HbIconLoader::AnyPurpose,
  1566                                    multiPieceImpls,
  1581                                    multiPieceImpls,
  1567                                    renderMode);  
  1582                                    renderMode);
  1568 #else
  1583 #else
  1569         //For OS other than Symbian, call HbIconLoader::loadIcon to individually load icons
  1584         //For OS other than Symbian, call HbIconLoader::loadIcon to individually load icons
  1570         for (int i = 0; i < count; i++) {
  1585         for (int i = 0; i < count; i++) {
  1571             HbIconImpl *impl = loadIcon(iconPathList[i], HbIconLoader::AnyType,
  1586             HbIconImpl *impl = loadIcon(iconPathList[i], HbIconLoader::AnyType,
  1572                                         HbIconLoader::AnyPurpose,
  1587                                         HbIconLoader::AnyPurpose,
  1585         return icon;
  1600         return icon;
  1586     }
  1601     }
  1587 }
  1602 }
  1588 
  1603 
  1589 // Initiates an IPC call to the ThemeServer to unload ( decrement ref count ) the icon
  1604 // Initiates an IPC call to the ThemeServer to unload ( decrement ref count ) the icon
  1590 void HbIconLoader::unLoadIcon(HbIconImpl * icon, bool unloadedByServer)
  1605 void HbIconLoader::unLoadIcon(HbIconImpl *icon, bool unloadedByServer)
  1591 {
  1606 {
  1592     if (!icon) {
  1607     if (!icon) {
  1593         return;
  1608         return;
  1594     }
  1609     }
  1595 
  1610 
  1596     icon->decrementRefCount();
  1611     icon->decrementRefCount();
  1597 
  1612 
  1598     if (icon->refCount() == 0 && icon->isCreatedOnServer()) {
  1613     if (icon->refCount() == 0 && icon->isCreatedOnServer()) {
  1599         if (!unloadedByServer) {
  1614         if (!unloadedByServer) {
  1600            HbThemeClient::global()->unloadIcon(icon->iconFileName(),
  1615             HbThemeClient::global()->unloadIcon(icon->iconFileName(),
  1601                                                icon->keySize(),
  1616                                                 icon->keySize(),
  1602                                                icon->iconAspectRatioMode(),
  1617                                                 icon->iconAspectRatioMode(),
  1603                                                icon->iconMode(),
  1618                                                 icon->iconMode(),
  1604                                                icon->isMirrored(),
  1619                                                 icon->isMirrored(),
  1605                                                icon->color(),
  1620                                                 icon->color(),
  1606                                                icon->iconRenderingMode()
  1621                                                 icon->iconRenderingMode()
  1607                                                );
  1622                                                );
  1608         }
  1623         }
  1609 #ifdef HB_ICONIMPL_CACHE
  1624 #ifdef HB_ICONIMPL_CACHE
  1610         int rem = iconImplCache.remove(iconImplCache.key(icon));
  1625         int rem = iconImplCache.remove(iconImplCache.key(icon));
  1611         if (rem > 0) {
  1626         if (rem > 0) {
  1636     return pixmap;
  1651     return pixmap;
  1637 }
  1652 }
  1638 
  1653 
  1639 /*!
  1654 /*!
  1640  * \fn void HbIconLoader::getMultiIconImplFromServer()
  1655  * \fn void HbIconLoader::getMultiIconImplFromServer()
  1641  * 
  1656  *
  1642  * This function is responsible for loading individual pieces of a multi-piece icon.
  1657  * This function is responsible for loading individual pieces of a multi-piece icon.
  1643  * This gets called if the consolidated icon-creation process on themeserver has failed.
  1658  * This gets called if the consolidated icon-creation process on themeserver has failed.
  1644  * This function initiates a single IPC to themeserver in which it sends out icon-parameters
  1659  * This function initiates a single IPC to themeserver in which it sends out icon-parameters
  1645  * for each of the frame-items and gets back a list of HbSharedIconInfo corresponding to 
  1660  * for each of the frame-items and gets back a list of HbSharedIconInfo corresponding to
  1646  * individual pieces.
  1661  * individual pieces.
  1647  * 
  1662  *
  1648  */
  1663  */
  1649 void HbIconLoader::getMultiIconImplFromServer(QStringList &multiPartIconList,
  1664 void HbIconLoader::getMultiIconImplFromServer(QStringList &multiPartIconList,
  1650                                 QVector<QSizeF> &sizeList,
  1665         QVector<QSizeF> &sizeList,
  1651                                 Qt::AspectRatioMode aspectRatioMode,
  1666         Qt::AspectRatioMode aspectRatioMode,
  1652                                 QIcon::Mode mode,
  1667         QIcon::Mode mode,
  1653                                 bool mirrored,
  1668         bool mirrored,
  1654                                 bool mirroredIconFound,
  1669         bool mirroredIconFound,
  1655                                 HbIconLoader::IconLoaderOptions options,
  1670         HbIconLoader::IconLoaderOptions options,
  1656                                 const QColor &color,
  1671         const QColor &color,
  1657                                 HbIconLoader::IconDataType type,
  1672         HbIconLoader::IconDataType type,
  1658                                 HbIconLoader::Purpose,
  1673         HbIconLoader::Purpose,
  1659                                 QVector<HbIconImpl *> & iconImplList,
  1674         QVector<HbIconImpl *> & iconImplList,
  1660                                 HbRenderingMode currRenderMode)
  1675         HbRenderingMode currRenderMode)
  1661 {
  1676 {
  1662     Q_UNUSED(type);
  1677     Q_UNUSED(type);
  1663     QVector<int> posList;
  1678     QVector<int> posList;
  1664 #ifdef HB_ICONIMPL_CACHE
  1679 #ifdef HB_ICONIMPL_CACHE
  1665     // search the client cache first before asking the server
  1680     // search the client cache first before asking the server
  1666     for(int i = 0; i < multiPartIconList.count(); i++) {
  1681     for (int i = 0; i < multiPartIconList.count(); i++) {
  1667         QByteArray cacheKey = d->createCacheKeyFrom( multiPartIconList[i], 
  1682         QByteArray cacheKey = d->createCacheKeyFrom(multiPartIconList[i],
  1668                                                      sizeList[i], 
  1683                               sizeList[i],
  1669                                                      aspectRatioMode,
  1684                               aspectRatioMode,
  1670                                                      mode, 
  1685                               mode,
  1671                                                      mirrored, 
  1686                               mirrored,
  1672                                                      color, 
  1687                               color,
  1673                                                      currRenderMode );
  1688                               currRenderMode);
  1674         //look up in the local iconImplCache. 
  1689         //look up in the local iconImplCache.
  1675         //If found return the ptr directly
  1690         //If found return the ptr directly
  1676         HbIconImpl * ptr = 0;
  1691         HbIconImpl *ptr = 0;
  1677         if (iconImplCache.contains(cacheKey)) {
  1692         if (iconImplCache.contains(cacheKey)) {
  1678             ptr = iconImplCache.value(cacheKey);
  1693             ptr = iconImplCache.value(cacheKey);
  1679             // if a specific frame-item is found in local impl-cache, 
  1694             // if a specific frame-item is found in local impl-cache,
  1680             // increment the ref count and remove the entry from the list that needs to be sent to server.
  1695             // increment the ref count and remove the entry from the list that needs to be sent to server.
  1681             ptr->incrementRefCount();
  1696             ptr->incrementRefCount();
  1682 #ifdef HB_ICON_CACHE_DEBUG
  1697 #ifdef HB_ICON_CACHE_DEBUG
  1683             qDebug() << "HbIconLoader::getMultiIconImplFromServer()" << "Cache hit in iconImplCache ";
  1698             qDebug() << "HbIconLoader::getMultiIconImplFromServer()" << "Cache hit in iconImplCache ";
  1684             qDebug() << "HbIconLoader::getMultiIconImplFromServer : Client RefCount now = " << ptr->refCount();
  1699             qDebug() << "HbIconLoader::getMultiIconImplFromServer : Client RefCount now = " << ptr->refCount();
  1702     int count = multiPartIconList.count();
  1717     int count = multiPartIconList.count();
  1703     if (count > 0) {
  1718     if (count > 0) {
  1704         HbSharedIconInfoList iconInfoList = HbThemeClient::global()->getMultiIconInfo(multiPartIconList, sizeList,
  1719         HbSharedIconInfoList iconInfoList = HbThemeClient::global()->getMultiIconInfo(multiPartIconList, sizeList,
  1705                                             aspectRatioMode, mode, mirrored, options, color, currRenderMode);
  1720                                             aspectRatioMode, mode, mirrored, options, color, currRenderMode);
  1706 
  1721 
  1707         HbIconImpl* impl = 0;
  1722         HbIconImpl *impl = 0;
  1708 
  1723 
  1709         HbIconLoadingParams params;
  1724         HbIconLoadingParams params;
  1710 
  1725 
  1711         params.aspectRatioMode = aspectRatioMode;
  1726         params.aspectRatioMode = aspectRatioMode;
  1712         params.mode = mode;
  1727         params.mode = mode;
  1720                 params.size = sizeList.at(i);
  1735                 params.size = sizeList.at(i);
  1721 
  1736 
  1722                 impl = HbIconImplCreator::createIconImpl(iconInfoList.icon[i], params);
  1737                 impl = HbIconImplCreator::createIconImpl(iconInfoList.icon[i], params);
  1723 
  1738 
  1724 #ifdef HB_ICONIMPL_CACHE
  1739 #ifdef HB_ICONIMPL_CACHE
  1725                 QByteArray cacheKey = d->createCacheKeyFrom( multiPartIconList[i], 
  1740                 QByteArray cacheKey = d->createCacheKeyFrom(multiPartIconList[i],
  1726                                                              sizeList.at(i) , 
  1741                                       sizeList.at(i) ,
  1727                                                              aspectRatioMode,
  1742                                       aspectRatioMode,
  1728                                                              mode, 
  1743                                       mode,
  1729                                                              mirrored, 
  1744                                       mirrored,
  1730                                                              color, 
  1745                                       color,
  1731                                                              currRenderMode );
  1746                                       currRenderMode);
  1732                 iconImplCache.insert(cacheKey, impl);
  1747                 iconImplCache.insert(cacheKey, impl);
  1733 #ifdef HB_ICON_CACHE_DEBUG
  1748 #ifdef HB_ICON_CACHE_DEBUG
  1734                 qDebug() << "HbIconLoader::getMultiIconImplFromServer(): " << params.iconName << " inserted into impl-cache, ref-count now = " << impl->refCount();
  1749                 qDebug() << "HbIconLoader::getMultiIconImplFromServer(): " << params.iconName << " inserted into impl-cache, ref-count now = " << impl->refCount();
  1735 #endif
  1750 #endif
  1736 
  1751 
  1768  */
  1783  */
  1769 void HbIconLoader::unLoadMultiIcon(QVector<HbIconImpl *> &multiPieceImpls)
  1784 void HbIconLoader::unLoadMultiIcon(QVector<HbIconImpl *> &multiPieceImpls)
  1770 {
  1785 {
  1771     QStringList iconNameList;
  1786     QStringList iconNameList;
  1772     QVector<QSizeF> sizeList;
  1787     QVector<QSizeF> sizeList;
  1773      
  1788 
  1774     // Decrement the ref count. If its zero, remove it from the client cache (if defined) and 
  1789     // Decrement the ref count. If its zero, remove it from the client cache (if defined) and
  1775     // then send to server for unload.
  1790     // then send to server for unload.
  1776     foreach(HbIconImpl* impl, multiPieceImpls) {
  1791     foreach(HbIconImpl * impl, multiPieceImpls) {
  1777         impl->decrementRefCount();
  1792         impl->decrementRefCount();
  1778         if (impl->refCount() == 0 && impl->isCreatedOnServer()) {        
  1793         if (impl->refCount() == 0 && impl->isCreatedOnServer()) {
  1779 #ifdef HB_ICONIMPL_CACHE        
  1794 #ifdef HB_ICONIMPL_CACHE
  1780             int rem = iconImplCache.remove(iconImplCache.key(impl));
  1795             int rem = iconImplCache.remove(iconImplCache.key(impl));
  1781             if (rem > 0) {
  1796             if (rem > 0) {
  1782 #ifdef HB_ICON_TRACES
  1797 #ifdef HB_ICON_TRACES
  1783             qDebug()<<"HbIconLoader::unLoadMultiIcon :Removed from HbIconImpl Cache "<<rem<< impl->iconFileName()<< impl->keySize().height()<<"X"<<impl->keySize().width() ;
  1798                 qDebug() << "HbIconLoader::unLoadMultiIcon :Removed from HbIconImpl Cache " << rem << impl->iconFileName() << impl->keySize().height() << "X" << impl->keySize().width() ;
  1784 #endif 
  1799 #endif
  1785             }
  1800             }
  1786 #endif      
  1801 #endif
  1787             // List of icons to be unloaded.
  1802             // List of icons to be unloaded.
  1788             iconNameList<<impl->iconFileName();
  1803             iconNameList << impl->iconFileName();
  1789             sizeList<<impl->keySize();
  1804             sizeList << impl->keySize();
  1790         }
  1805         }
  1791     }
  1806     }
  1792     
  1807 
  1793     if(iconNameList.count() > 0) {
  1808     if (iconNameList.count() > 0) {
  1794         HbThemeClient::global()->unLoadMultiIcon(iconNameList, 
  1809         HbThemeClient::global()->unLoadMultiIcon(iconNameList,
  1795                                             sizeList,
  1810                 sizeList,
  1796                                             multiPieceImpls[0]->iconAspectRatioMode(),
  1811                 multiPieceImpls[0]->iconAspectRatioMode(),
  1797                                             multiPieceImpls[0]->iconMode(),
  1812                 multiPieceImpls[0]->iconMode(),
  1798                                             multiPieceImpls[0]->isMirrored(),
  1813                 multiPieceImpls[0]->isMirrored(),
  1799                                             multiPieceImpls[0]->color(),
  1814                 multiPieceImpls[0]->color(),
  1800                                             multiPieceImpls[0]->iconRenderingMode()
  1815                 multiPieceImpls[0]->iconRenderingMode()
  1801                                             );
  1816                                                 );
  1802     }
  1817     }
  1803 }
  1818 }
  1804 
  1819 
  1805 // End of File
  1820 // End of File