52 #include "hbmemoryutils_p.h" |
52 #include "hbmemoryutils_p.h" |
53 #include "hbdeviceprofiledatabase_p.h" |
53 #include "hbdeviceprofiledatabase_p.h" |
54 #include "hbthemesystemeffect_p.h" |
54 #include "hbthemesystemeffect_p.h" |
55 #ifdef HB_SGIMAGE_ICON |
55 #ifdef HB_SGIMAGE_ICON |
56 #include "hbsgimagerenderer_p.h" |
56 #include "hbsgimagerenderer_p.h" |
|
57 #include <sgresource/sgerror.h> |
57 #endif |
58 #endif |
58 // 5 MB GPU cache size |
59 // 16 MB GPU cache size |
59 #define GPU_CACHE_SIZE 0x500000 |
60 #define GPU_CACHE_SIZE 0x1000000 |
60 |
61 |
61 // 5 MB CPU cache size |
62 // 5 MB CPU cache size |
62 #define CPU_CACHE_SIZE 0x500000 |
63 #define CPU_CACHE_SIZE 0x500000 |
63 |
64 |
64 static const TInt KThemeName = 0; |
65 static const TInt KThemeName = 0; |
65 |
66 |
66 const QString KOperatorCPath = "C:/resource/hb/prioritytheme/icons/"; |
67 const QString KOperatorCPath = "C:/resource/hb/prioritytheme/icons/"; |
67 const QString KOperatorZPath = "Z:/resource/hb/prioritytheme/icons/"; |
68 const QString KOperatorZPath = "Z:/resource/hb/prioritytheme/icons/"; |
|
69 const QString KBaseThemePath = "z:/resource/hb/"; |
68 |
70 |
69 bool HbThemeServerPrivate::gpuGoodMemoryState = true; |
71 bool HbThemeServerPrivate::gpuGoodMemoryState = true; |
70 // This is used as parent theme always regardless of the active theme |
72 |
|
73 #define HB_SPLASH_FLICKER_WORKAROUND |
71 |
74 |
72 //********************************** |
75 //********************************** |
73 //HbThemeServerPrivate |
76 //HbThemeServerPrivate |
74 //********************************** |
77 //********************************** |
75 /** |
78 /** |
89 self->ConstructL(); |
92 self->ConstructL(); |
90 CleanupStack::Pop(self); |
93 CleanupStack::Pop(self); |
91 return self; |
94 return self; |
92 } |
95 } |
93 |
96 |
|
97 #ifdef HB_SPLASH_FLICKER_WORKAROUND |
|
98 _LIT_SECURITY_POLICY_PASS(KHbTfxPsRdPolicy); // all pass |
|
99 _LIT_SECURITY_POLICY_S0(KHbTfxPsWrPolicy, KServerUid3.iUid); // pass themeserver only |
|
100 static void checkTfxRenderStage() |
|
101 { |
|
102 // Check wsini.ini for a line containing [tfxrenderstage]. When present, |
|
103 // publish 1 in the property that will be read by HbMainWindow. |
|
104 TUint32 key = 0x746678; |
|
105 RProperty::Define(KServerUid3, key, RProperty::EInt, KHbTfxPsRdPolicy, KHbTfxPsWrPolicy); |
|
106 RProperty::Set(KServerUid3, key, 0); |
|
107 QFile f(QLatin1String("z:/system/data/wsini.ini")); |
|
108 if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
109 QTextStream input(&f); |
|
110 input.setCodec("UTF-16"); |
|
111 while (!input.atEnd()) { |
|
112 QString line = input.readLine().trimmed(); |
|
113 if (!line.isEmpty()) { |
|
114 if (!line.compare(QLatin1String("[tfxrenderstage]"), Qt::CaseInsensitive)) { |
|
115 RProperty::Set(KServerUid3, key, 1); |
|
116 break; |
|
117 } |
|
118 } |
|
119 } |
|
120 f.close(); |
|
121 } |
|
122 } |
|
123 #else |
|
124 static void checkTfxRenderStage() |
|
125 { |
|
126 } |
|
127 #endif |
|
128 |
94 /** |
129 /** |
95 ConstructL |
130 ConstructL |
96 */ |
131 */ |
97 void HbThemeServerPrivate::ConstructL() |
132 void HbThemeServerPrivate::ConstructL() |
98 { |
133 { |
|
134 checkTfxRenderStage(); |
|
135 |
99 TInt err = RProperty::Define(KServerUid3, KThemeName, RProperty::ELargeText); |
136 TInt err = RProperty::Define(KServerUid3, KThemeName, RProperty::ELargeText); |
100 if ( err != KErrAlreadyExists ) { |
137 if ( err != KErrAlreadyExists ) { |
101 User::LeaveIfError( err ); |
138 User::LeaveIfError( err ); |
102 } |
139 } |
103 TInt error = iThemeProperty.Attach(KServerUid3, KThemeName ); |
140 TInt error = iThemeProperty.Attach(KServerUid3, KThemeName ); |
110 QDir path(currentTheme); |
147 QDir path(currentTheme); |
111 iCurrentThemeName = path.dirName(); |
148 iCurrentThemeName = path.dirName(); |
112 iCurrentThemePath = path.absolutePath(); |
149 iCurrentThemePath = path.absolutePath(); |
113 |
150 |
114 cache = 0; |
151 cache = 0; |
115 cssCache = 0; |
|
116 |
152 |
117 QT_TRY { |
153 QT_TRY { |
118 //Create the Icon cache |
154 //Create the Icon cache |
119 cache = new HbIconDataCache(); |
155 cache = new HbIconDataCache(); |
120 //Create the CSS cache |
|
121 cssCache = new HbCache(); |
|
122 } QT_CATCH(const std::bad_alloc &badalloc) { |
156 } QT_CATCH(const std::bad_alloc &badalloc) { |
123 delete cache; |
157 delete cache; |
124 delete cssCache; |
|
125 qt_symbian_exception2LeaveL(badalloc); |
158 qt_symbian_exception2LeaveL(badalloc); |
126 } |
159 } |
127 setMaxGpuCacheSize(GPU_CACHE_SIZE); |
160 setMaxGpuCacheSize(GPU_CACHE_SIZE); |
128 setMaxCpuCacheSize(CPU_CACHE_SIZE); |
161 setMaxCpuCacheSize(CPU_CACHE_SIZE); |
129 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
162 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
195 : CServer2( aActiveObjectPriority ), iWatcher(0) |
228 : CServer2( aActiveObjectPriority ), iWatcher(0) |
196 { |
229 { |
197 // Set up the listener to listen for Publish events |
230 // Set up the listener to listen for Publish events |
198 TRAPD(err, iListener = CHbThemeChangeNotificationListener::NewL(*this)); |
231 TRAPD(err, iListener = CHbThemeChangeNotificationListener::NewL(*this)); |
199 if (err) { |
232 if (err) { |
200 qWarning( "HbThemeServerPrivate::HbThemeServerPrivate: CHbThemeChangeNotificationListener::NewL failed = %d", err ); |
233 THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "CHbThemeChangeNotificationListener::NewL failed. Error code:" << err; |
201 } else { |
234 } else { |
202 TRAPD(err, iListener->startListeningL()); |
235 TRAPD(err, iListener->startListeningL()); |
203 if (err) { |
236 if (err) { |
204 qWarning( "HbThemeServerPrivate::HbThemeServerPrivate: iListener->startListening failed = %d", err ); |
237 THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "iListener->startListening failed. Error code:" << err; |
205 } |
238 } |
206 } |
239 } |
207 } |
240 } |
208 |
241 |
209 /** |
242 /** |
210 Destructor |
243 Destructor |
211 */ |
244 */ |
212 HbThemeServerPrivate::~HbThemeServerPrivate() |
245 HbThemeServerPrivate::~HbThemeServerPrivate() |
213 { |
246 { |
214 delete cache; |
247 delete cache; |
215 delete cssCache; |
|
216 cache = 0; // so that HbThemeServerSession::~HbThemeServerSession can avoid using these pointers; |
248 cache = 0; // so that HbThemeServerSession::~HbThemeServerSession can avoid using these pointers; |
217 cssCache = 0; // it may be called inside HbThemeServerPrivate::~HbThemeServerPrivate |
|
218 TInt err = RProperty::Delete(KServerUid3, KNewThemeForThemeChanger); |
249 TInt err = RProperty::Delete(KServerUid3, KNewThemeForThemeChanger); |
219 if(err != KErrNotFound) { |
250 if(err != KErrNotFound) { |
220 User::LeaveIfError(err); |
251 User::LeaveIfError(err); |
221 } |
252 } |
222 // Delete the listener for Publish/Subscribe |
253 // Delete the listener for Publish/Subscribe |
238 indexFileName.append(iCurrentThemePath); |
269 indexFileName.append(iCurrentThemePath); |
239 indexFileName.append("/index.theme"); |
270 indexFileName.append("/index.theme"); |
240 |
271 |
241 QFile currentIndexfile(indexFileName); |
272 QFile currentIndexfile(indexFileName); |
242 if(!currentIndexfile.open(QIODevice::ReadOnly)) { |
273 if(!currentIndexfile.open(QIODevice::ReadOnly)) { |
243 qWarning()<< "HbSymbianThemeServer: No Index file found in the new theme, How did this happen ??"; |
274 THEME_GENERIC_DEBUG()<< Q_FUNC_INFO << "No Index file found in the new theme."; |
244 return false; |
275 return false; |
245 } else { |
276 } else { |
246 currentIndexfile.close(); |
277 currentIndexfile.close(); |
247 if (!iWatcher) { |
278 if (!iWatcher) { |
248 // Set up the file watcher for active theme changes |
279 // Set up the file watcher for active theme changes |
249 TRAP_IGNORE(iWatcher = CHbThemeWatcher::NewL(*this)); |
280 iWatcher = new HbThemeWatcher(*this); |
250 } |
281 } |
251 // Start watching in case of mmc ejection |
282 // Start watching in case of mmc ejection or active theme uninstall |
252 if (iWatcher) { |
283 if (iWatcher) { |
253 iWatcher->startWatchingL(indexFileName); |
284 iWatcher->startWatching(indexFileName); |
254 } |
285 } |
255 } |
286 } |
256 } |
287 } |
257 return true; |
288 return true; |
258 } |
289 } |
260 /** |
291 /** |
261 Handles theme selection |
292 Handles theme selection |
262 */ |
293 */ |
263 void HbThemeServerPrivate::HandleThemeSelection( const QString& themeName) |
294 void HbThemeServerPrivate::HandleThemeSelection( const QString& themeName) |
264 { |
295 { |
265 QDir path(themeName.trimmed()); |
296 QString cleanThemeName = themeName; |
|
297 if (!HbThemeUtils::isThemeValid(cleanThemeName)) { |
|
298 // check if the theme name is logical |
|
299 cleanThemeName = KBaseThemePath + HbThemeUtils::platformHierarchy + '/' + |
|
300 HbThemeUtils::iconsResourceFolder + '/' + cleanThemeName; |
|
301 } |
|
302 |
|
303 QDir path(cleanThemeName); |
266 iCurrentThemeName = path.dirName(); |
304 iCurrentThemeName = path.dirName(); |
267 iCurrentThemePath = path.absolutePath(); |
305 iCurrentThemePath = path.absolutePath(); |
268 |
306 |
269 #ifdef THEME_INDEX_TRACES |
307 THEME_INDEX_DEBUG() << Q_FUNC_INFO << "Theme change request, new theme =" << cleanThemeName.toUtf8(); |
270 qDebug() << "ThemeIndex: theme change request, new theme =" << themeName.toUtf8(); |
|
271 #endif |
|
272 |
308 |
273 // Clear cached icons and session data |
309 // Clear cached icons and session data |
274 clearIconCache(); |
310 clearIconCache(); |
275 iSessionIter.SetToFirst(); |
311 iSessionIter.SetToFirst(); |
276 while(iSessionIter) { |
312 while(iSessionIter) { |
286 /** |
322 /** |
287 Creates a new session with the server. |
323 Creates a new session with the server. |
288 */ |
324 */ |
289 CSession2* HbThemeServerPrivate::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const |
325 CSession2* HbThemeServerPrivate::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const |
290 { |
326 { |
291 #ifdef THEME_SERVER_TRACES |
327 THEME_GENERIC_DEBUG() << "entering" << Q_FUNC_INFO; |
292 qDebug() << "HbThemeServerPrivate::NewSessionL: entered"; |
|
293 #endif |
|
294 // Check that the version is OK |
328 // Check that the version is OK |
295 TVersion v(KThemeServerMajorVersionNumber, KThemeServerMinorVersionNumber, KThemeServerBuildVersionNumber); |
329 TVersion v(KThemeServerMajorVersionNumber, KThemeServerMinorVersionNumber, KThemeServerBuildVersionNumber); |
296 if (!User::QueryVersionSupported(v, aVersion)) |
330 if (!User::QueryVersionSupported(v, aVersion)) |
297 User::Leave(KErrNotSupported); |
331 User::Leave(KErrNotSupported); |
298 // Create the session. |
332 // Create the session. |
318 return (cache->insert(key, item)); |
352 return (cache->insert(key, item)); |
319 |
353 |
320 } |
354 } |
321 |
355 |
322 /** |
356 /** |
323 * HbThemeServerPrivate::insertCssCacheItem |
|
324 * |
|
325 * Inserts a css-cache item along with its key into the css-cache. |
|
326 */ |
|
327 bool HbThemeServerPrivate::insertCssCacheItem(const QString& key, HbCacheItem* item) |
|
328 { |
|
329 return (cssCache->insert(key, item)); |
|
330 } |
|
331 |
|
332 /** |
|
333 * HbThemeServerPrivate::iconCacheItem |
357 * HbThemeServerPrivate::iconCacheItem |
334 * |
358 * |
335 * Retrieves a icon cache-item from the icon cache based on it's key. |
359 * Retrieves a icon cache-item from the icon cache based on it's key. |
336 */ |
360 */ |
337 HbIconCacheItem * HbThemeServerPrivate::iconCacheItem(const HbIconKey &key , bool isMultiIconPiece) |
361 HbIconCacheItem * HbThemeServerPrivate::iconCacheItem(const HbIconKey &key , bool isMultiIconPiece) |
338 { |
362 { |
339 return(cache->getCacheItem(key, renderMode, isMultiIconPiece)); |
363 return(cache->getCacheItem(key, renderMode, isMultiIconPiece)); |
340 } |
364 } |
341 |
365 |
342 /** |
366 /** |
343 * HbThemeServerPrivate::cssCacheItem |
|
344 * |
|
345 * Retrieves a css-cache item from the css cache based on it's key. |
|
346 */ |
|
347 HbCacheItem * HbThemeServerPrivate::cssCacheItem(const QString &key) |
|
348 { |
|
349 return(cssCache->cacheItem(key)); |
|
350 } |
|
351 |
|
352 /** |
|
353 * HbThemeServerPrivate::clearIconCache |
367 * HbThemeServerPrivate::clearIconCache |
354 * |
368 * |
355 * Clears icon cache. |
369 * Clears icon cache. |
356 */ |
370 */ |
357 void HbThemeServerPrivate::clearIconCache() |
371 void HbThemeServerPrivate::clearIconCache() |
358 { |
372 { |
359 cache->clear(); |
373 cache->clear(); |
360 } |
|
361 |
|
362 /** |
|
363 * HbThemeServerPrivate::clearCssCache |
|
364 * |
|
365 * Clears css cache. |
|
366 */ |
|
367 void HbThemeServerPrivate::clearCssCache() |
|
368 { |
|
369 cssCache->clear(); |
|
370 } |
374 } |
371 |
375 |
372 /** |
376 /** |
373 * HbThemeServerPrivate::CleanupSessionIconItem |
377 * HbThemeServerPrivate::CleanupSessionIconItem |
374 * |
378 * |
503 HbRenderingMode HbThemeServerPrivate::currentRenderingMode() const |
490 HbRenderingMode HbThemeServerPrivate::currentRenderingMode() const |
504 { |
491 { |
505 return renderMode; |
492 return renderMode; |
506 } |
493 } |
507 |
494 |
|
495 HbRenderingMode HbThemeServerPrivate::expectedRenderingMode(HbRenderingMode requsetedRenderingMode) const |
|
496 { |
|
497 HbRenderingMode renderingMode = ESWRendering; |
|
498 |
|
499 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
|
500 if((requsetedRenderingMode == EHWRendering) && |
|
501 (currentRenderingMode() == EHWRendering) && |
|
502 HbThemeServerPrivate::gpuMemoryState()) { |
|
503 renderingMode = EHWRendering; |
|
504 } |
|
505 #endif |
|
506 |
|
507 return renderingMode; |
|
508 } |
|
509 |
508 /** |
510 /** |
509 * HbThemeServerPrivate::setCurrentRenderingMode |
511 * HbThemeServerPrivate::setCurrentRenderingMode |
510 * This function sets ThemeServer's current rendering mode |
512 * This function sets ThemeServer's current rendering mode |
511 * |
513 * |
512 */ |
514 */ |
513 void HbThemeServerPrivate::setCurrentRenderingMode(HbRenderingMode currentMode) |
515 void HbThemeServerPrivate::setCurrentRenderingMode(HbRenderingMode currentMode) |
514 { |
516 { |
515 renderMode = currentMode; |
517 renderMode = currentMode; |
516 } |
|
517 |
|
518 //Debug Code for Test Purpose |
|
519 #ifdef HB_ICON_CACHE_DEBUG |
|
520 int HbThemeServerPrivate ::cacheIconCount() const |
|
521 { |
|
522 return cache->count(); |
|
523 } |
518 } |
524 |
519 |
525 unsigned long HbThemeServerPrivate::totalGPUMemory() |
520 unsigned long HbThemeServerPrivate::totalGPUMemory() |
526 { |
521 { |
527 #ifdef HB_SGIMAGE_ICON |
522 #ifdef HB_SGIMAGE_ICON |
530 #else |
525 #else |
531 return 0; |
526 return 0; |
532 #endif |
527 #endif |
533 } |
528 } |
534 |
529 |
|
530 int HbThemeServerPrivate::cachedSgImagesCount() const |
|
531 { |
|
532 return cache->cachedSgImagesCount(); |
|
533 } |
|
534 |
|
535 int HbThemeServerPrivate::totalSgImagesCost() const |
|
536 { |
|
537 return cache->totalSgImagesCost(); |
|
538 } |
|
539 |
|
540 int HbThemeServerPrivate::cachedPixmapCount() const |
|
541 { |
|
542 return cache->cachedPixmapCount(); |
|
543 } |
|
544 |
535 unsigned long HbThemeServerPrivate::freeGPUMemory() |
545 unsigned long HbThemeServerPrivate::freeGPUMemory() |
536 { |
546 { |
537 #ifdef HB_SGIMAGE_ICON |
547 #ifdef HB_SGIMAGE_ICON |
|
548 #ifdef HB_ICON_CACHE_DEBUG |
538 qDebug() << "Inside HbThemeServerSymbian::freeGPUMemory() " ; |
549 qDebug() << "Inside HbThemeServerSymbian::freeGPUMemory() " ; |
|
550 #endif |
539 return HbSgImageRenderer::global()->freeGPUMemory(); |
551 return HbSgImageRenderer::global()->freeGPUMemory(); |
540 #else |
552 #else |
541 return 0; |
553 return 0; |
542 #endif |
554 #endif |
543 } |
555 } |
|
556 |
|
557 |
|
558 bool HbThemeServerPrivate::isItemCacheableinGpu(int itemCost, HbIconFormatType type) |
|
559 { |
|
560 return cache->isItemCachableInGpu(itemCost, type); |
|
561 } |
|
562 |
|
563 bool HbThemeServerPrivate::isItemCacheableinCpu(int itemCost, HbIconFormatType type) |
|
564 { |
|
565 return cache->isItemCachableInCpu(itemCost, type); |
|
566 } |
|
567 |
|
568 |
|
569 //Debug Code for Test Purpose |
|
570 #ifdef HB_ICON_CACHE_DEBUG |
|
571 int HbThemeServerPrivate ::cacheIconCount() const |
|
572 { |
|
573 return cache->count(); |
|
574 } |
|
575 |
544 int HbThemeServerPrivate::freeVectorMemory() |
576 int HbThemeServerPrivate::freeVectorMemory() |
545 { |
577 { |
546 return cache->freeVectorMemory(); |
578 return cache->freeVectorMemory(); |
547 } |
579 } |
548 |
580 |
610 |
642 |
611 int HbThemeServerPrivate::vectorLruCount() |
643 int HbThemeServerPrivate::vectorLruCount() |
612 { |
644 { |
613 return cache->vectorLruCount(); |
645 return cache->vectorLruCount(); |
614 } |
646 } |
615 |
|
616 #endif |
647 #endif |
617 |
648 |
618 int HbThemeServerPrivate::gpuLRUSize() const |
649 int HbThemeServerPrivate::gpuLRUSize() const |
619 { |
650 { |
620 return cache->gpuLRUSize(); |
651 return cache->gpuLRUSize(); |
621 } |
652 } |
622 |
653 |
623 /** |
654 //********************************* |
624 * HbThemeServerPrivate::doCleanup() |
|
625 * |
|
626 * This function releases shared memory occupied by css-resources whose reference count is zero, |
|
627 * so that subsequent css-requests could be fulfilled by the server. Those css-files whose reference |
|
628 * count are zero, are already appended to the LRU list maintained by the css-cache. Since these resources |
|
629 * are not being referred to by any application, they can be removed from the cache and corresponding |
|
630 * shared memory can be freed up. |
|
631 */ |
|
632 void HbThemeServerPrivate::doCleanup() |
|
633 { |
|
634 HbThemeServerUtils::cleanupUnusedCss(cssCache); |
|
635 } |
|
636 |
|
637 //********************************** |
|
638 //HbThemeServerSession |
655 //HbThemeServerSession |
639 //********************************** |
656 //********************************** |
640 /** |
657 /** |
641 This class represents a session with the server. |
658 This class represents a session with the server. |
642 Functions are provided to respond appropriately to client messages. |
659 Functions are provided to respond appropriately to client messages. |
643 */ |
660 */ |
644 |
661 |
645 /** |
662 /** |
646 Constructor |
663 Constructor |
688 /** |
697 /** |
689 Services a client request. |
698 Services a client request. |
690 */ |
699 */ |
691 void HbThemeServerSession::ServiceL(const RMessage2& aMessage) |
700 void HbThemeServerSession::ServiceL(const RMessage2& aMessage) |
692 { |
701 { |
693 #ifdef THEME_SERVER_TRACES |
702 THEME_GENERIC_DEBUG() << "entered" << Q_FUNC_INFO << "with function:" << aMessage.Function(); |
694 qDebug() << "Just entered HbThemeServerSession::ServiceL"; |
|
695 #endif |
|
696 |
703 |
697 TRAPD(err, DispatchMessageL(aMessage)); |
704 TRAPD(err, DispatchMessageL(aMessage)); |
698 aMessage.Complete(err); |
705 aMessage.Complete(err); |
699 |
706 THEME_GENERIC_DEBUG() << "completed" << Q_FUNC_INFO << "with error code" + err; |
700 #ifdef THEME_SERVER_TRACES |
|
701 QString er; |
|
702 er.setNum(err); |
|
703 qDebug() << "completed DispatchMessageL error code is " + er; |
|
704 #endif |
|
705 |
|
706 } |
707 } |
707 |
708 |
708 /** |
709 /** |
709 Called by ServiceL() |
710 Called by ServiceL() |
710 |
711 |
711 It tests the function code and then delegates to |
712 It tests the function code and then delegates to |
712 the appropriate function. |
713 the appropriate function. |
713 */ |
714 */ |
714 void HbThemeServerSession::DispatchMessageL(const RMessage2& aMessage) |
715 void HbThemeServerSession::DispatchMessageL(const RMessage2& aMessage) |
715 { |
716 { |
716 #ifdef THEME_SERVER_TRACES |
|
717 qDebug() << "Just entered HbThemeServerSession::DispatchMessageL"; |
|
718 #endif |
|
719 |
|
720 switch (aMessage.Function()) { |
717 switch (aMessage.Function()) { |
721 case EStyleSheetLookup: |
718 case EStyleSheetLookup: |
722 HandleStyleSheetLookupL(aMessage); |
719 HandleStyleSheetLookupL(aMessage); |
723 break; |
720 break; |
724 case EWidgetMLLookup: |
721 case EWidgetMLLookup: |
746 |
743 |
747 case EUnloadIcon: |
744 case EUnloadIcon: |
748 unLoadIcon(aMessage); |
745 unLoadIcon(aMessage); |
749 break; |
746 break; |
750 |
747 |
|
748 case EBatchUnloadIcon: |
|
749 batchUnLoadIcon(aMessage); |
|
750 break; |
|
751 |
751 case EUnloadMultiIcon: |
752 case EUnloadMultiIcon: |
752 unloadMultiIcon(aMessage); |
753 unloadMultiIcon(aMessage); |
753 break; |
754 break; |
|
755 |
754 case ENotifyForegroundLost: |
756 case ENotifyForegroundLost: |
755 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
757 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
756 freeClientGpuResources(); |
758 freeIconResources(); |
757 #endif |
759 #endif |
758 break; |
760 break; |
759 //Debug Code for Test Purpose |
761 //Debug Code for Test Purpose |
760 #ifdef HB_ICON_CACHE_DEBUG |
762 #ifdef HB_ICON_CACHE_DEBUG |
761 case ECacheIconCount: { |
763 case ECacheIconCount: { |
786 break; |
788 break; |
787 } |
789 } |
788 case EFreeVectorMem: { |
790 case EFreeVectorMem: { |
789 TInt freeVectMem = iServer->freeVectorMemory(); |
791 TInt freeVectMem = iServer->freeVectorMemory(); |
790 TPckg<TInt> out(freeVectMem); |
792 TPckg<TInt> out(freeVectMem); |
791 aMessage.WriteL(1, out); |
|
792 break; |
|
793 } |
|
794 |
|
795 case EFreeGPUMem: { |
|
796 unsigned long freeMem = iServer->freeGPUMemory(); |
|
797 TPckg<unsigned long> out(freeMem); |
|
798 aMessage.WriteL(1, out); |
|
799 break; |
|
800 } |
|
801 case ETotalGPUMem: { |
|
802 unsigned long totalMem = iServer->totalGPUMemory(); |
|
803 TPckg<unsigned long> out(totalMem); |
|
804 aMessage.WriteL(1, out); |
793 aMessage.WriteL(1, out); |
805 break; |
794 break; |
806 } |
795 } |
807 case ELastAddedItemMem: { |
796 case ELastAddedItemMem: { |
808 TInt lAddItemMem = iServer->lastAddedItemMem(); |
797 TInt lAddItemMem = iServer->lastAddedItemMem(); |
901 case EServerAllocReset: { |
890 case EServerAllocReset: { |
902 //TODO |
891 //TODO |
903 break; |
892 break; |
904 } |
893 } |
905 #endif |
894 #endif |
|
895 case EFreeGPUMem: { |
|
896 unsigned long freeMem = iServer->freeGPUMemory(); |
|
897 TPckg<unsigned long> out(freeMem); |
|
898 aMessage.WriteL(1, out); |
|
899 break; |
|
900 } |
|
901 case ECachedSgImages: { |
|
902 TInt cachedSgImages = iServer->cachedSgImagesCount(); |
|
903 TPckg<TInt> out(cachedSgImages); |
|
904 aMessage.WriteL(1, out); |
|
905 break; |
|
906 } |
|
907 case ETotalSgImagesCost: { |
|
908 TInt cachedSgImagesCost = iServer->totalSgImagesCost(); |
|
909 TPckg<TInt> out(cachedSgImagesCost); |
|
910 aMessage.WriteL(1, out); |
|
911 break; |
|
912 } |
|
913 case ECachedPixmapImages: { |
|
914 TInt cachedPixImages = iServer->cachedPixmapCount(); |
|
915 TPckg<TInt> out(cachedPixImages); |
|
916 aMessage.WriteL(1, out); |
|
917 break; |
|
918 } |
|
919 case ECurrentRenderingMode: { |
|
920 TInt currentRenderingMode = iServer->currentRenderingMode(); |
|
921 TPckg<TInt> out(currentRenderingMode); |
|
922 aMessage.WriteL(1, out); |
|
923 break; |
|
924 } |
|
925 case ETotalGPUMem: { |
|
926 unsigned long totalMem = iServer->totalGPUMemory(); |
|
927 TPckg<unsigned long> out(totalMem); |
|
928 aMessage.WriteL(1, out); |
|
929 break; |
|
930 } |
906 #ifdef HB_THEME_SERVER_MEMORY_REPORT |
931 #ifdef HB_THEME_SERVER_MEMORY_REPORT |
907 case ECreateMemoryReport: { |
932 case ECreateMemoryReport: { |
908 GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory); |
933 GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory); |
909 static_cast<HbSharedMemoryManager *>(manager)->createReport(); |
934 static_cast<HbSharedMemoryManager *>(manager)->createReport(); |
910 break; |
935 break; |
931 iServer->setCurrentRenderingMode(ESWRendering ); |
956 iServer->setCurrentRenderingMode(ESWRendering ); |
932 } |
957 } |
933 iServer->FreeGpuRam(params.bytesToFree, params.useSwRendering); |
958 iServer->FreeGpuRam(params.bytesToFree, params.useSwRendering); |
934 break; |
959 break; |
935 } |
960 } |
936 |
|
937 case ERenderModeSwitch: { |
961 case ERenderModeSwitch: { |
938 TInt mode = 0; |
962 TInt mode = 0; |
939 TPckg<TInt> paramPckg(mode); |
963 TPckg<TInt> paramPckg(mode); |
940 aMessage.ReadL(0, paramPckg, 0); |
964 aMessage.ReadL(0, paramPckg, 0); |
941 SwitchRenderingMode((HbRenderingMode)mode); |
965 SwitchRenderingMode((HbRenderingMode)mode); |
942 break; |
966 break; |
943 } |
967 } |
944 case EFreeSharedMem: { |
968 case EFreeSharedMem: { |
945 int freeSharedMem = iServer->freeSharedMemory(); |
969 int freeSharedMem = iServer->freeSharedMemory(); |
946 TPckg<int> out(freeSharedMem); |
970 TPckg<int> out(freeSharedMem); |
947 aMessage.WriteL(1, out); |
971 aMessage.WriteL(1, out); |
948 break; |
972 break; |
957 int allocatedHeapMem = iServer->allocatedHeapMemory(); |
981 int allocatedHeapMem = iServer->allocatedHeapMemory(); |
958 TPckg<int> out(allocatedHeapMem); |
982 TPckg<int> out(allocatedHeapMem); |
959 aMessage.WriteL(1, out); |
983 aMessage.WriteL(1, out); |
960 break; |
984 break; |
961 } |
985 } |
962 |
|
963 case ETypefaceOffset: { |
986 case ETypefaceOffset: { |
964 HandleTypefaceReqL(aMessage); |
987 HandleTypefaceReqL(aMessage); |
965 break; |
988 break; |
966 } |
989 } |
967 |
990 case EMissedHbCssLookup: { |
968 |
991 HandleMissedHbCssLookupL(aMessage); |
969 |
992 break; |
970 // This is an example of a request that we know about, but don't support. |
993 } |
971 // We cause KErrNotSupported to be returned to the client. |
|
972 default: |
994 default: |
973 PanicClient(aMessage, EBadRequest); |
995 PanicClient(aMessage, EBadRequest); |
974 break; |
996 break; |
975 } |
997 } |
976 #ifdef THEME_SERVER_TRACES |
|
977 qDebug() << "Leave HbThemeServerSession::DispatchMessageL"; |
|
978 #endif |
|
979 } |
998 } |
980 |
999 |
981 void HbThemeServerSession::SwitchRenderingMode(HbRenderingMode aRenderMode) |
1000 void HbThemeServerSession::SwitchRenderingMode(HbRenderingMode aRenderMode) |
982 { |
1001 { |
983 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
1002 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
992 qDebug()<< "HbThemeServerSession::SwitchRenderingMode:GPU Memory After Switching to Software:" << sgImg->freeGPUMemory(); |
1011 qDebug()<< "HbThemeServerSession::SwitchRenderingMode:GPU Memory After Switching to Software:" << sgImg->freeGPUMemory(); |
993 #endif //HB_ICON_CACHE_DEBUG |
1012 #endif //HB_ICON_CACHE_DEBUG |
994 } |
1013 } |
995 #endif |
1014 #endif |
996 } |
1015 } |
997 |
|
998 /** |
1016 /** |
999 * HandleStyleSheetLookupL |
1017 * HandleStyleSheetLookupL |
1000 */ |
1018 */ |
1001 void HbThemeServerSession::HandleStyleSheetLookupL(const RMessage2& aMessage) |
1019 void HbThemeServerSession::HandleStyleSheetLookupL(const RMessage2& aMessage) |
1002 { |
1020 { |
1003 if (aMessage.GetDesLength(0) == 0) { |
1021 if (aMessage.GetDesLength(0) == 0) { |
1004 #ifdef THEME_SERVER_TRACES |
1022 THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "no filename given."; |
1005 qDebug() << "Empty Filename"; |
|
1006 #endif |
|
1007 return; |
1023 return; |
1008 } |
1024 } |
1009 |
1025 |
1010 TFileName fileName; |
1026 TFileName fileName; |
1011 aMessage.ReadL(0, fileName, 0); |
1027 aMessage.ReadL(0, fileName, 0); |
1017 |
1033 |
1018 HbLayeredStyleLoader::LayerPriority layerPriority = (HbLayeredStyleLoader::LayerPriority) priorityValue; |
1034 HbLayeredStyleLoader::LayerPriority layerPriority = (HbLayeredStyleLoader::LayerPriority) priorityValue; |
1019 |
1035 |
1020 QString cssFileName((QChar*)fileName.Ptr(), fileName.Length()); |
1036 QString cssFileName((QChar*)fileName.Ptr(), fileName.Length()); |
1021 HbSharedStyleSheetInfo offsetInfo; |
1037 HbSharedStyleSheetInfo offsetInfo; |
1022 HbCacheItem* cssCacheItem = iServer->cssCacheItem(cssFileName); |
1038 |
1023 bool insertKeyIntoSessionList = false; |
1039 offsetInfo.offset = HbThemeServerUtils::getSharedStylesheet(cssFileName, |
1024 if (cssCacheItem) { |
1040 layerPriority, offsetInfo.fileExists); |
1025 //The item was found in the cache and reference count was incremented |
1041 |
1026 insertKeyIntoSessionList = true; |
|
1027 offsetInfo.offset = cssCacheItem->offset; |
|
1028 } else { |
|
1029 bool tryAgain = false; |
|
1030 do { |
|
1031 offsetInfo.offset = HbThemeServerUtils::getSharedStylesheet(cssFileName, layerPriority); |
|
1032 if (offsetInfo.offset >= 0) { |
|
1033 HbCacheItem *cssItem = new HbCacheItem(offsetInfo.offset, 0, cssFileName); |
|
1034 insertKeyIntoSessionList = iServer->insertCssCacheItem(cssFileName, cssItem); |
|
1035 if (layerPriority == HbLayeredStyleLoader::Priority_Core && cssItem->refCount == 1) { |
|
1036 // This will make sure the requested stylesheet will always remain |
|
1037 // in the primary and secondary cache. |
|
1038 cssItem->incrementRefCount(); |
|
1039 } |
|
1040 break; |
|
1041 } else if (offsetInfo.offset == OUT_OF_MEMORY_ERROR && tryAgain == false) { |
|
1042 iServer->doCleanup(); |
|
1043 tryAgain = true; |
|
1044 } else if (offsetInfo.offset == OUT_OF_MEMORY_ERROR && tryAgain == true) { |
|
1045 //try only once to free up memory, else offset remains -2 |
|
1046 tryAgain = false; |
|
1047 } |
|
1048 } while (tryAgain); |
|
1049 } |
|
1050 if (insertKeyIntoSessionList) { |
|
1051 //The session will only keep track of cssFiles that were either successfully found or were |
|
1052 //successfully inserted in the cache. |
|
1053 if (!sessionCssData.contains(cssFileName)) { |
|
1054 sessionCssData.append(cssFileName); |
|
1055 } |
|
1056 } |
|
1057 TPckg<HbSharedStyleSheetInfo> data(offsetInfo); |
1042 TPckg<HbSharedStyleSheetInfo> data(offsetInfo); |
1058 aMessage.WriteL(2, data); |
1043 aMessage.WriteL(2, data); |
|
1044 } |
|
1045 |
|
1046 /** |
|
1047 * HandleMissedHbCssLookupL |
|
1048 */ |
|
1049 void HbThemeServerSession::HandleMissedHbCssLookupL(const RMessage2& aMessage) |
|
1050 { |
|
1051 HbSharedMissedHbCssInfo offsetInfo; |
|
1052 offsetInfo.offset = HbThemeServerUtils::getMissedHbCssFilesOffset(); |
|
1053 TPckg<HbSharedMissedHbCssInfo> data(offsetInfo); |
|
1054 aMessage.WriteL(0, data); |
1059 } |
1055 } |
1060 |
1056 |
1061 static const TInt KMaxLayoutName = 256; |
1057 static const TInt KMaxLayoutName = 256; |
1062 static const TInt KMaxSectionName = 256; |
1058 static const TInt KMaxSectionName = 256; |
1063 |
1059 |
1080 QString wmlFileName((QChar*)fileName.Ptr(), fileName.Length()); |
1076 QString wmlFileName((QChar*)fileName.Ptr(), fileName.Length()); |
1081 QString layout((QChar*)layoutName.Ptr(), layoutName.Length()); |
1077 QString layout((QChar*)layoutName.Ptr(), layoutName.Length()); |
1082 QString section((QChar*)sectionName.Ptr(), sectionName.Length()); |
1078 QString section((QChar*)sectionName.Ptr(), sectionName.Length()); |
1083 |
1079 |
1084 HbSharedWMLInfo offsetInfo; |
1080 HbSharedWMLInfo offsetInfo; |
1085 offsetInfo.offset = HbThemeServerUtils::getSharedLayoutDefinition(wmlFileName, layout, section); |
1081 offsetInfo.offset = HbThemeServerUtils::getSharedLayoutDefinition(wmlFileName, layout, |
|
1082 section, offsetInfo.fileExists); |
1086 TPckg<HbSharedWMLInfo> data(offsetInfo); |
1083 TPckg<HbSharedWMLInfo> data(offsetInfo); |
1087 aMessage.WriteL(3, data); |
1084 aMessage.WriteL(3, data); |
1088 } |
1085 } |
1089 |
1086 |
1090 |
1087 |
1136 HbIconKey key(filename, QSizeF(params.width, params.height), |
1133 HbIconKey key(filename, QSizeF(params.width, params.height), |
1137 (Qt::AspectRatioMode)params.aspectRatioMode, |
1134 (Qt::AspectRatioMode)params.aspectRatioMode, |
1138 (QIcon::Mode)params.mode, params.mirrored, color, |
1135 (QIcon::Mode)params.mode, params.mirrored, color, |
1139 (HbRenderingMode)params.renderMode); |
1136 (HbRenderingMode)params.renderMode); |
1140 |
1137 |
1141 HbIconCacheItem* cacheItem = iServer->iconCacheItem(key); |
|
1142 bool insertKeyIntoSessionList = false; |
1138 bool insertKeyIntoSessionList = false; |
|
1139 QString format = HbThemeServerUtils::formatFromPath(key.filename); |
|
1140 HbIconFormatType iconType = getIconFormatType(format); |
|
1141 |
|
1142 HbIconCacheItem* cacheItem = getCachedIcon(key, format, false); |
1143 if (cacheItem) { |
1143 if (cacheItem) { |
1144 insertKeyIntoSessionList = true; //The item was found in the cache and ref count was incremented |
1144 insertKeyIntoSessionList = true; //The item was found in the cache and ref count was incremented |
1145 if (cacheItem->rasterIconData.type != INVALID_FORMAT) { |
1145 if (cacheItem->rasterIconData.type != INVALID_FORMAT) { |
1146 data = cacheItem->rasterIconData; |
1146 data = cacheItem->rasterIconData; |
1147 } else if (cacheItem->vectorIconData.type != INVALID_FORMAT) { |
1147 } else if (cacheItem->vectorIconData.type != INVALID_FORMAT) { |
1151 } else { |
1151 } else { |
1152 data.type = INVALID_FORMAT; |
1152 data.type = INVALID_FORMAT; |
1153 } |
1153 } |
1154 } else { |
1154 } else { |
1155 QT_TRY { |
1155 QT_TRY { |
1156 QString format = HbThemeServerUtils::formatFromPath(key.filename); |
1156 QScopedPointer <HbIconCacheItem> tempIconCacheItem; |
1157 QScopedPointer <HbIconCacheItem> tempIconCacheItem( |
1157 int gpuItemCost = HbThemeServerUtils::computeGpuCost(key, iconType, false); |
1158 HbIconCacheItemCreator::createCacheItem(key, |
1158 HbRenderingMode rm = iServer->expectedRenderingMode((HbRenderingMode)key.renderMode); |
1159 static_cast<HbIconLoader::IconLoaderOptions>(params.options), |
1159 // A hardware icon (SGImage) is only created when icon format is NVG, |
1160 format, iServer->currentRenderingMode())); |
1160 // when both client and ThemeServer is in HW rendering mode and |
|
1161 // there is enough GPU space to create anew HW icon |
|
1162 if (rm == EHWRendering && format == HbIconCacheItemCreator::KNvg && |
|
1163 iServer->isItemCacheableinGpu(gpuItemCost, iconType)) { |
|
1164 tempIconCacheItem.reset(HbIconCacheItemCreator::createCacheItem(key, |
|
1165 static_cast<HbIconLoader::IconLoaderOptions>(params.options), |
|
1166 format, EHWRendering)); |
|
1167 } else { |
|
1168 int cpuItemCost = HbThemeServerUtils::computeCpuCost(key, iconType, false); |
|
1169 if (iServer->isItemCacheableinCpu(cpuItemCost, iconType)){ |
|
1170 tempIconCacheItem.reset(HbIconCacheItemCreator::createCacheItem(key, |
|
1171 static_cast<HbIconLoader::IconLoaderOptions>(params.options), |
|
1172 format, ESWRendering)); |
|
1173 } |
|
1174 } |
1161 cacheItem = tempIconCacheItem.data(); |
1175 cacheItem = tempIconCacheItem.data(); |
1162 if (cacheItem) { |
1176 if (cacheItem) { |
1163 if (cacheItem->rasterIconData.type != INVALID_FORMAT) { |
1177 if (cacheItem->rasterIconData.type != INVALID_FORMAT) { |
1164 data = cacheItem->rasterIconData; |
1178 data = cacheItem->rasterIconData; |
1165 } else if (cacheItem->vectorIconData.type != INVALID_FORMAT) { |
1179 } else if (cacheItem->vectorIconData.type != INVALID_FORMAT) { |
1168 data = cacheItem->blobIconData; |
1182 data = cacheItem->blobIconData; |
1169 } else { |
1183 } else { |
1170 data.type = INVALID_FORMAT; |
1184 data.type = INVALID_FORMAT; |
1171 } |
1185 } |
1172 if (data.type != INVALID_FORMAT) { |
1186 if (data.type != INVALID_FORMAT) { |
|
1187 // set the rendering mode according to the actual rendering mode |
|
1188 // in which the icon is created |
|
1189 key.renderMode = cacheItem->renderingMode(); |
|
1190 |
1173 insertKeyIntoSessionList = iServer->insertIconCacheItem(key, cacheItem); |
1191 insertKeyIntoSessionList = iServer->insertIconCacheItem(key, cacheItem); |
1174 if (!insertKeyIntoSessionList) { |
1192 if (!insertKeyIntoSessionList) { |
1175 FreeDataFromCacheItem(cacheItem); |
1193 FreeDataFromCacheItem(cacheItem); |
1176 tempIconCacheItem.take(); |
1194 tempIconCacheItem.take(); |
1177 delete cacheItem; // do delete the item after gpu/cpu memory is freed |
1195 delete cacheItem; // do delete the item after gpu/cpu memory is freed |
1192 if (insertKeyIntoSessionList) { |
1210 if (insertKeyIntoSessionList) { |
1193 //The session will only keep track of icons that were either successfully found or were |
1211 //The session will only keep track of icons that were either successfully found or were |
1194 //successfully inserted in the cache. |
1212 //successfully inserted in the cache. |
1195 sessionData.append(key); |
1213 sessionData.append(key); |
1196 } |
1214 } |
|
1215 #ifdef HB_SGIMAGE_ICON |
|
1216 HbSgImageRenderer *sgImg = HbSgImageRenderer::global(); |
|
1217 if (sgImg->lastError() == KErrNoGraphicsMemory ) { |
|
1218 iServer->freeGpuRam(); |
|
1219 } |
|
1220 #endif |
1197 // create dshared pixmap info from HbIconCacheItem |
1221 // create dshared pixmap info from HbIconCacheItem |
1198 TPckg<HbSharedIconInfo> pixdata(data); |
1222 TPckg<HbSharedIconInfo> pixdata(data); |
1199 aMessage.WriteL(1, pixdata); |
1223 aMessage.WriteL(1, pixdata); |
1200 |
|
1201 #ifdef THEME_SERVER_TRACES |
|
1202 qDebug() << "Completed aMessage.WriteL"; |
|
1203 #endif |
|
1204 } |
1224 } |
1205 |
1225 |
1206 /** |
1226 /** |
1207 * Panics the client |
1227 * Panics the client |
1208 */ |
1228 */ |
1246 TMultiIconSymbParams params = ReadMessageAndRetrieveMultiIconParams(aMessage); |
1266 TMultiIconSymbParams params = ReadMessageAndRetrieveMultiIconParams(aMessage); |
1247 |
1267 |
1248 QColor color = GetColorFromRgba(params.rgba, params.colorflag); |
1268 QColor color = GetColorFromRgba(params.rgba, params.colorflag); |
1249 QString iconId((QChar*)params.multiPartIconId.Ptr(), params.multiPartIconId.Length()); |
1269 QString iconId((QChar*)params.multiPartIconId.Ptr(), params.multiPartIconId.Length()); |
1250 QString fullPath((QChar*)params.multiPartIconList[0].Ptr(), params.multiPartIconList[0].Length()); |
1270 QString fullPath((QChar*)params.multiPartIconList[0].Ptr(), params.multiPartIconList[0].Length()); |
1251 int index = fullPath.lastIndexOf("/"); |
1271 QString format = HbThemeServerUtils::formatFromPath(fullPath); |
|
1272 int index = fullPath.lastIndexOf('/'); |
1252 fullPath = fullPath.left(index + 1); |
1273 fullPath = fullPath.left(index + 1); |
1253 iconId.prepend(fullPath); |
1274 iconId.prepend(fullPath); |
1254 HbIconKey finalIconKey(iconId, |
1275 HbIconKey finalIconKey(iconId, |
1255 params.size, |
1276 params.size, |
1256 static_cast<Qt::AspectRatioMode>(params.aspectRatioMode), |
1277 static_cast<Qt::AspectRatioMode>(params.aspectRatioMode), |
1257 static_cast<QIcon::Mode>(params.mode), |
1278 static_cast<QIcon::Mode>(params.mode), |
1258 params.mirrored, |
1279 params.mirrored, |
1259 color, |
1280 color, |
1260 static_cast<HbRenderingMode>(params.renderMode)); |
1281 static_cast<HbRenderingMode>(params.renderMode)); |
1261 |
1282 |
1262 if (!IconInfoFromSingleIcon(finalIconKey, stitchedData)) { |
1283 if (!IconInfoFromSingleIcon(finalIconKey, stitchedData, format, false)) { |
1263 HbMultiIconParams frameItemParams; |
1284 HbMultiIconParams frameItemParams; |
1264 int noOfPieces = 1; |
1285 int noOfPieces = 1; |
1265 if (iconId.contains("_3PV", Qt::CaseInsensitive) || iconId.contains("_3PH", Qt::CaseInsensitive)) { |
1286 if (iconId.contains("_3PV", Qt::CaseInsensitive) || iconId.contains("_3PH", Qt::CaseInsensitive)) { |
1266 noOfPieces = 3; |
1287 noOfPieces = 3; |
1267 } else if (iconId.contains("_9P", Qt::CaseInsensitive)) { |
1288 } else if (iconId.contains("_9P", Qt::CaseInsensitive)) { |
1296 // create dshared pixmap info from HbIconCacheItem |
1317 // create dshared pixmap info from HbIconCacheItem |
1297 TPckg<HbSharedIconInfo> pixdata(stitchedData); |
1318 TPckg<HbSharedIconInfo> pixdata(stitchedData); |
1298 aMessage.WriteL(1, pixdata); |
1319 aMessage.WriteL(1, pixdata); |
1299 } |
1320 } |
1300 |
1321 |
|
1322 HbIconCacheItem* HbThemeServerSession::getCachedIcon(HbIconKey & key, const QString & format, |
|
1323 bool isConsolidatedIcon) |
|
1324 { |
|
1325 HbIconCacheItem* cacheItem = 0; |
|
1326 |
|
1327 // try to find the icon in other rendering mode, |
|
1328 // if rendering will take place in another rendering mode |
|
1329 HbRenderingMode rm = iServer->expectedRenderingMode((HbRenderingMode)key.renderMode); |
|
1330 HbIconFormatType type = getIconFormatType(format); |
|
1331 if (rm == key.renderMode) { |
|
1332 cacheItem = iServer->iconCacheItem(key); |
|
1333 } else if (rm != key.renderMode) { |
|
1334 HbIconKey newKey(key); |
|
1335 newKey.renderMode = rm; |
|
1336 cacheItem = iServer->iconCacheItem(newKey); |
|
1337 if (cacheItem) { |
|
1338 key.renderMode = rm; |
|
1339 } |
|
1340 } |
|
1341 |
|
1342 if (!cacheItem) { |
|
1343 // try search for icon in software mode if the icon is not of type nvg |
|
1344 // currently only nvg type is used to create RSgImage. |
|
1345 // If hardware icon is not found and there is not space to create a hardware |
|
1346 // icon, search for the icon in software mode. |
|
1347 int itemGpuCost = HbThemeServerUtils::computeGpuCost(key, type, isConsolidatedIcon ); |
|
1348 if (format != HbIconCacheItemCreator::KNvg || |
|
1349 (rm == EHWRendering && !iServer->isItemCacheableinGpu(itemGpuCost, type)) ) { |
|
1350 HbIconKey newKey(key); |
|
1351 newKey.renderMode = ESWRendering; |
|
1352 cacheItem = iServer->iconCacheItem(newKey); |
|
1353 if (cacheItem) { |
|
1354 key.renderMode = ESWRendering; |
|
1355 } |
|
1356 } |
|
1357 |
|
1358 } |
|
1359 |
|
1360 return cacheItem; |
|
1361 } |
|
1362 |
1301 /** |
1363 /** |
1302 * HbThemeServerPrivate::IconInfoFromSingleIcon |
1364 * HbThemeServerPrivate::IconInfoFromSingleIcon |
1303 Checks for the cacheItem for a given key, if found gets the data relevant of the cacheItem. |
1365 Checks for the cacheItem for a given key, if found gets the data relevant of the cacheItem. |
1304 */ |
1366 */ |
1305 |
1367 |
1306 bool HbThemeServerSession::IconInfoFromSingleIcon(HbIconKey key, |
1368 bool HbThemeServerSession::IconInfoFromSingleIcon(HbIconKey key, |
1307 HbSharedIconInfo &stitchedData) |
1369 HbSharedIconInfo &stitchedData, const QString & format, bool isMultiPiece) |
1308 { |
1370 { |
1309 stitchedData.type = INVALID_FORMAT; |
1371 HbIconCacheItem* cacheItem = 0; |
1310 HbIconCacheItem * cacheItem = iServer->iconCacheItem(key, true); |
1372 |
|
1373 // try to find the icon in other rendering mode, |
|
1374 // if rendering will take place in another rendering mode |
|
1375 HbRenderingMode rm = iServer->expectedRenderingMode((HbRenderingMode)key.renderMode); |
|
1376 HbIconFormatType type = getIconFormatType(format); |
|
1377 bool consolidatedIcon = !isMultiPiece; |
|
1378 if (rm == key.renderMode) { |
|
1379 cacheItem = iServer->iconCacheItem(key, true); |
|
1380 } else if (rm != key.renderMode) { |
|
1381 HbIconKey newKey(key); |
|
1382 newKey.renderMode = rm; |
|
1383 cacheItem = iServer->iconCacheItem(newKey, true); |
|
1384 if (cacheItem) { |
|
1385 key.renderMode = rm; |
|
1386 } |
|
1387 } |
|
1388 |
|
1389 if (!cacheItem) { |
|
1390 if (!format.isEmpty()) { |
|
1391 int gpuItemCost = 0; |
|
1392 // only consolidated icon ican be cached in GPU |
|
1393 if (consolidatedIcon) { |
|
1394 gpuItemCost = HbThemeServerUtils::computeGpuCost(key, type, consolidatedIcon); |
|
1395 } |
|
1396 |
|
1397 // try search for icon in software mode if the icon is not of type nvg |
|
1398 // currently only nvg type is used to create RSgImage |
|
1399 if ((format != HbIconCacheItemCreator::KNvg) || |
|
1400 (rm == EHWRendering && !iServer->isItemCacheableinGpu(gpuItemCost, type) && |
|
1401 !isMultiPiece)) { |
|
1402 HbIconKey newKey(key); |
|
1403 newKey.renderMode = ESWRendering; |
|
1404 cacheItem = iServer->iconCacheItem(newKey); |
|
1405 if (cacheItem) { |
|
1406 key.renderMode = ESWRendering; |
|
1407 } |
|
1408 } |
|
1409 } |
|
1410 } |
|
1411 |
1311 if (cacheItem) { |
1412 if (cacheItem) { |
1312 GetDataFromCacheItem(cacheItem, stitchedData); |
1413 GetDataFromCacheItem(cacheItem, stitchedData); |
1313 return true; //The item was found in the cache and ref count was incremented |
1414 return true; //The item was found in the cache and ref count was incremented |
1314 } |
1415 } |
1315 return false; |
1416 return false; |
1324 bool HbThemeServerSession::CreateCacheItemData(HbIconKey key, int options , HbSharedIconInfo &data, bool isMultiIcon) |
1425 bool HbThemeServerSession::CreateCacheItemData(HbIconKey key, int options , HbSharedIconInfo &data, bool isMultiIcon) |
1325 { |
1426 { |
1326 bool insertKeyIntoSessionList = false; |
1427 bool insertKeyIntoSessionList = false; |
1327 data.type = INVALID_FORMAT; |
1428 data.type = INVALID_FORMAT; |
1328 QString format = HbThemeServerUtils::formatFromPath(key.filename); |
1429 QString format = HbThemeServerUtils::formatFromPath(key.filename); |
1329 HbIconCacheItem * cacheItemOfPiece = iServer->iconCacheItem(key, isMultiIcon); |
1430 HbIconFormatType type = getIconFormatType(format); |
1330 if (cacheItemOfPiece) { |
1431 HbIconCacheItem * cacheItemOfPiece = 0; |
1331 GetDataFromCacheItem(cacheItemOfPiece, data); |
1432 HbRenderingMode rm = iServer->expectedRenderingMode((HbRenderingMode)key.renderMode); |
1332 insertKeyIntoSessionList = true; |
1433 int cpuItemCost = HbThemeServerUtils::computeFrameItemCpuCost(key, type, rm); |
1333 } else { |
1434 |
|
1435 if (iServer->isItemCacheableinCpu(cpuItemCost, type)) { |
1334 cacheItemOfPiece = HbIconCacheItemCreator::createCacheItem(key, |
1436 cacheItemOfPiece = HbIconCacheItemCreator::createCacheItem(key, |
1335 (HbIconLoader::IconLoaderOptions)options, |
1437 (HbIconLoader::IconLoaderOptions)options, |
1336 format, |
1438 format, |
1337 iServer->currentRenderingMode(), |
1439 rm, |
1338 isMultiIcon); |
1440 isMultiIcon); |
1339 if (cacheItemOfPiece) { |
1441 if (cacheItemOfPiece) { |
1340 GetDataFromCacheItem(cacheItemOfPiece, data); |
1442 GetDataFromCacheItem(cacheItemOfPiece, data); |
1341 if (data.type != INVALID_FORMAT) { |
1443 if (data.type != INVALID_FORMAT) { |
|
1444 // set the rendering mode according to the actual rendering mode |
|
1445 // in which the icon is created |
|
1446 key.renderMode = cacheItemOfPiece->renderingMode(); |
1342 insertKeyIntoSessionList = iServer->insertIconCacheItem(key, cacheItemOfPiece); |
1447 insertKeyIntoSessionList = iServer->insertIconCacheItem(key, cacheItemOfPiece); |
1343 if (!insertKeyIntoSessionList) { |
1448 if (!insertKeyIntoSessionList) { |
1344 //if insertion failed free the memory |
1449 //if insertion failed free the memory |
1345 FreeDataFromCacheItem(cacheItemOfPiece); |
1450 FreeDataFromCacheItem(cacheItemOfPiece); |
1346 delete cacheItemOfPiece; // do delete the item after gpu/cpu memory is freed |
1451 delete cacheItemOfPiece; // do delete the item after gpu/cpu memory is freed |
1364 bool allNvg) |
1469 bool allNvg) |
1365 { |
1470 { |
1366 bool insertKeyIntoSessionList = false; |
1471 bool insertKeyIntoSessionList = false; |
1367 stitchedData.type = INVALID_FORMAT; |
1472 stitchedData.type = INVALID_FORMAT; |
1368 QString format = HbThemeServerUtils::formatFromPath(params.multiPartIconList[0]); |
1473 QString format = HbThemeServerUtils::formatFromPath(params.multiPartIconList[0]); |
1369 |
1474 HbIconFormatType type = getIconFormatType(format); |
1370 QScopedPointer<HbIconCacheItem> tempCacheItem(HbIconCacheItemCreator::createMultiPieceCacheItem(finalIconKey, |
1475 QScopedPointer <HbIconCacheItem> tempCacheItem; |
1371 (HbIconLoader::IconLoaderOptions)params.options, |
1476 |
1372 format, dataForParts, params, allNvg, |
1477 int gpuItemCost = HbThemeServerUtils::computeGpuCost(finalIconKey, type, true); |
1373 iServer->currentRenderingMode())); |
1478 |
|
1479 HbRenderingMode rm = iServer->expectedRenderingMode((HbRenderingMode)finalIconKey.renderMode); |
|
1480 |
|
1481 // A consolidated hardware icon (SGImage) is only created when icon format is NVG, |
|
1482 // when both client and ThemeServer is in HW rendering mode and |
|
1483 // there is enough GPU space to create anew HW icon |
|
1484 |
|
1485 if (rm == EHWRendering && format == HbIconCacheItemCreator::KNvg && |
|
1486 iServer->isItemCacheableinGpu(gpuItemCost, type)) { |
|
1487 tempCacheItem.reset(HbIconCacheItemCreator::createMultiPieceCacheItem(finalIconKey, |
|
1488 (HbIconLoader::IconLoaderOptions)params.options, format, dataForParts, |
|
1489 params, allNvg, EHWRendering)); |
|
1490 } |
|
1491 else { |
|
1492 int cpuItemCost = HbThemeServerUtils::computeCpuCost(finalIconKey, type, true); |
|
1493 if (iServer->isItemCacheableinCpu(cpuItemCost, type)) { |
|
1494 tempCacheItem.reset(HbIconCacheItemCreator::createMultiPieceCacheItem(finalIconKey, |
|
1495 (HbIconLoader::IconLoaderOptions)params.options, format, dataForParts, |
|
1496 params, allNvg, ESWRendering)); |
|
1497 } |
|
1498 } |
1374 HbIconCacheItem * cacheItem = tempCacheItem.data(); |
1499 HbIconCacheItem * cacheItem = tempCacheItem.data(); |
1375 if (cacheItem) { |
1500 if (cacheItem) { |
1376 if (cacheItem->rasterIconData.type == INVALID_FORMAT) { |
1501 if (cacheItem->rasterIconData.type == INVALID_FORMAT) { |
1377 return false; |
1502 return false; |
1378 } |
1503 } |
1380 return false; |
1505 return false; |
1381 } |
1506 } |
1382 |
1507 |
1383 stitchedData = cacheItem->rasterIconData; |
1508 stitchedData = cacheItem->rasterIconData; |
1384 if (stitchedData.type != INVALID_FORMAT) { |
1509 if (stitchedData.type != INVALID_FORMAT) { |
|
1510 finalIconKey.renderMode = cacheItem->renderingMode(); |
1385 insertKeyIntoSessionList = iServer->insertIconCacheItem(finalIconKey, cacheItem); |
1511 insertKeyIntoSessionList = iServer->insertIconCacheItem(finalIconKey, cacheItem); |
1386 if (!insertKeyIntoSessionList) { |
1512 if (!insertKeyIntoSessionList) { |
1387 //if insertion failed free the memory |
1513 //if insertion failed free the memory |
1388 FreeDataFromCacheItem(cacheItem); |
1514 FreeDataFromCacheItem(cacheItem); |
1389 tempCacheItem.take(); |
1515 tempCacheItem.take(); |
1390 delete cacheItem; // do delete the item after gpu/cpu memory is freed |
1516 delete cacheItem; // do delete the item after gpu/cpu memory is freed |
1391 stitchedData.type = INVALID_FORMAT; |
1517 stitchedData.type = INVALID_FORMAT; |
1392 } |
1518 } |
1393 } |
1519 } |
|
1520 #ifdef HB_SGIMAGE_ICON |
|
1521 HbSgImageRenderer *sgImg = HbSgImageRenderer::global(); |
|
1522 if (sgImg->lastError() == KErrNoGraphicsMemory ) { |
|
1523 iServer->freeGpuRam(); |
|
1524 } |
|
1525 #endif |
1394 if (tempCacheItem.data()) { |
1526 if (tempCacheItem.data()) { |
1395 tempCacheItem.take(); |
1527 tempCacheItem.take(); |
1396 } |
1528 } |
1397 return insertKeyIntoSessionList; |
1529 return insertKeyIntoSessionList; |
1398 } |
1530 } |
1421 HbSharedIconInfo data; |
1553 HbSharedIconInfo data; |
1422 bool iconPieceMirrored = false; |
1554 bool iconPieceMirrored = false; |
1423 HbIconKey key(frameItemParams.multiPartIconList.at(i), frameItemParams.multiPartIconData.pixmapSizes[i], |
1555 HbIconKey key(frameItemParams.multiPartIconList.at(i), frameItemParams.multiPartIconData.pixmapSizes[i], |
1424 (Qt::AspectRatioMode)stichedKey.aspectRatioMode, (QIcon::Mode)stichedKey.mode, iconPieceMirrored, |
1556 (Qt::AspectRatioMode)stichedKey.aspectRatioMode, (QIcon::Mode)stichedKey.mode, iconPieceMirrored, |
1425 stichedKey.color,(HbRenderingMode)frameItemParams.renderMode); |
1557 stichedKey.color,(HbRenderingMode)frameItemParams.renderMode); |
1426 insertKeyIntoSessionList = IconInfoFromSingleIcon(key, data); |
1558 QString format = HbThemeServerUtils::formatFromPath(key.filename); |
|
1559 insertKeyIntoSessionList = IconInfoFromSingleIcon(key, data, format, true ); |
1427 if (!insertKeyIntoSessionList) { |
1560 if (!insertKeyIntoSessionList) { |
1428 insertKeyIntoSessionList = CreateCacheItemData(key, frameItemParams.options, data, true); |
1561 insertKeyIntoSessionList = CreateCacheItemData(key, frameItemParams.options, data, true); |
1429 } |
1562 } |
1430 if ((data.type == INVALID_FORMAT) || (!insertKeyIntoSessionList)) { |
1563 if ((data.type == INVALID_FORMAT) || (!insertKeyIntoSessionList)) { |
1431 failedToCreateParts = true; |
1564 failedToCreateParts = true; |
1615 HbSharedIconInfo data; |
1753 HbSharedIconInfo data; |
1616 QString pieceName((QChar*)frameItemParams.iconList[i].Ptr(), frameItemParams.iconList[i].Length()); |
1754 QString pieceName((QChar*)frameItemParams.iconList[i].Ptr(), frameItemParams.iconList[i].Length()); |
1617 HbIconKey key(pieceName, frameItemParams.sizeList[i], |
1755 HbIconKey key(pieceName, frameItemParams.sizeList[i], |
1618 (Qt::AspectRatioMode)frameItemParams.aspectRatioMode, (QIcon::Mode)frameItemParams.mode, |
1756 (Qt::AspectRatioMode)frameItemParams.aspectRatioMode, (QIcon::Mode)frameItemParams.mode, |
1619 (bool)frameItemParams.mirrored, color, (HbRenderingMode)frameItemParams.renderMode); |
1757 (bool)frameItemParams.mirrored, color, (HbRenderingMode)frameItemParams.renderMode); |
1620 insertKeyIntoSessionList = IconInfoFromSingleIcon(key, data); |
1758 QString format = HbThemeServerUtils::formatFromPath(key.filename); |
|
1759 insertKeyIntoSessionList = IconInfoFromSingleIcon(key, data, format, true ); |
1621 if (!insertKeyIntoSessionList) { |
1760 if (!insertKeyIntoSessionList) { |
1622 insertKeyIntoSessionList = CreateCacheItemData(key, 0, data, false); |
1761 insertKeyIntoSessionList = CreateCacheItemData(key, 0, data, false); |
1623 } |
1762 } |
1624 if ((data.type != INVALID_FORMAT) || (insertKeyIntoSessionList)) { |
1763 if ((data.type != INVALID_FORMAT) || (insertKeyIntoSessionList)) { |
1625 //The session will only keep track of icons that were either successfully found or were |
1764 //The session will only keep track of icons that were either successfully found or were |
1655 TPckg<HbTypefaceDataInfo> data(offsetInfo); |
1794 TPckg<HbTypefaceDataInfo> data(offsetInfo); |
1656 aMessage.WriteL(0, data); |
1795 aMessage.WriteL(0, data); |
1657 } |
1796 } |
1658 |
1797 |
1659 |
1798 |
1660 void HbThemeServerSession::unLoadIcon(const RMessage2& aMessage) |
1799 void HbThemeServerSession::performUnload(const TIconParams ¶ms) |
1661 { |
1800 { |
1662 TIconParams params = ReadMessageAndRetrieveParams(aMessage); |
1801 QString filename((QChar*) params.fileName.Ptr(), params.fileName.Length()); |
1663 QString filename((QChar*)params.fileName.Ptr(), params.fileName.Length()); |
1802 HbIconKey key(filename, |
1664 QColor color = GetColorFromRgba(params.rgba, params.colorflag); |
1803 QSizeF(params.width, params.height), |
1665 HbIconKey key(filename, QSizeF(params.width, params.height), |
1804 (Qt::AspectRatioMode) params.aspectRatioMode, |
1666 (Qt::AspectRatioMode)params.aspectRatioMode, |
1805 (QIcon::Mode) params.mode, |
1667 (QIcon::Mode)params.mode, params.mirrored, color, (HbRenderingMode)params.renderMode); |
1806 params.mirrored, |
|
1807 GetColorFromRgba(params.rgba, params.colorflag), |
|
1808 (HbRenderingMode) params.renderMode); |
1668 iServer->CleanupSessionIconItem(key); |
1809 iServer->CleanupSessionIconItem(key); |
1669 sessionData.removeOne(key); |
1810 sessionData.removeOne(key); |
1670 } |
1811 } |
1671 |
1812 |
|
1813 void HbThemeServerSession::unLoadIcon(const RMessage2& aMessage) |
|
1814 { |
|
1815 TIconParams params = ReadMessageAndRetrieveParams(aMessage); |
|
1816 performUnload(params); |
|
1817 } |
|
1818 |
|
1819 void HbThemeServerSession::batchUnLoadIcon(const RMessage2& aMessage) |
|
1820 { |
|
1821 typedef TIconParams Params[BATCH_SIZE_LIMIT]; |
|
1822 Params paramList; |
|
1823 TPckg<Params> paramsPckg(paramList); |
|
1824 aMessage.ReadL(0, paramsPckg); |
|
1825 for (int i = 0; i < BATCH_SIZE_LIMIT; ++i) { |
|
1826 const TIconParams ¶ms(paramList[i]); |
|
1827 if (params.fileName.Length()) { |
|
1828 performUnload(params); |
|
1829 } |
|
1830 } |
|
1831 } |
|
1832 |
1672 void HbThemeServerSession::unloadMultiIcon(const RMessage2& aMessage) |
1833 void HbThemeServerSession::unloadMultiIcon(const RMessage2& aMessage) |
1673 { |
1834 { |
1674 TIconListParams params; |
1835 TIconListParams params; |
1675 |
|
1676 TInt deslen = aMessage.GetDesLength(0); |
|
1677 TPckg<TIconListParams> paramPckg(params); |
1836 TPckg<TIconListParams> paramPckg(params); |
1678 // Copy the client's descriptor data into our buffer. |
1837 // Copy the client's descriptor data into our buffer. |
1679 aMessage.ReadL(0, paramPckg, 0); |
1838 aMessage.ReadL(0, paramPckg, 0); |
1680 |
1839 |
1681 QColor color = GetColorFromRgba(params.rgba, params.colorflag); |
1840 QColor color = GetColorFromRgba(params.rgba, params.colorflag); |
1717 } |
1876 } |
1718 #endif |
1877 #endif |
1719 } |
1878 } |
1720 |
1879 |
1721 /** |
1880 /** |
|
1881 freeIconResources - unloads all the resources in the session |
|
1882 |
|
1883 Iterates all the keys in sessionData and then CleanUpSessionIConItem is called |
|
1884 on that item, which will do the cleanup based on the reference count. |
|
1885 */ |
|
1886 void HbThemeServerSession::freeIconResources() |
|
1887 { |
|
1888 QList<HbIconKey> tempSessionData(sessionData); |
|
1889 QList<HbIconKey>::const_iterator itEnd( tempSessionData.constEnd() ); |
|
1890 for ( QList<HbIconKey>::const_iterator iter = tempSessionData.constBegin(); |
|
1891 iter != itEnd; |
|
1892 ++iter ) { |
|
1893 |
|
1894 iServer->CleanupSessionIconItem(*iter); |
|
1895 // remove the item in the session data. |
|
1896 sessionData.removeOne(*iter); |
|
1897 |
|
1898 } |
|
1899 } |
|
1900 |
|
1901 |
|
1902 |
|
1903 |
|
1904 /** |
1722 * HbThemeServerSession::ClearSessionData |
1905 * HbThemeServerSession::ClearSessionData |
1723 * |
1906 * |
1724 * Clears the session data list. Items in the server should be deleted before clearing. |
1907 * Clears the session data list. Items in the server should be deleted before clearing. |
1725 */ |
1908 */ |
1726 void HbThemeServerSession::ClearSessionData() |
1909 void HbThemeServerSession::ClearSessionData() |