diff options
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 |