diff options
author | mread <qt-info@nokia.com> | 2009-08-07 13:34:12 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2009-08-07 13:34:12 (GMT) |
commit | 5a72890b7ce12815f9567316da867006cff73f39 (patch) | |
tree | 46c8c793f19274f9ed19678d1732d2123adbdf34 /src/gui/image/qpixmapcache.cpp | |
parent | 0f6f1f841cea61cbb6905de92c2ca63bd369d55d (diff) | |
parent | cc0a411e5e874aa224c26298a109973cb15ea291 (diff) | |
download | Qt-5a72890b7ce12815f9567316da867006cff73f39.zip Qt-5a72890b7ce12815f9567316da867006cff73f39.tar.gz Qt-5a72890b7ce12815f9567316da867006cff73f39.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Conflicts fixed:
src/corelib/io/qdiriterator.cpp
Diffstat (limited to 'src/gui/image/qpixmapcache.cpp')
-rw-r--r-- | src/gui/image/qpixmapcache.cpp | 75 |
1 files changed, 43 insertions, 32 deletions
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index af13375..aedc90c 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -64,25 +64,24 @@ QT_BEGIN_NAMESPACE access the global pixmap cache. It creates an internal QCache object for caching the pixmaps. - The cache associates a pixmap with a string as a key or with a QPixmapCache::Key. - The QPixmapCache::Key is faster than using strings as key. The string API is - very convenient for complex keys but the QPixmapCache::Key API will be very efficient - and convenient for a 1 object <-> 1 pixmap mapping (then you can store the key as - a member). - If two pixmaps are inserted into the cache using equal keys, then the - last pixmap will hide the first pixmap. The QHash and QCache classes do - exactly the same. + The cache associates a pixmap with a user-provided string as a key, + or with a QPixmapCache::Key that the cache generates. + Using QPixmapCache::Key for keys is faster than using strings. The string API is + very convenient for complex keys but the QPixmapCache::Key API will be very + efficient and convenient for a one-to-one object-to-pixmap mapping \mdash in + this case, you can store the keys as members of an object. + + If two pixmaps are inserted into the cache using equal keys then the + last pixmap will replace the first pixmap in the cache. This follows the + behavior of the QHash and QCache classes. The cache becomes full when the total size of all pixmaps in the cache exceeds cacheLimit(). The initial cache limit is - 2048 KB(2 MB) for Embedded, 10240 KB (10 - MB) for Desktops; it is changed with setCacheLimit(). - A pixmap takes roughly (\e{width} * \e{height} * \e{depth})/8 bytes of memory. - - The \e{Qt Quarterly} article - \l{http://doc.trolltech.com/qq/qq12-qpixmapcache.html}{Optimizing - with QPixmapCache} explains how to use QPixmapCache to speed up - applications by caching the results of painting. + 2048 KB (2 MB) on embedded platforms, 10240 KB (10 MB) on desktop + platforms; you can change this by calling setCacheLimit() with the + required value. + A pixmap takes roughly (\e{width} * \e{height} * \e{depth})/8 bytes of + memory. \sa QCache, QPixmap */ @@ -96,6 +95,17 @@ static int cache_limit = 10240; // 10 MB cache limit for desktop #endif /*! + \class QPixmapCache::Key + \brief The QPixmapCache::Key class can be used for efficient access + to the QPixmapCache. + \since 4.6 + + Use QPixmapCache::insert() to receive an instance of Key generated + by the pixmap cache. You can store the key in your own objects for + a very efficient one-to-one object-to-pixmap mapping. +*/ + +/*! Constructs an empty Key object. */ QPixmapCache::Key::Key() : d(0) @@ -114,7 +124,7 @@ QPixmapCache::Key::Key(const Key &other) } /*! - Destructor; called immediately before the object is deleted. + Destroys the key. */ QPixmapCache::Key::~Key() { @@ -125,7 +135,8 @@ QPixmapCache::Key::~Key() /*! \internal - Returns true if this key is the same as the given \a key. + Returns true if this key is the same as the given \a key; otherwise returns + false. */ bool QPixmapCache::Key::operator ==(const Key &key) const { @@ -410,7 +421,7 @@ QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key) Q_GLOBAL_STATIC(QPMCache, pm_cache) /*! - \obsolete + \obsolete \overload Returns the pixmap associated with the \a key in the cache, or @@ -443,7 +454,7 @@ bool QPixmapCache::find(const QString &key, QPixmap& pixmap) } /*! - Looks for a cached pixmap associated with the \a key in the cache. + Looks for a cached pixmap associated with the given \a key in the cache. If the pixmap is found, the function sets \a pixmap to that pixmap and returns true; otherwise it leaves \a pixmap alone and returns false. @@ -462,10 +473,10 @@ bool QPixmapCache::find(const QString &key, QPixmap* pixmap) } /*! - Looks for a cached pixmap associated with the \a key in the cache. + Looks for a cached pixmap associated with the given \a key in the cache. If the pixmap is found, the function sets \a pixmap to that pixmap and returns true; otherwise it leaves \a pixmap alone and returns false. If - the pixmap is not found, it means that the \a key is not valid anymore, + the pixmap is not found, it means that the \a key is no longer valid, so it will be released for the next insertion. \since 4.6 @@ -507,8 +518,8 @@ bool QPixmapCache::insert(const QString &key, const QPixmap &pixmap) } /*! - Inserts a copy of the pixmap \a pixmap into - the cache and return you the key. + Inserts a copy of the given \a pixmap into the cache and returns a key + that can be used to retrieve it. When a pixmap is inserted and the cache is about to exceed its limit, it removes pixmaps until there is enough room for the @@ -527,9 +538,9 @@ QPixmapCache::Key QPixmapCache::insert(const QPixmap &pixmap) } /*! - Replace the pixmap associated to the \a key into - the cache. It return true if the pixmap \a pixmap has been correctly - inserted into the cache false otherwise. + Replaces the pixmap associated with the given \a key with the \a pixmap + specified. Returns true if the \a pixmap has been correctly inserted into + the cache; otherwise returns false. \sa setCacheLimit(), insert() @@ -546,8 +557,8 @@ bool QPixmapCache::replace(const Key &key, const QPixmap &pixmap) /*! Returns the cache limit (in kilobytes). - The default cache limit is 2048 KB for Embedded, 10240 KB for - Desktops. + The default cache limit is 2048 KB on embedded platforms, 10240 KB on + desktop platforms. \sa setCacheLimit() */ @@ -560,8 +571,8 @@ int QPixmapCache::cacheLimit() /*! Sets the cache limit to \a n kilobytes. - The default setting is 2048 KB for Embedded, 10240 KB for - Desktops. + The default setting is 2048 KB on embedded platforms, 10240 KB on + desktop platforms. \sa cacheLimit() */ @@ -581,7 +592,7 @@ void QPixmapCache::remove(const QString &key) } /*! - Removes the pixmap associated with \a key from the cache and release + Removes the pixmap associated with \a key from the cache and releases the key for a future insertion. \since 4.6 |