Equalizer  1.4.1
include/eq/client/channel.h
00001 
00002 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *                    2010, Cedric Stalder <cedric.stalder@gmail.com>
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef EQ_CHANNEL_H
00020 #define EQ_CHANNEL_H
00021 
00022 #include <eq/client/event.h>          // member
00023 #include <eq/client/types.h>
00024 
00025 #include <eq/fabric/channel.h>        // base class
00026 #include <eq/fabric/drawableConfig.h> // member
00027 
00028 namespace eq
00029 {
00030 namespace detail { class Channel; struct RBStat; }
00031 
00032     struct ChannelFinishReadbackPacket;
00033     struct ChannelFrameSetReadyNodePacket;
00034     struct ChannelFrameSetReadyPacket;
00035     struct ChannelFrameTilesPacket;
00036     struct ChannelFrameTransmitImagePacket;
00037 
00049     class Channel : public fabric::Channel< Window, Channel >
00050     {
00051     public:
00053         EQ_API Channel( Window* parent );
00054 
00056         EQ_API virtual ~Channel();
00057 
00060         EQ_API co::CommandQueue* getPipeThreadQueue(); 
00061         EQ_API co::CommandQueue* getCommandThreadQueue(); 
00062         EQ_API uint32_t getCurrentFrame() const; 
00063         void waitFrameFinished( const uint32_t frame ) const; 
00064 
00069         EQ_API bool isStopped() const;
00070 
00072         EQ_API Pipe* getPipe();
00073 
00075         EQ_API const Pipe* getPipe() const;
00076 
00078         EQ_API Node* getNode();
00079 
00081         EQ_API const Node* getNode() const;
00082 
00084         EQ_API Config* getConfig();
00085 
00087         EQ_API const Config* getConfig() const;
00088 
00090         EQ_API ServerPtr getServer();
00091 
00106         EQ_API const GLEWContext* glewGetContext() const;
00107 
00109         EQ_API ObjectManager* getObjectManager();
00110 
00112         EQ_API const DrawableConfig& getDrawableConfig() const;
00113 
00125         EQ_API View* getNativeView();
00126 
00128         EQ_API const View* getNativeView() const;
00129 
00131         EQ_API util::FrameBufferObject* getFrameBufferObject();
00132 
00134         EQ_API const Vector3ub& getUniqueColor() const;
00135 
00137         EQ_API void addStatistic( Event& event );
00139 
00154         EQ_API virtual Vector2f getJitter() const;
00155 
00160         EQ_API const Frames& getInputFrames();
00161 
00166         EQ_API const Frames& getOutputFrames();
00167 
00181         EQ_API View* getView();
00182 
00184         EQ_API const View* getView() const;
00185 
00195         EQ_API Frustumf getScreenFrustum() const;
00197 
00211         EQ_API virtual void applyBuffer();
00212 
00218         EQ_API virtual void applyColorMask() const;
00219 
00225         EQ_API virtual void applyViewport() const;
00226 
00239         EQ_API virtual void applyFrustum() const;
00240 
00245         EQ_API virtual void applyPerspective() const;
00246 
00251         EQ_API virtual void applyOrtho() const;
00252 
00260         EQ_API void applyScreenFrustum() const;
00261 
00267         EQ_API virtual void applyHeadTransform() const;
00268 
00273         EQ_API virtual void applyPerspectiveTransform() const;
00274 
00279         EQ_API virtual void applyOrthoTransform() const;
00280 
00285         EQ_API virtual void applyFrameBufferObject();
00286 
00291         EQ_API void bindFrameBuffer();        
00293 
00303         EQ_API virtual void resetRegions();
00304 
00314         EQ_API virtual void declareRegion( const eq::PixelViewport& region );
00315 
00322         EQ_API void declareRegion( const eq::Viewport& vp );
00323 
00325         EQ_API PixelViewport getRegion() const;
00326 
00338         EQ_API const PixelViewports& getRegions() const;
00339 
00341 
00353         EQ_API virtual bool processEvent( const Event& event );
00354 
00356         EQ_API virtual void drawStatistics();
00357 
00359         EQ_API virtual void outlineViewport();
00360 
00367         void changeLatency( const uint32_t latency );
00368 
00369     protected:
00371         EQ_API void attach( const UUID& id, const uint32_t instanceID );
00372 
00381         EQ_API void startFrame( const uint32_t frameNumber );
00382 
00389         EQ_API void releaseFrame( const uint32_t frameNumber );
00390 
00397         EQ_API void releaseFrameLocal( const uint32_t frameNumber );
00398 
00409         EQ_API virtual void setupAssemblyState();
00410 
00412         EQ_API virtual void resetAssemblyState();
00414 
00430         EQ_API virtual bool configInit( const uint128_t& initID );
00431 
00433         EQ_API virtual bool configExit();
00434 
00446         EQ_API virtual void frameStart( const uint128_t& frameID,
00447                                         const uint32_t frameNumber );
00448 
00459         EQ_API virtual void frameFinish( const uint128_t& frameID, 
00460                                          const uint32_t frameNumber );
00461 
00472         EQ_API virtual void frameDrawFinish( const uint128_t& frameID, 
00473                                              const uint32_t frameNumber );
00474 
00483         EQ_API virtual void frameClear( const uint128_t& frameID );
00484 
00493         EQ_API virtual void frameDraw( const uint128_t& frameID );
00494 
00504         EQ_API virtual void frameAssemble( const uint128_t& frameID );
00505 
00515          EQ_API virtual void frameReadback( const uint128_t& frameID );
00516 
00527         EQ_API virtual void frameViewStart( const uint128_t& frameID );
00528 
00542         EQ_API virtual void frameViewFinish( const uint128_t& frameID );
00544 
00546         virtual void frameTilesStart( const uint128_t& frameID ) {}
00547 
00549         virtual void frameTilesFinish( const uint128_t& frameID ) {}
00550 
00552         EQ_API virtual void notifyViewportChanged();
00553 
00566         virtual void notifyStopFrame( const uint32_t lastFrameNumber ) {}
00567 
00568     private:
00569         detail::Channel* const _impl;
00570         friend class fabric::Window< Pipe, Window, Channel >;
00571 
00572         //-------------------- Methods --------------------
00574         void _setRenderContext( RenderContext& context );
00575 
00577         bool _configInitFBO();
00578 
00580         void _initDrawableConfig();
00581 
00583         void _frameTiles( const ChannelFrameTilesPacket* packet );
00584 
00586         void _refFrame( const uint32_t frameNumber );
00587 
00589         void _unrefFrame( const uint32_t frameNumber );
00590 
00592         void _transmitImage( const ChannelFrameTransmitImagePacket* packet );
00593         
00594         void _frameReadback( const uint128_t& frameID, uint32_t nFrames,
00595                              co::ObjectVersion* frames );
00596         void _finishReadback( const ChannelFinishReadbackPacket* packet );
00597 
00598         bool _asyncFinishReadback( const std::vector< size_t >& imagePos );
00599 
00600         void _asyncTransmit( FrameDataPtr frame, const uint32_t frameNumber,
00601                              const size_t image,
00602                              const std::vector<uint128_t>& nodes,
00603                              const std::vector< uint128_t >& netNodes,
00604                              const uint32_t taskID );
00605 
00606         void _setReady( const bool async, detail::RBStat* stat );
00607         void _asyncSetReady( const FrameDataPtr frame, detail::RBStat* stat,
00608                              const std::vector< uint128_t >& nodes,
00609                              const std::vector< uint128_t >& netNodes );
00610 
00611         void _setReady( FrameDataPtr frame, detail::RBStat* stat,
00612                         const std::vector< uint128_t >& nodes,
00613                         const std::vector< uint128_t >& netNodes );
00614 
00616         co::QueueSlave* _getQueue( const co::ObjectVersion& queueVersion );
00617 
00618         void _setOutputFrames( const uint32_t nFrames,
00619                                const co::ObjectVersion* frames );
00620         void _resetOutputFrames();
00621 
00622         void _deleteTransferContext();
00623 
00624         /* The command handler functions. */
00625         bool _cmdConfigInit( co::Command& command );
00626         bool _cmdConfigExit( co::Command& command );
00627         bool _cmdFrameStart( co::Command& command );
00628         bool _cmdFrameFinish( co::Command& command );
00629         bool _cmdFrameClear( co::Command& command );
00630         bool _cmdFrameDraw( co::Command& command );
00631         bool _cmdFrameDrawFinish( co::Command& command );
00632         bool _cmdFrameAssemble( co::Command& command );
00633         bool _cmdFrameReadback( co::Command& command );
00634         bool _cmdFinishReadback( co::Command& command );
00635         bool _cmdFrameSetReady( co::Command& command );
00636         bool _cmdFrameTransmitImage( co::Command& command );
00637         bool _cmdFrameSetReadyNode( co::Command& command );
00638         bool _cmdFrameViewStart( co::Command& command );
00639         bool _cmdFrameViewFinish( co::Command& command );
00640         bool _cmdStopFrame( co::Command& command );
00641         bool _cmdFrameTiles( co::Command& command );
00642         bool _cmdDeleteTransferContext( co::Command& command );
00643 
00644         LB_TS_VAR( _pipeThread );
00645     };
00646 }
00647 
00648 #endif // EQ_CHANNEL_H
00649 
Generated on Mon Nov 26 2012 14:41:48 for Equalizer 1.4.1 by  doxygen 1.7.6.1