Renamed include/osg/OperationsThread to OperationThread.

Created a new GraphicsThread subclass from OperationThread which allows the
GraphicsContext specific calls to be moved out of the base OperationThread class.

Updated the rest of the OSG to respect these changes.
This commit is contained in:
Robert Osfield
2007-07-12 15:54:45 +00:00
parent 4d7e8b12ae
commit ecf0b58a19
24 changed files with 212 additions and 145 deletions

View File

@@ -352,13 +352,13 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
void createCameraThread();
/** Assign a operation thread to the camera.*/
void setCameraThread(OperationsThread* gt);
void setCameraThread(OperationThread* gt);
/** Get the operation thread assigned to this camera.*/
OperationsThread* getCameraThread() { return _cameraThread.get(); }
OperationThread* getCameraThread() { return _cameraThread.get(); }
/** Get the const operation thread assigned to this camera.*/
const OperationsThread* getCameraThread() const { return _cameraThread.get(); }
const OperationThread* getCameraThread() const { return _cameraThread.get(); }
@@ -467,7 +467,7 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
RenderTargetImplementation _renderTargetFallback;
BufferAttachmentMap _bufferAttachmentMap;
ref_ptr<OperationsThread> _cameraThread;
ref_ptr<OperationThread> _cameraThread;
ref_ptr<GraphicsContext> _graphicsContext;

View File

@@ -303,13 +303,13 @@ class OSG_EXPORT GraphicsContext : public Object
void createGraphicsThread();
/** Assign a graphics thread to the graphics context, so that the thread handles all OpenGL operations.*/
void setGraphicsThread(OperationsThread* gt);
void setGraphicsThread(GraphicsThread* gt);
/** Get the graphics thread assigned the graphics context.*/
OperationsThread* getGraphicsThread() { return _graphicsThread.get(); }
GraphicsThread* getGraphicsThread() { return _graphicsThread.get(); }
/** Get the const graphics thread assigned the graphics context.*/
const OperationsThread* getGraphicsThread() const { return _graphicsThread.get(); }
const GraphicsThread* getGraphicsThread() const { return _graphicsThread.get(); }
/** Realise the GraphicsContext implementation,
@@ -423,7 +423,7 @@ class OSG_EXPORT GraphicsContext : public Object
OperationQueue _operations;
osg::ref_ptr<Operation> _currentOperation;
ref_ptr<OperationsThread> _graphicsThread;
ref_ptr<GraphicsThread> _graphicsThread;
ref_ptr<ResizedCallback> _resizedCallback;

View File

@@ -14,10 +14,20 @@
#ifndef OSG_GRAPHICSTHREAD
#define OSG_GRAPHICSTHREAD 1
#include <osg/OperationsThread>
#include <osg/OperationThread>
namespace osg {
class OSG_EXPORT GraphicsThread : public osg::OperationThread
{
public:
GraphicsThread();
/** Run does the graphics thread run loop.*/
virtual void run();
};
/** SwapBufferOperation calls swap buffers on the GraphicsContext.*/
struct OSG_EXPORT SwapBuffersOperation : public Operation
{

View File

@@ -170,7 +170,7 @@ class OSG_EXPORT OperationThread : public Referenced, public OpenThreads::Thread
/** Get the operation currently being run.*/
osg::ref_ptr<Operation> getCurrentOperation() { return _currentOperation; }
/** Run does the graphics thread run loop.*/
/** Run does the opertion thread run loop.*/
virtual void run();
void setDone(bool done);

View File

@@ -121,22 +121,14 @@ class OSGTERRAIN_EXPORT TerrainNode : public osg::Group
bool getTreatBoundariesToValidDataAsDefaultValue() const { return _treatBoundariesToValidDataAsDefaultValue; }
/** Set an OperationsThread to do an data initialization and update work.*/
void setOperationsThread(osg::OperationsThread* operationsThread) { _operationsThread = operationsThread; }
/** Set an OperationQueue to do an data initialization and update work.*/
void setOperationQueue(osg::OperationQueue* operations) { _operationQueue = operations; }
/** Get the OperationsThread if one is attached, return NULL otherwise.*/
osg::OperationsThread* getOperationsThread() { return _operationsThread.get(); }
/** Get the const OperationsThread if one is attached, return NULL otherwise.*/
const osg::OperationsThread* getOperationsThread() const { return _operationsThread.get(); }
/** Add a graphics context that should be used to compile/delete OpenGL objects.*/
void addCompileGraphicsContext(osg::GraphicsContext* gc);
/** Removed a graphics context that should be used to compile/delete OpenGL objects.*/
void removeCompileGraphicsContext(osg::GraphicsContext* gc);
/** Get the OperationsQueue if one is attached, return NULL otherwise.*/
osg::OperationQueue* getOperationQueue() { return _operationQueue.get(); }
/** Get the const OperationsQueue if one is attached, return NULL otherwise.*/
const osg::OperationQueue* getOperationsQueue() const { return _operationQueue.get(); }
/** Compute the bounding volume of the terrain by computing the union of the bounding volumes of all layers.*/
virtual osg::BoundingSphere computeBound() const;
@@ -180,10 +172,7 @@ class OSGTERRAIN_EXPORT TerrainNode : public osg::Group
bool _requiresNormals;
bool _treatBoundariesToValidDataAsDefaultValue;
osg::ref_ptr<osg::OperationsThread> _operationsThread;
typedef std::vector< osg::observer_ptr<osg::GraphicsContext> > CompileGraphicsContexts;
CompileGraphicsContexts _compileGraphicsContexts;
osg::ref_ptr<osg::OperationQueue> _operationQueue;
};
}

View File

@@ -151,8 +151,8 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
typedef std::vector<OpenThreads::Thread*> Threads;
void getAllThreads(Threads& threads, bool onlyActive=true);
typedef std::vector<osg::OperationsThread*> OperationsThreads;
void getOperationsThreads(OperationsThreads& threads, bool onlyActive=true);
typedef std::vector<osg::OperationThread*> OperationThreads;
void getOperationThreads(OperationThreads& threads, bool onlyActive=true);
/** Set the graphics operation to call on realization of the viewers graphics windows.*/
void setRealizeOperation(osg::Operation* op) { _realizeOperation = op; }