From 5a29748ddba6fb93d46ed51c9260d98961785ae8 Mon Sep 17 00:00:00 2001 From: lordjaxom Date: Wed, 26 Jan 2005 20:44:06 +0000 Subject: - 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 --- bitmap.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) (limited to 'bitmap.h') diff --git a/bitmap.h b/bitmap.h index 9d8e8f6..33d40ad 100644 --- a/bitmap.h +++ b/bitmap.h @@ -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 +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 mCache; std::vector 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::Delete(const tBitmapSpec &Key, + cText2SkinBitmap *&Data); +template<> +void cxCache::Reset(cText2SkinBitmap *&Data); + #endif // VDR_TEXT2SKIN_BITMAP_H -- cgit v1.2.3