Unified the osg::GraphicsThread::Operation and osg::GraphicsContext::Operation classes

as osg::GraphicsOperation.  Unpdated parts of OSG depending upon these.

Added a virtaul bool valid() method to osg::GraphicsContext to allow apps to
test whether a valid graphis context has been created or not.
This commit is contained in:
Robert Osfield
2006-12-24 16:40:19 +00:00
parent 76461b3ab2
commit 39c0c2df76
10 changed files with 139 additions and 112 deletions

View File

@@ -146,40 +146,11 @@ class OSG_EXPORT GraphicsContext : public Referenced
public:
/** Base class for implementing graphics operations.*/
struct OSG_EXPORT Operation : virtual public Referenced
{
Operation(const std::string& name, bool keep):
_name(name),
_keep(keep) {}
/** Set the human readable name of the operation.*/
void setName(const std::string& name) { _name = name; }
/** Get the human readable name of the operation.*/
const std::string& getName() const { return _name; }
/** Set whether the operation should be kept once its been applied.*/
void setKeep(bool keep) { _keep = keep; }
/** Get whether the operation should be kept once its been applied.*/
bool getKeep() const { return _keep; }
/** if this operation is a barrier then release it.*/
virtual void release() {}
/** Do the actual task of this operation.*/
virtual void operator () (GraphicsContext*) {}
std::string _name;
bool _keep;
};
/** Add operation to end of OperationQueue.*/
void add(Operation* operation);
void add(GraphicsOperation* operation);
/** Remove operation from OperationQueue.*/
void remove(Operation* operation);
void remove(GraphicsOperation* operation);
/** Remove named operation from OperationQueue.*/
void remove(const std::string& name);
@@ -206,6 +177,9 @@ class OSG_EXPORT GraphicsContext : public Referenced
inline const State* getState() const { return _state.get(); }
/** Return whether a valid and usable GraphicsContext has been created.*/
virtual bool valid() const { return false; }
/** Realise the GraphicsContext.*/
bool realize();
@@ -296,13 +270,14 @@ class OSG_EXPORT GraphicsContext : public Referenced
OpenThreads::Mutex _mutex;
OpenThreads::Thread* _threadOfLastMakeCurrent;
typedef std::list< ref_ptr<Operation> > OperationQueue;
OpenThreads::Mutex _operationsMutex;
osg::ref_ptr<osg::Block> _operationsBlock;
OperationQueue _operations;
osg::ref_ptr<Operation> _currentOperation;
typedef std::list< ref_ptr<GraphicsOperation> > OperationQueue;
OpenThreads::Mutex _operationsMutex;
osg::ref_ptr<osg::Block> _operationsBlock;
OperationQueue _operations;
osg::ref_ptr<GraphicsOperation> _currentOperation;
ref_ptr<GraphicsThread> _graphicsThread;
ref_ptr<GraphicsThread> _graphicsThread;
};