Equalizer 1.0

include/eq/frameData.h

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/frame.h>         // enum Frame::Buffer
00022 #include <eq/types.h>         // member
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 #include <co/object.h>           // base class
00029 #include <co/base/monitor.h>         // member
00030 #include <co/base/scopedMutex.h>     // member
00031 #include <co/base/spinLock.h>        // member
00032 
00033 #include <set>                       // member
00034 
00035 namespace eq
00036 {
00037 
00038 namespace server
00039 {
00040     class FrameData;
00041 }
00042     class  ROIFinder;
00043     struct NodeFrameDataTransmitPacket;
00044     struct NodeFrameDataReadyPacket;
00045 
00061     class FrameData : public co::Object
00062     {
00063     public:
00064         void assembleFrame( Frame* frame, Channel* channel );
00065         struct ImageHeader
00066         {
00067             uint32_t                internalFormat;
00068             uint32_t                externalFormat;
00069             uint32_t                pixelSize;
00070             fabric::PixelViewport   pvp;
00071             uint32_t                compressorName;
00072             uint32_t                compressorFlags;
00073             uint32_t                nChunks;
00074             float                   quality;
00075         };
00076 
00078         EQ_API FrameData();
00079 
00081         EQ_API virtual ~FrameData();
00082 
00086         uint32_t getBuffers() const { return _data.buffers; }
00087 
00095         void setBuffers( const uint32_t buffers ){ _data.buffers = buffers;}
00096 
00106         const Range& getRange() const { return _data.range; }
00107 
00109         void setRange( const Range& range ) { _data.range = range; }
00110         
00115         const Pixel& getPixel() const { return _data.pixel; }
00116         
00121         const SubPixel& getSubPixel() const { return _data.subpixel; }
00122 
00127         uint32_t getPeriod() const { return _data.period; }
00128 
00133         uint32_t getPhase() const { return _data.phase; }
00134 
00136         const Images& getImages() const { return _images; }
00137 
00146         void setPixelViewport( const PixelViewport& pvp ) { _data.pvp = pvp; }
00147         
00155         void setAlphaUsage( const bool useAlpha ) { _useAlpha = useAlpha; }
00156 
00166         void setQuality( const Frame::Buffer buffer, const float quality );
00167 
00169         void setZoom( const Zoom& zoom ) { _data.zoom = zoom; }
00170 
00172         const Zoom& getZoom() const { return _data.zoom; }
00174 
00187         EQ_API Image* newImage( const Frame::Type type,
00188                                 const DrawableConfig& config );
00189 
00191         void flush();
00192 
00194         EQ_API void clear();
00195 
00207         void readback( const Frame& frame, 
00208                        util::ObjectManager< const void* >* glObjects,
00209                        const DrawableConfig& config );
00210 
00218         void setReady();
00219 
00221         bool isReady() const   { return _readyVersion.get() >= _version; }
00222 
00224         void waitReady() const { _readyVersion.waitGE( _version ); }
00225         
00227         void setVersion( const uint64_t version );
00228 
00238         void addListener( co::base::Monitor<uint32_t>& listener );
00239 
00246         void removeListener( co::base::Monitor<uint32_t>& listener );
00247         
00254         void disableBuffer( const Frame::Buffer buffer )
00255             { _data.buffers &= ~buffer; }
00257 
00259         bool addImage( const NodeFrameDataTransmitPacket* packet );
00260         void setReady( const NodeFrameDataReadyPacket* packet ); 
00261 
00262     protected:
00263         virtual ChangeType getChangeType() const { return INSTANCE; }
00264         virtual void getInstanceData( co::DataOStream& os );
00265         virtual void applyInstanceData( co::DataIStream& is );
00266 
00267     private:
00268         friend struct NodeFrameDataReadyPacket;
00269         struct Data
00270         {
00271             Data() : frameType( Frame::TYPE_MEMORY ), buffers( 0 ), period( 1 )
00272                    , phase( 0 ) {}
00273 
00274             PixelViewport pvp;
00275             Frame::Type   frameType;
00276             uint32_t      buffers;
00277             uint32_t      period;
00278             uint32_t      phase;
00279             Range         range;     //<! database-range of src wrt to dest
00280             Pixel         pixel;     //<! pixel decomposition of source
00281             SubPixel      subpixel;  //<! subpixel decomposition of source
00282             Zoom          zoom;
00283         } _data;
00284 
00285         friend class server::FrameData;
00286 
00287         Images _images;
00288         Images _imageCache;
00289         co::base::Lock _imageCacheLock;
00290 
00291         ROIFinder* _roiFinder;
00292 
00293         Images _pendingImages;
00294 
00295         uint64_t _version; 
00296 
00297         typedef co::base::Monitor< uint64_t > Monitor;
00298 
00300         Monitor _readyVersion;
00301 
00302         typedef co::base::Monitor< uint32_t > Listener;
00303         typedef std::vector< Listener* > Listeners;
00305         co::base::Lockable< Listeners, co::base::SpinLock > _listeners;
00306 
00307         bool _useAlpha;
00308         float _colorQuality;
00309         float _depthQuality;
00310 
00311         struct Private;
00312         Private* _private; // placeholder for binary-compatible changes
00313 
00315         Image* _allocImage( const Frame::Type type,
00316                             const DrawableConfig& config,
00317                             const bool setQuality );
00318 
00320         void _applyVersion( const uint128_t& version );
00321 
00323         void _setReady( const uint64_t version );
00324 
00325         EQ_TS_VAR( _commandThread );
00326     };
00327 
00329     std::ostream& operator << ( std::ostream& os, const FrameData* data );
00330 }
00331 
00332 #endif // EQ_FRAMEDATA_H
00333 
Generated on Sun May 8 2011 19:11:05 for Equalizer 1.0 by  doxygen 1.7.3