80 \fn HbIconCacheItemCreator::createCacheItem() |
80 \fn HbIconCacheItemCreator::createCacheItem() |
81 The createCacheItem is responsible for creating an icon in cpu or gpu memory based on the format provided |
81 The createCacheItem is responsible for creating an icon in cpu or gpu memory based on the format provided |
82 \a key denotes the unique identifier for the cache item |
82 \a key denotes the unique identifier for the cache item |
83 \a options indicate different ways of loading icons |
83 \a options indicate different ways of loading icons |
84 \a format indicates the icon format e.g. svg/nvg etc.\ |
84 \a format indicates the icon format e.g. svg/nvg etc.\ |
85 \a gpuMemoryStatus indicates the global GPU memory status (GoodMemory state or FreeRAM state) |
85 \a currentRenderingMode ThemeServer's current rendering mode state. |
86 */ |
86 */ |
87 HbIconCacheItem* HbIconCacheItemCreator::createCacheItem(const HbIconKey &key, |
87 HbIconCacheItem* HbIconCacheItemCreator::createCacheItem(const HbIconKey &key, |
88 HbIconLoader::IconLoaderOptions options, |
88 HbIconLoader::IconLoaderOptions options, |
89 const QString &format, |
89 const QString &format, |
|
90 HbRenderingMode currentRenderingMode, |
90 bool isMultiPiece) |
91 bool isMultiPiece) |
91 { |
92 { |
92 #ifndef Q_OS_SYMBIAN |
93 #ifndef Q_OS_SYMBIAN |
93 Q_UNUSED(isMultiPiece) |
94 Q_UNUSED(isMultiPiece) |
|
95 Q_UNUSED(currentRenderingMode) |
94 #endif |
96 #endif |
95 QScopedPointer <HbIconCacheItem> tempIconCacheItem(new HbIconCacheItem); |
97 QScopedPointer <HbIconCacheItem> tempIconCacheItem(new HbIconCacheItem); |
96 HbIconCacheItem* item = tempIconCacheItem.data(); |
98 HbIconCacheItem* item = tempIconCacheItem.data(); |
97 QScopedPointer <HbIconProcessor> rasterIcon; |
99 QScopedPointer <HbIconProcessor> rasterIcon; |
98 QScopedPointer <HbIconProcessor> vectorIcon; |
100 QScopedPointer <HbIconProcessor> vectorIcon; |
|
101 |
|
102 // Set the render mode to EHWRendering, only if the client is requesting a HW rendered icon |
|
103 // and ThemeServer is in HW rendering mode |
|
104 HbRenderingMode renderMode = ESWRendering; |
|
105 #ifndef Q_OS_SYMBIAN |
|
106 Q_UNUSED(renderMode) |
|
107 #endif |
|
108 |
|
109 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
|
110 if((key.renderMode == EHWRendering) && (currentRenderingMode == EHWRendering)) { |
|
111 renderMode = EHWRendering; |
|
112 } |
|
113 #endif |
99 bool isIconCreated = false; |
114 bool isIconCreated = false; |
100 |
115 |
101 if ((format == KSvg) || (format == KPic)) { |
116 if ((format == KSvg) || (format == KPic)) { |
102 |
|
103 #ifdef HB_NVG_TLV_ICON |
|
104 rasterIcon.reset(new HbNvgIconProcessor(key, options, format)); |
|
105 vectorIcon.reset(new HbNvgIconProcessor(key, options, format)); |
|
106 #else |
|
107 rasterIcon.reset(new HbPixmapIconProcessor(key, options, format)); |
117 rasterIcon.reset(new HbPixmapIconProcessor(key, options, format)); |
108 #endif |
118 |
109 |
|
110 #ifdef SVG_INTERMEDIATE_PIC |
119 #ifdef SVG_INTERMEDIATE_PIC |
111 vectorIcon.reset(new HbPicIconProcessor(key, options, format)); |
120 vectorIcon.reset(new HbPicIconProcessor(key, options, format)); |
112 #endif |
121 #endif |
113 } else if (format == KNvg) { |
122 } else if (format == KNvg) { |
114 #ifdef HB_NVG_CS_ICON |
123 #ifdef HB_NVG_CS_ICON |
115 if (!isMultiPiece) { |
124 if (!isMultiPiece) { |
116 #ifdef HB_SGIMAGE_ICON |
125 #ifdef HB_SGIMAGE_ICON |
117 if (HbThemeServerPrivate::gpuMemoryState()) { |
126 if(renderMode == ESWRendering){ |
118 rasterIcon.reset(new HbSgimageIconProcessor(key, options, format)); |
127 rasterIcon.reset(new HbPixmapIconProcessor( key, options, format)); |
119 } |
128 }else { |
120 #endif |
129 if (HbThemeServerPrivate::gpuMemoryState()) { |
121 vectorIcon.reset(new HbNvgIconProcessor(key, options, format)); |
130 rasterIcon.reset(new HbSgimageIconProcessor( key, options, format)); |
122 } else { |
131 } |
123 // multipieceIcon So make nvgiconimpl for .nvg files |
132 vectorIcon.reset(new HbNvgIconProcessor( key, options, format )); |
124 // No raster icon data is created |
133 } |
125 vectorIcon.reset(new HbNvgIconProcessor(key, options, format)); |
134 #endif |
|
135 |
|
136 // if sgImage support is enabled by default remove this block |
|
137 #ifndef HB_SGIMAGE_ICON |
|
138 if(renderMode == ESWRendering){ |
|
139 rasterIcon.reset(new HbPixmapIconProcessor( key, options, format)); |
|
140 } else { |
|
141 vectorIcon.reset(new HbNvgIconProcessor( key, options, format )); |
|
142 } |
|
143 #endif |
|
144 // block end |
|
145 } |
|
146 else { |
|
147 if(renderMode == ESWRendering){ |
|
148 rasterIcon.reset(new HbPixmapIconProcessor( key, options, format)); |
|
149 } else { |
|
150 // multipieceIcon So make nvgiconimpl for .nvg files |
|
151 // No raster icon data is created |
|
152 vectorIcon.reset(new HbNvgIconProcessor( key, options, format )); |
|
153 } |
126 } |
154 } |
127 #endif |
155 #endif |
128 } else if (format == KBlob) { |
156 } else if (format == KBlob) { |
129 item->blobIconData.type = BLOB; |
157 item->blobIconData.type = BLOB; |
130 QFile f(key.filename); |
158 QFile f(key.filename); |
184 \fn HbIconCacheItemCreator::createCacheItem() |
212 \fn HbIconCacheItemCreator::createCacheItem() |
185 This overloaded createCacheItem is a helper function to populate a cache item if this item is already |
213 This overloaded createCacheItem is a helper function to populate a cache item if this item is already |
186 created with some parameters either on the Gpu or the Cpu |
214 created with some parameters either on the Gpu or the Cpu |
187 \a iconCacheItem denotes the cacheItem to be populated |
215 \a iconCacheItem denotes the cacheItem to be populated |
188 \a key unique identifier to identify the cache item |
216 \a key unique identifier to identify the cache item |
|
217 \a currentRenderingMode ThemeServer's current rendering mode state |
189 |
218 |
190 */ |
219 */ |
191 void HbIconCacheItemCreator::createCacheItem(HbIconCacheItem& iconCacheItem, |
220 void HbIconCacheItemCreator::createCacheItem(HbIconCacheItem& iconCacheItem, |
192 const HbIconKey &key) |
221 const HbIconKey &key, |
|
222 HbRenderingMode currentRenderingMode) |
193 { |
223 { |
|
224 #ifndef Q_OS_SYMBIAN |
|
225 Q_UNUSED(currentRenderingMode) |
|
226 #endif |
194 QScopedPointer <HbIconProcessor> rasterIcon; |
227 QScopedPointer <HbIconProcessor> rasterIcon; |
195 QScopedPointer <HbIconProcessor> vectorIcon; |
228 QScopedPointer <HbIconProcessor> vectorIcon; |
|
229 |
|
230 // Set the render mode to EHWRendering, only if the client is requesting a HW rendered icon |
|
231 // and ThemeServer is in HW rendering mode |
|
232 HbRenderingMode renderMode = ESWRendering; |
|
233 #ifndef Q_OS_SYMBIAN |
|
234 Q_UNUSED(renderMode) |
|
235 #endif |
|
236 |
|
237 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
|
238 if((key.renderMode == EHWRendering) && (currentRenderingMode == EHWRendering)) { |
|
239 renderMode = EHWRendering; |
|
240 } |
|
241 #endif |
196 bool isIconCreated = false; |
242 bool isIconCreated = false; |
197 QString format = HbThemeServerUtils::formatFromPath(key.filename); |
243 QString format = HbThemeServerUtils::formatFromPath(key.filename); |
198 |
244 |
199 // If the item is already created on the CPU side but not on the GPU side |
245 // If the item is already created on the CPU side but not on the GPU side |
200 if (iconCacheItem.rasterIconData.type == INVALID_FORMAT && |
246 if (iconCacheItem.rasterIconData.type == INVALID_FORMAT && |
202 if ((format == KSvg) || (format == KPic)) { |
248 if ((format == KSvg) || (format == KPic)) { |
203 rasterIcon.reset(new HbPixmapIconProcessor(key, iconCacheItem.iconOptions, format)); |
249 rasterIcon.reset(new HbPixmapIconProcessor(key, iconCacheItem.iconOptions, format)); |
204 } |
250 } |
205 if (format == KNvg) { |
251 if (format == KNvg) { |
206 #ifdef HB_SGIMAGE_ICON |
252 #ifdef HB_SGIMAGE_ICON |
207 if (HbThemeServerPrivate::gpuMemoryState()) { |
253 if(renderMode == EHWRendering){ |
208 rasterIcon.reset(new HbSgimageIconProcessor(key, iconCacheItem.iconOptions, format)); |
254 if (HbThemeServerPrivate::gpuMemoryState()){ |
|
255 rasterIcon.reset(new HbSgimageIconProcessor( key, iconCacheItem.iconOptions, format)); |
|
256 } |
|
257 }else { |
|
258 rasterIcon.reset(new HbPixmapIconProcessor( key, iconCacheItem.iconOptions, format)); |
209 } |
259 } |
210 #endif |
260 #endif |
211 #ifdef NVG_ICON |
261 #ifdef NVG_ICON |
212 rasterIcon.reset(new HbPixmapIconProcessor(key, options, format)); |
262 rasterIcon.reset(new HbPixmapIconProcessor(key, options, format)); |
213 #endif |
263 #endif |
248 const HbIconKey &finalIconKey, |
298 const HbIconKey &finalIconKey, |
249 HbIconLoader::IconLoaderOptions options, |
299 HbIconLoader::IconLoaderOptions options, |
250 const QString &format, |
300 const QString &format, |
251 const QVector<HbSharedIconInfo> &multiPieceIconInfo, |
301 const QVector<HbSharedIconInfo> &multiPieceIconInfo, |
252 HbMultiIconParams &multiPieceIconParams, |
302 HbMultiIconParams &multiPieceIconParams, |
253 bool allNvg) |
303 bool allNvg, |
|
304 HbRenderingMode currentRenderingMode) |
254 { |
305 { |
255 |
306 |
|
307 #ifndef Q_OS_SYMBIAN |
|
308 Q_UNUSED(currentRenderingMode) |
|
309 #endif |
|
310 |
256 HbIconCacheItem* item = 0; |
311 HbIconCacheItem* item = 0; |
257 QScopedPointer <HbIconCacheItem> tempIconCacheItem; |
312 QScopedPointer <HbIconCacheItem> tempIconCacheItem; |
258 bool isIconCreated = false; |
313 bool isIconCreated = false; |
259 QScopedPointer<HbIconProcessor> rasterIcon; |
314 QScopedPointer<HbIconProcessor> rasterIcon; |
260 |
315 |
|
316 // Set the render mode to EHWRendering, only if the client is requesting a HW rendered icon |
|
317 // and ThemeServer is in HW rendering mode |
|
318 HbRenderingMode renderMode = ESWRendering; |
|
319 #ifndef Q_OS_SYMBIAN |
|
320 Q_UNUSED(renderMode) |
|
321 #endif |
|
322 |
|
323 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON) |
|
324 if((finalIconKey.renderMode == EHWRendering) && (currentRenderingMode == EHWRendering)) { |
|
325 renderMode = EHWRendering; |
|
326 } |
|
327 #endif |
261 if (allNvg) { |
328 if (allNvg) { |
262 #ifdef HB_SGIMAGE_ICON |
329 #ifdef HB_SGIMAGE_ICON |
263 if (HbThemeServerPrivate::gpuMemoryState()) { |
330 if(renderMode == EHWRendering){ |
264 rasterIcon.reset(new HbSgimageIconProcessor( |
331 if (HbThemeServerPrivate::gpuMemoryState()) { |
265 finalIconKey, |
332 rasterIcon.reset(new HbSgimageIconProcessor( |
266 (HbIconLoader::IconLoaderOptions)multiPieceIconParams.options, |
333 finalIconKey, |
267 KSgimage)); |
334 (HbIconLoader::IconLoaderOptions)multiPieceIconParams.options, |
|
335 KSgimage)); |
|
336 } |
|
337 |
|
338 } else { |
|
339 rasterIcon.reset(new HbPixmapIconProcessor( |
|
340 finalIconKey, |
|
341 (HbIconLoader::IconLoaderOptions)multiPieceIconParams.options, |
|
342 KNvg)); |
268 } |
343 } |
269 #else |
344 #else |
270 return item; |
345 return item; |
271 #endif |
346 #endif |
272 } else { |
347 } else { |