summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmapcache.cpp
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-07-24 09:45:33 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-07-27 13:04:30 (GMT)
commit3643028959f0b38350e57e60ba4000435b75e592 (patch)
treec129e4dee11487abd437ab8ebd993ba261e06fa6 /src/gui/image/qpixmapcache.cpp
parentcf66c667a97c0079141eb3f2d9e997b7378ae792 (diff)
parentc36139c665e61866aff4bf8572890a735167a7d0 (diff)
downloadQt-3643028959f0b38350e57e60ba4000435b75e592.zip
Qt-3643028959f0b38350e57e60ba4000435b75e592.tar.gz
Qt-3643028959f0b38350e57e60ba4000435b75e592.tar.bz2
Merge commit 'qt/master-stable'
Conflicts: configure.exe qmake/Makefile.unix qmake/generators/makefile.cpp src/corelib/global/qglobal.h src/corelib/kernel/kernel.pri src/corelib/kernel/qcoreevent.cpp src/corelib/kernel/qsharedmemory_unix.cpp src/gui/graphicsview/qgraphicsscene.cpp src/gui/kernel/qaction.cpp src/gui/kernel/qaction.h src/gui/kernel/qaction_p.h src/gui/kernel/qapplication.cpp src/gui/kernel/qapplication.h src/gui/kernel/qwidget.cpp src/gui/kernel/qwidget.h src/gui/kernel/qwidget_mac.mm src/gui/painting/qgraphicssystemfactory.cpp src/gui/styles/qwindowsstyle.cpp src/gui/text/qfontengine_qpf.cpp src/gui/widgets/qabstractscrollarea_p.h src/network/access/qnetworkaccessdebugpipebackend.cpp src/network/socket/qlocalsocket_unix.cpp src/network/socket/qnativesocketengine_p.h src/network/socket/qnativesocketengine_unix.cpp src/openvg/qpaintengine_vg.cpp tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp tests/auto/qcssparser/qcssparser.pro tests/auto/qdir/tst_qdir.cpp tests/auto/qfile/tst_qfile.cpp tests/auto/qobject/tst_qobject.cpp tests/auto/qpathclipper/qpathclipper.pro tests/auto/qprocess/tst_qprocess.cpp tests/auto/qsettings/tst_qsettings.cpp tests/auto/qsharedpointer/qsharedpointer.pro tests/auto/qsqlquerymodel/qsqlquerymodel.pro tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro tests/auto/qsqltablemodel/qsqltablemodel.pro tests/auto/qsqlthread/qsqlthread.pro tests/auto/qwidget/tst_qwidget.cpp
Diffstat (limited to 'src/gui/image/qpixmapcache.cpp')
-rw-r--r--src/gui/image/qpixmapcache.cpp75
1 files changed, 43 insertions, 32 deletions
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index baa2969..b4a3a49 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
{
@@ -409,7 +420,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
@@ -442,7 +453,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.
@@ -461,10 +472,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
@@ -506,8 +517,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
@@ -526,9 +537,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()
@@ -545,8 +556,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()
*/
@@ -559,8 +570,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()
*/
@@ -580,7 +591,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