#pragma once #include //#include #include struct hashPr_TextCache { struct Key { Key(){} Key( const Key& key1 ) { _copy(key1); } Key(LPCSTR _lpszText, KColor _color, LPCSTR _lpszFont, int _nSize, DWORD _dwWidth, DWORD _dwHeight, DWORD _dwFlag, KColor _color_fx) { sText = _lpszText; color = _color; sFontName = _lpszFont; nSize = _nSize; dwWidth = _dwWidth; dwHeight = _dwHeight; dwFlag = _dwFlag; color_fx = _color_fx; } void _copy(const Key& key1) { sText = key1.sText; color = key1.color; sFontName = key1.sFontName; nSize = key1.nSize; dwWidth = key1.dwWidth; dwHeight = key1.dwHeight; dwFlag = key1.dwFlag; color_fx = key1.color_fx; } std::string sText; KColor color; std::string sFontName; int nSize; DWORD dwWidth; DWORD dwHeight; DWORD dwFlag; KColor color_fx; }; static inline unsigned int getindex( const Key &keystr, int nCapacity ) { unsigned int key; const char *str = keystr.sText.c_str(); for ( key = 0; *str; str++ ) key = key * 32 - key + *str; return key % nCapacity; } static inline bool isequal( const Key &key1, const Key &key2 ) { return key1.sText == key2.sText && key1.color == key2.color && key1.sFontName == key2.sFontName && key1.nSize == key2.nSize && key1.dwWidth == key2.dwWidth && key1.dwHeight == key2.dwHeight && key1.dwFlag == key2.dwFlag && key1.color_fx == key2.color_fx; } static inline bool isless( const Key &key1, const Key &key2 ) { if( key1.sText != key2.sText ) return key1.sText < key2.sText; if( !(key1.color == key2.color) ) return key1.color < key2.color; if( key1.sFontName != key2.sFontName) return key1.sFontName < key2.sFontName; if( key1.nSize != key2.nSize) return key1.nSize < key2.nSize; if( key1.dwWidth != key2.dwWidth) return key1.dwWidth < key2.dwWidth; if( key1.dwHeight != key2.dwHeight) return key1.dwHeight < key2.dwHeight; if( key1.dwFlag != key2.dwFlag ) return key1.dwFlag < key2.dwFlag; return key1.color_fx < key2.color_fx; } }; struct KCacheItem; struct KCacheIterItem; class KTextCacheManager { public: static KTextCacheManager* GetInstance() { static KTextCacheManager obj; return &obj; } KTextCacheManager(); ~KTextCacheManager(); K3DTexture* FindCache(LPCSTR _lpszText, KColor _color, LPCSTR _lpszFont, int _nSize, DWORD _dwWidth, DWORD _dwHeight, DWORD _dwFlag, KColor _color_fx); bool RegisterCache(LPCSTR _lpszText, KColor _color, LPCSTR _lpszFont, int _nSize, DWORD _dwWidth, DWORD _dwHeight, DWORD _dwFlag, KColor _color_fx, K3DTexture* pTex); void SetCacheSize(DWORD dwMaxSize) { m_dwMaxCacheSize = dwMaxSize; } void DestroyAll(); private: void _RemoveCacheItem(); private: DWORD m_dwMaxCacheSize; KHash m_hashTextCache; /// 순차로 Remove std::vector m_vtTextCache; };