|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TPASSIVECACHEMANAGER_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TPASSIVECACHEMANAGER_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxcachemanager.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
class TXsheet;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Typedefs
|
|
Toshihiro Shimizu |
890ddd |
typedef void (*TreeDescriptor)(std::string &desc, const TFxP &root);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================
|
|
Toshihiro Shimizu |
890ddd |
// TPassiveCacheManager class
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
The TPassiveCacheManager is the cache delegate manager that allows render processes to cache
|
|
Toshihiro Shimizu |
890ddd |
fx results from externally specified schematic nodes for future reuse.
|
|
Toshihiro Shimizu |
890ddd |
Observe that this manager takes no effort in verifying the usefulness of caching an fx, as the
|
|
Toshihiro Shimizu |
890ddd |
expected behaviour for such cached results is that of being recycled on future, \a unpredictable render
|
|
Toshihiro Shimizu |
890ddd |
instances under the same passive cache management. Active, predictive caching takes place
|
|
Toshihiro Shimizu |
890ddd |
under control of another manager class - namely, the TFxCacheManager - for single render instances.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TPassiveCacheManager : public TFxCacheManagerDelegate
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
T_RENDER_RESOURCE_MANAGER
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
struct FxData {
|
|
Toshihiro Shimizu |
890ddd |
TFxP m_fx;
|
|
Toshihiro Shimizu |
890ddd |
UCHAR m_storageFlag;
|
|
Toshihiro Shimizu |
890ddd |
int m_passiveCacheId;
|
|
Toshihiro Shimizu |
890ddd |
//std::set<tcacheresourcep> m_resources;</tcacheresourcep>
|
|
Toshihiro Shimizu |
890ddd |
std::string m_treeDescription;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxData();
|
|
Toshihiro Shimizu |
890ddd |
~FxData();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*void insert(const TCacheResourceP& resource);
|
|
Toshihiro Shimizu |
890ddd |
std::set<tcacheresourcep>::iterator erase(const std::set<tcacheresourcep>::iterator& it);</tcacheresourcep></tcacheresourcep>
|
|
Toshihiro Shimizu |
890ddd |
void clear();*/
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class ResourcesContainer;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
QMutex m_mutex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::vector<fxdata> m_fxDataVector;</fxdata>
|
|
Toshihiro Shimizu |
890ddd |
std::set<std::string> m_invalidatedLevels;</std::string>
|
|
Toshihiro Shimizu |
890ddd |
ResourcesContainer *m_resources;
|
|
Toshihiro Shimizu |
890ddd |
std::map<std::string, uchar=""> m_contextNames;</std::string,>
|
|
Toshihiro Shimizu |
890ddd |
std::map<unsigned long,="" std::string=""> m_contextNamesByRenderId;</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_updatingPassiveCacheIds;
|
|
Toshihiro Shimizu |
890ddd |
int m_currentPassiveCacheId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_enabled;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TPassiveCacheManager();
|
|
Toshihiro Shimizu |
890ddd |
~TPassiveCacheManager();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static TPassiveCacheManager *instance();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setContextName(unsigned long renderId, const std::string &name);
|
|
Toshihiro Shimizu |
890ddd |
void releaseContextNamesWithPrefix(const std::string &prefix);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *getNotAllowingAncestor(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setEnabled(bool enabled);
|
|
Toshihiro Shimizu |
890ddd |
bool isEnabled() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void reset();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum StorageFlag { NONE = 0x0,
|
|
Toshihiro Shimizu |
890ddd |
IN_MEMORY = 0x1,
|
|
Toshihiro Shimizu |
890ddd |
ON_DISK = 0x2 };
|
|
Toshihiro Shimizu |
890ddd |
void setStorageMode(StorageFlag mode);
|
|
Toshihiro Shimizu |
890ddd |
StorageFlag getStorageMode() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int declareCached(TFx *fx, int passiveCacheId);
|
|
Toshihiro Shimizu |
890ddd |
void onSceneLoaded();
|
|
Toshihiro Shimizu |
890ddd |
int getPassiveCacheId(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void enableCache(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
void disableCache(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
bool cacheEnabled(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
void toggleCache(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StorageFlag getStorageMode(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void invalidateLevel(const std::string &levelName);
|
|
Toshihiro Shimizu |
890ddd |
void forceInvalidate();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void getResource(
|
|
Toshihiro Shimizu |
890ddd |
TCacheResourceP &resource, const string &alias,
|
|
Toshihiro Shimizu |
890ddd |
const TFxP &fx, double frame, const TRenderSettings &rs,
|
|
Toshihiro Shimizu |
890ddd |
ResourceDeclaration *resData);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onRenderInstanceStart(unsigned long renderId);
|
|
Toshihiro Shimizu |
890ddd |
void onRenderInstanceEnd(unsigned long renderId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onRenderStatusEnd(int renderStatus);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool renderHasOwnership() { return false; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
void setTreeDescriptor(TreeDescriptor callback);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onFxChanged(const TFxP &fx);
|
|
Toshihiro Shimizu |
890ddd |
void onXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
TreeDescriptor m_descriptorCallback;
|
|
Toshihiro Shimizu |
890ddd |
StorageFlag m_currStorageFlag;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
void touchFxData(int &idx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getNewPassiveCacheId();
|
|
Toshihiro Shimizu |
890ddd |
int updatePassiveCacheId(int id);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::string getContextName();
|
|
Toshihiro Shimizu |
890ddd |
void releaseOldResources();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //TPASSIVECACHEMANAGER_INCLUDED
|