00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined SOCPUBUFFEROBJECT_H
00024 #define SOCPUBUFFEROBJECT_H
00025
00026 #include <Inventor/devices/SoBufferObject.h>
00027 #include <Inventor/devices/SoCpuContext.h>
00028
00029 class SoGLBufferObject;
00030
00147 class SoCpuBufferObject : public SoBufferObject
00148 {
00149 SO_TYPED_CLASS_HEADER();
00150
00151 friend class SoGLBufferObject;
00152
00153
00154
00155 public:
00156
00161 SoCpuBufferObject();
00162
00173 SoCpuBufferObject(void *buffer, size_t size);
00174
00197 virtual void map( SoBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00198
00208 virtual void unmap( SoBufferObject* bufferObject );
00209
00229 virtual void* map( AccessMode accessMode );
00230
00237 virtual void unmap();
00238
00252 virtual void memcpy( SoBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00253
00257 virtual void memset( void* value, size_t valueSize = 1, size_t offset = 0, size_t count = SO_BUFFER_SIZE_ALL );
00258
00278 virtual bool setSize( size_t size );
00279
00285 virtual SoBufferObject* createInstance() const;
00286
00290 virtual void clearInstance();
00291
00305 void setBuffer(void *buffer, size_t size);
00306
00312 virtual void map( SoCpuBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00313
00319 virtual void unmap( SoCpuBufferObject* bufferObject );
00320
00326 virtual void memcpy( SoCpuBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00327
00333 virtual void memcpy( SoGLBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00334
00340 virtual void map( SoGLBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00341
00347 virtual void unmap( SoGLBufferObject* bufferObject );
00348
00349 private:
00350
00354 void copyToCpuBuffer( SoCpuBufferObject* targetBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00355
00360 bool isBufferOwner() const;
00361
00362 static void memcpyPtr2Ptr( void* dest, void* data, size_t dataSize, size_t count );
00363
00364 private:
00369 virtual ~SoCpuBufferObject();
00370
00372 unsigned char* m_buffer;
00373
00374 private:
00375
00377 bool m_isOwner;
00378
00380 static bool m_useVirtualAlloc;
00381
00383 int m_alignment;
00384 };
00385
00386
00387
00388
00389
00390
00391 inline bool
00392 SoCpuBufferObject::isBufferOwner() const
00393 {
00394 return m_isOwner;
00395 }
00396
00397
00398
00399 #endif // SOCPUBUFFEROBJECT_H
00400
00401