| #pragma once |
| |
| #ifndef TIMAGECACHE_H |
| #define TIMAGECACHE_H |
| |
| #include <memory> |
| |
| |
| #include "tcommon.h" |
| #include "timage.h" |
| #include "tsmartpointer.h" |
| |
| |
| #ifndef TNZCORE_LIGHT |
| #include <QString> |
| #endif |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TSYSTEM_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| |
| |
| |
| |
| class TFilePath; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TImageCache { |
| class Imp; |
| std::unique_ptr<Imp> m_imp; |
| |
| public: |
| static TImageCache *instance(); |
| |
| std::string getUniqueId(); |
| |
| |
| |
| void setEnabled(bool enable); |
| |
| |
| bool isEnabled(); |
| |
| |
| |
| void setRootDir(const TFilePath &fp); |
| |
| |
| |
| |
| |
| void add(const std::string &id, const TImageP &img, bool overwrite = true); |
| |
| |
| void remove(const std::string &id); |
| |
| |
| void remap(const std::string &dstId, const std::string &srcId); |
| |
| |
| |
| void remapIcons(const std::string &dstId, const std::string &srcId); |
| |
| |
| |
| |
| void clear(bool deleteFolder = false); |
| |
| |
| |
| |
| |
| |
| |
| void clearSceneImages(); |
| |
| |
| |
| bool isCached(const std::string &id) const; |
| |
| |
| bool getSubsampling(const std::string &id, int &subs) const; |
| |
| |
| |
| TImageP get(const std::string &id, bool toBeModified) const; |
| |
| |
| UINT getMemUsage() const; |
| |
| |
| UINT getDiskUsage() const; |
| |
| UINT getUncompressedMemUsage(const std::string &id) const; |
| |
| |
| UINT getMemUsage(const std::string &id) const; |
| UINT getDiskUsage(const std::string &id) const; |
| |
| void dump(std::ostream &os) const; |
| |
| UCHAR *compressAndMalloc(TUINT32 requestedSize); |
| |
| |
| |
| |
| void outputMap(UINT chunkRequested, std::string filename); |
| |
| bool hasBeenModified(const std::string &id, bool reset) const; |
| |
| #ifndef TNZCORE_LIGHT |
| void add(const QString &id, const TImageP &img, bool overwrite = true); |
| void remove(const QString &id); |
| TImageP get(const QString &id, bool toBeModified) const; |
| #endif |
| |
| |
| void compress(const std::string &id); |
| |
| private: |
| TImageCache(); |
| ~TImageCache(); |
| |
| |
| TImageCache(const TImageCache &); |
| void operator=(const TImageCache &); |
| }; |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TCachedImage final : public TSmartObject { |
| DECLARE_CLASS_CODE |
| |
| std::string m_ref; |
| |
| public: |
| TCachedImage(); |
| TCachedImage(const TImageP &img); |
| ~TCachedImage(); |
| |
| |
| void setImage(const TImageP &img, bool overwrite = true); |
| |
| |
| TImageP image(bool toBeModified = true); |
| }; |
| |
| |
| |
| #ifdef _WIN32 |
| template class DVAPI TSmartPointerT<TCachedImage>; |
| #endif |
| |
| typedef TSmartPointerT<TCachedImage> TCachedImageP; |
| |
| #endif |