--- a/src/hbcore/image/hbiconloader.cpp Tue Jul 06 14:36:53 2010 +0300
+++ b/src/hbcore/image/hbiconloader.cpp Wed Aug 18 10:05:37 2010 +0300
@@ -624,7 +624,7 @@
}
}
- foreach (const QString &suffix, suffixList) {
+ foreach(const QString & suffix, suffixList) {
bool dummy = false;
QString nameWithSuffix = iconName;
@@ -698,9 +698,10 @@
// directionality must be updated in the icon loader before that.
// Thus, there are these separate signals.
QList<HbMainWindow *> allWindows = hbInstance->allMainWindows();
- HbMainWindow *primaryWindow = allWindows.value(0);
-
- d->setLayoutMirrored(primaryWindow->layoutDirection() == Qt::RightToLeft);
+ if (allWindows.count()) {
+ HbMainWindow *primaryWindow = allWindows.value(0);
+ d->setLayoutMirrored(primaryWindow->layoutDirection() == Qt::RightToLeft);
+ }
}
void HbIconLoader::handleForegroundLost()
@@ -949,8 +950,9 @@
#endif
HbSharedIconInfo iconInfo;
iconInfo.type = INVALID_FORMAT;
+ HbThemeClient *themeClient = HbThemeClient::global();
//Initiate an IPC to themeserver to get the icon-data from the server via themeclient.
- iconInfo = HbThemeClient::global()->getSharedIconInfo(
+ iconInfo = themeClient->getSharedIconInfo(
params.iconFileName,
params.size,
params.aspectRatioMode,
@@ -967,6 +969,29 @@
//3. HbPixmapIconImpl
icon = HbIconImplCreator::createIconImpl(iconInfo, params);
+ if (icon && (icon->intialize() == HbIconImpl::ErrorLowGraphicsMemory)) {
+ // initialisation failed due to low graphics memory, in sgimage icon case
+ // try creating pixmap based icon
+
+ // unload the created GPU icon
+ unLoadIcon(icon);
+ icon = 0;
+
+ // create a pixmap based icon
+ iconInfo = themeClient->getSharedIconInfo(
+ params.iconFileName,
+ params.size,
+ params.aspectRatioMode,
+ params.mode,
+ (params.mirrored && !params.mirroredIconFound),
+ params.options,
+ params.color,
+ ESWRendering);
+
+ icon = HbIconImplCreator::createIconImpl(iconInfo, params);
+ // no need call initialize of this icon
+ }
+
#ifdef HB_ICON_TRACES
qDebug() << "Image from server: " << params.iconFileName << " offset = " << iconInfo.pixmapData.offset << "icon ptr" << (int) icon;
#endif
@@ -1386,7 +1411,24 @@
if (icon) {
#ifdef HB_ICONIMPL_CACHE
- iconImplCache.insert(cacheKey, icon);
+ if (params.renderMode != icon->iconRenderingMode()) {
+ cacheKey = d->createCacheKeyFrom(params.iconName,
+ params.size,
+ params.aspectRatioMode,
+ params.mode,
+ params.mirrored,
+ params.color,
+ icon->iconRenderingMode());
+ if (iconImplCache.contains(cacheKey)) {
+ HbIconImpl * oldIcon = iconImplCache.value(cacheKey);
+ this->unLoadIcon(icon);
+ icon->dispose();
+ icon = oldIcon;
+ icon->incrementRefCount();
+ }
+ } else {
+ iconImplCache.insert(cacheKey, icon);
+ }
#ifdef HB_ICON_CACHE_DEBUG
qDebug() << "HbIconLoader::loadIcon(): " << params.iconName << " inserted into impl-cache, ref-count now = " << icon->refCount();
#endif
@@ -1421,6 +1463,15 @@
}
}
+ if (params.color.isValid()) {
+ QPixmap &pm = params.canvasPixmap;
+ if (!pm.isNull()) {
+ QPixmap mask = pm.alphaChannel();
+ pm.fill(color);
+ pm.setAlphaChannel(mask);
+ }
+ }
+
if (!params.modeHandled) {
// Apply mode
if (mode != QIcon::Normal) {
@@ -1430,15 +1481,6 @@
}
}
- if ((params.color.isValid()) && (params.mode != QIcon::Disabled)) {
- QPixmap &pm = params.canvasPixmap;
- if (!pm.isNull()) {
- QPixmap mask = pm.alphaChannel();
- pm.fill(color);
- pm.setAlphaChannel(mask);
- }
- }
-
#ifdef HB_ICON_TRACES
qDebug() << "HbIconLoader::loadIcon END";
#endif
@@ -1548,7 +1590,24 @@
icon = HbIconImplCreator::createIconImpl(iconInfo, params);
if (icon) {
#ifdef HB_ICONIMPL_CACHE
- iconImplCache.insert(cacheKey, icon);
+ if (renderMode != icon->iconRenderingMode()) {
+ cacheKey = d->createCacheKeyFrom(params.iconName,
+ params.size,
+ params.aspectRatioMode,
+ params.mode,
+ params.mirrored,
+ params.color,
+ icon->iconRenderingMode());
+ if (iconImplCache.contains(cacheKey)) {
+ HbIconImpl * oldIcon = iconImplCache.value(cacheKey);
+ this->unLoadIcon(icon);
+ icon->dispose();
+ icon = oldIcon;
+ icon->incrementRefCount();
+ }
+ } else {
+ iconImplCache.insert(cacheKey, icon);
+ }
#ifdef HB_ICON_CACHE_DEBUG
qDebug() << "HbIconLoader::loadMultiPieceIcon(): " << params.iconName << " inserted into impl-cache, ref-count now = " << icon->refCount();
#endif
@@ -1730,21 +1789,29 @@
for (int i = 0; i < count; i++) {
- if (iconInfoList.icon[i].type != INVALID_FORMAT) {
+ impl = HbIconImplCreator::createIconImpl(iconInfoList.icon[i], params);
+ if (impl) {
params.iconFileName = multiPartIconList[i];
params.size = sizeList.at(i);
- impl = HbIconImplCreator::createIconImpl(iconInfoList.icon[i], params);
#ifdef HB_ICONIMPL_CACHE
- QByteArray cacheKey = d->createCacheKeyFrom(multiPartIconList[i],
- sizeList.at(i) ,
- aspectRatioMode,
- mode,
- mirrored,
- color,
- currRenderMode);
- iconImplCache.insert(cacheKey, impl);
+ QByteArray cacheKey = d->createCacheKeyFrom( multiPartIconList[i],
+ sizeList.at(i) ,
+ aspectRatioMode,
+ mode,
+ mirrored,
+ color,
+ impl->iconRenderingMode() );
+ if (iconImplCache.contains(cacheKey)) {
+ HbIconImpl * oldIcon = iconImplCache.value(cacheKey);
+ this->unLoadIcon(impl);
+ impl->dispose();
+ impl = oldIcon;
+ impl->incrementRefCount();
+ } else {
+ iconImplCache.insert(cacheKey, impl);
+ }
#ifdef HB_ICON_CACHE_DEBUG
qDebug() << "HbIconLoader::getMultiIconImplFromServer(): " << params.iconName << " inserted into impl-cache, ref-count now = " << impl->refCount();
#endif
@@ -1821,12 +1888,12 @@
{
Q_UNUSED(filename);
bool isPrivate = false;
-
+
#ifdef Q_OS_SYMBIAN
if (filename.length() > 11) {
// Private dir starts with e.g. "z:/private/"
if (filename[1] == ':' && (filename[2] == '/' || filename[2] == '\\') &&
- (filename[10] == '/' || filename[10] == '\\') && filename.mid(3, 7).compare("private"), Qt::CaseInsensitive) {
+ (filename[10] == '/' || filename[10] == '\\') && filename.mid(3, 7).compare("private"), Qt::CaseInsensitive) {
isPrivate = true;
}
}