Commits

rob...@16af8721-9629-0410-8352-f15c8da7e697  committed 2d1282a Draft

Added support for setting the <image> paging_mode property to PRE_LOAD_ALL_IMAGES, PAGE_AND_RETAIN_IMAGES or PAGE_AND_DICARD_IMAGE for osg::ImageStream,
with PAGE_AND_DICARD_IMAGE set as the default.

  • Participants
  • Parent commits 6d8b081

Comments (0)

Files changed (3)

File include/osgPresentation/SlideShowConstructor

 #include <osg/AnimationPath>
 #include <osg/TransferFunction>
 #include <osg/ImageStream>
+#include <osg/ImageSequence>
 #include <osgText/Text>
 #include <osgGA/GUIEventAdapter>
 
             page(-1),
             backgroundColor(1.0f,1.0f,1.0f,1.0f),
             fps(30.0),
-            duration(-1.0) {}
+            duration(-1.0),
+            imageSequencePagingMode(osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES)
+        {}
 
         std::string                     options;
         float                           width;
         osg::Vec4                       backgroundColor;
         double                          fps;
         double                          duration;
+        osg::ImageSequence::Mode        imageSequencePagingMode;
     };
 
     struct VolumeData

File src/osgPlugins/p3d/ReaderWriterP3D.cpp

         OSG_NOTIFY(_notifyLevel)<<"read duration \""<<value.duration<<"\""<<std::endl;
     }
 
+    if (getProperty(cur, "paging_mode", str))
+    {
+        propertiesRead = true;
+        if (str=="PRE_LOAD_ALL_IMAGES") value.imageSequencePagingMode = osg::ImageSequence::PRE_LOAD_ALL_IMAGES;
+        else if (str=="PAGE_AND_RETAIN_IMAGES") value.imageSequencePagingMode = osg::ImageSequence::PAGE_AND_RETAIN_IMAGES;
+        else if (str=="PAGE_AND_DISCARD_USED_IMAGES") value.imageSequencePagingMode = osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES;
+
+        OSG_NOTIFY(_notifyLevel)<<"read imageSequencePagingMode \""<<value.imageSequencePagingMode<<"\""<<std::endl;
+    }
+
     /*
     if (getProperty(cur, "texcoord_offset", value.texcoord_offset))
     {

File src/osgPresentation/SlideShowConstructor.cpp

             {
                 osg::Texture2D* texture = new osg::Texture2D(image.get());
                 texture->setResizeNonPowerOfTwoHint(false);
+                texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
+                texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
+                texture->setClientStorageHint(true);
+
                 backgroundStateSet->setTextureAttributeAndModes(0,
                             texture,
                             osg::StateAttribute::ON);
         texture = new osg::Texture2D(image);
 
         texture->setResizeNonPowerOfTwoHint(false);
+        texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
+        texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
+        texture->setClientStorageHint(true);
 
         stateset->setTextureAttributeAndModes(0,
                     texture,
 
     osg::ref_ptr<osg::Image> image;
     osgDB::DirectoryContents filenames;
-    bool preLoad = true;
 
     std::string foundFile = filename;
 
 
         osg::ref_ptr<osg::ImageSequence> imageSequence = new osg::ImageSequence;
 
+        imageSequence->setMode(imageData.imageSequencePagingMode);
+
+        bool firstLoad = true;
+
         for(osgDB::DirectoryContents::iterator itr = filenames.begin();
             itr != filenames.end();
             ++itr)
         {
-            if (preLoad)
+            if (imageSequence->getMode()==osg::ImageSequence::PRE_LOAD_ALL_IMAGES)
             {
                 OSG_INFO<<"Attempting to read "<<*itr<<std::endl;
                 osg::ref_ptr<osg::Image> loadedImage = osgDB::readImageFile(*itr, options.get());
             {
                 OSG_INFO<<"Adding filename for load image on demand "<<*itr<<std::endl;
                 imageSequence->addImageFile(*itr);
+                if (firstLoad)
+                {
+                    osg::ref_ptr<osg::Image> loadedImage = osgDB::readImageFile(*itr, options.get());
+                    if (loadedImage.valid())
+                    {                    
+                        imageSequence->addImage(loadedImage.get());
+                        firstLoad = false;
+                    }
+                }
             }
         }
 
             imageSequence->setLength(double(maxNum)*(1.0/imageData.fps));
         }
 
+        imageSequence->play();
+
         image = imageSequence;
     }