Equalizer  1.4.1
include/eq/client/frameData.h
00001 
00002 /* Copyright (c) 2006-2012, 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 <lunchbox/monitor.h>         // member
00031 #include <lunchbox/spinLock.h>        // member
00032 
00033 namespace eq
00034 {
00035 namespace server { class FrameData; }
00036 
00037     class  ROIFinder;
00038     struct NodeFrameDataTransmitPacket;
00039     struct NodeFrameDataReadyPacket;
00040 
00056     class FrameData : public co::Object, public lunchbox::Referenced
00057     {
00058     public:
00059         void assembleFrame( Frame* frame, Channel* channel );
00060         struct ImageHeader
00061         {
00062             uint32_t                internalFormat;
00063             uint32_t                externalFormat;
00064             uint32_t                pixelSize;
00065             fabric::PixelViewport   pvp;
00066             uint32_t                compressorName;
00067             uint32_t                compressorFlags;
00068             uint32_t                nChunks;
00069             float                   quality;
00070         };
00071 
00073         EQ_API FrameData();
00074 
00076         EQ_API virtual ~FrameData();
00077 
00081         Frame::Type getType() const { return _data.frameType; }
00082 
00084         void setType( const Frame::Type type ){ _data.frameType = type; }
00085 
00087         uint32_t getBuffers() const { return _data.buffers; }
00088 
00096         void setBuffers( const uint32_t buffers ){ _data.buffers = buffers;}
00097 
00107         const Range& getRange() const { return _data.range; }
00108 
00110         void setRange( const Range& range ) { _data.range = range; }
00111         
00116         const Pixel& getPixel() const { return _data.pixel; }
00117         
00122         const SubPixel& getSubPixel() const { return _data.subpixel; }
00123 
00128         uint32_t getPeriod() const { return _data.period; }
00129 
00134         uint32_t getPhase() const { return _data.phase; }
00135 
00137         const Images& getImages() const { return _images; }
00138 
00147         void setPixelViewport( const PixelViewport& pvp ) { _data.pvp = pvp; }
00148 
00150         const PixelViewport& getPixelViewport() const { return _data.pvp; }
00151 
00159         void setAlphaUsage( const bool useAlpha ) { _useAlpha = useAlpha; }
00160 
00170         void setQuality( const Frame::Buffer buffer, const float quality );
00171 
00173         void setZoom( const Zoom& zoom ) { _data.zoom = zoom; }
00174 
00176         const Zoom& getZoom() const { return _data.zoom; }
00177 
00188         void useCompressor( const Frame::Buffer buffer, const uint32_t name );
00190 
00203         EQ_API Image* newImage( const Frame::Type type,
00204                                 const DrawableConfig& config );
00205 
00207         EQ_API void clear();
00208 
00210         void flush();
00211 
00213         void deleteGLObjects( ObjectManager* om );
00214 
00216         void resetPlugins();
00217 
00218 #ifndef EQ_2_0_API
00219 
00231         void readback( const Frame& frame, ObjectManager* glObjects,
00232                        const DrawableConfig& config );
00233 #endif
00234 
00248         Images startReadback( const Frame& frame, ObjectManager* glObjects,
00249                               const DrawableConfig& config,
00250                               const PixelViewports& regions );
00251 
00259         void setReady();
00260 
00262         bool isReady() const   { return _readyVersion.get() >= _version; }
00263 
00265         void waitReady( const uint32_t timeout = LB_TIMEOUT_INDEFINITE ) const;
00266         
00268         void setVersion( const uint64_t version );
00269 
00279         void addListener( lunchbox::Monitor<uint32_t>& listener );
00280 
00287         void removeListener( lunchbox::Monitor<uint32_t>& listener );
00288         
00295         void disableBuffer( const Frame::Buffer buffer )
00296             { _data.buffers &= ~buffer; }
00298 
00300         bool addImage( const NodeFrameDataTransmitPacket* packet );
00301         void setReady( const NodeFrameDataReadyPacket* packet ); 
00302 
00303     protected:
00304         virtual ChangeType getChangeType() const { return INSTANCE; }
00305         virtual void getInstanceData( co::DataOStream& os );
00306         virtual void applyInstanceData( co::DataIStream& is );
00307 
00308     private:
00309         friend struct NodeFrameDataReadyPacket;
00310         struct Data
00311         {
00312             Data() : frameType( Frame::TYPE_MEMORY ), buffers( 0 ), period( 1 )
00313                    , phase( 0 ) {}
00314 
00315             EQ_API Data& operator=( const Data& rhs );
00316 
00317             PixelViewport pvp;
00318             fabric::Frame::Type frameType;
00319             uint32_t      buffers;
00320             uint32_t      period;
00321             uint32_t      phase;
00322             Range         range;     //<! database-range of src wrt to dest
00323             Pixel         pixel;     //<! pixel decomposition of source
00324             SubPixel      subpixel;  //<! subpixel decomposition of source
00325             Zoom          zoom;
00326 
00327             EQ_API void serialize( co::DataOStream& os ) const;
00328             EQ_API void deserialize( co::DataIStream& is );
00329         } _data;
00330 
00331         friend class server::FrameData;
00332 
00333         Images _images;
00334         Images _imageCache;
00335         lunchbox::Lock _imageCacheLock;
00336 
00337         ROIFinder* _roiFinder;
00338 
00339         Images _pendingImages;
00340 
00341         uint64_t _version; 
00342 
00343         typedef lunchbox::Monitor< uint64_t > Monitor;
00344 
00346         Monitor _readyVersion;
00347 
00348         typedef lunchbox::Monitor< uint32_t > Listener;
00349         typedef std::vector< Listener* > Listeners;
00351         lunchbox::Lockable< Listeners, lunchbox::SpinLock > _listeners;
00352 
00353         bool _useAlpha;
00354         float _colorQuality;
00355         float _depthQuality;
00356 
00357         uint32_t _colorCompressor;
00358         uint32_t _depthCompressor;
00359 
00360         struct Private;
00361         Private* _private; // placeholder for binary-compatible changes
00362 
00364         Image* _allocImage( const Frame::Type type,
00365                             const DrawableConfig& config,
00366                             const bool setQuality );
00367 
00369         void _applyVersion( const uint128_t& version );
00370 
00372         void _setReady( const uint64_t version );
00373 
00374         LB_TS_VAR( _commandThread );
00375     };
00376 
00378     EQ_API std::ostream& operator << ( std::ostream&, const FrameData& );
00379 }
00380 
00381 #endif // EQ_FRAMEDATA_H
00382 
Generated on Mon Nov 26 2012 14:41:48 for Equalizer 1.4.1 by  doxygen 1.7.6.1