2012-03-22 01:36:20 +08:00
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2003-07-08 22:44:00 +08:00
*
2012-03-22 01:36:20 +08:00
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
2003-07-08 22:44:00 +08:00
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
2012-03-22 01:36:20 +08:00
*
2003-07-08 22:44:00 +08:00
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2012-03-22 01:36:20 +08:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2003-07-08 22:44:00 +08:00
* OpenSceneGraph Public License for more details.
*/
2003-07-21 16:19:36 +08:00
#ifndef OSGDB_DATABASEPAGER
#define OSGDB_DATABASEPAGER 1
2003-07-08 22:44:00 +08:00
#include <osg/NodeVisitor>
#include <osg/Group>
#include <osg/PagedLOD>
2003-07-10 03:48:04 +08:00
#include <osg/Drawable>
2005-08-19 04:17:51 +08:00
#include <osg/GraphicsThread>
2008-08-18 00:52:35 +08:00
#include <osg/FrameStamp>
2010-02-19 05:21:59 +08:00
#include <osg/ObserverNodePath>
2010-03-04 00:40:19 +08:00
#include <osg/observer_ptr>
2003-07-08 22:44:00 +08:00
2003-07-19 08:18:07 +08:00
#include <OpenThreads/Thread>
#include <OpenThreads/Mutex>
2004-05-08 03:55:12 +08:00
#include <OpenThreads/ScopedLock>
2003-10-12 22:51:54 +08:00
#include <OpenThreads/Condition>
2003-10-12 20:13:58 +08:00
2010-10-15 02:16:03 +08:00
#include <osgUtil/IncrementalCompileOperation>
2004-01-11 01:13:20 +08:00
#include <osgDB/SharedStateManager>
2006-12-05 22:50:46 +08:00
#include <osgDB/ReaderWriter>
2009-05-09 16:49:27 +08:00
#include <osgDB/Options>
2003-07-08 22:44:00 +08:00
2010-10-15 02:16:03 +08:00
2003-07-10 03:48:04 +08:00
#include <map>
2004-09-22 01:26:08 +08:00
#include <list>
2007-12-11 20:32:31 +08:00
#include <algorithm>
#include <functional>
2003-07-10 03:48:04 +08:00
2003-07-21 16:19:36 +08:00
namespace osgDB {
2003-07-08 22:44:00 +08:00
2003-10-12 22:51:54 +08:00
2008-05-22 05:09:45 +08:00
2012-03-22 01:36:20 +08:00
/** Database paging class which manages the loading of files in a background thread,
2007-12-11 01:30:18 +08:00
* and synchronizing of loaded models with the main scene graph.*/
2008-05-22 05:09:45 +08:00
class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandler
2003-07-08 22:44:00 +08:00
{
public :
2005-05-16 04:32:10 +08:00
typedef OpenThreads::Thread::ThreadPriority ThreadPriority;
2003-07-08 22:44:00 +08:00
DatabasePager();
2007-08-08 16:10:38 +08:00
DatabasePager(const DatabasePager& rhs);
2010-02-17 01:38:49 +08:00
virtual const char* className() const { return "DatabasePager"; }
2007-08-08 16:10:38 +08:00
/** Create a shallow copy on the DatabasePager.*/
virtual DatabasePager* clone() const { return new DatabasePager(*this); }
/** get the prototype singleton used by DatabasePager::create().*/
static osg::ref_ptr<DatabasePager>& prototype();
2012-03-22 01:36:20 +08:00
2007-08-08 16:10:38 +08:00
/** create a DatabasePager by cloning DatabasePager::prototype().*/
static DatabasePager* create();
2012-03-22 01:36:20 +08:00
2007-08-08 16:10:38 +08:00
2003-07-09 22:55:39 +08:00
/** Add a request to load a node file to end the the database request list.*/
2011-01-13 03:29:24 +08:00
virtual void requestNodeFile(const std::string& fileName, osg::NodePath& nodePath,
2006-12-05 22:50:46 +08:00
float priority, const osg::FrameStamp* framestamp,
2008-05-22 05:09:45 +08:00
osg::ref_ptr<osg::Referenced>& databaseRequest,
2009-05-11 19:39:12 +08:00
const osg::Referenced* options);
2003-07-08 22:44:00 +08:00
2008-05-22 05:09:45 +08:00
/** Set the priority of the database pager thread(s).*/
int setSchedulePriority(OpenThreads::Thread::ThreadPriority priority);
2012-03-22 01:36:20 +08:00
/** Cancel the database pager thread(s).*/
2004-09-20 04:09:54 +08:00
virtual int cancel();
2012-03-22 01:36:20 +08:00
2008-05-22 05:09:45 +08:00
virtual bool isRunning() const;
2012-03-22 01:36:20 +08:00
2004-09-20 04:09:54 +08:00
/** Clear all internally cached structures.*/
2004-11-17 22:25:17 +08:00
virtual void clear();
2012-03-22 01:36:20 +08:00
2008-06-06 16:42:37 +08:00
class OSGDB_EXPORT DatabaseThread : public osg::Referenced, public OpenThreads::Thread
2008-05-22 05:09:45 +08:00
{
public:
2012-03-22 01:36:20 +08:00
2008-05-22 05:09:45 +08:00
enum Mode
{
HANDLE_ALL_REQUESTS,
HANDLE_NON_HTTP,
HANDLE_ONLY_HTTP
};
2012-03-22 01:36:20 +08:00
2008-05-22 05:09:45 +08:00
DatabaseThread(DatabasePager* pager, Mode mode, const std::string& name);
2012-03-22 01:36:20 +08:00
2008-05-22 05:09:45 +08:00
DatabaseThread(const DatabaseThread& dt, DatabasePager* pager);
2010-06-16 16:13:00 +08:00
void setName(const std::string& name) { _name = name; }
const std::string& getName() const { return _name; }
2010-12-23 04:11:05 +08:00
void setDone(bool done) { _done.exchange(done?1:0); }
bool getDone() const { return _done!=0; }
2012-03-22 01:36:20 +08:00
2008-11-26 19:12:19 +08:00
void setActive(bool active) { _active = active; }
bool getActive() const { return _active; }
2008-05-22 05:09:45 +08:00
virtual int cancel();
2012-03-22 01:36:20 +08:00
2008-05-22 05:09:45 +08:00
virtual void run();
2012-03-22 01:36:20 +08:00
2008-05-22 05:09:45 +08:00
protected:
virtual ~DatabaseThread();
2012-03-22 01:36:20 +08:00
2010-12-23 04:11:05 +08:00
OpenThreads::Atomic _done;
2010-12-10 23:27:19 +08:00
volatile bool _active;
DatabasePager* _pager;
Mode _mode;
std::string _name;
2010-06-16 16:13:00 +08:00
2008-05-22 05:09:45 +08:00
};
2012-03-22 01:36:20 +08:00
2008-10-27 06:22:38 +08:00
void setUpThreads(unsigned int totalNumThreads=2, unsigned int numHttpThreads=1);
2012-02-20 20:33:17 +08:00
virtual unsigned int addDatabaseThread(DatabaseThread::Mode mode, const std::string& name);
2008-05-22 05:09:45 +08:00
DatabaseThread* getDatabaseThread(unsigned int i) { return _databaseThreads[i].get(); }
2012-03-22 01:36:20 +08:00
2008-05-22 05:09:45 +08:00
const DatabaseThread* getDatabaseThread(unsigned int i) const { return _databaseThreads[i].get(); }
2013-05-15 00:12:21 +08:00
unsigned int getNumDatabaseThreads() const { return static_cast<unsigned int>(_databaseThreads.size()); }
2012-03-22 01:36:20 +08:00
2004-09-20 04:09:54 +08:00
/** Set whether the database pager thread should be paused or not.*/
void setDatabasePagerThreadPause(bool pause);
2012-03-22 01:36:20 +08:00
2004-09-20 04:09:54 +08:00
/** Get whether the database pager thread should is paused or not.*/
bool getDatabasePagerThreadPause() const { return _databasePagerThreadPaused; }
2012-03-22 01:36:20 +08:00
2004-09-20 04:09:54 +08:00
/** Set whether new database request calls are accepted or ignored.*/
void setAcceptNewDatabaseRequests(bool acceptNewRequests) { _acceptNewRequests = acceptNewRequests; }
2012-03-22 01:36:20 +08:00
2004-09-20 04:09:54 +08:00
/** Get whether new database request calls are accepted or ignored.*/
bool getAcceptNewDatabaseRequests() const { return _acceptNewRequests; }
2012-03-22 01:36:20 +08:00
2004-09-28 16:39:46 +08:00
/** Get the number of frames that are currently active.*/
int getNumFramesActive() const { return _numFramesActive; }
2003-10-12 20:13:58 +08:00
/** Signal the database thread that the update, cull and draw has begun for a new frame.
* Note, this is called by the application so that the database pager can go to sleep while the CPU is busy on the main rendering threads. */
2004-11-17 22:25:17 +08:00
virtual void signalBeginFrame(const osg::FrameStamp* framestamp);
2012-03-22 01:36:20 +08:00
2003-10-12 20:13:58 +08:00
/** Signal the database thread that the update, cull and draw dispatch has completed.
* Note, this is called by the application so that the database pager can go to wake back up now the main rendering threads are iddle waiting for the next frame.*/
2004-11-17 22:25:17 +08:00
virtual void signalEndFrame();
2003-07-09 22:55:39 +08:00
2012-03-22 01:36:20 +08:00
/** Find all PagedLOD nodes in a subgraph and register them with
2003-07-09 22:55:39 +08:00
* the DatabasePager so it can keep track of expired nodes.
* note, should be only be called from the update thread. */
2010-12-23 04:11:05 +08:00
virtual void registerPagedLODs(osg::Node* subgraph, unsigned int frameNumber = 0);
2003-07-08 22:44:00 +08:00
2010-10-15 02:16:03 +08:00
/** Set the incremental compile operation.
* Used to manage the OpenGL object compilation and merging of subgraphs in a way that avoids overloading
* the rendering of frame with too many new objects in one frame. */
void setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation* ico);
/** Get the incremental compile operation. */
osgUtil::IncrementalCompileOperation* getIncrementalCompileOperation() { return _incrementalCompileOperation.get(); }
2005-05-31 13:37:13 +08:00
/** Set whether the database pager should pre compile OpenGL objects before allowing
* them to be merged into the scene graph.
* Pre compilation helps reduce the chances of frame drops, but also slows the
* speed at which tiles are merged as they have to be compiled first.*/
void setDoPreCompile(bool flag) { _doPreCompile = flag; }
/** Get whether the database pager should pre compile OpenGL objects before allowing
* them to be merged into the scene graph.*/
bool getDoPreCompile() const { return _doPreCompile; }
2003-07-09 22:55:39 +08:00
2005-03-18 03:32:09 +08:00
2008-11-26 19:12:19 +08:00
/** Set the target maximum number of PagedLOD to maintain in memory.
* Note, if more than the target number are required for rendering of a frame then these active PagedLOD are excempt from being expiried.
* But once the number of active drops back below the target the inactive PagedLOD will be trimmed back to the target number.*/
void setTargetMaximumNumberOfPageLOD(unsigned int target) { _targetMaximumNumberOfPageLOD = target; }
/** Get the target maximum number of PagedLOD to maintain in memory.*/
unsigned int getTargetMaximumNumberOfPageLOD() const { return _targetMaximumNumberOfPageLOD; }
2005-11-22 21:14:00 +08:00
/** Set whether the removed subgraphs should be deleted in the database thread or not.*/
2003-07-09 22:55:39 +08:00
void setDeleteRemovedSubgraphsInDatabaseThread(bool flag) { _deleteRemovedSubgraphsInDatabaseThread = flag; }
2012-03-22 01:36:20 +08:00
2005-11-22 21:14:00 +08:00
/** Get whether the removed subgraphs should be deleted in the database thread or not.*/
2003-07-09 22:55:39 +08:00
bool getDeleteRemovedSubgraphsInDatabaseThread() const { return _deleteRemovedSubgraphsInDatabaseThread; }
2005-11-22 21:14:00 +08:00
enum DrawablePolicy
{
DO_NOT_MODIFY_DRAWABLE_SETTINGS,
USE_DISPLAY_LISTS,
USE_VERTEX_BUFFER_OBJECTS,
USE_VERTEX_ARRAYS
};
/** Set how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.*/
void setDrawablePolicy(DrawablePolicy policy) { _drawablePolicy = policy; }
2004-07-20 13:37:59 +08:00
2005-11-22 21:14:00 +08:00
/** Get how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.*/
DrawablePolicy getDrawablePolicy() const { return _drawablePolicy; }
2011-02-04 20:43:00 +08:00
/** Set whether newly loaded textures should have a PixelBufferObject assigned to them to aid download to the GPU.*/
void setApplyPBOToImages(bool assignPBOToImages) { _assignPBOToImages = assignPBOToImages; }
/** Get whether newly loaded textures should have a PixelBufferObject assigned to them..*/
bool getApplyPBOToImages() const { return _assignPBOToImages; }
2005-11-22 21:14:00 +08:00
/** Set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/
2004-07-20 13:37:59 +08:00
void setUnrefImageDataAfterApplyPolicy(bool changeAutoUnRef, bool valueAutoUnRef) { _changeAutoUnRef = changeAutoUnRef; _valueAutoUnRef = valueAutoUnRef; }
2005-11-22 21:14:00 +08:00
/** Get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/
2004-07-20 13:37:59 +08:00
void getUnrefImageDataAfterApplyPolicy(bool& changeAutoUnRef, bool& valueAutoUnRef) const { changeAutoUnRef = _changeAutoUnRef; valueAutoUnRef = _valueAutoUnRef; }
2005-11-22 21:14:00 +08:00
/** Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/
2004-07-20 13:37:59 +08:00
void setMaxAnisotropyPolicy(bool changeAnisotropy, float valueAnisotropy) { _changeAnisotropy = changeAnisotropy; _valueAnisotropy = valueAnisotropy; }
2005-11-22 21:14:00 +08:00
/** Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/
2004-07-20 13:37:59 +08:00
void getMaxAnisotropyPolicy(bool& changeAnisotropy, float& valueAnisotropy) const { changeAnisotropy = _changeAnisotropy; valueAnisotropy = _valueAnisotropy; }
2004-09-24 04:13:16 +08:00
/** Return true if there are pending updates to the scene graph that require a call to updateSceneGraph(double). */
2004-09-24 02:50:38 +08:00
bool requiresUpdateSceneGraph() const;
2012-03-22 01:36:20 +08:00
2004-09-24 02:50:38 +08:00
/** Merge the changes to the scene graph by calling calling removeExpiredSubgraphs then addLoadedDataToSceneGraph.
* Note, must only be called from single thread update phase. */
2010-03-04 00:40:19 +08:00
virtual void updateSceneGraph(const osg::FrameStamp& frameStamp);
2007-06-22 22:48:18 +08:00
2006-02-05 05:06:48 +08:00
/** Report how many items are in the _fileRequestList queue */
2013-05-15 00:12:21 +08:00
unsigned int getFileRequestListSize() const { return static_cast<unsigned int>(_fileRequestQueue->size() + _httpRequestQueue->size()); }
2006-02-05 05:06:48 +08:00
/** Report how many items are in the _dataToCompileList queue */
2013-05-15 00:12:21 +08:00
unsigned int getDataToCompileListSize() const { return static_cast<unsigned int>(_dataToCompileList->size()); }
2012-03-22 01:36:20 +08:00
2010-10-15 02:16:03 +08:00
/** Report how many items are in the _dataToMergeList queue */
2013-05-15 00:12:21 +08:00
unsigned int getDataToMergeListSize() const { return static_cast<unsigned int>(_dataToMergeList->size()); }
2007-08-24 21:33:35 +08:00
2008-11-26 19:12:19 +08:00
/** Report whether any requests are in the pager.*/
bool getRequestsInProgress() const;
2012-03-22 01:36:20 +08:00
2007-08-24 21:33:35 +08:00
/** Get the minimum time between the first request for a tile to be loaded and the time of its merge into the main scene graph.*/
double getMinimumTimeToMergeTile() const { return _minimumTimeToMergeTile; }
/** Get the maximum time between the first request for a tile to be loaded and the time of its merge into the main scene graph.*/
double getMaximumTimeToMergeTile() const { return _maximumTimeToMergeTile; }
/** Get the average time between the first request for a tile to be loaded and the time of its merge into the main scene graph.*/
2009-03-23 23:47:01 +08:00
double getAverageTimeToMergeTiles() const { return (_numTilesMerges > 0) ? _totalTimeToMergeTiles/static_cast<double>(_numTilesMerges) : 0; }
2007-08-24 21:33:35 +08:00
/** Reset the Stats variables.*/
void resetStats();
2006-02-05 05:06:48 +08:00
2007-06-22 22:48:18 +08:00
typedef std::set< osg::ref_ptr<osg::StateSet> > StateSetList;
typedef std::vector< osg::ref_ptr<osg::Drawable> > DrawableList;
2003-07-15 17:39:45 +08:00
2011-03-30 23:15:07 +08:00
class ExpirePagedLODsVisitor;
2010-06-03 22:14:40 +08:00
2010-12-21 17:36:03 +08:00
typedef std::list< osg::ref_ptr<osg::Object> > ObjectList;
2010-06-03 22:14:40 +08:00
struct PagedLODList : public osg::Referenced
{
virtual PagedLODList* clone() = 0;
virtual void clear() = 0;
virtual unsigned int size() = 0;
2010-12-23 04:11:05 +08:00
virtual void removeExpiredChildren(int numberChildrenToRemove, double expiryTime, unsigned int expiryFrame, ObjectList& childrenRemoved, bool visitActive) = 0;
2010-06-07 17:05:58 +08:00
virtual void removeNodes(osg::NodeList& nodesToRemove) = 0;
virtual void insertPagedLOD(const osg::observer_ptr<osg::PagedLOD>& plod) = 0;
2010-10-01 23:37:35 +08:00
virtual bool containsPagedLOD(const osg::observer_ptr<osg::PagedLOD>& plod) const = 0;
2010-06-03 22:14:40 +08:00
};
2010-10-15 02:16:03 +08:00
2004-11-29 11:05:27 +08:00
protected:
virtual ~DatabasePager();
2008-05-22 05:09:45 +08:00
friend class DatabaseThread;
2004-11-18 20:07:28 +08:00
friend struct DatabaseRequest;
2007-12-11 20:32:31 +08:00
2008-06-17 00:06:01 +08:00
struct RequestQueue;
2008-06-16 17:32:22 +08:00
2011-01-20 20:34:41 +08:00
struct OSGDB_EXPORT DatabaseRequest : public osg::Referenced
2003-07-08 22:44:00 +08:00
{
DatabaseRequest():
2008-05-22 05:09:45 +08:00
osg::Referenced(true),
2010-01-23 04:47:39 +08:00
_valid(false),
2008-05-22 05:09:45 +08:00
_frameNumberFirstRequest(0),
_timestampFirstRequest(0.0),
_priorityFirstRequest(0.f),
_frameNumberLastRequest(0),
_timestampLastRequest(0.0),
_priorityLastRequest(0.0f),
2011-03-30 23:15:07 +08:00
_numOfRequests(0),
_groupExpired(false)
2003-07-08 22:44:00 +08:00
{}
2010-01-23 04:47:39 +08:00
void invalidate();
bool valid() const { return _valid; }
2010-12-10 23:27:19 +08:00
bool _valid;
std::string _fileName;
2010-12-23 04:11:05 +08:00
unsigned int _frameNumberFirstRequest;
2010-12-10 23:27:19 +08:00
double _timestampFirstRequest;
float _priorityFirstRequest;
2010-12-23 04:11:05 +08:00
unsigned int _frameNumberLastRequest;
2010-12-10 23:27:19 +08:00
double _timestampLastRequest;
float _priorityLastRequest;
unsigned int _numOfRequests;
2012-03-22 01:36:20 +08:00
2011-01-13 03:29:24 +08:00
osg::observer_ptr<osg::Node> _terrain;
osg::observer_ptr<osg::Group> _group;
osg::ref_ptr<osg::Node> _loadedModel;
osg::ref_ptr<Options> _loadOptions;
2010-12-10 23:27:19 +08:00
osg::observer_ptr<osgUtil::IncrementalCompileOperation::CompileSet> _compileSet;
2011-03-30 23:15:07 +08:00
bool _groupExpired; // flag used only in update thread
2007-12-11 20:32:31 +08:00
bool isRequestCurrent (int frameNumber) const
{
2010-03-24 22:27:00 +08:00
return _valid && (frameNumber - _frameNumberLastRequest <= 1);
2007-12-11 20:32:31 +08:00
}
2003-07-08 22:44:00 +08:00
};
2010-10-15 02:16:03 +08:00
2011-01-20 20:34:41 +08:00
struct OSGDB_EXPORT RequestQueue : public osg::Referenced
2008-06-16 17:32:22 +08:00
{
2010-01-23 04:47:39 +08:00
public:
2008-06-28 02:59:27 +08:00
2010-03-24 22:27:00 +08:00
RequestQueue(DatabasePager* pager);
2010-01-23 04:47:39 +08:00
2010-03-24 22:27:00 +08:00
void add(DatabaseRequest* databaseRequest);
2010-12-10 23:27:19 +08:00
void remove(DatabaseRequest* databaseRequest);
2010-06-07 19:28:25 +08:00
void addNoLock(DatabaseRequest* databaseRequest);
2010-03-24 22:27:00 +08:00
void takeFirst(osg::ref_ptr<DatabaseRequest>& databaseRequest);
/// prune all the old requests and then return true if requestList left empty
bool pruneOldRequestsAndCheckIfEmpty();
virtual void updateBlock() {}
2010-12-10 23:27:19 +08:00
void invalidate(DatabaseRequest* dr);
2010-12-21 17:36:03 +08:00
bool empty();
2010-06-07 19:28:25 +08:00
2010-12-21 17:36:03 +08:00
unsigned int size();
2010-06-07 19:28:25 +08:00
2010-03-24 22:27:00 +08:00
void clear();
2010-06-07 19:28:25 +08:00
2010-03-24 22:27:00 +08:00
typedef std::list< osg::ref_ptr<DatabaseRequest> > RequestList;
2010-06-07 19:28:25 +08:00
void swap(RequestList& requestList);
2010-03-24 22:27:00 +08:00
DatabasePager* _pager;
RequestList _requestList;
OpenThreads::Mutex _requestMutex;
2010-12-23 04:11:05 +08:00
unsigned int _frameNumberLastPruned;
2010-01-23 04:47:39 +08:00
protected:
virtual ~RequestQueue();
2008-06-16 17:32:22 +08:00
};
2012-03-22 01:36:20 +08:00
2008-05-22 05:09:45 +08:00
typedef std::vector< osg::ref_ptr<DatabaseThread> > DatabaseThreadList;
2003-07-08 22:44:00 +08:00
2011-01-20 20:34:41 +08:00
struct OSGDB_EXPORT ReadQueue : public RequestQueue
2008-05-22 05:09:45 +08:00
{
2008-06-16 17:32:22 +08:00
ReadQueue(DatabasePager* pager, const std::string& name);
2010-02-10 19:21:45 +08:00
2008-05-22 05:09:45 +08:00
void block() { _block->block(); }
2010-02-10 19:21:45 +08:00
2008-05-22 05:09:45 +08:00
void release() { _block->release(); }
2010-02-10 19:21:45 +08:00
2010-03-24 22:27:00 +08:00
virtual void updateBlock();
2010-02-10 19:21:45 +08:00
2008-05-22 05:09:45 +08:00
osg::ref_ptr<osg::RefBlock> _block;
2010-02-10 19:21:45 +08:00
2008-05-22 05:09:45 +08:00
std::string _name;
2010-02-10 19:21:45 +08:00
2008-05-22 05:09:45 +08:00
OpenThreads::Mutex _childrenToDeleteListMutex;
ObjectList _childrenToDeleteList;
};
2004-11-17 22:25:17 +08:00
// forward declare inner helper classes
class FindCompileableGLObjectsVisitor;
friend class FindCompileableGLObjectsVisitor;
2010-10-15 02:16:03 +08:00
struct DatabasePagerCompileCompletedCallback;
friend struct DatabasePagerCompileCompletedCallback;
2004-11-17 22:25:17 +08:00
class FindPagedLODsVisitor;
friend class FindPagedLODsVisitor;
2004-11-18 17:09:22 +08:00
struct SortFileRequestFunctor;
friend struct SortFileRequestFunctor;
2003-10-11 03:25:14 +08:00
2012-03-22 01:36:20 +08:00
2004-09-22 05:33:52 +08:00
OpenThreads::Mutex _run_mutex;
2010-12-21 17:36:03 +08:00
OpenThreads::Mutex _dr_mutex;
2004-09-22 05:33:52 +08:00
bool _startThreadCalled;
2010-10-15 02:16:03 +08:00
void compileCompleted(DatabaseRequest* databaseRequest);
2010-11-29 17:32:43 +08:00
/** Iterate through the active PagedLOD nodes children removing
2004-09-24 02:50:38 +08:00
* children which havn't been visited since specified expiryTime.
* note, should be only be called from the update thread. */
2008-08-18 00:52:35 +08:00
virtual void removeExpiredSubgraphs(const osg::FrameStamp &frameStamp);
2004-09-24 02:50:38 +08:00
/** Add the loaded data to the scene graph.*/
2008-08-18 00:52:35 +08:00
void addLoadedDataToSceneGraph(const osg::FrameStamp &frameStamp);
2004-09-24 02:50:38 +08:00
2004-09-20 04:09:54 +08:00
bool _done;
bool _acceptNewRequests;
bool _databasePagerThreadPaused;
2010-11-29 17:32:43 +08:00
2008-05-22 05:09:45 +08:00
DatabaseThreadList _databaseThreads;
2004-09-28 16:39:46 +08:00
int _numFramesActive;
mutable OpenThreads::Mutex _numFramesActiveMutex;
2010-12-23 04:11:05 +08:00
OpenThreads::Atomic _frameNumber;
2003-10-12 20:13:58 +08:00
2008-06-16 17:32:22 +08:00
osg::ref_ptr<ReadQueue> _fileRequestQueue;
osg::ref_ptr<ReadQueue> _httpRequestQueue;
osg::ref_ptr<RequestQueue> _dataToCompileList;
2010-12-10 23:27:19 +08:00
osg::ref_ptr<RequestQueue> _dataToMergeList;
2004-07-20 13:37:59 +08:00
2005-11-22 21:14:00 +08:00
DrawablePolicy _drawablePolicy;
2011-02-04 20:43:00 +08:00
bool _assignPBOToImages;
2004-07-20 13:37:59 +08:00
bool _changeAutoUnRef;
bool _valueAutoUnRef;
bool _changeAnisotropy;
float _valueAnisotropy;
2004-01-27 22:49:59 +08:00
2003-10-12 20:13:58 +08:00
bool _deleteRemovedSubgraphsInDatabaseThread;
2003-07-09 22:55:39 +08:00
2010-11-29 17:32:43 +08:00
2010-06-03 22:14:40 +08:00
osg::ref_ptr<PagedLODList> _activePagedLODList;
2003-07-08 22:44:00 +08:00
2010-11-29 17:32:43 +08:00
unsigned int _targetMaximumNumberOfPageLOD;
2008-10-07 19:35:41 +08:00
2005-05-31 13:37:13 +08:00
bool _doPreCompile;
2010-10-15 02:16:03 +08:00
osg::ref_ptr<osgUtil::IncrementalCompileOperation> _incrementalCompileOperation;
2010-11-29 17:32:43 +08:00
2007-08-24 21:33:35 +08:00
double _minimumTimeToMergeTile;
double _maximumTimeToMergeTile;
double _totalTimeToMergeTiles;
unsigned int _numTilesMerges;
2003-07-08 22:44:00 +08:00
};
}
#endif