summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-14 17:54:47 (UTC)
committer simon <simon>2002-12-14 17:54:47 (UTC)
commit03c4518324c328c530eb795705b6a4281d65055a (patch) (side-by-side diff)
tree903d32d360050d5eb1a65f104618d215e6f804ae
parenta3b9d0a1e6ee4f1e74ac3335cb2ba67f6da30476 (diff)
downloadopie-03c4518324c328c530eb795705b6a4281d65055a.zip
opie-03c4518324c328c530eb795705b6a4281d65055a.tar.gz
opie-03c4518324c328c530eb795705b6a4281d65055a.tar.bz2
- save a bit of memory by caching a pixmap instead
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp46
-rw-r--r--noncore/multimedia/opieplayer2/skin.h4
2 files changed, 25 insertions, 25 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp
index e9fb5a6..d6f4080 100644
--- a/noncore/multimedia/opieplayer2/skin.cpp
+++ b/noncore/multimedia/opieplayer2/skin.cpp
@@ -38,3 +38,3 @@ struct SkinData
- QImage backgroundImage;
+ QPixmap backgroundPixmap;
QImage buttonUpImage;
@@ -56,3 +56,3 @@ private:
typedef QCache<SkinData> DataCache;
- typedef QCache<QImage> BackgroundImageCache;
+ typedef QCache<QPixmap> BackgroundPixmapCache;
@@ -62,3 +62,3 @@ private:
DataCache m_cache;
- BackgroundImageCache m_backgroundImageCache;
+ BackgroundPixmapCache m_backgroundPixmapCache;
};
@@ -90,3 +90,3 @@ void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint butt
{
- backgroundImage();
+ backgroundPixmap();
buttonUpImage();
@@ -96,7 +96,7 @@ void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint butt
-QImage Skin::backgroundImage() const
+QPixmap Skin::backgroundPixmap() const
{
- if ( d->backgroundImage.isNull() )
- d->backgroundImage = loadImage( QString( "%1/background" ).arg( m_skinPath ) );
- return d->backgroundImage;
+ if ( d->backgroundPixmap.isNull() )
+ d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) );
+ return d->backgroundPixmap;
}
@@ -175,3 +175,3 @@ SkinCache::SkinCache()
// ... and one background pixmap
- m_backgroundImageCache.setMaxCost( 1 );
+ m_backgroundPixmapCache.setMaxCost( 1 );
}
@@ -188,9 +188,9 @@ SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &file
- QImage *bgImage = m_backgroundImageCache.find( skinPath );
- if ( bgImage ) {
- qDebug( "SkinCache: hit on bgimage" );
- data->backgroundImage = *bgImage;
+ QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath );
+ if ( bgPixmap ) {
+ qDebug( "SkinCache: hit on bgpixmap" );
+ data->backgroundPixmap = *bgPixmap;
}
else
- data->backgroundImage = QImage();
+ data->backgroundPixmap = QPixmap();
@@ -201,5 +201,5 @@ void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, Sk
{
- QImage *backgroundImage = new QImage( data->backgroundImage );
+ QPixmap *backgroundPixmap = new QPixmap( data->backgroundPixmap );
- data->backgroundImage = QImage();
+ data->backgroundPixmap = QPixmap();
@@ -211,5 +211,5 @@ void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, Sk
- if ( m_backgroundImageCache.find( skinPath, false /*ref*/ ) != 0 ||
- !m_backgroundImageCache.insert( skinPath, backgroundImage ) )
- delete backgroundImage;
+ if ( m_backgroundPixmapCache.find( skinPath, false /*ref*/ ) != 0 ||
+ !m_backgroundPixmapCache.insert( skinPath, backgroundPixmap ) )
+ delete backgroundPixmap;
}
@@ -219,3 +219,3 @@ SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info )
{
- m_currentState = LoadBackgroundImage;
+ m_currentState = LoadBackgroundPixmap;
}
@@ -225,5 +225,5 @@ SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadS
switch ( m_currentState ) {
- case LoadBackgroundImage:
- qDebug( "load bgimage" );
- m_skin.backgroundImage();
+ case LoadBackgroundPixmap:
+ qDebug( "load bgpixmap" );
+ m_skin.backgroundPixmap();
m_currentState = LoadButtonUpImage;
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h
index a43a1d0..90062c2 100644
--- a/noncore/multimedia/opieplayer2/skin.h
+++ b/noncore/multimedia/opieplayer2/skin.h
@@ -42,3 +42,3 @@ public:
- QImage backgroundImage() const;
+ QPixmap backgroundPixmap() const;
QImage buttonUpImage() const;
@@ -108,3 +108,3 @@ private:
private:
- enum State { LoadBackgroundImage, LoadButtonUpImage, LoadButtonDownImage, LoadButtonMasks, LoadButtonMask };
+ enum State { LoadBackgroundPixmap, LoadButtonUpImage, LoadButtonDownImage, LoadButtonMasks, LoadButtonMask };