VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgFileCache.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2017 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
18 
19 #include <vrvCore/DtFileCache.h>
20 
21 #include <vrvUtil/signalslib.h>
22 
23 #include <osgDB/ReaderWriter>
24 
25 #define _WINSOCKAPI_
26 #include <boost/signals2.hpp>
27 
28 namespace osg
29 {
30  class Drawable;
31  class GraphicsContext;
32  class Node;
33  class Texture;
34  class Object;
35 }
36 
37 namespace makVrv
38 {
39  class DtMeifConverter;
40  class DtMetaFileManager;
41  class DtOsgShaderManager;
42  class DtOsgShaderFilesCache;
43  class DtEffectControllerFactory;
44  class DtReadFileCallback;
45 
51  {
52  public:
53 
56  friend class DtOsgFileCacheCreator;
57 
59  virtual ~DtOsgFileCache();
60 
62  virtual void releaseResources()
63  {
64  releaseResources(0);
65  }
66 
68  virtual void releaseResources(osg::State* state);
69 
71  virtual void setFromRecord( const makArchives::DtCacheSettingsRecord& rec );
72 
76  static void optimizeNodeGeometry(osg::Node* node);
77 
81  osg::Node* readNodeFile( const std::string& inputFilename,
82  const LoadFileOptions& loadFileOptions);
83 
86  inline osg::ref_ptr<osg::Node> findNodeFile( const std::string& inputFilename )
87  {
88  return ts_findNodeFile(inputFilename);
89  }
90 
94  osg::Image* readImageFile( const std::string& inputFilename,
95  const LoadFileOptions& loadFileOptions);
96 
99  virtual osg::Texture* getTextureInstance(const std::string& filePath,
100  osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
101  osg::Texture::WrapMode s, osg::Texture::WrapMode t,
102  const LoadFileOptions& loadFileOptions);
103 
107  virtual void ts_getTextureInstance(const std::string& filePath,
108  osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
109  osg::Texture::WrapMode s, osg::Texture::WrapMode t,
110  const LoadFileOptions& loadFileOptions, osg::ref_ptr<osg::Texture>& texture);
111 
113  virtual void encodeOptionsString(const LoadFileOptions& loadFileOptions,
114  osgDB::ReaderWriter::Options& options) const;
115 
117  virtual void decodeOptions(const osgDB::ReaderWriter::Options& options,
118  LoadFileOptions& loadFileOptions) const;
119 
121  DtMetaFileManager* metaFileManager();
122 
126  void cleanDataFilePathList(FilePathList& fileList);
127 
132  boost::signals2::signal<void (osg::Node*, const std::string& origFileName,
133  const std::string& actualFileName)> signal_nodeFileLoaded;
134 
139  boost::signals2::signal<void (osg::Image*, const std::string& origFileName,
140  const std::string& actualFileName)> signal_imageFileLoaded;
141 
146  boost::signals2::signal<void(osg::Object*, const std::string& origFileName,
147  const std::string& actualFileName)> signal_objectFileLoaded;
148 
152  boost::signals2::signal<void (const std::string& filename,
153  osgDB::ReaderWriter::ReadResult&,const osgDB::ReaderWriter::Options*)>
155 
159  boost::signals2::signal<void (const std::string& filename,
160  osgDB::ReaderWriter::ReadResult&,const osgDB::ReaderWriter::Options*)>
162 
166  boost::signals2::signal<void(const std::string& filename,
167  osgDB::ReaderWriter::ReadResult&, const osgDB::ReaderWriter::Options*)>
169 
171  virtual const DtOsgShaderFilesCache& shaderFilesCache(void) const;
172 
173  virtual DtEffectControllerFactory& effectControllerFactory(void) const;
174 
178  virtual const std::string& loadShaderSource(const std::string& shaderFile) const;
179 
182  virtual std::string ts_getTextureFilePathAndSetNameIfNotSet(const osg::Texture* baseTexture) const;
183 
185  virtual void ts_setEffectTextureName(osg::ref_ptr<osg::Texture>& effectTexture, const std::string& validFile) const;
186 
188  virtual void ts_setEffectTextureFilterAndHardwareMipMapGen(osg::Texture* effectTexture, osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter, bool hardwareMipMapGen) const;
189 
191  virtual void ts_compareAndSwapIgnoreHint(osg::Texture* effectTexture, bool oldVal, bool newVal) const;
192 
197  virtual bool ts_checkAndSetIgnoreHint(osg::Object* obj, bool val, const char* hint) const;
198 
201  virtual bool ts_ignore(osg::Object* obj, const char* hint) const;
202 
204  virtual const DtEffectControllerContainer& effectControllerContainer(void) const;
205 
207  virtual const DtEffectControllerShaderCache& effectControllerShaderCache(void) const;
208 
209  virtual void setNumActivePagerThreads(int active) { myNumActivePagerThreads = active; }
210 
211  virtual int getNumberOfImageProcessingTasks() const;
212 
214  virtual DtOsgShaderManager& shaderManager(void);
215 
217  virtual const DtOsgShaderManager& shaderManager(void) const;
218 
219  protected:
220 
221  friend class DtReadFileCallback;
222 
224  virtual osg::ref_ptr<osg::Node> ts_readNodeFile( const std::string& inputFilename,
225  const LoadFileOptions& loadFileOptions, const osg::UserDataContainer *optionsUserData);
226 
228  virtual osg::ref_ptr<osg::Node> ts_findNodeFile( const std::string& inputFilename );
229 
231  virtual osg::ref_ptr<osg::Image> ts_readImageFile( const std::string& inputFilename,
232  const LoadFileOptions& loadFileOptions,
233  const osg::UserDataContainer* optionsUserData =0L);
234 
236  virtual osg::ref_ptr<osg::Object> ts_readObject(
237  const std::string& filename, const osgDB::ReaderWriter::Options* options);
238 
240  void ts_encryptImage( const std::string& inputFileName,
241  const std::string& outputFilename, const osgDB::ReaderWriter::Options* options, bool printToConsole);
242 
244  bool ts_resolveRelativeFilename( const LoadFileOptions& loadFileOptions,
245  std::string& absoluteInputFilename );
246 
248  virtual void ts_clearInstancingCache();
249 
251  virtual void ts_flushInstancingCache( bool multipass,
252  bool flushNodes, bool flushTextures, bool flushImages);
253 
255  virtual void applyEffectTexture(osg::Node* node, const std::string& extension,
256  bool isCdb, osgDB::ReaderWriter::Options* option);
257 
259  DtOsgFileCache(DtDe& de);
260 
264  std::string ts_buildAcceleratedFilename( const std::string& filePathIn,
265  const std::string& cachedDir,
266  const std::string& cachedExtension) const;
267 
271  std::string ts_buildCdbAcceleratedFilename(const std::string& zipfile,
272  const std::string& ftlfile,
273  const std::string& cachedDir,
274  const std::string& cachedExtension) const;
275 
278  virtual bool save(const std::string& origFilename,
279  const std::string& cachedFilename, bool optimize);
280 
282  bool shouldSaveFile( const std::string& filename);
283 
285  bool saveToAcceleratedFile( const std::string& origFileName,
286  osg::Node* nodeRef, const std::string& cachedFilename,
287  bool writeExternalReferences);
288 
290  virtual void addMetaFlightOptions(std::string& optionsString);
291 
293  virtual bool needsShaderGeneration(const std::string& extension, const LoadFileOptions& options) const;
294 
296  virtual void updateGlobalOptions();
297 
299  virtual void slot_onDdsFlipChanged(bool flip);
300 
302  virtual void slot_instancingChanged(bool enabled);
303 
304  // check if an attrData object is in the cache (only for FLT and CDB)
305  virtual bool getAttrFromLocalCache(const std::string& filename, osg::Object* attrData);
306 
307  protected:
308 
309  typedef boost::unordered_map<std::string,std::string> RelativePathCache;
310 
314  typedef std::map< std::string, osg::ref_ptr<osg::Object> > AttrCacheMap;
316 
318  unsigned int myMaxFlushNodeCount;
319  unsigned int myMaxFlushImageCount;
320 
321  boost::mutex myRelativePathMutex;
325 
329 
330  // mutex for protecting against setUserValue threading issues.
331  boost::mutex myImageUserValueMutex;
332 
333  // mutex for protecting any modification across any effect textures
334  mutable boost::mutex myEffectTexturesMutex;
335 
336  // controller container
338 
339  // effect controller shader cache
341 
342  // determines threading behavior
344  };
345 
349  {
350 
351  public:
352 
354  virtual DtFileCache* create(DtDe& de);
355 
356  };
357 }
358 
359 // Include the inl to solve a circular dependency problem for gcc
360 #include <vrvOsg/DtOsgReferencedCollection.inl>
361 

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)