diff options
author | lordjaxom <lordjaxom> | 2005-01-26 20:44:06 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2005-01-26 20:44:06 +0000 |
commit | 5a29748ddba6fb93d46ed51c9260d98961785ae8 (patch) | |
tree | 9b3a81c52efed529531c2a1a71a82ef76b2a88bf /bitmap.h | |
parent | 49b23b49fca6df6b3e52ae2b7a03bb650b32470f (diff) | |
download | vdr-plugin-text2skin-5a29748ddba6fb93d46ed51c9260d98961785ae8.tar.gz vdr-plugin-text2skin-5a29748ddba6fb93d46ed51c9260d98961785ae8.tar.bz2 |
- moved tBitmapSpec from cache.h to bitmap.h
- replaced image cache with universal version
- cache check now respects requested image's dimensions and alpha
- consolidated duplicate code
Diffstat (limited to 'bitmap.h')
-rw-r--r-- | bitmap.h | 55 |
1 files changed, 51 insertions, 4 deletions
@@ -1,5 +1,5 @@ /* - * $Id: bitmap.h,v 1.3 2004/12/28 01:54:02 lordjaxom Exp $ + * $Id: bitmap.h,v 1.4 2005/01/26 20:44:06 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_BITMAP_H @@ -9,9 +9,48 @@ #include "cache.h" #include <vdr/osd.h> +struct tBitmapSpec { + std::string Filename; + int Alpha; + int Width; + int Height; + int Colors; + + tBitmapSpec(const std::string &filename, int alpha, int width, int height, int colors): + Filename(filename), Alpha(alpha), Width(width), Height(height), Colors(colors) {} + + bool operator<(const tBitmapSpec &Src) const; + bool operator==(const tBitmapSpec &Src) const; +}; + +inline bool tBitmapSpec::operator<(const tBitmapSpec &Src) const +{ + if (Filename == Src.Filename) { + if (Alpha == Src.Alpha) { + if (Width == Src.Width) { + if (Height == Src.Height) + return Colors < Src.Colors; + return Height < Src.Height; + } + return Width < Src.Width; + } + return Alpha < Src.Alpha; + } + return Filename < Src.Filename; +} + +inline bool tBitmapSpec::operator==(const tBitmapSpec &Src) const +{ + return Filename == Src.Filename + && Alpha == Src.Alpha + && Width == Src.Width + && Height == Src.Height + && Colors == Src.Colors; +} + class cText2SkinBitmap { private: - static cText2SkinCache mCache; + static cxCache<tBitmapSpec,cText2SkinBitmap*> mCache; std::vector<cBitmap*> mBitmaps; int mCurrent; @@ -22,8 +61,10 @@ private: cText2SkinBitmap(void); public: - static cText2SkinBitmap *Load(const std::string &Filename, int Alpha = 0, int height = 0, int width = 0, int colors = 0); - static bool Available(const std::string &Filename); + static cText2SkinBitmap *Load(const std::string &Filename, int Alpha = 0, int height = 0, + int width = 0, int colors = 0, bool Quiet = false); + static bool Available(const std::string &Filename, int Alpha = 0, int height = 0, + int width = 0, int colors = 0); static void ResetCache(void) { mCache.Reset(); } static void FlushCache(void) { mCache.Flush(); } @@ -47,4 +88,10 @@ inline void cText2SkinBitmap::SetColor(int Index, tColor Color) { mBitmaps[mCurrent]->SetColor(Index, Color); } +template<> +void cxCache<tBitmapSpec,cText2SkinBitmap*>::Delete(const tBitmapSpec &Key, + cText2SkinBitmap *&Data); +template<> +void cxCache<tBitmapSpec,cText2SkinBitmap*>::Reset(cText2SkinBitmap *&Data); + #endif // VDR_TEXT2SKIN_BITMAP_H |