Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2006-2011, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 00004 * This library is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU Lesser General Public License version 2.1 as published 00006 * by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, but WITHOUT 00009 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00010 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00011 * details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this library; if not, write to the Free Software Foundation, Inc., 00015 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 */ 00017 00018 #ifndef EQ_FRAMEDATA_H 00019 #define EQ_FRAMEDATA_H 00020 00021 #include <eq/client/frame.h> // enum Frame::Buffer 00022 #include <eq/client/types.h> 00023 00024 #include <eq/fabric/pixelViewport.h> // member 00025 #include <eq/fabric/pixel.h> // member 00026 #include <eq/fabric/range.h> // member 00027 #include <eq/fabric/subPixel.h> // member 00028 00029 #include <co/object.h> // base class 00030 #include <co/base/monitor.h> // member 00031 #include <co/base/spinLock.h> // member 00032 00033 namespace eq 00034 { 00035 00036 namespace server 00037 { 00038 class FrameData; 00039 } 00040 class ROIFinder; 00041 struct NodeFrameDataTransmitPacket; 00042 struct NodeFrameDataReadyPacket; 00043 00059 class FrameData : public co::Object 00060 { 00061 public: 00062 void assembleFrame( Frame* frame, Channel* channel ); 00063 struct ImageHeader 00064 { 00065 uint32_t internalFormat; 00066 uint32_t externalFormat; 00067 uint32_t pixelSize; 00068 fabric::PixelViewport pvp; 00069 uint32_t compressorName; 00070 uint32_t compressorFlags; 00071 uint32_t nChunks; 00072 float quality; 00073 }; 00074 00076 EQ_API FrameData(); 00077 00079 EQ_API virtual ~FrameData(); 00080 00084 uint32_t getBuffers() const { return _data.buffers; } 00085 00093 void setBuffers( const uint32_t buffers ){ _data.buffers = buffers;} 00094 00104 const Range& getRange() const { return _data.range; } 00105 00107 void setRange( const Range& range ) { _data.range = range; } 00108 00113 const Pixel& getPixel() const { return _data.pixel; } 00114 00119 const SubPixel& getSubPixel() const { return _data.subpixel; } 00120 00125 uint32_t getPeriod() const { return _data.period; } 00126 00131 uint32_t getPhase() const { return _data.phase; } 00132 00134 const Images& getImages() const { return _images; } 00135 00144 void setPixelViewport( const PixelViewport& pvp ) { _data.pvp = pvp; } 00145 00153 void setAlphaUsage( const bool useAlpha ) { _useAlpha = useAlpha; } 00154 00164 void setQuality( const Frame::Buffer buffer, const float quality ); 00165 00167 void setZoom( const Zoom& zoom ) { _data.zoom = zoom; } 00168 00170 const Zoom& getZoom() const { return _data.zoom; } 00171 00182 void useCompressor( const Frame::Buffer buffer, const uint32_t name ); 00184 00197 EQ_API Image* newImage( const Frame::Type type, 00198 const DrawableConfig& config ); 00199 00201 void flush(); 00202 00204 EQ_API void clear(); 00205 00217 void readback( const Frame& frame, 00218 util::ObjectManager< const void* >* glObjects, 00219 const DrawableConfig& config ); 00220 00228 void setReady(); 00229 00231 bool isReady() const { return _readyVersion.get() >= _version; } 00232 00234 void waitReady( const uint32_t timeout = EQ_TIMEOUT_INDEFINITE ) const; 00235 00237 void setVersion( const uint64_t version ); 00238 00248 void addListener( co::base::Monitor<uint32_t>& listener ); 00249 00256 void removeListener( co::base::Monitor<uint32_t>& listener ); 00257 00264 void disableBuffer( const Frame::Buffer buffer ) 00265 { _data.buffers &= ~buffer; } 00267 00269 bool addImage( const NodeFrameDataTransmitPacket* packet ); 00270 void setReady( const NodeFrameDataReadyPacket* packet ); 00271 00272 protected: 00273 virtual ChangeType getChangeType() const { return INSTANCE; } 00274 virtual void getInstanceData( co::DataOStream& os ); 00275 virtual void applyInstanceData( co::DataIStream& is ); 00276 00277 private: 00278 friend struct NodeFrameDataReadyPacket; 00279 struct Data 00280 { 00281 Data() : frameType( Frame::TYPE_MEMORY ), buffers( 0 ), period( 1 ) 00282 , phase( 0 ) {} 00283 00284 EQ_API Data& operator=( const Data& rhs ); 00285 00286 PixelViewport pvp; 00287 Frame::Type frameType; 00288 uint32_t buffers; 00289 uint32_t period; 00290 uint32_t phase; 00291 Range range; //<! database-range of src wrt to dest 00292 Pixel pixel; //<! pixel decomposition of source 00293 SubPixel subpixel; //<! subpixel decomposition of source 00294 Zoom zoom; 00295 00296 EQ_API void serialize( co::DataOStream& os ) const; 00297 EQ_API void deserialize( co::DataIStream& is ); 00298 } _data; 00299 00300 friend class server::FrameData; 00301 00302 Images _images; 00303 Images _imageCache; 00304 co::base::Lock _imageCacheLock; 00305 00306 ROIFinder* _roiFinder; 00307 00308 Images _pendingImages; 00309 00310 uint64_t _version; 00311 00312 typedef co::base::Monitor< uint64_t > Monitor; 00313 00315 Monitor _readyVersion; 00316 00317 typedef co::base::Monitor< uint32_t > Listener; 00318 typedef std::vector< Listener* > Listeners; 00320 co::base::Lockable< Listeners, co::base::SpinLock > _listeners; 00321 00322 bool _useAlpha; 00323 float _colorQuality; 00324 float _depthQuality; 00325 00326 uint32_t _colorCompressor; 00327 uint32_t _depthCompressor; 00328 00329 struct Private; 00330 Private* _private; // placeholder for binary-compatible changes 00331 00333 Image* _allocImage( const Frame::Type type, 00334 const DrawableConfig& config, 00335 const bool setQuality ); 00336 00338 void _applyVersion( const uint128_t& version ); 00339 00341 void _setReady( const uint64_t version ); 00342 00343 EQ_TS_VAR( _commandThread ); 00344 }; 00345 00347 std::ostream& operator << ( std::ostream& os, const FrameData* data ); 00348 } 00349 00350 #endif // EQ_FRAMEDATA_H 00351