LCOV - code coverage report
Current view: top level - eq/server - window.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 5 11 45.5 %
Date: 2016-09-29 05:02:09 Functions: 5 10 50.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2005-2015, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Cedric Stalder <cedric.stalder@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #ifndef EQSERVER_WINDOW_H
      20             : #define EQSERVER_WINDOW_H
      21             : 
      22             : #include <eq/server/api.h>
      23             : #include "state.h"          // enum
      24             : #include "types.h"
      25             : #include "visitorResult.h"  // enum
      26             : 
      27             : #include <eq/fabric/window.h> // base class
      28             : #include <co/barrier.h>
      29             : #include <lunchbox/monitor.h>   // member
      30             : #include <lunchbox/uint128_t.h> // member
      31             : #include <iostream>
      32             : #include <vector>
      33             : 
      34             : namespace eq
      35             : {
      36             : namespace server
      37             : {
      38             : /** The window. */
      39             : class Window : public fabric::Window< Pipe, Window, Channel >
      40             : {
      41             : public:
      42             :     /** Construct a new Window. */
      43             :     EQSERVER_API explicit Window( Pipe* parent );
      44             : 
      45             :     virtual ~Window();
      46             : 
      47             :     /** @name Data Access */
      48             :     //@{
      49             :     Node* getNode();
      50             :     const Node* getNode() const;
      51             : 
      52             :     Config* getConfig();
      53             :     const Config* getConfig() const;
      54             : 
      55             :     /** @return the Server of this window. */
      56             :     ServerPtr getServer();
      57             : 
      58             :     Channel* getChannel( const ChannelPath& path );
      59             : 
      60             :     co::CommandQueue* getMainThreadQueue();
      61             :     co::CommandQueue* getCommandThreadQueue();
      62             : 
      63             :     /** Increase window activition count. */
      64             :     void activate();
      65             : 
      66             :     /** Decrease window activition count. */
      67             :     void deactivate();
      68             : 
      69             :     /** @return the state of this window. */
      70          16 :     State getState() const { return _state.get(); }
      71             : 
      72             :     /** @internal */
      73           2 :     void setState( const State state ) { _state = state; }
      74             : 
      75             :     /** @return if this window is actively used for rendering. */
      76          10 :     bool isActive() const { return (_active != 0); }
      77             : 
      78             :     /** @return true if this window is stopped. */
      79             :     bool isStopped() const { return _state & STATE_STOPPED; }
      80             : 
      81             :     /** @return true if this window is running. */
      82           2 :     bool isRunning() const { return _state & STATE_RUNNING; }
      83             : 
      84             :     /** @return true if this window should be deleted. */
      85          16 :     bool needsDelete() const { return _state & STATE_DELETE; }
      86             : 
      87             :     /** Schedule deletion of this window. */
      88             :     void postDelete();
      89             : 
      90             :     /**
      91             :      * Add additional tasks this window, and all its parents, might
      92             :      * potentially execute.
      93             :      */
      94             :     void addTasks( const uint32_t tasks );
      95             : 
      96             :     /**
      97             :      * Join a swap barrier for the next update.
      98             :      *
      99             :      * @param barrier the net::Barrier for the swap barrier group, or 0 if
     100             :      *                this is the first window.
     101             :      * @return the net::Barrier for the swap barrier group.
     102             :      */
     103             :     co::Barrier* joinSwapBarrier( co::Barrier* barrier );
     104             : 
     105             :     /**
     106             :      * Join a NV_swap_group barrier for the next update.
     107             :      *
     108             :      * @param swapBarrier the swap barrier containing the NV_swap_group
     109             :      *                    parameters.
     110             :      * @param netBarrier the net::Barrier to protect the entry from the
     111             :      *                   NV_swap_group , or 0 if this is the first window
     112             :      *                   entering.
     113             :      * @return the net::Barrier for protecting the swap group entry.
     114             :      */
     115             :     co::Barrier* joinNVSwapBarrier( SwapBarrierConstPtr swapBarrier,
     116             :                                     co::Barrier* netBarrier );
     117             : 
     118             :     /** @return true if this window has entered a NV_swap_group. */
     119           0 :     bool hasNVSwapBarrier() const { return (_nvSwapBarrier != 0); }
     120             : 
     121             :     /** The last drawing channel for this entity. @internal */
     122           0 :     void setLastDrawChannel( const Channel* channel )
     123           0 :     { _lastDrawChannel = channel; }
     124           0 :     const Channel* getLastDrawChannel() const { return _lastDrawChannel; }
     125             : 
     126             :     /** The maximum frame rate for this window. @internal */
     127           0 :     void setMaxFPS( const float fps ) { _maxFPS = fps; }
     128           0 :     float getMaxFPS() const { return _maxFPS; }
     129             :     //@}
     130             : 
     131             :     /**
     132             :      * @name Operations
     133             :      */
     134             :     //@{
     135             :     /** Start initializing this entity. */
     136             :     void configInit( const uint128_t& initID, const uint32_t frameNumber );
     137             : 
     138             :     /** Sync initialization of this entity. */
     139             :     bool syncConfigInit();
     140             : 
     141             :     /** Start exiting this entity. */
     142             :     void configExit();
     143             : 
     144             :     /** Sync exit of this entity. */
     145             :     bool syncConfigExit();
     146             : 
     147             :     /**
     148             :      * Update one frame.
     149             :      *
     150             :      * @param frameID a per-frame identifier passed to all rendering
     151             :      *                methods.
     152             :      * @param frameNumber the number of the frame.
     153             :      */
     154             :     void updateDraw( const uint128_t& frameID, const uint32_t frameNumber );
     155             : 
     156             :     /**
     157             :      * Trigger the post-draw operations.
     158             :      *
     159             :      * @param frameID a per-frame identifier passed to all rendering
     160             :      *                methods.
     161             :      * @param frameNumber the number of the frame.
     162             :      */
     163             :     void updatePost( const uint128_t& frameID, const uint32_t frameNumber );
     164             :     //@}
     165             : 
     166             :     co::ObjectOCommand send( const uint32_t cmd );
     167             :     void output( std::ostream& ) const; //!< @internal
     168             : 
     169             : protected:
     170             : 
     171             :     /** @sa net::Object::attach. */
     172             :     virtual void attach( const uint128_t& id, const uint32_t instanceID );
     173             : 
     174             :     /** @internal Execute the slave remove request. */
     175             :     virtual void removeChild( const uint128_t& id );
     176             : 
     177             : private:
     178             : 
     179             :     /** Number of activations for this window. */
     180             :     uint32_t _active;
     181             : 
     182             :     /** The current state for state change synchronization. */
     183             :     lunchbox::Monitor< State > _state;
     184             : 
     185             :     /** The maximum frame rate allowed for this window. */
     186             :     float _maxFPS;
     187             : 
     188             :     /** The list of master swap barriers for the current frame. */
     189             :     co::Barriers _masterBarriers;
     190             :     /** The list of slave swap barriers for the current frame. */
     191             :     co::Barriers _barriers;
     192             : 
     193             :     /** The hardware swap barrier to use. */
     194             :     SwapBarrierConstPtr _nvSwapBarrier;
     195             : 
     196             :     /** The network barrier used to protect hardware barrier entry. */
     197             :     co::Barrier* _nvNetBarrier;
     198             : 
     199             :     /** The last draw channel for this entity */
     200             :     const Channel* _lastDrawChannel;
     201             : 
     202             :     /** The flag if the window has to execute a finish */
     203             :     bool _swapFinish;
     204             : 
     205             :     /**
     206             :      * The flag if the window has to swap, i.e, something was done during
     207             :      * the last update.
     208             :      */
     209             :     bool _swap;
     210             : 
     211             :     struct Private;
     212             :     Private* _private; // placeholder for binary-compatible changes
     213             : 
     214             :     /** Clears all swap barriers of the window. */
     215             :     void _resetSwapBarriers();
     216             : 
     217             :     void _updateSwap( const uint32_t frameNumber );
     218             : 
     219             :     /* command handler functions. */
     220             :     bool _cmdConfigInitReply( co::ICommand& command );
     221             :     bool _cmdConfigExitReply( co::ICommand& command );
     222             : 
     223             :     // For access to _fixedPVP
     224             :     friend std::ostream& operator << ( std::ostream&, const Window*);
     225             : };
     226             : }
     227             : }
     228             : 
     229             : #endif // EQSERVER_WINDOW_H

Generated by: LCOV version 1.11