| #pragma once |
| |
| #ifndef TFXCACHEMANAGER_H |
| #define TFXCACHEMANAGER_H |
| |
| #include <memory> |
| |
| #include "trenderresourcemanager.h" |
| #include "tcacheresource.h" |
| |
| |
| |
| |
| struct ResourceDeclaration; |
| typedef std::pair<ResourceDeclaration *, TCacheResourceP> ResourceData; |
| |
| class TFxCacheManager; |
| class TFxCacheManagerDelegate; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI ResourceBuilder { |
| TFxCacheManager *m_cacheManager; |
| ResourceData m_data; |
| |
| protected: |
| virtual void simCompute(const TRectD &rect) = 0; |
| virtual void compute(const TRectD &rect) = 0; |
| |
| virtual void upload(TCacheResourceP &resource) = 0; |
| virtual bool download(TCacheResourceP &resource) = 0; |
| |
| public: |
| ResourceBuilder(const std::string &resourceName, const TFxP &fx, double frame, |
| const TRenderSettings &rs); |
| virtual ~ResourceBuilder() {} |
| |
| static void declareResource(const std::string &alias, const TFxP &fx, |
| const TRectD &rect, double frame, |
| const TRenderSettings &rs, |
| bool subtileable = true); |
| |
| void simBuild(const TRectD &tile); |
| void build(const TRectD &tile); |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| struct ResourceDeclaration { |
| |
| |
| |
| struct RawData { |
| |
| |
| |
| TFxP m_fx; |
| |
| double m_frame; |
| |
| TRenderSettings m_rs; |
| |
| |
| std::vector<TRectD> m_tiles; |
| |
| |
| |
| |
| |
| |
| |
| bool m_subtileable; |
| }; |
| |
| |
| |
| |
| struct TileData { |
| TRectD m_rect; |
| int m_refCount; |
| bool m_calculated; |
| |
| TileData(const TRectD &rect) |
| : m_rect(rect), m_refCount(0), m_calculated(false) {} |
| }; |
| |
| public: |
| RawData *m_rawData; |
| std::vector<TileData> m_tiles; |
| int m_tilesCount; |
| |
| ResourceDeclaration() : m_rawData(0), m_tilesCount(0) {} |
| ~ResourceDeclaration() {} |
| }; |
| |
| |
| |
| typedef std::pair<ResourceDeclaration *, TCacheResourceP> ResourceData; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TFxCacheManager final : public TRenderResourceManager { |
| T_RENDER_RESOURCE_MANAGER |
| |
| private: |
| |
| std::set<TFxCacheManagerDelegate *> m_delegates; |
| |
| std::set<std::string> m_staticCacheIds; |
| |
| class Imp; |
| std::unique_ptr<Imp> m_imp; |
| |
| public: |
| TFxCacheManager(); |
| ~TFxCacheManager(); |
| |
| static TFxCacheManager *instance(); |
| |
| void add(const std::string &cacheId, TImageP img); |
| void remove(const std::string &cacheId); |
| |
| void onRenderStatusStart(int renderStatus) override; |
| void onRenderStatusEnd(int renderStatus) override; |
| |
| |
| |
| |
| private: |
| friend class ResourceBuilder; |
| |
| void declareResource(const std::string &alias, const TFxP &fx, |
| const TRectD &rect, double frame, |
| const TRenderSettings &rs, bool subtileable); |
| |
| ResourceData getResource(const std::string &resourceName, const TFxP &fx, |
| double frame, const TRenderSettings &rs); |
| |
| |
| |
| |
| |
| |
| private: |
| friend class TFxCacheManagerDelegate; |
| |
| void install(TFxCacheManagerDelegate *managerDelegate); |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class TFxCacheManagerDelegate : public TRenderResourceManager { |
| public: |
| TFxCacheManagerDelegate() {} |
| |
| virtual void getResource(TCacheResourceP &resource, const std::string &alias, |
| const TFxP &fx, double frame, |
| const TRenderSettings &rs, |
| ResourceDeclaration *resData) = 0; |
| |
| void onRenderInstanceStart(unsigned long renderId) override { |
| assert(TFxCacheManager::instance()); |
| TFxCacheManager::instance()->install(this); |
| } |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #endif |