| #pragma once |
| |
| #ifndef TPASSIVECACHEMANAGER_INCLUDED |
| #define TPASSIVECACHEMANAGER_INCLUDED |
| |
| #include "tfxcachemanager.h" |
| |
| |
| |
| |
| class TXsheet; |
| |
| |
| typedef void (*TreeDescriptor)(std::string &desc, const TFxP &root); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TPassiveCacheManager final : public TFxCacheManagerDelegate { |
| T_RENDER_RESOURCE_MANAGER |
| |
| private: |
| struct FxData { |
| TFxP m_fx; |
| UCHAR m_storageFlag; |
| int m_passiveCacheId; |
| |
| std::string m_treeDescription; |
| |
| FxData(); |
| ~FxData(); |
| |
| |
| |
| |
| |
| }; |
| |
| class ResourcesContainer; |
| |
| private: |
| QMutex m_mutex; |
| |
| std::vector<FxData> m_fxDataVector; |
| std::set<std::string> m_invalidatedLevels; |
| ResourcesContainer *m_resources; |
| std::map<std::string, UCHAR> m_contextNames; |
| std::map<unsigned long, std::string> m_contextNamesByRenderId; |
| |
| bool m_updatingPassiveCacheIds; |
| int m_currentPassiveCacheId; |
| |
| bool m_enabled; |
| |
| public: |
| TPassiveCacheManager(); |
| ~TPassiveCacheManager(); |
| |
| static TPassiveCacheManager *instance(); |
| |
| void setContextName(unsigned long renderId, const std::string &name); |
| void releaseContextNamesWithPrefix(const std::string &prefix); |
| |
| TFx *getNotAllowingAncestor(TFx *fx); |
| |
| void setEnabled(bool enabled); |
| bool isEnabled() const; |
| |
| void reset(); |
| |
| enum StorageFlag { NONE = 0x0, IN_MEMORY = 0x1, ON_DISK = 0x2 }; |
| void setStorageMode(StorageFlag mode); |
| StorageFlag getStorageMode() const; |
| |
| int declareCached(TFx *fx, int passiveCacheId); |
| void onSceneLoaded(); |
| int getPassiveCacheId(TFx *fx); |
| |
| void enableCache(TFx *fx); |
| void disableCache(TFx *fx); |
| bool cacheEnabled(TFx *fx); |
| void toggleCache(TFx *fx); |
| |
| StorageFlag getStorageMode(TFx *fx); |
| |
| void invalidateLevel(const std::string &levelName); |
| void forceInvalidate(); |
| |
| void getResource(TCacheResourceP &resource, const std::string &alias, |
| const TFxP &fx, double frame, const TRenderSettings &rs, |
| ResourceDeclaration *resData) override; |
| |
| void onRenderInstanceStart(unsigned long renderId) override; |
| void onRenderInstanceEnd(unsigned long renderId) override; |
| |
| void onRenderStatusEnd(int renderStatus) override; |
| |
| bool renderHasOwnership() override { return false; } |
| |
| public: |
| void setTreeDescriptor(TreeDescriptor callback); |
| |
| void onFxChanged(const TFxP &fx); |
| void onXsheetChanged(); |
| |
| private: |
| TreeDescriptor m_descriptorCallback; |
| StorageFlag m_currStorageFlag; |
| |
| private: |
| void touchFxData(int &idx); |
| |
| int getNewPassiveCacheId(); |
| int updatePassiveCacheId(int id); |
| |
| std::string getContextName(); |
| void releaseOldResources(); |
| }; |
| |
| #endif |