src/hbcore/theme/hbthemeclient_p.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    27 #include "hbthemeclient_p_p.h"
    27 #include "hbthemeclient_p_p.h"
    28 #include "hbsharedmemorymanager_p.h"
    28 #include "hbsharedmemorymanager_p.h"
    29 #include "hbmemoryutils_p.h"
    29 #include "hbmemoryutils_p.h"
    30 
    30 
    31 static HbThemeClient *clientInst=0;
    31 static HbThemeClient *clientInst=0;
    32 static int sharedCacheOffset = -1;
       
    33 
    32 
    34 /**
    33 /**
    35  * Constructor
    34  * Constructor
    36  */
    35  */
    37 HbThemeClient::HbThemeClient():d_ptr(new HbThemeClientPrivate)
    36 HbThemeClient::HbThemeClient():d_ptr(new HbThemeClientPrivate)
    38 {
    37 {
    39     
    38 
    40 }
    39 }
    41 
    40 
    42 /**
    41 /**
    43  * HbThemeClient::connectToServer()
    42  * HbThemeClient::connectToServer()
    44  */
    43  */
    66  * \a mode
    65  * \a mode
    67  * \a mirrored
    66  * \a mirrored
    68  * \a options
    67  * \a options
    69  * \a color
    68  * \a color
    70  *
    69  *
    71  
    70 
    72  */
    71  */
    73 HbSharedIconInfo HbThemeClient::getSharedIconInfo(const QString& iconPath , 
    72 HbSharedIconInfo HbThemeClient::getSharedIconInfo(const QString& iconPath ,
    74                                                   const QSizeF &size,
    73                                                   const QSizeF &size,
    75                                                   Qt::AspectRatioMode aspectRatioMode,
    74                                                   Qt::AspectRatioMode aspectRatioMode,
    76                                                   QIcon::Mode mode,
    75                                                   QIcon::Mode mode,
    77                                                   bool mirrored,
    76                                                   bool mirrored,
    78                                                   HbIconLoader::IconLoaderOptions options,
    77                                                   HbIconLoader::IconLoaderOptions options,
    79                                                   const QColor &color)
    78                                                   const QColor &color,
       
    79                                                   HbRenderingMode renderMode)
    80 {
    80 {
    81     Q_D(HbThemeClient);
    81     Q_D(HbThemeClient);
    82     return d->getSharedIconInfo(iconPath,
    82     return d->getSharedIconInfo(iconPath,
    83                                 size,
    83                                 size,
    84                                 aspectRatioMode, 
    84                                 aspectRatioMode,
    85                                 mode, 
    85                                 mode,
    86                                 mirrored, 
    86                                 mirrored,
    87                                 options,
    87                                 options,
    88                                 color);
    88                                 color,
       
    89                                 renderMode);
    89 }
    90 }
    90 
    91 
    91 /**
    92 /**
    92  * HbThemeClient::getSharedBlob()
    93  * HbThemeClient::getSharedBlob()
    93  * 
    94  *
    94  * \a name 
    95  * \a name
    95  */
    96  */
    96 QByteArray HbThemeClient::getSharedBlob(const QString &name)
    97 QByteArray HbThemeClient::getSharedBlob(const QString &name)
    97 {
    98 {
    98     HbSharedIconInfo info = getSharedIconInfo(
    99     HbSharedIconInfo info = getSharedIconInfo(
    99         name,
   100         name,
   100         QSizeF(),
   101         QSizeF(),
   101         Qt::KeepAspectRatio,
   102         Qt::KeepAspectRatio,
   102         QIcon::Normal,
   103         QIcon::Normal,
   103         false,
   104         false,
   104         HbIconLoader::NoOptions,
   105         HbIconLoader::NoOptions,
   105         QColor());
   106         QColor(),
       
   107         ESWRendering);
   106     return info.type == BLOB
   108     return info.type == BLOB
   107         ? QByteArray::fromRawData(HbMemoryUtils::getAddress<char>(
   109         ? QByteArray::fromRawData(HbMemoryUtils::getAddress<char>(
   108                                       HbMemoryManager::SharedMemory,
   110                                       HbMemoryManager::SharedMemory,
   109                                       info.blobData.offset),
   111                                       info.blobData.offset),
   110                                   info.blobData.dataSize)
   112                                   info.blobData.dataSize)
   111         : QByteArray();
   113         : QByteArray();
   112 }
   114 }
   113   
   115 
   114     
   116 
   115     HbSharedIconInfo HbThemeClient::getMultiPartIconInfo(const QStringList &multiPartIconList, 
   117     HbSharedIconInfo HbThemeClient::getMultiPartIconInfo(const QStringList &multiPartIconList,
   116                         const HbMultiPartSizeData  &multiPartIconData ,
   118                         const HbMultiPartSizeData  &multiPartIconData ,
   117                         const QSizeF &size,
   119                         const QSizeF &size,
   118                         Qt::AspectRatioMode aspectRatioMode,
   120                         Qt::AspectRatioMode aspectRatioMode,
   119                         QIcon::Mode mode,
   121                         QIcon::Mode mode,
   120                         bool mirrored,
   122                         bool mirrored,
   121                         HbIconLoader::IconLoaderOptions options,
   123                         HbIconLoader::IconLoaderOptions options,
   122                         const QColor &color)
   124                         const QColor &color,
   123 {
   125                         HbRenderingMode renderMode)
   124     Q_D(HbThemeClient);
   126 {
   125     return d->getMultiPartIconInfo(multiPartIconList, multiPartIconData, size, aspectRatioMode, mode, mirrored, options, color);
   127     Q_D(HbThemeClient);
   126 }
   128     return d->getMultiPartIconInfo(multiPartIconList, multiPartIconData, size, aspectRatioMode, mode, mirrored, options, color, renderMode);
   127 
       
   128 void HbThemeClient::getThemeIndexTables(ThemeIndexTables &tables)
       
   129 {
       
   130     Q_D(HbThemeClient);
       
   131     d->getThemeIndexTables(tables);
       
   132 }
   129 }
   133 
   130 
   134 /**
   131 /**
   135  * HbThemeClient::getSharedStyleSheet()
   132  * HbThemeClient::getSharedStyleSheet()
   136  *
   133  *
   137  * \a fielName  css filename
   134  * \a fielName  css filename
   138  * \a priority  layer priority
   135  * \a priority  layer priority
   139  */  
   136  */
   140 HbCss::StyleSheet *HbThemeClient::getSharedStyleSheet(const QString &fileName, HbLayeredStyleLoader::LayerPriority priority)
   137 HbCss::StyleSheet *HbThemeClient::getSharedStyleSheet(const QString &fileName, HbLayeredStyleLoader::LayerPriority priority)
   141 {
   138 {
   142     int offset = -1;
   139     int offset = -1;
   143     if( HbLayeredStyleLoader::Priority_Core == priority ) {
   140     if( HbLayeredStyleLoader::Priority_Core == priority ) {
   144         offset = sharedCacheItemOffset(fileName);
   141         offset = sharedCacheItemOffset(HbSharedCache::Stylesheet, fileName);
   145     }
   142     }
   146     if ( -1 != offset ) {
   143     if ( -1 != offset ) {
   147         HbCss::StyleSheet *styleSheet = HbMemoryUtils::getAddress<HbCss::StyleSheet>(HbMemoryManager::SharedMemory,offset);
   144         HbCss::StyleSheet *styleSheet = HbMemoryUtils::getAddress<HbCss::StyleSheet>(HbMemoryManager::SharedMemory,offset);
   148         return styleSheet;
   145         return styleSheet;
   149     }
   146     }
   155  * HbThemeClient::getSharedLayoutDefs()
   152  * HbThemeClient::getSharedLayoutDefs()
   156  *
   153  *
   157  * \a fileName
   154  * \a fileName
   158  * \a layout
   155  * \a layout
   159  * \a section
   156  * \a section
   160  */  
   157  */
   161 HbWidgetLoader::LayoutDefinition *HbThemeClient::getSharedLayoutDefs(const QString &fileName,const QString &layout,const QString &section)
   158 HbWidgetLoader::LayoutDefinition *HbThemeClient::getSharedLayoutDefs(const QString &fileName,const QString &layout,const QString &section)
   162 {
   159 {
   163     int offset = sharedCacheItemOffset(fileName + layout + section);
   160     int offset = sharedCacheItemOffset(HbSharedCache::LayoutDefinition, fileName + layout + section);
   164     if ( -1 != offset ) {
   161     if ( -1 != offset ) {
   165        HbWidgetLoader::LayoutDefinition *layoutDefs =
   162        HbWidgetLoader::LayoutDefinition *layoutDefs =
   166            HbMemoryUtils::getAddress<HbWidgetLoader::LayoutDefinition>(HbMemoryManager::SharedMemory,offset);
   163            HbMemoryUtils::getAddress<HbWidgetLoader::LayoutDefinition>(HbMemoryManager::SharedMemory,offset);
   167        return layoutDefs;
   164        return layoutDefs;
   168     }
   165     }
   169     Q_D(HbThemeClient);
   166     Q_D(HbThemeClient);
   170     return d->getSharedLayoutDefs(fileName,layout,section);
   167     return d->getSharedLayoutDefs(fileName,layout,section);
   171 }
   168 }
   172 /**
   169 /**
   173  * HbThemeClient::deviceProfiles()
   170  * HbThemeClient::deviceProfiles()
   174  */ 
   171  */
   175 HbDeviceProfileList *HbThemeClient::deviceProfiles()
   172 HbDeviceProfileList *HbThemeClient::deviceProfiles()
   176 {
   173 {
   177     Q_D(HbThemeClient);
   174     Q_D(HbThemeClient);
   178     return d->deviceProfiles();
   175     return d->deviceProfiles();
   179 }
   176 }
   180 
   177 
   181 /**
   178 /**
   182  * HbThemeClient::globalCacheOffset()
   179  * HbThemeClient::typefaceInfo()
   183  *
   180  */
   184  */
   181 HbTypefaceInfoVector *HbThemeClient::typefaceInfo()
   185 int HbThemeClient::globalCacheOffset()
   182 {
   186 {
   183     Q_D(HbThemeClient);
   187     if ( -1 == sharedCacheOffset ) {
   184     return d->typefaceInfo();
   188         Q_D(HbThemeClient);
   185 }
   189         sharedCacheOffset = d->globalCacheOffset();
   186 
   190     }
       
   191     return sharedCacheOffset;
       
   192 }
       
   193 
   187 
   194 /**
   188 /**
   195  * HbThemeClient::notifyForegroundLostToServer()
   189  * HbThemeClient::notifyForegroundLostToServer()
   196  *
   190  *
   197  */
   191  */
   203 
   197 
   204 /**
   198 /**
   205  * HbThemeClient::getSharedEffect()
   199  * HbThemeClient::getSharedEffect()
   206  *
   200  *
   207  * \a filePath
   201  * \a filePath
   208  */ 
   202  */
   209 HbEffectFxmlData *HbThemeClient::getSharedEffect(const QString &filePath)
   203 HbEffectFxmlData *HbThemeClient::getSharedEffect(const QString &filePath)
   210 {
   204 {
   211     int offset = sharedCacheItemOffset(filePath);
   205     int offset = sharedCacheItemOffset(HbSharedCache::Effect, filePath);
   212     if ( -1 != offset ) {
   206     if ( -1 != offset ) {
   213        HbEffectFxmlData  *effectFxmlData = HbMemoryUtils::getAddress<HbEffectFxmlData>(HbMemoryManager::SharedMemory,offset);
   207        HbEffectFxmlData  *effectFxmlData = HbMemoryUtils::getAddress<HbEffectFxmlData>(HbMemoryManager::SharedMemory,offset);
   214        return effectFxmlData;
   208        return effectFxmlData;
   215     }
   209     }
   216     Q_D(HbThemeClient);
   210     Q_D(HbThemeClient);
   219 
   213 
   220 /**
   214 /**
   221  * HbThemeClient::addSharedEffect()
   215  * HbThemeClient::addSharedEffect()
   222  *
   216  *
   223  * \a filePath
   217  * \a filePath
   224  */ 
   218  */
   225 bool HbThemeClient::addSharedEffect(const QString& filePath)
   219 bool HbThemeClient::addSharedEffect(const QString& filePath)
   226 {
   220 {
   227     int offset = sharedCacheItemOffset(filePath);
   221     int offset = sharedCacheItemOffset(HbSharedCache::Effect, filePath);
   228     if ( -1 != offset ) {
   222     if ( -1 != offset ) {
   229         // effect already added.
   223         // effect already added.
   230         return true;
   224         return true;
   231     }
   225     }
   232     Q_D(HbThemeClient);
   226     Q_D(HbThemeClient);
   241  * \a aspectRatioMode
   235  * \a aspectRatioMode
   242  * \a mode
   236  * \a mode
   243  * \a mirrored
   237  * \a mirrored
   244  * \a options
   238  * \a options
   245  * \a color
   239  * \a color
   246  
   240 
   247  */
   241  */
   248 void HbThemeClient::unloadIcon(const QString& iconPath , 
   242 void HbThemeClient::unloadIcon(const QString& iconPath ,
   249                                const QSizeF &size,
   243                                const QSizeF &size,
   250                                Qt::AspectRatioMode aspectRatioMode,
   244                                Qt::AspectRatioMode aspectRatioMode,
   251                                QIcon::Mode mode,
   245                                QIcon::Mode mode,
   252                                bool mirrored,
   246                                bool mirrored,
   253                                const QColor &color)
   247                                const QColor &color,
       
   248                                HbRenderingMode renderMode)
   254 {
   249 {
   255     Q_D(HbThemeClient);
   250     Q_D(HbThemeClient);
   256     return d->unloadIcon(iconPath,
   251     return d->unloadIcon(iconPath,
   257                          size,
   252                          size,
   258                          aspectRatioMode, 
   253                          aspectRatioMode,
   259                          mode, 
   254                          mode,
   260                          mirrored, 
   255                          mirrored,
   261                          color);
   256                          color,
       
   257                          renderMode);
   262 }
   258 }
   263 
   259 
   264 /**
   260 /**
   265  * HbThemeClient::unLoadMultiIcon()
   261  * HbThemeClient::unLoadMultiIcon()
   266  *
   262  *
   269  * \a aspectRatioMode
   265  * \a aspectRatioMode
   270  * \a mode
   266  * \a mode
   271  * \a mirrored
   267  * \a mirrored
   272  * \a color
   268  * \a color
   273  */
   269  */
   274 void HbThemeClient::unLoadMultiIcon(const QStringList& iconPathList, 
   270 void HbThemeClient::unLoadMultiIcon(const QStringList& iconPathList,
   275                     const QVector<QSizeF> &sizeList,
   271                     const QVector<QSizeF> &sizeList,
   276                     Qt::AspectRatioMode aspectRatioMode,
   272                     Qt::AspectRatioMode aspectRatioMode,
   277                     QIcon::Mode mode,
   273                     QIcon::Mode mode,
   278                     bool mirrored,
   274                     bool mirrored,
   279                     const QColor &color)
   275                     const QColor &color,
       
   276                     HbRenderingMode renderMode)
   280 {
   277 {
   281     Q_D(HbThemeClient);
   278     Q_D(HbThemeClient);
   282     return d->unLoadMultiIcon(iconPathList,
   279     return d->unLoadMultiIcon(iconPathList,
   283                          sizeList,
   280                          sizeList,
   284                          aspectRatioMode, 
   281                          aspectRatioMode,
   285                          mode, 
   282                          mode,
   286                          mirrored, 
   283                          mirrored,
   287                          color);
   284                          color,
       
   285                          renderMode);
   288 }
   286 }
   289 
   287 
   290 /**
   288 /**
   291  * HbThemeClient::~HbThemeClient()
   289  * HbThemeClient::~HbThemeClient()
   292  */
   290  */
   329  * sharedCacheItemOffset  function returns the offset of the cache item
   327  * sharedCacheItemOffset  function returns the offset of the cache item
   330  * for the given key
   328  * for the given key
   331  * \param key
   329  * \param key
   332  *
   330  *
   333  */
   331  */
   334 int HbThemeClient::sharedCacheItemOffset(const QString & key)
   332 int HbThemeClient::sharedCacheItemOffset(HbSharedCache::ItemType type, const QString & key)
   335 {
   333 {
   336     if ( -1 == sharedCacheOffset ) {
   334     HbSharedCache *cache = HbSharedCache::instance();
   337         // No IPC call happened so far for the globalCacheOffset
   335     return cache->offset(type, key);
   338         globalCacheOffset();
       
   339     }
       
   340     if ( -1 != sharedCacheOffset ) {
       
   341         HbSharedCache *sharedCache = HbMemoryUtils::getAddress<HbSharedCache>(HbMemoryManager::SharedMemory,sharedCacheOffset);
       
   342         int count = sharedCache->count();
       
   343         for(int i = 0; i < count ; i++ ) {
       
   344             if (sharedCache->at(i).key == key) {
       
   345                 return sharedCache->at(i).offset;
       
   346             }
       
   347         }
       
   348     }
       
   349     // item not found in the secondary cache.
       
   350     return -1;
       
   351 }
   336 }
   352 
   337 
   353 #ifdef HB_THEME_SERVER_MEMORY_REPORT
   338 #ifdef HB_THEME_SERVER_MEMORY_REPORT
   354 /**
   339 /**
   355  * createMemoryReport  creates memory report from current shared memory
   340  * createMemoryReport  creates memory report from current shared memory
   370                         const QVector<QSizeF>  &sizeList ,
   355                         const QVector<QSizeF>  &sizeList ,
   371                         Qt::AspectRatioMode aspectRatioMode,
   356                         Qt::AspectRatioMode aspectRatioMode,
   372                         QIcon::Mode mode,
   357                         QIcon::Mode mode,
   373                         bool mirrored,
   358                         bool mirrored,
   374                         HbIconLoader::IconLoaderOptions options,
   359                         HbIconLoader::IconLoaderOptions options,
   375                         const QColor &color)
   360                         const QColor &color,
   376 {
   361                         HbRenderingMode renderMode)
   377     Q_D(HbThemeClient);
   362 {
   378     return d->getMultiIconInfo(multiPartIconList, sizeList,aspectRatioMode, mode, mirrored, options, color);
   363     Q_D(HbThemeClient);
       
   364     return d->getMultiIconInfo(multiPartIconList, sizeList,aspectRatioMode, mode, mirrored, options, color, renderMode);
   379 }
   365 }
   380 
   366 
   381 /**
   367 /**
   382  * freeSharedMemory  gets free memory in shared chunk
   368  * freeSharedMemory  gets free memory in shared chunk
   383  *
   369  *
   406 {
   392 {
   407     Q_D(HbThemeClient);
   393     Q_D(HbThemeClient);
   408     return d->allocatedHeapMemory();
   394     return d->allocatedHeapMemory();
   409 }
   395 }
   410 
   396 
       
   397 /**
       
   398  * switchRenderingMode  IPC sent to themeserver
       
   399  *
       
   400  */
       
   401 bool HbThemeClient::switchRenderingMode(HbRenderingMode renderMode)
       
   402 {
       
   403     Q_D(HbThemeClient);    
       
   404     return d->switchRenderingMode(renderMode);    
       
   405 }