summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-08-03 04:02:47 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-08-03 04:02:47 (GMT)
commit6b2a5c6f18cb766801a50db583e14a8e559e9bfb (patch)
tree7ed719f4539ecb0a634dad714105c70819683810 /src
parent30e55019f3ddf9d0df82df68c6324c96904fdc3a (diff)
parente62f266a7642e675e9d235a1f54a6b5746500d48 (diff)
downloadQt-6b2a5c6f18cb766801a50db583e14a8e559e9bfb.zip
Qt-6b2a5c6f18cb766801a50db583e14a8e559e9bfb.tar.gz
Qt-6b2a5c6f18cb766801a50db583e14a8e559e9bfb.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Make it possible to manually set the orientation of QML Viewer on Symbian Limit the pixmap cache in space as well as in time.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index a83cac8..9ced14f 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -70,6 +70,16 @@
QT_BEGIN_NAMESPACE
+// The cache limit describes the maximum "junk" in the cache.
+// These are the same defaults as QPixmapCache
+#if defined(Q_OS_SYMBIAN)
+static int cache_limit = 1024 * 1024; // 1048 KB cache limit for symbian
+#elif defined(Q_WS_QWS) || defined(Q_WS_WINCE)
+static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded
+#else
+static int cache_limit = 10240 * 1024; // 10 MB cache limit for desktop
+#endif
+
class QDeclarativePixmapReader;
class QDeclarativePixmapData;
class QDeclarativePixmapReply : public QObject
@@ -580,6 +590,8 @@ public:
QHash<QDeclarativePixmapKey, QDeclarativePixmapData *> m_cache;
private:
+ void shrinkCache(int remove);
+
QDeclarativePixmapData *m_unreferencedPixmaps;
QDeclarativePixmapData *m_lastUnreferencedPixmap;
@@ -613,7 +625,9 @@ void QDeclarativePixmapStore::unreferencePixmap(QDeclarativePixmapData *data)
m_unreferencedCost += data->cost();
- if (m_timerId == -1)
+ shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit
+
+ if (m_timerId == -1 && m_unreferencedPixmaps)
m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000);
}
@@ -636,11 +650,9 @@ void QDeclarativePixmapStore::referencePixmap(QDeclarativePixmapData *data)
m_unreferencedCost -= data->cost();
}
-void QDeclarativePixmapStore::timerEvent(QTimerEvent *)
+void QDeclarativePixmapStore::shrinkCache(int remove)
{
- int removalCost = m_unreferencedCost / CACHE_REMOVAL_FRACTION;
-
- while (removalCost > 0 && m_lastUnreferencedPixmap) {
+ while ((remove > 0 || m_unreferencedCost > cache_limit) && m_lastUnreferencedPixmap) {
QDeclarativePixmapData *data = m_lastUnreferencedPixmap;
Q_ASSERT(data->nextUnreferenced == 0);
@@ -649,10 +661,17 @@ void QDeclarativePixmapStore::timerEvent(QTimerEvent *)
data->prevUnreferencedPtr = 0;
data->prevUnreferenced = 0;
- removalCost -= data->cost();
+ remove -= data->cost();
data->removeFromCache();
delete data;
}
+}
+
+void QDeclarativePixmapStore::timerEvent(QTimerEvent *)
+{
+ int removalCost = m_unreferencedCost / CACHE_REMOVAL_FRACTION;
+
+ shrinkCache(removalCost);
if (m_unreferencedPixmaps == 0) {
killTimer(m_timerId);
@@ -702,7 +721,7 @@ bool QDeclarativePixmapReply::event(QEvent *event)
int QDeclarativePixmapData::cost() const
{
- return pixmap.width() * pixmap.height() * pixmap.depth();
+ return (pixmap.width() * pixmap.height() * pixmap.depth()) / 8;
}
void QDeclarativePixmapData::addref()