diff options
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qimage.h | 2 | ||||
-rw-r--r-- | src/gui/image/qimagereader.cpp | 18 | ||||
-rw-r--r-- | src/gui/image/qmovie.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qpixmap.h | 2 | ||||
-rw-r--r-- | src/gui/image/qpixmap_raster_p.h | 2 | ||||
-rw-r--r-- | src/gui/image/qpixmap_s60.cpp | 15 | ||||
-rw-r--r-- | src/gui/image/qpixmapcache.cpp | 66 | ||||
-rw-r--r-- | src/gui/image/qpixmapcache_p.h | 6 |
8 files changed, 67 insertions, 48 deletions
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 89d7de5..1ac56a7 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -314,7 +314,7 @@ private: QImageData *d; friend class QRasterPixmapData; - friend class QDetachedPixmap; + friend class QPixmapCacheEntry; friend Q_GUI_EXPORT qint64 qt_image_id(const QImage &image); friend const QVector<QRgb> *qt_image_colortable(const QImage &image); diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index aff186b..074f3eb 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -696,14 +696,17 @@ bool QImageReader::autoDetectImageFormat() const /*! - Specifies that the image reader should decide which plugin to use - solely based on the contents in the datastream. + If \a ignored is set to true, then the image reader will ignore + specified formats or file extensions and decide which plugin to + use only based on the contents in the datastream. Setting this flag means that all image plugins gets loaded. Each plugin will read the first bytes in the image data and decide if - the plugin is compatible or not. The flag is set to \a ignored. + the plugin is compatible or not. - This also disables auto detecting image format. + This also disables auto detecting the image format. + + \sa decideFormatFromContent() */ void QImageReader::setDecideFormatFromContent(bool ignored) @@ -713,8 +716,11 @@ void QImageReader::setDecideFormatFromContent(bool ignored) /*! - Returns wether the image reader should decide which plugin to use - sloley based on the contents of the datastream + Returns whether the image reader should decide which plugin to use + only based on the contents of the datastream rather than on the file + extension. + + \sa setDecideFormatFromContent() */ bool QImageReader::decideFormatFromContent() const diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 48aee1c..42b8dea 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -47,6 +47,10 @@ \ingroup painting + This class is used to show simple animations without sound. If you want + to display video and media content, use the \l{Phonon Module}{Phonon} + multimedia framework instead. + First, create a QMovie object by passing either the name of a file or a pointer to a QIODevice containing an animated image format to QMovie's constructor. You can call isValid() to check if the image data is valid, diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index a891637..d11bd03 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -270,7 +270,7 @@ private: friend class QWidgetPrivate; friend class QRasterPaintEngine; friend class QRasterBuffer; - friend class QDetachedPixmap; + friend class QPixmapCacheEntry; #if !defined(QT_NO_DATASTREAM) friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &); #endif diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h index 2af2399..da0405e 100644 --- a/src/gui/image/qpixmap_raster_p.h +++ b/src/gui/image/qpixmap_raster_p.h @@ -88,7 +88,7 @@ protected: private: friend class QPixmap; friend class QBitmap; - friend class QDetachedPixmap; + friend class QPixmapCacheEntry; friend class QRasterPaintEngine; }; diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index cab6116..dccc691 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -64,13 +64,14 @@ const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; - /*! + \class QSymbianFbsClient \since 4.6 + \internal - Symbian Font And Bitmap server client that is - used to lock the global bitmap heap. Only used in - S60 v3.1 and S60 v3.2. + Symbian Font And Bitmap server client that is + used to lock the global bitmap heap. Only used in + S60 v3.1 and S60 v3.2. */ class QSymbianFbsClient { @@ -145,7 +146,9 @@ void QSymbianFbsHeapLock::relock() } /*! + \class QSymbianBitmapDataAccess \since 4.6 + \internal Data access class that is used to locks/unlocks pixel data when drawing or modifying CFbsBitmap pixel data. @@ -297,7 +300,7 @@ QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h) } /*! - \fn CFbsBitmap *QPixmap::toSymbianCFbsBitmap() + \fn CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const \since 4.6 Creates a \c CFbsBitmap that is equivalent to the QPixmap. Internally this @@ -724,7 +727,7 @@ void QS60PixmapData::endDataAccess(bool readOnly) const /*! \since 4.6 - Returns a QPixmap that wraps given \c RSgImage \a graphics resource. + Returns a QPixmap that wraps given \a sgImage graphics resource. The data should be valid even when original RSgImage handle has been closed. diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 8029977..f12d397 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -167,7 +167,7 @@ QPixmapCache::Key &QPixmapCache::Key::operator =(const Key &other) return *this; } -class QPMCache : public QObject, public QCache<QPixmapCache::Key, QDetachedPixmap> +class QPMCache : public QObject, public QCache<QPixmapCache::Key, QPixmapCacheEntry> { Q_OBJECT public: @@ -215,7 +215,7 @@ uint qHash(const QPixmapCache::Key &k) QPMCache::QPMCache() : QObject(0), - QCache<QPixmapCache::Key, QDetachedPixmap>(cache_limit * 1024), + QCache<QPixmapCache::Key, QPixmapCacheEntry>(cache_limit * 1024), keyArray(0), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false) { } @@ -238,7 +238,6 @@ void QPMCache::timerEvent(QTimerEvent *) { int mc = maxCost(); bool nt = totalCost() == ps; - QList<QPixmapCache::Key> keys = QCache<QPixmapCache::Key, QDetachedPixmap>::keys(); setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1); setMaxCost(mc); ps = totalCost(); @@ -252,10 +251,6 @@ void QPMCache::timerEvent(QTimerEvent *) ++it; } } - for (int i = 0; i < keys.size(); ++i) { - if (!contains(keys.at(i))) - releaseKey(keys.at(i)); - } if (!size()) { killTimer(theid); @@ -274,11 +269,10 @@ QPixmap *QPMCache::object(const QString &key) const const_cast<QPMCache *>(this)->cacheKeys.remove(key); return 0; } - QPixmap *ptr = QCache<QPixmapCache::Key, QDetachedPixmap>::object(cacheKey); + QPixmap *ptr = QCache<QPixmapCache::Key, QPixmapCacheEntry>::object(cacheKey); //We didn't find the pixmap in the cache, the key is not valid anymore if (!ptr) { const_cast<QPMCache *>(this)->cacheKeys.remove(key); - const_cast<QPMCache *>(this)->releaseKey(cacheKey); } return ptr; } @@ -286,7 +280,7 @@ QPixmap *QPMCache::object(const QString &key) const QPixmap *QPMCache::object(const QPixmapCache::Key &key) const { Q_ASSERT(key.d->isValid); - QPixmap *ptr = QCache<QPixmapCache::Key, QDetachedPixmap>::object(key); + QPixmap *ptr = QCache<QPixmapCache::Key, QPixmapCacheEntry>::object(key); //We didn't find the pixmap in the cache, the key is not valid anymore if (!ptr) const_cast<QPMCache *>(this)->releaseKey(key); @@ -299,13 +293,14 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) QPixmapCache::Key oldCacheKey = cacheKeys.value(key); //If for the same key we add already a pixmap we should delete it if (oldCacheKey.d) { - QCache<QPixmapCache::Key, QDetachedPixmap>::remove(oldCacheKey); - cacheKey = oldCacheKey; - } else { - cacheKey = createKey(); - } + QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(oldCacheKey); + cacheKeys.remove(key); + } + + //we create a new key the old one has been removed + cacheKey = createKey(); - bool success = QCache<QPixmapCache::Key, QDetachedPixmap>::insert(cacheKey, new QDetachedPixmap(pixmap), cost); + bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { cacheKeys.insert(key, cacheKey); if (!theid) { @@ -322,7 +317,7 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) { QPixmapCache::Key cacheKey = createKey(); - bool success = QCache<QPixmapCache::Key, QDetachedPixmap>::insert(cacheKey, new QDetachedPixmap(pixmap), cost); + bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { if (!theid) { theid = startTimer(30000); @@ -338,13 +333,21 @@ QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int cost) { Q_ASSERT(key.d->isValid); - //If for the same key we add already a pixmap we should delete it - QCache<QPixmapCache::Key, QDetachedPixmap>::remove(key); + //If for the same key we had already an entry so we should delete the pixmap and use the new one + QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(key); + + QPixmapCache::Key cacheKey = createKey(); - bool success = QCache<QPixmapCache::Key, QDetachedPixmap>::insert(key, new QDetachedPixmap(pixmap), cost); - if (success && !theid) { - theid = startTimer(30000); - t = false; + bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); + if (success) { + if(!theid) { + theid = startTimer(30000); + t = false; + } + const_cast<QPixmapCache::Key&>(key) = cacheKey; + } else { + //Insertion failed we released the key + releaseKey(cacheKey); } return success; } @@ -356,16 +359,12 @@ bool QPMCache::remove(const QString &key) if (!cacheKey.d) return false; cacheKeys.remove(key); - releaseKey(cacheKey); - return QCache<QPixmapCache::Key, QDetachedPixmap>::remove(cacheKey); + return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey); } bool QPMCache::remove(const QPixmapCache::Key &key) { - bool result = QCache<QPixmapCache::Key, QDetachedPixmap>::remove(key); - //We release the key after we removed it from the cache - releaseKey(key); - return result; + return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(key); } void QPMCache::resizeKeyArray(int size) @@ -409,10 +408,10 @@ void QPMCache::clear() freeKey = 0; keyArraySize = 0; //Mark all keys as invalid - QList<QPixmapCache::Key> keys = QCache<QPixmapCache::Key, QDetachedPixmap>::keys(); + QList<QPixmapCache::Key> keys = QCache<QPixmapCache::Key, QPixmapCacheEntry>::keys(); for (int i = 0; i < keys.size(); ++i) keys.at(i).d->isValid = false; - QCache<QPixmapCache::Key, QDetachedPixmap>::clear(); + QCache<QPixmapCache::Key, QPixmapCacheEntry>::clear(); } QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key) @@ -424,6 +423,11 @@ QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key) Q_GLOBAL_STATIC(QPMCache, pm_cache) +QPixmapCacheEntry::~QPixmapCacheEntry() +{ + pm_cache()->releaseKey(key); +} + /*! \obsolete \overload diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 33f93bc..84e4a03 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -76,10 +76,10 @@ public: }; // XXX: hw: is this a general concept we need to abstract? -class QDetachedPixmap : public QPixmap +class QPixmapCacheEntry : public QPixmap { public: - QDetachedPixmap(const QPixmap &pix) : QPixmap(pix) + QPixmapCacheEntry(const QPixmapCache::Key &key, const QPixmap &pix) : QPixmap(pix), key(key) { if (data && data->classId() == QPixmapData::RasterClass) { QRasterPixmapData *d = static_cast<QRasterPixmapData*>(data.data()); @@ -91,6 +91,8 @@ public: } } } + ~QPixmapCacheEntry(); + QPixmapCache::Key key; }; QT_END_NAMESPACE |