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 SOCPUBUFFERBITSET_H
00024 #define SOCPUBUFFERBITSET_H
00025
00026
00027 #include <Inventor/devices/SoCpuBufferObject.h>
00028
00029
00030 #include <LDM/tiles/SoBufferPropertiesInterface.h>
00031 #include <LDM/tiles/SoLDMBufferObjectInterface.h>
00032 #include <LDM/tiles/SoCpuBufferCompressed.h>
00033 #include <Inventor/algorithms/SoConversion.h>
00034
00035 class SoDataCompressor;
00036 class SoCpuBufferUniform;
00037 class SoCpuBufferBitSet;
00038
00039 #ifdef _MSC_VER
00040 #pragma warning( push )
00041 #pragma warning(disable:4251)
00042 #endif
00043
00058 class SoCpuBufferBitSet: public SoCpuBufferObject, public SoBufferPropertiesInterface, public SoLDMBufferObjectInterface
00059 {
00060 SO_TYPED_CLASS_HEADER();
00061
00062
00063 public:
00064
00068 SoCpuBufferBitSet();
00069
00073 SoCpuBufferBitSet(SoCpuBufferObject* cpuBuffer);
00074
00080 virtual SoBufferObject* createInstance() const;
00081
00093 virtual void map( SoBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00094
00100 virtual void map( SoCpuBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL);
00101
00107 virtual void map( SoGLBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL);
00108
00115 virtual void* map( AccessMode accessMode );
00116
00125 virtual void unmap( SoCpuBufferObject* bufferObject );
00126
00135 virtual void unmap( SoGLBufferObject* bufferObject );
00136
00145 virtual void unmap( SoBufferObject* bufferObject );
00146
00152 virtual void unmap();
00153
00155 virtual void memcpy( SoBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00156
00169 virtual void memset( void* value, size_t valueSize = 1, size_t offset = 0, size_t count = SO_BUFFER_SIZE_ALL );
00170
00179 virtual bool getMinMax ( double& min, double& max);
00180
00187 virtual void setMinMax ( const double& min, const double& max);
00188
00194 virtual size_t getRealSize() const;
00195
00202 virtual bool setSize( size_t size );
00203
00204 #if 1 SoDEPRECATED
00210 SoCpuBufferBitSet(SoDataCompressor* compressor);
00211 SoDEPRECATED
00218 virtual void setCompressor( SoDataCompressor* compressor );
00219 SoDEPRECATED
00227 virtual void setBufferUncompress( unsigned char* dataBuffer, size_t bufferSize );
00228 SoDEPRECATED
00234 virtual void setBufferCompressed( bool ){};
00235
00236 #endif
00238 private:
00239
00242 void memcpy( SoCpuBufferBitSet* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00243
00246 void memcpy( SoCpuBufferUniform* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00247
00250 void memcpyInternal( SoBufferObject* sourceBufferObject, size_t dataSize, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00251
00254 unsigned char* mapRawBitSet(AccessMode accessMode);
00255
00257 void unmapRawBitSet();
00258
00260 static inline unsigned char getBit(unsigned char* dataPtr, const int pos)
00261 { return (((dataPtr[pos>>0x3]) >> (7- (pos & 0x7))) & 1); }
00262
00263
00264 virtual void setCacheSignature(const uint64_t& cacheSignature);
00265
00267 static inline void setBit(unsigned char* dataPtr, const int pos, bool v)
00268 {
00269 unsigned char& val = dataPtr[pos/8];
00270 const unsigned char mask = 0x80 >> pos%8;
00271 const unsigned char bitChar = (unsigned char)v << (7 - pos%8);
00272 val = (val & ~mask) | bitChar;
00273 }
00274
00275 private:
00279 virtual ~SoCpuBufferBitSet();
00280
00281 private:
00283 void setBitSetData(SoCpuBufferObject* buffer);
00284
00286 void updateUnpackBuffer(AccessMode accessMode);
00287
00288 SoCpuBufferObject* m_tempBitSetBuffer;
00289 SoCpuBufferObject* m_unpackedBuffer;
00290
00293 SoRef<SoCpuBufferObject> m_bitSetBuffer;
00294 };
00295
00296 #ifdef _MSC_VER
00297 #pragma warning( pop )
00298 #endif
00299
00300 #endif //SOCPUBUFFERBITSET_H
00301
00302